227 lines
8.2 KiB
Diff
227 lines
8.2 KiB
Diff
|
|
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 }}
|
|||
|
|
<!-- {{ record.last_scan === null ? '未扫描' : record.last_scan }} -->
|
|||
|
|
</div>
|
|||
|
|
+ <div slot="repo" slot-scope="repo">
|
|||
|
|
+ {{ repo || '——' }}
|
|||
|
|
+ </div>
|
|||
|
|
<div slot="hotpatch" slot-scope="hotpatch">
|
|||
|
|
{{ hotpatch ? '是' : '否' }}
|
|||
|
|
<!-- {{ record.last_scan === null ? '未扫描' : record.last_scan }} -->
|
|||
|
|
@@ -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
|
|||
|
|
>
|
|||
|
|
<a-icon slot="prefix" type="lock" :style="{color: 'rgba(0,0,0,.25)'}" />
|
|||
|
|
</a-input-password>
|
|||
|
|
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
|
|||
|
|
|