Skip to content

Commit

Permalink
Merge pull request #111 from 434ROOM/app-front
Browse files Browse the repository at this point in the history
fix #110
  • Loading branch information
Nero978 authored Jan 11, 2024
2 parents 9e31cf5 + 96bd3b4 commit 0b8fef7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 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": "1.0.0",
"version": "2.0.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
30 changes: 16 additions & 14 deletions app-front/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,25 @@ router.beforeEach((to, from) => {
let wholeTitle = to.meta.title + " | GreenWorld - 人与自然和谐共生";
document.title = wholeTitle;
// 判断该路由是否需要登录权限
if (to.meta.requireAuth) {
if (JWTToken.hasToken()) {
if (JWTToken.isVaildRefreshToken()) {
if (!JWTToken.isVaildAccessToken()) {
JWTToken.refreshToken();
}
return true;
} else {
message.error('登录过期,请重新登录');
if (JWTToken.hasToken()) {
if (JWTToken.isVaildRefreshToken()) {
if (!JWTToken.isVaildAccessToken()) {
JWTToken.refreshToken();
}
return true;
} else {
message.info('访问此页面需要登录');
message.error('登录过期,请重新登录');
JWTToken.logout();
}
} else {
if (to.meta.requireAuth) {
message.info('访问此页面需要登录'); router.replace({
path: '/login',
query: { redirect: to.fullPath }
});
} else {
return true;
}
router.replace({
path: '/login',
query: { redirect: to.fullPath }
});
}
// 如果已登录,访问登录页面则跳转到首页
if (to.path === '/login' && JWTToken.hasToken() && JWTToken.isVaildRefreshToken()) {
Expand Down

0 comments on commit 0b8fef7

Please sign in to comment.