Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
e7931380
提交
e7931380
authored
2月 17, 2022
作者:
积硅步,至千里
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改登录超时刷新页面跳转登录页面还提示重新登录问题
上级
d734bfc3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
62 行增加
和
62 行删除
+62
-62
permission.js
ruoyi-ui/src/permission.js
+56
-53
request.js
ruoyi-ui/src/utils/request.js
+6
-9
没有找到文件。
ruoyi-ui/src/permission.js
浏览文件 @
e7931380
import
router
from
'./router'
import
router
from
'./router'
import
store
from
'./store'
import
store
from
'./store'
import
{
Message
}
from
'element-ui'
import
{
Message
}
from
'element-ui'
import
NProgress
from
'nprogress'
import
NProgress
from
'nprogress'
import
'nprogress/nprogress.css'
import
'nprogress/nprogress.css'
import
{
getToken
}
from
'@/utils/auth'
import
{
getToken
}
from
'@/utils/auth'
import
{
isRelogin
}
from
'@/utils/request'
NProgress
.
configure
({
showSpinner
:
false
})
NProgress
.
configure
({
showSpinner
:
false
})
const
whiteList
=
[
'/login'
,
'/auth-redirect'
,
'/bind'
,
'/register'
]
const
whiteList
=
[
'/login'
,
'/auth-redirect'
,
'/bind'
,
'/register'
]
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
NProgress
.
start
()
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
if
(
getToken
())
{
NProgress
.
start
()
to
.
meta
.
title
&&
store
.
dispatch
(
'settings/setTitle'
,
to
.
meta
.
title
)
if
(
getToken
())
{
/* has token*/
to
.
meta
.
title
&&
store
.
dispatch
(
'settings/setTitle'
,
to
.
meta
.
title
)
if
(
to
.
path
===
'/login'
)
{
/* has token*/
next
({
path
:
'/'
})
if
(
to
.
path
===
'/login'
)
{
NProgress
.
done
()
next
({
path
:
'/'
})
}
else
{
NProgress
.
done
()
if
(
store
.
getters
.
roles
.
length
===
0
)
{
}
else
{
// 判断当前用户是否已拉取完user_info信息
if
(
store
.
getters
.
roles
.
length
===
0
)
{
store
.
dispatch
(
'GetInfo'
).
then
(()
=>
{
isRelogin
.
show
=
true
store
.
dispatch
(
'GenerateRoutes'
).
then
(
accessRoutes
=>
{
// 判断当前用户是否已拉取完user_info信息
// 根据roles权限生成可访问的路由表
store
.
dispatch
(
'GetInfo'
).
then
(()
=>
{
router
.
addRoutes
(
accessRoutes
)
// 动态添加可访问路由表
isRelogin
.
show
=
false
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成
store
.
dispatch
(
'GenerateRoutes'
).
then
(
accessRoutes
=>
{
})
// 根据roles权限生成可访问的路由表
}).
catch
(
err
=>
{
router
.
addRoutes
(
accessRoutes
)
// 动态添加可访问路由表
store
.
dispatch
(
'LogOut'
).
then
(()
=>
{
next
({
...
to
,
replace
:
true
})
// hack方法 确保addRoutes已完成
Message
.
error
(
err
)
})
next
({
path
:
'/'
})
}).
catch
(
err
=>
{
})
store
.
dispatch
(
'LogOut'
).
then
(()
=>
{
})
Message
.
error
(
err
)
}
else
{
next
({
path
:
'/'
})
next
()
})
}
})
}
}
else
{
}
else
{
next
()
// 没有token
}
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
}
// 在免登录白名单,直接进入
}
else
{
next
()
// 没有token
}
else
{
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
next
(
`/login?redirect=
${
to
.
fullPath
}
`
)
// 否则全部重定向到登录页
// 在免登录白名单,直接进入
NProgress
.
done
()
next
()
}
}
else
{
}
next
(
`/login?redirect=
${
to
.
fullPath
}
`
)
// 否则全部重定向到登录页
})
NProgress
.
done
()
}
router
.
afterEach
(()
=>
{
}
NProgress
.
done
()
})
})
router
.
afterEach
(()
=>
{
NProgress
.
done
()
})
ruoyi-ui/src/utils/request.js
浏览文件 @
e7931380
...
@@ -9,7 +9,7 @@ import { saveAs } from 'file-saver'
...
@@ -9,7 +9,7 @@ import { saveAs } from 'file-saver'
let
downloadLoadingInstance
;
let
downloadLoadingInstance
;
// 是否显示重新登录
// 是否显示重新登录
let
isReloginShow
;
export
let
isRelogin
=
{
show
:
false
}
;
axios
.
defaults
.
headers
[
'Content-Type'
]
=
'application/json;charset=utf-8'
axios
.
defaults
.
headers
[
'Content-Type'
]
=
'application/json;charset=utf-8'
// 创建axios实例
// 创建axios实例
...
@@ -76,23 +76,20 @@ service.interceptors.response.use(res => {
...
@@ -76,23 +76,20 @@ service.interceptors.response.use(res => {
return
res
.
data
return
res
.
data
}
}
if
(
code
===
401
)
{
if
(
code
===
401
)
{
if
(
!
isRelogin
S
how
)
{
if
(
!
isRelogin
.
s
how
)
{
isRelogin
S
how
=
true
;
isRelogin
.
s
how
=
true
;
MessageBox
.
confirm
(
'登录状态已过期,您可以继续留在该页面,或者重新登录'
,
'系统提示'
,
{
MessageBox
.
confirm
(
'登录状态已过期,您可以继续留在该页面,或者重新登录'
,
'系统提示'
,
{
confirmButtonText
:
'重新登录'
,
confirmButtonText
:
'重新登录'
,
cancelButtonText
:
'取消'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
type
:
'warning'
}
}
).
then
(()
=>
{
).
then
(()
=>
{
isRelogin
S
how
=
false
;
isRelogin
.
s
how
=
false
;
store
.
dispatch
(
'LogOut'
).
then
(()
=>
{
store
.
dispatch
(
'LogOut'
).
then
(()
=>
{
// 如果是登录页面不需要重新加载
location
.
href
=
'/index'
;
if
(
window
.
location
.
hash
.
indexOf
(
"#/login"
)
!=
0
)
{
location
.
href
=
'/index'
;
}
})
})
}).
catch
(()
=>
{
}).
catch
(()
=>
{
isRelogin
S
how
=
false
;
isRelogin
.
s
how
=
false
;
});
});
}
}
return
Promise
.
reject
(
'无效的会话,或者会话已过期,请重新登录。'
)
return
Promise
.
reject
(
'无效的会话,或者会话已过期,请重新登录。'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论