From a9db2570fe0acb1ae8f6b8ea5e04406ac56a44c4 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Mon, 8 Jul 2024 10:04:16 +0800 Subject: [PATCH] fix --- .env | 2 +- .env.production | 2 +- src/components/Panel/index.vue | 1 + src/utils/request.ts | 22 ++++++++++++++++++---- src/views/report/Index.vue | 1 + 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.env b/.env index 104e2c6..79153fd 100644 --- a/.env +++ b/.env @@ -2,7 +2,7 @@ VITE_APP_TITLE=金融产品设计及数字化营销沙盘 VITE_PORT=9520 # VITE_PROXY=http://192.168.31.125:8080 VITE_PUBLIC_PATH=./ -VITE_BASE_API=http://192.168.31.217:9000 +VITE_BASE_API=http://192.168.31.51:9000 # VITE_BASE_API=http://121.37.12.51 # VITE_BASE_API=https://www.occupationlab.com VITE_I18N_LOCALE=zh-cn diff --git a/.env.production b/.env.production index 01ed17a..d003acb 100644 --- a/.env.production +++ b/.env.production @@ -1 +1 @@ -VITE_BASE_API=https://www.occupationlab.com \ No newline at end of file +VITE_BASE_API=https://occupationlab.com \ No newline at end of file diff --git a/src/components/Panel/index.vue b/src/components/Panel/index.vue index 874d474..1d09b96 100644 --- a/src/components/Panel/index.vue +++ b/src/components/Panel/index.vue @@ -972,6 +972,7 @@ onUnmounted(() => { @media (max-width: 1450px) { .panel-header { .actions { + z-index: 10; position: absolute; top: 70px; right: 30px; diff --git a/src/utils/request.ts b/src/utils/request.ts index f0163f1..4e511ae 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -7,7 +7,7 @@ const service = axios.create({ baseURL: import.meta.env.VITE_BASE_API, timeout: 10000, }); -let loaded = 0; +let logouted = 0; service.interceptors.request.use( (config) => { config.headers = { ...config.headers, ...getAuthHeaders() }; @@ -18,13 +18,27 @@ service.interceptors.request.use( service.interceptors.response.use( (res) => { - const { message, status } = res.data; + const { message, status, code, msg } = res.data; if (status) { if (status === 200) { return res; } ElMessage.error(message); + } else if (code === 401) { + // 账号互踢 + if (!logouted) { + ElMessageBox.alert(msg.includes('顶') ? '您的账号已在其他设备登录,您已被迫下线!' : '登录过期,请重新登录!', { + confirmButtonText: '重新登录', + type: 'warning', + closeOnClickModal: false, + showClose: false, + }).then(() => { + // 未登录 + logout(); + }); + logouted = 1; + } } else { return res; } @@ -37,12 +51,12 @@ service.interceptors.response.use( }, } = e; if (status === 401) { - loaded || + logouted || ElMessageBox.alert('登录状态已过期,请重新登录', { confirmButtonText: '重新登录', type: 'warning', closeOnClickModal: false, showClose: false }).then(() => { // 未登录 logout(); }); - loaded = 1; + logouted = 1; } else if (message) { ElMessage.error(message); } diff --git a/src/views/report/Index.vue b/src/views/report/Index.vue index c94eba0..7e378e7 100644 --- a/src/views/report/Index.vue +++ b/src/views/report/Index.vue @@ -302,6 +302,7 @@ samp { padding: 10px 16px; font-size: 14px; color: #333; + white-space: pre-wrap; &.edit { color: #abb3c6; border: 1px solid #cacfdb;