Commit fb1648ecbaed13d8553e6e5c302613670f1f15d1

Authored by YunaiV
1 parent e923bc66

v3.8.2 修改登录超时刷新页面跳转登录页面还提示重新登录问题

yudao-ui-admin/.env.demo1024
@@ -19,3 +19,6 @@ VUE_APP_TENANT_ENABLE = true @@ -19,3 +19,6 @@ VUE_APP_TENANT_ENABLE = true
19 19
20 # 文档的开关 20 # 文档的开关
21 VUE_APP_DOC_ENABLE = true 21 VUE_APP_DOC_ENABLE = true
  22 +
  23 +# 百度统计
  24 +VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab
yudao-ui-admin/.env.development
@@ -16,3 +16,6 @@ VUE_APP_TENANT_ENABLE = true @@ -16,3 +16,6 @@ VUE_APP_TENANT_ENABLE = true
16 16
17 # 文档的开关 17 # 文档的开关
18 VUE_APP_DOC_ENABLE = true 18 VUE_APP_DOC_ENABLE = true
  19 +
  20 +# 百度统计
  21 +VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab
yudao-ui-admin/.env.production
@@ -17,3 +17,6 @@ VUE_APP_TENANT_ENABLE = true @@ -17,3 +17,6 @@ VUE_APP_TENANT_ENABLE = true
17 17
18 # 文档的开关 18 # 文档的开关
19 VUE_APP_DOC_ENABLE = false 19 VUE_APP_DOC_ENABLE = false
  20 +
  21 +# 百度统计
  22 +VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab
yudao-ui-admin/.env.staging
@@ -17,3 +17,6 @@ VUE_APP_TENANT_ENABLE = true @@ -17,3 +17,6 @@ VUE_APP_TENANT_ENABLE = true
17 17
18 # 文档的开关 18 # 文档的开关
19 VUE_APP_DOC_ENABLE = false 19 VUE_APP_DOC_ENABLE = false
  20 +
  21 +# 百度统计
  22 +VUE_APP_BAIDU_CODE = fadc1bd5db1a1d6f581df60a1807f8ab
yudao-ui-admin/src/main.js
@@ -15,6 +15,7 @@ import plugins from './plugins' // plugins @@ -15,6 +15,7 @@ import plugins from './plugins' // plugins
15 15
16 import './assets/icons' // icon 16 import './assets/icons' // icon
17 import './permission' // permission control 17 import './permission' // permission control
  18 +import './tongji' // 百度统计
18 import { getDicts } from "@/api/system/dict/data"; 19 import { getDicts } from "@/api/system/dict/data";
19 import { getConfigKey } from "@/api/infra/config"; 20 import { getConfigKey } from "@/api/infra/config";
20 import { parseTime, resetForm, addDateRange, addBeginAndEndTime, handleTree} from "@/utils/ruoyi"; 21 import { parseTime, resetForm, addDateRange, addBeginAndEndTime, handleTree} from "@/utils/ruoyi";
yudao-ui-admin/src/permission.js
@@ -4,9 +4,11 @@ import { Message } from 'element-ui' @@ -4,9 +4,11 @@ import { Message } from 'element-ui'
4 import NProgress from 'nprogress' 4 import NProgress from 'nprogress'
5 import 'nprogress/nprogress.css' 5 import 'nprogress/nprogress.css'
6 import { getToken } from '@/utils/auth' 6 import { getToken } from '@/utils/auth'
  7 +import { isRelogin } from '@/utils/request'
7 8
8 NProgress.configure({ showSpinner: false }) 9 NProgress.configure({ showSpinner: false })
9 10
  11 +// 增加三方登陆 update by 芋艿
