Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
前端资源
RuoYi-Vue
提交
965bdc99
R
RuoYi-Vue
项目概览
前端资源
/
RuoYi-Vue
11 个月 前同步成功
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
RuoYi-Vue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
965bdc99
编写于
2月 19, 2022
作者:
若
若依
提交者:
Gitee
2月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
!431 修改登录超时刷新页面跳转登录页面还提示重新登录问题
Merge pull request !431 from 也曾为你、像超人/master
上级
d734bfc3
e7931380
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
62 deletion
+62
-62
ruoyi-ui/src/permission.js
ruoyi-ui/src/permission.js
+56
-53
ruoyi-ui/src/utils/request.js
ruoyi-ui/src/utils/request.js
+6
-9
未找到文件。
ruoyi-ui/src/permission.js
浏览文件 @
965bdc99
import
router
from
'
./router
'
import
store
from
'
./store
'
import
{
Message
}
from
'
element-ui
'
import
NProgress
from
'
nprogress
'
import
'
nprogress/nprogress.css
'
import
{
getToken
}
from
'
@/utils/auth
'
NProgress
.
configure
({
showSpinner
:
false
})
const
whiteList
=
[
'
/login
'
,
'
/auth-redirect
'
,
'
/bind
'
,
'
/register
'
]
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
NProgress
.
start
()
if
(
getToken
())
{
to
.
meta
.
title
&&
store
.
dispatch
(
'
settings/setTitle
'
,
to
.
meta
.
title
)
/* has token*/
if
(
to
.
path
===
'
/login
'
)
{
next
({
path
:
'
/
'
})
NProgress
.
done
()
}
else
{
if
(
store
.
getters
.
roles
.
length
===
0
)
{
// 判断当前用户是否已拉取完user_info信息
store
.
dispatch
(
'
GetInfo
'
).
then
(()
=>
{
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
:
'
/
'
})
})
})
}
else
{
next
()
}
}
}
else
{
// 没有token
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
// 在免登录白名单,直接进入
next
()
}
else
{
next
(
`/login?redirect=
${
to
.
fullPath
}
`
)
// 否则全部重定向到登录页
NProgress
.
done
()
}
}
})
router
.
afterEach
(()
=>
{
NProgress
.
done
()
})
import
router
from
'
./router
'
import
store
from
'
./store
'
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
})
const
whiteList
=
[
'
/login
'
,
'
/auth-redirect
'
,
'
/bind
'
,
'
/register
'
]
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
NProgress
.
start
()
if
(
getToken
())
{
to
.
meta
.
title
&&
store
.
dispatch
(
'
settings/setTitle
'
,
to
.
meta
.
title
)
/* has token*/
if
(
to
.
path
===
'
/login
'
)
{
next
({
path
:
'
/
'
})
NProgress
.
done
()
}
else
{
if
(
store
.
getters
.
roles
.
length
===
0
)
{
isRelogin
.
show
=
true
// 判断当前用户是否已拉取完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
:
'
/
'
})
})
})
}
else
{
next
()
}
}
}
else
{
// 没有token
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
// 在免登录白名单,直接进入
next
()
}
else
{
next
(
`/login?redirect=
${
to
.
fullPath
}
`
)
// 否则全部重定向到登录页
NProgress
.
done
()
}
}
})
router
.
afterEach
(()
=>
{
NProgress
.
done
()
})
ruoyi-ui/src/utils/request.js
浏览文件 @
965bdc99
...
...
@@ -9,7 +9,7 @@ import { saveAs } from 'file-saver'
let
downloadLoadingInstance
;
// 是否显示重新登录
let
isReloginShow
;
export
let
isRelogin
=
{
show
:
false
}
;
axios
.
defaults
.
headers
[
'
Content-Type
'
]
=
'
application/json;charset=utf-8
'
// 创建axios实例
...
...
@@ -76,23 +76,20 @@ service.interceptors.response.use(res => {
return
res
.
data
}
if
(
code
===
401
)
{
if
(
!
isRelogin
S
how
)
{
isRelogin
S
how
=
true
;
if
(
!
isRelogin
.
s
how
)
{
isRelogin
.
s
how
=
true
;
MessageBox
.
confirm
(
'
登录状态已过期,您可以继续留在该页面,或者重新登录
'
,
'
系统提示
'
,
{
confirmButtonText
:
'
重新登录
'
,
cancelButtonText
:
'
取消
'
,
type
:
'
warning
'
}
).
then
(()
=>
{
isRelogin
S
how
=
false
;
isRelogin
.
s
how
=
false
;
store
.
dispatch
(
'
LogOut
'
).
then
(()
=>
{
// 如果是登录页面不需要重新加载
if
(
window
.
location
.
hash
.
indexOf
(
"
#/login
"
)
!=
0
)
{
location
.
href
=
'
/index
'
;
}
location
.
href
=
'
/index
'
;
})
}).
catch
(()
=>
{
isRelogin
S
how
=
false
;
isRelogin
.
s
how
=
false
;
});
}
return
Promise
.
reject
(
'
无效的会话,或者会话已过期,请重新登录。
'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录