Skip to content

Commit

Permalink
fix #112
Browse files Browse the repository at this point in the history
  • Loading branch information
Nero978 committed Jan 29, 2024
1 parent 0b8fef7 commit e5f9220
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app-front/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app-front",
"version": "2.0.1",
"version": "2.0.2",
"private": true,
"type": "module",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions app-front/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ router.beforeEach((to, from) => {
// 设置页面标题
let wholeTitle = to.meta.title + " | GreenWorld - 人与自然和谐共生";
document.title = wholeTitle;

// 判断该路由是否需要登录权限
if (JWTToken.hasToken()) {
if (JWTToken.isVaildRefreshToken()) {
if (!JWTToken.isVaildAccessToken()) {
JWTToken.refreshToken();
}
return true;
} else {
message.error('登录过期,请重新登录');
JWTToken.logout();
Expand All @@ -149,17 +149,17 @@ router.beforeEach((to, from) => {
path: '/login',
query: { redirect: to.fullPath }
});
} else {
return true;
}
}

// 如果已登录,访问登录页面则跳转到首页
if (to.path === '/login' && JWTToken.hasToken() && JWTToken.isVaildRefreshToken()) {
message.success('您已登录,无需重复登录');
router.replace({
path: '/',
});
}

return true;
});

Expand Down

0 comments on commit e5f9220

Please sign in to comment.