10 const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/register', '/oauthLogin/gitee'] 12 const whiteList = ['/login', '/social-login', '/auth-redirect', '/bind', '/register', '/oauthLogin/gitee']
11 13
12 router.beforeEach((to, from, next) => { 14 router.beforeEach((to, from, next) => {
@@ -19,21 +21,23 @@ router.beforeEach((to, from, next) => { @@ -19,21 +21,23 @@ router.beforeEach((to, from, next) => {
19 NProgress.done() 21 NProgress.done()
20 } else { 22 } else {
21 if (store.getters.roles.length === 0) { 23 if (store.getters.roles.length === 0) {
22 - // 获取字典数据 24 + isRelogin.show = true
  25 + // 获取字典数据 add by 芋艿
23 store.dispatch('dict/loadDictDatas') 26 store.dispatch('dict/loadDictDatas')
24 // 判断当前用户是否已拉取完user_info信息 27 // 判断当前用户是否已拉取完user_info信息
25 store.dispatch('GetInfo').then(() => { 28 store.dispatch('GetInfo').then(() => {
  29 + isRelogin.show = false
26 store.dispatch('GenerateRoutes').then(accessRoutes => { 30 store.dispatch('GenerateRoutes').then(accessRoutes => {
27 // 根据roles权限生成可访问的路由表 31 // 根据roles权限生成可访问的路由表
28 router.addRoutes(accessRoutes) // 动态添加可访问路由表 32 router.addRoutes(accessRoutes) // 动态添加可访问路由表
29 next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 33 next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
30 }) 34 })
31 }).catch(err => { 35 }).catch(err => {
32 - store.dispatch('LogOut').then(() => {  
33 - Message.error(err)  
34 - next({ path: '/' })  
35 - }) 36 + store.dispatch('LogOut').then(() => {
  37 + Message.error(err)
  38 + next({ path: '/' })
36 }) 39 })
  40 + })
37 } else { 41 } else {
38 next() 42 next()
39 } 43 }
yudao-ui-admin/src/tongji.js 0 → 100644
  1 +// Baidu 统计 integration
  2 +import router from './router'
  3 +
  4 +window._hmt = window._hmt || []; // 用于 router push
  5 +const HM_ID = process.env.VUE_APP_BAIDU_CODE || ''; // 有值的时候,才开启
  6 +(function() {
  7 + if (!HM_ID) {
  8 + return;
  9 + }
  10 + const hm = document.createElement("script")
  11 + hm.src = "https://hm.baidu.com/hm.js?" + HM_ID
  12 + const s = document.getElementsByTagName("script")[0]
  13 + s.parentNode.insertBefore(hm, s)
  14 +})()
  15 +
  16 +router.afterEach(function (to) {
  17 + if (!HM_ID) {
  18 + return;
  19 + }
  20 + _hmt.push(['_trackPageview', to.fullPath])
  21 +})
yudao-ui-admin/src/utils/dict.js
@@ -96,7 +96,7 @@ export function getDictDatas2(dictType, values) { @@ -96,7 +96,7 @@ export function getDictDatas2(dictType, values) {
96 } 96 }
97 } 97 }
98 // debugger 98 // debugger
99 - console.log(results); 99 + // console.log(results);
100 return results; 100 return results;
101 } 101 }
102 102
yudao-ui-admin/src/utils/request.js
@@ -7,7 +7,7 @@ import Cookies from "js-cookie"; @@ -7,7 +7,7 @@ import Cookies from "js-cookie";
7 import {getTenantEnable} from "@/utils/ruoyi"; 7 import {getTenantEnable} from "@/utils/ruoyi";
8 8
9 // 是否显示重新登录 9 // 是否显示重新登录
10 -let isReloginShow; 10 +export let isRelogin = { show: false };
11 11
12 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' 12 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
13 // 创建axios实例 13 // 创建axios实例
@@ -66,23 +66,20 @@ service.interceptors.response.use(res => { @@ -66,23 +66,20 @@ service.interceptors.response.use(res => {
66 // 获取错误信息 66 // 获取错误信息
67 const msg = errorCode[code] || res.data.msg || errorCode['default'] 67 const msg = errorCode[code] || res.data.msg || errorCode['default']
68 if (code === 401) { 68 if (code === 401) {
69 - if (!isReloginShow) {  
70 - isReloginShow = true; 69 + if (!isRelogin.show) {
  70 + isRelogin.show = true;
71 MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { 71 MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
72 confirmButtonText: '重新登录', 72 confirmButtonText: '重新登录',
73 cancelButtonText: '取消', 73 cancelButtonText: '取消',
74 type: 'warning' 74 type: 'warning'
75 } 75 }
76 ).then(() => { 76 ).then(() => {
77 - isReloginShow = false; 77 + isRelogin.show = false;
78 store.dispatch('LogOut').then(() => { 78 store.dispatch('LogOut').then(() => {
79 - // 如果是登录页面不需要重新加载  
80 - if (window.location.hash.indexOf("#/login") !== 0) {  
81 - location.href = '/index';  
82 - } 79 + location.href = '/index';
83 }) 80 })
84 }).catch(() => { 81 }).catch(() => {
85 - isReloginShow = false; 82 + isRelogin.show = false;
86 }); 83 });
87 } 84 }
88 return Promise.reject('无效的会话,或者会话已过期,请重新登录。') 85 return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
yudao-ui-admin/src/views/socialLogin.vue
@@ -28,7 +28,6 @@ @@ -28,7 +28,6 @@
28 </template> 28 </template>
29 29
30 <script> 30 <script>
31 -import { socialLogin } from "@/api/login";  
32 import Cookies from "js-cookie"; 31 import Cookies from "js-cookie";
33 import { encrypt, decrypt } from '@/utils/jsencrypt' 32 import { encrypt, decrypt } from '@/utils/jsencrypt'
34 33