From 042db393ca1efadd4b35e8ace5a4cba3b7200c15 Mon Sep 17 00:00:00 2001 From: wangxiaoshuang <825034831@qq.com> Date: Fri, 25 Apr 2025 10:36:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E9=94=81=E5=AE=9A=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E8=BE=93=E5=85=A5=E8=B4=A6=E5=8F=B7=E5=AF=86=E7=A0=81?= =?UTF-8?q?=E8=A7=A3=E9=94=81=EF=BC=8C=E7=84=B6=E5=90=8E=E5=86=8D=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=85=B6=E4=BB=96=E9=A1=B5=E9=9D=A2=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=BC=B9=E5=87=BA=E5=AF=B9=E8=AF=9D=E6=A1=86?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 27 ++++++++++++++++++++------- src/utils/request.js | 9 +++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main.js b/src/main.js index d04871c..c04eb76 100644 --- a/src/main.js +++ b/src/main.js @@ -338,18 +338,31 @@ async function VueInit() { /* eslint-disable */ waitOperate(eval(process.env.VUE_APP_LOGOUT_FOR_PERMISSION) ? () => { var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh' - if (_vm.$route.path === '/ReviewersResearchForm' || _vm.$route.path === '/ReviewersResearch' || path === '/' || _vm.$route.path === '/login' || _vm.$route.path === '/email-recompose' || _vm.$route.path === '/recompose' || _vm.$route.path === '/resetpassword' || _vm.$route.path === '/error') { + if (_vm.$route.path === '/ReviewersResearchForm' || _vm.$route.path === '/ReviewersResearch' || _vm.$route.path === '/' || _vm.$route.path === '/login' || _vm.$route.path === '/email-recompose' || _vm.$route.path === '/recompose' || _vm.$route.path === '/resetpassword' || _vm.$route.path === '/error') { count = 0; localStorage.setItem('count', '0') return } _vm.$store.dispatch('user/logout').then(res => { - window.location.href = `/login` + // window.location.href = `/login` + try { + if (_vm.$msgbox && _vm.$msgbox.close) { + _vm.$msgbox.close(); + } + } catch (err) { + console.log(err) + } + isOpen = false + isLock = null + zzSessionStorage.removeItem('isLock') + router.push("/login") + }).then(() => { + _vm.$alert(lang === 'zh' ? '由于您长时间未操作,为保护您的数据安全已强制将您下线,如果需要继续操作请重新登陆!' : 'No operation for a long time non-operation, you have been forced logout to protect data security. If continue to operate, please login again!', { + type: 'warning', + }) }) - _vm.$alert(lang === 'zh' ? '由于您长时间未操作,为保护您的数据安全已强制将您下线,如果需要继续操作请重新登陆!' : 'No operation for a long time non-operation, you have been forced logout to protect data security. If continue to operate, please login again!', { - type: 'warning', - }) + } : () => { }, process.env.VUE_APP_LOGOUT_FOR_TIME, eval(process.env.VUE_APP_LOCK_FOR_PERMISSION) ? () => { var lang = zzSessionStorage.getItem('lang') ? zzSessionStorage.getItem('lang') : 'zh' @@ -375,11 +388,11 @@ async function VueInit() { beforeClose: (action, instance, done) => { if (action === 'confirm') { if (!_vm.unlock.my_username) { - _vm.$alert(lang === 'zh' ? '请输入您的用户名解锁' : 'Please enter your user name to unlock.') + _vm.$message.warning(lang === 'zh' ? '请输入您的用户名解锁' : 'Please enter your user name to unlock.') return } if (!_vm.unlock.my_password) { - _vm.$alert(lang === 'zh' ? '请输入您的密码解锁' : 'Please enter the correct password to unlock.') + _vm.$message.warning(lang === 'zh' ? '请输入您的密码解锁' : 'Please enter the correct password to unlock.') return } var my_username = zzSessionStorage.getItem('my_username') diff --git a/src/utils/request.js b/src/utils/request.js index 3c48c3f..b75c3d0 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -3,6 +3,7 @@ import { Message, MessageBox, Alert } from 'element-ui' import store from '@/store' import router from '@/router' import Vue from 'vue' +const ROUTER = require('@/router'); axios.defaults.withCredentials = false const service = axios.create({ baseURL: '/api', @@ -77,6 +78,14 @@ service.interceptors.response.use( const status = error.response.status if (error.response.data && (error.response.data.Code === -1 || error.response.data.Code === -2)) { store.dispatch('user/logout').then(() => { + let _vm = ROUTER.default.app + try { + if (_vm.$msgbox && _vm.$msgbox.close) { + _vm.$msgbox.close(); + } + } catch (err) { + console.log(err) + } router.push(`/login`) this.$i18n.locale = 'zh' this.setLanguage('zh')