!47 [sync] PR-46: 解决用户不定时退出问题及任务列表筛选有误等问题
From: @openeuler-sync-bot Reviewed-by: @zhu-yuncheng Signed-off-by: @zhu-yuncheng
This commit is contained in:
commit
61fe113184
157
0005-fix-token-refresh-issue.patch
Normal file
157
0005-fix-token-refresh-issue.patch
Normal file
@ -0,0 +1,157 @@
|
||||
From 6d60ace02d2a80c5ecc200e847963780cbc861cc Mon Sep 17 00:00:00 2001
|
||||
From: wkl505997900 <2313665567@qq.com>
|
||||
Date: Fri, 9 Jun 2023 17:50:01 +0800
|
||||
Subject: [PATCH] fix tokenissue
|
||||
|
||||
---
|
||||
src/vendor/ant-design-pro/utils/request.js | 64 +++++++++++++++++-----
|
||||
src/vendor/ant-design-pro/utils/util.js | 16 ++++++
|
||||
src/views/leaks/LeakTaskList.vue | 3 +-
|
||||
src/views/leaks/components/HostTable.vue | 3 +-
|
||||
4 files changed, 69 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/src/vendor/ant-design-pro/utils/request.js b/src/vendor/ant-design-pro/utils/request.js
|
||||
index 53d4f3b..bccd36c 100644
|
||||
--- a/src/vendor/ant-design-pro/utils/request.js
|
||||
+++ b/src/vendor/ant-design-pro/utils/request.js
|
||||
@@ -7,6 +7,24 @@ import store from '@/store';
|
||||
import notification from 'ant-design-vue/es/notification';
|
||||
import { VueAxios } from './axios';
|
||||
|
||||
+// 全局声明缓存变量
|
||||
+var timestamp1;
|
||||
+var isRefreshing = false;
|
||||
+
|
||||
+let subscribers = []
|
||||
+// 刷新 token 后, 将缓存的接口重新请求一次
|
||||
+function onAccessTokenFetched(newToken) {
|
||||
+ subscribers.forEach((callback) => {
|
||||
+ callback(newToken)
|
||||
+ })
|
||||
+ // 清空缓存接口
|
||||
+ subscribers = []
|
||||
+}
|
||||
+// 添加缓存接口
|
||||
+function addSubscriber(callback) {
|
||||
+ subscribers.push(callback)
|
||||
+}
|
||||
+
|
||||
const errorMsgs = {
|
||||
noResponse: 'request failed, no response'
|
||||
};
|
||||
@@ -77,25 +95,41 @@ request.interceptors.response.use(response => {
|
||||
let err = null;
|
||||
switch (code) {
|
||||
case '1201':
|
||||
- notification.error({
|
||||
- message: '用户校验失败',
|
||||
- description: response.data.message
|
||||
- });
|
||||
- store.dispatch('Logout').then(() => {
|
||||
+ if (!timestamp1 || timestamp1 + 1632252465 < new Date().getTime()) {
|
||||
+ timestamp1 = new Date().getTime();
|
||||
+ notification.error({
|
||||
+ message: '用户校验失败',
|
||||
+ description: response.data.message
|
||||
+ });
|
||||
setTimeout(() => {
|
||||
- window.location.reload();
|
||||
- }, 1500);
|
||||
- })
|
||||
+ store.dispatch('Logout').then(() => {
|
||||
+ window.location.reload();
|
||||
+ }).catch((err) => {
|
||||
+ this.$message.error(err.response.message)
|
||||
+ })
|
||||
+ }, 1000)
|
||||
+ }
|
||||
break;
|
||||
case '1207':
|
||||
- // token过期后,调接口,刷新token
|
||||
- store.dispatch('RefreshToken').then(() => {
|
||||
- // 再发请求
|
||||
- return request(response.config);
|
||||
- }).catch((err) => {
|
||||
- this.$message.error(err.response.message)
|
||||
+ if (!isRefreshing) {
|
||||
+ isRefreshing = true
|
||||
+ store.dispatch('RefreshToken').then(() => {
|
||||
+ // 再发请求
|
||||
+ isRefreshing = false
|
||||
+ onAccessTokenFetched(localStorage.getItem('Access-Token'))
|
||||
+ }).catch(() => {
|
||||
+ isRefreshing = false;
|
||||
+ window.location.reload();
|
||||
+ })
|
||||
+ }
|
||||
+ const retryRequest = new Promise((resolve) => {
|
||||
+ addSubscriber((newToken) => {
|
||||
+ response.config.headers['Access-Token'] = newToken;
|
||||
+ response.config.url = response.config.url.replace(response.config.baseURL, '')
|
||||
+ resolve(request(response.config))
|
||||
+ })
|
||||
})
|
||||
- break;
|
||||
+ return retryRequest
|
||||
default:
|
||||
err = new Error(response.data.message);
|
||||
err.data = response.data.data;
|
||||
diff --git a/src/vendor/ant-design-pro/utils/util.js b/src/vendor/ant-design-pro/utils/util.js
|
||||
index 979e320..dd73f3e 100644
|
||||
--- a/src/vendor/ant-design-pro/utils/util.js
|
||||
+++ b/src/vendor/ant-design-pro/utils/util.js
|
||||
@@ -2,6 +2,22 @@
|
||||
* @file: antd vue框架的通用工具文件
|
||||
*/
|
||||
|
||||
+// 节流函数
|
||||
+export function throttle(func, wait) {
|
||||
+ let timeout;
|
||||
+ return () => {
|
||||
+ const context = this
|
||||
+ const args = arguments
|
||||
+ if (!timeout) {
|
||||
+ func.apply(context, args);
|
||||
+ timeout = setTimeout(function () {
|
||||
+ timeout = null
|
||||
+ }, wait)
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+export default throttle
|
||||
+
|
||||
export function timeFix() {
|
||||
const time = new Date();
|
||||
const hour = time.getHours();
|
||||
diff --git a/src/views/leaks/LeakTaskList.vue b/src/views/leaks/LeakTaskList.vue
|
||||
index d40d8d8..ca4b697 100644
|
||||
--- a/src/views/leaks/LeakTaskList.vue
|
||||
+++ b/src/views/leaks/LeakTaskList.vue
|
||||
@@ -251,7 +251,8 @@ export default {
|
||||
handleTableChange(pagination, filters, sorter) {
|
||||
// 存储翻页状态
|
||||
this.pagination = pagination;
|
||||
- this.filters = filters;
|
||||
+ // this.filters = filters;
|
||||
+ this.filters = Object.assign({}, this.filters, filters);
|
||||
this.sorter = sorter;
|
||||
// 出发排序、筛选、分页时,重新请求主机列表
|
||||
this.getTaskList();
|
||||
diff --git a/src/views/leaks/components/HostTable.vue b/src/views/leaks/components/HostTable.vue
|
||||
index 96a7737..4f9e431 100644
|
||||
--- a/src/views/leaks/components/HostTable.vue
|
||||
+++ b/src/views/leaks/components/HostTable.vue
|
||||
@@ -20,8 +20,9 @@
|
||||
已修复
|
||||
</a-radio-button>
|
||||
</a-radio-group>
|
||||
+ <a-input-search placeholder="按主机名搜索" v-model="hostSearch" @change="searchChange" style="width: 200px;margin-left: 10px;" @search="onSearch" />
|
||||
</a-col>
|
||||
- <a-col>
|
||||
+ <a-col v-else>
|
||||
<a-input-search placeholder="按主机名搜索" v-model="hostSearch" @change="searchChange" style="width: 200px" @search="onSearch" />
|
||||
</a-col>
|
||||
<a-col>
|
||||
--
|
||||
Gitee
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
Name: aops-hermes
|
||||
Version: v1.2.1
|
||||
Release: 5
|
||||
Release: 6
|
||||
Summary: Web for an intelligent diagnose frame
|
||||
License: MulanPSL2
|
||||
URL: https://gitee.com/openeuler/%{name}
|
||||
@ -12,6 +12,7 @@ Patch0001: 0001-Resolve-issues-such-as-abnormal-display.patch
|
||||
Patch0002: 0002-Host-management-field-changes-and-hot-patch-repair.patch
|
||||
Patch0003: 0003-add-Hot-patch-Filtering-function.patch
|
||||
Patch0004: 0004-add-host-under-cve-hotpatch-Filtering-function.patch
|
||||
Patch0005: 0005-fix-token-refresh-issue.patch
|
||||
|
||||
|
||||
BuildRequires: nodejs node-gyp nodejs-yarn
|
||||
@ -47,6 +48,11 @@ cp -r deploy/aops-hermes.service %{buildroot}/usr/lib/systemd/system/
|
||||
|
||||
|
||||
%changelog
|
||||
* Fri Jun 9 2023 wangkunlong<505997900@qq.com> - v1.2.1-6
|
||||
- Fix-token-refresh-issue
|
||||
- Solve-the-issue-of-unreasonable-layout-in-the-CVE-detail-interface
|
||||
- Resolve-the-issue-of-incorrect-task-list-filtering
|
||||
|
||||
* Fri Jun 2 2023 wangkunlong<505997900@qq.com> - v1.2.1-5
|
||||
- Add host under cve hotpatch Filtering function
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user