mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
v3.8.2 修改登录超时刷新页面跳转登录页面还提示重新登录问题
This commit is contained in:
parent
e923bc661d
commit
fb1648ecba
@ -19,3 +19,6 @@ VUE_APP_TENANT_ENABLE = true
|
||||
|
||||
# 文档的开关
|
||||
VUE_APP_DOC_ENABLE = true
|
||||
|
||||
# 百度统计
|
||||
VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab
|
||||
|
@ -16,3 +16,6 @@ VUE_APP_TENANT_ENABLE = true
|
||||
|
||||
# 文档的开关
|
||||
VUE_APP_DOC_ENABLE = true
|
||||
|
||||
# 百度统计
|
||||
VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab
|
||||
|
@ -17,3 +17,6 @@ VUE_APP_TENANT_ENABLE = true
|
||||
|
||||
# 文档的开关
|
||||
VUE_APP_DOC_ENABLE = false
|
||||
|
||||
# 百度统计
|
||||
VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab
|
||||
|
@ -17,3 +17,6 @@ VUE_APP_TENANT_ENABLE = true
|
||||
|
||||
# 文档的开关
|
||||
VUE_APP_DOC_ENABLE = false
|
||||
|
||||
# 百度统计
|
||||
VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab
|
||||
|
@ -15,6 +15,7 @@ import plugins from './plugins' // plugins
|
||||
|
||||
import './assets/icons' // icon
|
||||
import './permission' // permission control
|
||||
import './tongji' // 百度统计
|
||||
import { getDicts } from "@/api/system/dict/data";
|
||||
import { getConfigKey } from "@/api/infra/config";
|
||||
import { parseTime, resetForm, addDateRange, addBeginAndEndTime, handleTree} from "@/utils/ruoyi";
|
||||
|
@ -4,9 +4,11 @@ import { Message } from 'element-ui'
|
||||
import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { isRelogin } from '@/utils/request'
|
||||
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
||||
// 增加三方登陆 update by 芋艿
|
||||
const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/register', '/oauthLogin/gitee']
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
@ -19,21 +21,23 @@ router.beforeEach((to, from, next) => {
|
||||
NProgress.done()
|
||||
} else {
|
||||
if (store.getters.roles.length === 0) {
|
||||
// 获取字典数据
|
||||
isRelogin.show = true
|
||||
// 获取字典数据 add by 芋艿
|
||||
store.dispatch('dict/loadDictDatas')
|
||||
// 判断当前用户是否已拉取完user_info信息
|
||||
store.dispatch('GetInfo').then(() => {
|
||||
isRelogin.show = false
|
||||
store.dispatch('GenerateRoutes').then(accessRoutes => {
|
||||
// 根据roles权限生成可访问的路由表
|
||||
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
||||
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||
})
|
||||
}).catch(err => {
|
||||
store.dispatch('LogOut').then(() => {
|
||||
Message.error(err)
|
||||
next({ path: '/' })
|
||||
})
|
||||
store.dispatch('LogOut').then(() => {
|
||||
Message.error(err)
|
||||
next({ path: '/' })
|
||||
})
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
21
yudao-ui-admin/src/tongji.js
Normal file
21
yudao-ui-admin/src/tongji.js
Normal file
@ -0,0 +1,21 @@
|
||||
// Baidu 统计 integration
|
||||
import router from './router'
|
||||
|
||||
window._hmt = window._hmt || []; // 用于 router push
|
||||
const HM_ID = process.env.VUE_APP_BAIDU_CODE || ''; // 有值的时候,才开启
|
||||
(function() {
|
||||
if (!HM_ID) {
|
||||
return;
|
||||
}
|
||||
const hm = document.createElement("script")
|
||||
hm.src = "https://hm.baidu.com/hm.js?" + HM_ID
|
||||
const s = document.getElementsByTagName("script")[0]
|
||||
s.parentNode.insertBefore(hm, s)
|
||||
})()
|
||||
|
||||
router.afterEach(function (to) {
|
||||
if (!HM_ID) {
|
||||
return;
|
||||
}
|
||||
_hmt.push(['_trackPageview', to.fullPath])
|
||||
})
|
@ -96,7 +96,7 @@ export function getDictDatas2(dictType, values) {
|
||||
}
|
||||
}
|
||||
// debugger
|
||||
console.log(results);
|
||||
// console.log(results);
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import Cookies from "js-cookie";
|
||||
import {getTenantEnable} from "@/utils/ruoyi";
|
||||
|
||||
// 是否显示重新登录
|
||||
let isReloginShow;
|
||||
export let isRelogin = { show: false };
|
||||
|
||||
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
|
||||
// 创建axios实例
|
||||
@ -66,23 +66,20 @@ service.interceptors.response.use(res => {
|
||||
// 获取错误信息
|
||||
const msg = errorCode[code] || res.data.msg || errorCode['default']
|
||||
if (code === 401) {
|
||||
if (!isReloginShow) {
|
||||
isReloginShow = true;
|
||||
if (!isRelogin.show) {
|
||||
isRelogin.show = true;
|
||||
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
|
||||
confirmButtonText: '重新登录',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}
|
||||
).then(() => {
|
||||
isReloginShow = false;
|
||||
isRelogin.show = false;
|
||||
store.dispatch('LogOut').then(() => {
|
||||
// 如果是登录页面不需要重新加载
|
||||
if (window.location.hash.indexOf("#/login") !== 0) {
|
||||
location.href = '/index';
|
||||
}
|
||||
location.href = '/index';
|
||||
})
|
||||
}).catch(() => {
|
||||
isReloginShow = false;
|
||||
isRelogin.show = false;
|
||||
});
|
||||
}
|
||||
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
|
||||
|
@ -28,7 +28,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { socialLogin } from "@/api/login";
|
||||
import Cookies from "js-cookie";
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user