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')