diff --git a/0001-optimize-page-loading-and-routing.patch b/0001-optimize-page-loading-and-routing.patch new file mode 100644 index 0000000..ee36181 --- /dev/null +++ b/0001-optimize-page-loading-and-routing.patch @@ -0,0 +1,226 @@ +From 1a318efbb8d9b27cf01f3dd8544baa549863575a Mon Sep 17 00:00:00 2001 +From: wkl505997900 <505997900@qq.com> +Date: Sun, 23 Apr 2023 10:03:06 +0800 +Subject: [PATCH 1/2] Optimize page loading and routing +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + src/config/router.config.js | 20 +++++++++++++++++++- + src/views/leaks/components/HostTable.vue | 9 +++++++-- + 2 files changed, 26 insertions(+), 3 deletions(-) + +diff --git a/src/config/router.config.js b/src/config/router.config.js +index 1a9bad3..8a15f2a 100644 +--- a/src/config/router.config.js ++++ b/src/config/router.config.js +@@ -37,6 +37,10 @@ const routeMap = { + path: '/assests/hosts-management/host-edit' + } + } ++ }, ++ hostgroupView: { ++ title: 'menu.assests.host-group-management', ++ path: '/assests/host-group-management' + } + } + }, +@@ -303,7 +307,21 @@ export const asyncRouterMap = [ + component: () => import('@/views/assests/HostGroupManagement'), + meta: { + title: 'menu.assests.host-group-management', +- permission: ['assests'] ++ permission: ['assests'], ++ diyBreadcrumb: [ ++ { ++ breadcrumbName: routeMap.index.title, ++ path: routeMap.index.path ++ }, ++ { ++ breadcrumbName: routeMap.assests.title, ++ path: routeMap.assests.path ++ }, ++ { ++ breadcrumbName: routeMap.assests.children.hostgroupView.title, ++ path: routeMap.assests.children.hostgroupView.path ++ } ++ ] + } + } + ] +diff --git a/src/views/leaks/components/HostTable.vue b/src/views/leaks/components/HostTable.vue +index e95e974..38618de 100644 +--- a/src/views/leaks/components/HostTable.vue ++++ b/src/views/leaks/components/HostTable.vue +@@ -104,6 +104,9 @@ + {{ last_scan }} + + ++
++ {{ repo || '——' }} ++
+
+ {{ hotpatch ? '是' : '否' }} + +@@ -199,7 +202,8 @@ export default { + key: 'repo', + title: 'CVE REPO', + filteredValue: filters.repo || [], +- filters: this.repoList ++ filters: this.repoList, ++ scopedSlots: {customRender: 'repo'} + }, + { + dataIndex: 'cve_num', +@@ -243,7 +247,8 @@ export default { + key: 'repo', + title: 'CVE REPO', + filteredValue: filters.repo || null, +- filters: this.standalone ? this.repoList : this.repoFilterList ++ filters: this.standalone ? this.repoList : this.repoFilterList, ++ scopedSlots: {customRender: 'repo'} + }, + { + dataIndex: 'hotpatch', +-- +Gitee + + +From 0faf5b381a1d84f3a152ffa887207af138255f5b Mon Sep 17 00:00:00 2001 +From: wkl505997900 <505997900@qq.com> +Date: Sun, 23 Apr 2023 18:46:51 +0800 +Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B7=AF=E7=94=B1?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + .../components/GlobalHeader/AvatarDropdown.vue | 1 + + src/vendor/ant-design-pro/permission.js | 13 ++++++++++++- + src/vendor/ant-design-pro/store/modules/user.js | 15 +++------------ + src/vendor/ant-design-pro/utils/request.js | 2 +- + src/views/user/Login.vue | 1 + + vue.config.js | 3 +++ + 6 files changed, 21 insertions(+), 14 deletions(-) + +diff --git a/src/vendor/ant-design-pro/components/GlobalHeader/AvatarDropdown.vue b/src/vendor/ant-design-pro/components/GlobalHeader/AvatarDropdown.vue +index a30ed66..ae97aed 100644 +--- a/src/vendor/ant-design-pro/components/GlobalHeader/AvatarDropdown.vue ++++ b/src/vendor/ant-design-pro/components/GlobalHeader/AvatarDropdown.vue +@@ -67,6 +67,7 @@ export default { + content: this.$t('layouts.usermenu.dialog.content'), + onOk: () => { + return this.$store.dispatch('Logout').then(() => { ++ this.$message.info('退出登陆!') + this.$router.push({name: 'login'}); + }); + }, +diff --git a/src/vendor/ant-design-pro/permission.js b/src/vendor/ant-design-pro/permission.js +index 41ffbfb..7d85dbd 100644 +--- a/src/vendor/ant-design-pro/permission.js ++++ b/src/vendor/ant-design-pro/permission.js +@@ -64,7 +64,18 @@ router.beforeEach((to, from, next) => { + }); + }); + } else { +- next(); ++ // 路由跳转前判断token是否过期 ++ if (localStorage.getItem('is_tokenvalid')) { ++ var interval = setInterval(function() { ++ if (!localStorage.getItem('is_tokenvalid')) { ++ clearInterval(interval); ++ // 执行某些操作 ++ next() ++ } ++ }, 1000); // 每隔1秒钟执行一次判断操作 ++ } else { ++ next(); ++ } + } + } + } else { +diff --git a/src/vendor/ant-design-pro/store/modules/user.js b/src/vendor/ant-design-pro/store/modules/user.js +index 4f185e3..505ce1c 100644 +--- a/src/vendor/ant-design-pro/store/modules/user.js ++++ b/src/vendor/ant-design-pro/store/modules/user.js +@@ -4,7 +4,7 @@ + + import storage from 'store'; + import cookie from 'js-cookie'; +-import { login, logout, refreshTokenFn } from '@/api/login'; ++import { login, refreshTokenFn } from '@/api/login'; + import { ACCESS_TOKEN, REFRESH_TOKIN } from '@/vendor/ant-design-pro/store/mutation-types'; + + const user = { +@@ -130,26 +130,17 @@ const user = { + cookie.remove('aops_token'); + cookie.remove('user_name'); + cookie.remove('refreshtoken'); +- +- return new Promise(resolve => { +- logout(state.token) +- .then(() => { +- resolve(); +- }) +- .catch(() => { +- resolve(); +- }) +- .finally(() => { }); +- }); + }, + + // 刷新token + RefreshToken({ commit, state }) { ++ storage.set('is_tokenvalid', true, 7 * 24 * 60 * 60 * 1000); + return new Promise((resolve, reject) => { + const refreshToken = localStorage.getItem('Refresh-Token').substring(1, localStorage.getItem('Refresh-Token').length - 1) + refreshTokenFn(refreshToken).then((res) => { + if (res.code === '200') { + const in20Minutes = 1 / 72; ++ storage.remove('is_tokenvalid'); + storage.set(ACCESS_TOKEN, res.data.token, 7 * 24 * 60 * 60 * 1000); + storage.set(REFRESH_TOKIN, res.data.refresh_token, 7 * 24 * 60 * 60 * 1000) + cookie.set('aops_token', res.data.token, { +diff --git a/src/vendor/ant-design-pro/utils/request.js b/src/vendor/ant-design-pro/utils/request.js +index e6f49ce..4a2383f 100644 +--- a/src/vendor/ant-design-pro/utils/request.js ++++ b/src/vendor/ant-design-pro/utils/request.js +@@ -96,7 +96,7 @@ request.interceptors.response.use(response => { + // token过期后,调接口,刷新token + store.dispatch('RefreshToken').then(() => { + // 再发请求 +- return request(response.config) ++ return request(response.config); + }).catch((err) => { + this.$message.error(err.response.message) + }) +diff --git a/src/views/user/Login.vue b/src/views/user/Login.vue +index 0026155..fae311a 100644 +--- a/src/views/user/Login.vue ++++ b/src/views/user/Login.vue +@@ -30,6 +30,7 @@ + validateTrigger: 'blur' + } + ]" ++ autocomplete + > + + +diff --git a/vue.config.js b/vue.config.js +index 4c6dec4..e38f377 100644 +--- a/vue.config.js ++++ b/vue.config.js +@@ -53,6 +53,9 @@ const vueConfig = { + }, + + chainWebpack: config => { ++ config.plugins.delete('prefetch') ++ config.plugins.delete('preload') ++ + config.resolve.alias.set('@$', resolve('src')); + + const svgRule = config.module.rule('svg'); +-- +Gitee + diff --git a/0002-fix-verify-the-host-name-field-issue.patch b/0002-fix-verify-the-host-name-field-issue.patch new file mode 100644 index 0000000..5586c17 --- /dev/null +++ b/0002-fix-verify-the-host-name-field-issue.patch @@ -0,0 +1,567 @@ +From 4ab8ff449fd0ae87de58a64509f1218eaf0a1efd Mon Sep 17 00:00:00 2001 +From: wkl505997900 <505997900@qq.com> +Date: Mon, 24 Apr 2023 16:11:22 +0800 +Subject: [PATCH] Verify the host name field before and after adding a host +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + .../ant-design-pro/layouts/UserLayout.vue | 3 +- + src/views/assests/HostEdition.vue | 80 ++++++++++--------- + src/views/assests/HostManagement.vue | 24 +++--- + src/views/assests/components/EditableCell.vue | 48 ++++++++--- + src/views/assests/components/addMoreHost.vue | 54 ++++++++++--- + src/views/leaks/components/UploadFile.vue | 4 +- + src/views/user/Login.vue | 2 +- + src/views/user/Register.vue | 6 +- + 8 files changed, 145 insertions(+), 76 deletions(-) + +diff --git a/src/vendor/ant-design-pro/layouts/UserLayout.vue b/src/vendor/ant-design-pro/layouts/UserLayout.vue +index 72dc176..b054097 100644 +--- a/src/vendor/ant-design-pro/layouts/UserLayout.vue ++++ b/src/vendor/ant-design-pro/layouts/UserLayout.vue +@@ -158,7 +158,8 @@ export default { + } + + .footer { +- width: 100%; ++ position: absolute; ++ width: 98%; + bottom: 0; + padding: 0 16px; + margin: 155px 0 24px; +diff --git a/src/views/assests/HostEdition.vue b/src/views/assests/HostEdition.vue +index fac76fc..a945a68 100644 +--- a/src/views/assests/HostEdition.vue ++++ b/src/views/assests/HostEdition.vue +@@ -12,10 +12,10 @@ + :maxLength="50" + v-decorator="[ + 'host_name', +- {rules: [{ required: true, message: '请输入主机名称'}, {validator: checkNameInput}]} ++ {rules: [{ required: true, message: '请输入主机名称'}, {validator: checkNameInput, validateTrigger: 'blur'}]}, + ]" + placeholder="请输入主机名称,50个字符以内"> +- ++ + + + +@@ -64,6 +64,7 @@ + + ++ :placeholder="pageType === 'create' ? '请设置主机登录密码' : '请输入主机登陆密码, 若未修改主机用户名或端口可以为空'"> + +- +- + + 取消 + state.host.hostInfo + }) +@@ -200,6 +193,16 @@ export default { + } + }, + methods: { ++ handleUserChange(value) { ++ if (this.pageType === 'edit') { ++ value.target.value === this.basicHostInfo.ssh_user ? this.UserRequired = false : this.UserRequired = true ++ } ++ }, ++ handlePortChange(value) { ++ if (this.pageType === 'edit') { ++ value === this.basicHostInfo.ssh_port ? this.PortRequired = false : this.PortRequired = true ++ } ++ }, + // 获取主机组列表数据 + getHostGroupList() { + const _this = this; +@@ -240,18 +243,23 @@ export default { + } + } + } +- editHost(tableParams, this.hostId) +- .then(function (res) { +- _this.$message.success(res.message); +- store.dispatch('resetHostInfo'); +- router.push('/assests/hosts-management'); +- }) +- .catch(function (err) { +- _this.$message.error(err.response.message); +- }) +- .finally(function () { +- _this.submitLoading = false; +- }); ++ if (JSON.stringify(tableParams) === '{}') { ++ this.$message.info('未存在修改数据!') ++ this.submitLoading = false; ++ } else { ++ editHost(tableParams, this.hostId) ++ .then(function (res) { ++ _this.$message.success(res.message); ++ store.dispatch('resetHostInfo'); ++ router.push('/assests/hosts-management'); ++ }) ++ .catch(function (err) { ++ _this.$message.error(err.response.message); ++ }) ++ .finally(function () { ++ _this.submitLoading = false; ++ }); ++ } + } else { + addHost(values) + .then(function (res) { +@@ -278,15 +286,15 @@ export default { + router.go(-1); + }, + checkNameInput(rule, value, cb) { +- if (/[^0-9a-z_.]/.test(value)) { ++ if (!/^\S.*\S$/.test(value)) { + /* eslint-disable */ +- cb('只能输入数字、小写字母和英文.和_'); ++ cb('首尾不允许空格'); + /* eslint-enable */ + return; + } +- if (/[_]$/.test(value)) { ++ if (!/^(?!\s*$).+/.test(value)) { + /* eslint-disable */ +- cb('结尾不能是英文下划线'); ++ cb('不允许全空格'); + /* eslint-enable */ + return; + } +diff --git a/src/views/assests/HostManagement.vue b/src/views/assests/HostManagement.vue +index 81c25eb..080c145 100644 +--- a/src/views/assests/HostManagement.vue ++++ b/src/views/assests/HostManagement.vue +@@ -58,7 +58,7 @@ + slot="hostName" + slot-scope="hostName, record">{{ hostName }} + {{ isMana ? '是' : '否' }} +- {{ statusMap(status) }} ++ {{ hostStatusMap[status] }} + {{ scene ? ( scene === 'normal' ? '通用' : scene ) : '暂无' }} + + ++ ++ + +
+ +- ****** ++ {{ countStar(form[formkey]) }} + {{ value || ' ' }} +
+ +@@ -58,15 +60,15 @@ export default { + } + }; + const checkNameInput = (rule, value, callback) => { +- if (/[^0-9a-z_.]/.test(value)) { ++ if (!/^\S.*\S$/.test(value)) { + /* eslint-disable */ +- callback(new Error('只能输入数字、小写字母和英文.和_')); ++ callback(new Error('首尾不允许空格')); + /* eslint-enable */ + return; + } +- if (/[_]$/.test(value)) { ++ if (!/^(?!\s*$).+/.test(value)) { + /* eslint-disable */ +- callback(new Error('结尾不能是英文下划线')); ++ callback(new Error('不允许全空格')); + /* eslint-enable */ + return; + } +@@ -102,6 +104,13 @@ export default { + }; + }, + methods: { ++ countStar(num) { ++ let str = '' ++ for (let i = 0; i < num.length; i++) { ++ str += '*' ++ } ++ return str ++ }, + handleChange(e) { + const value = e.target.value; + this.value = value; +@@ -113,22 +122,39 @@ export default { + check() { + this.$refs.ruleForm.validate(valid => { + if (valid) { +- this.editable = false; +- this.$emit('change', this.value); ++ if (this.editable) { ++ // 判断当前状态,只对处于修改状态的组件执行此操作,节省性能 ++ this.editable = false; ++ this.$emit('allowSub') ++ this.$emit('change', this.value); ++ } + } else { + return false; + } + }); + }, + edit() { ++ this.$emit('unSubmit') + this.editable = true; ++ }, ++ handleClickOutside(event) { ++ // 鼠标监听事件 ++ const target = event.target ++ const wrapper = this.$refs.childitem ++ // 判断点击的区域是否是当前组件的区域 ++ if (!wrapper.contains(target)) { ++ // 当点击组件之外时 执行校验操作 ++ this.check() ++ } + } + }, + created() { + }, ++ beforeDestroy() { ++ document.removeEventListener('mouseup', this.handleClickOutside) ++ }, + mounted() { +- // this.edit() +- // this.check() ++ document.addEventListener('mouseup', this.handleClickOutside) + }, + computed: { + form () { +diff --git a/src/views/assests/components/addMoreHost.vue b/src/views/assests/components/addMoreHost.vue +index 830bf03..4cd9a65 100644 +--- a/src/views/assests/components/addMoreHost.vue ++++ b/src/views/assests/components/addMoreHost.vue +@@ -32,7 +32,8 @@ + ref="host_ip" + formkey="host_ip" + :text="String(text)" +- @uploadstatus="uploadstatus($event)" ++ @unSubmit="unSubmit()" ++ @allowSub="allowSub()" + @change="onCellChange(record.key, 'host_ip', $event)" /> + + + + + + + +