Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
mlaj
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-06-13 10:05:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
34a3c1668d83a6ad91b3a94d6dc0dc6e7ff30599
34a3c166
1 parent
9f78f5ed
fix(路由): 恢复登录后重定向功能
修复登录流程中重定向功能被注释的问题,现在未登录用户将被重定向到登录页并携带当前路由信息,登录成功后自动跳转回原页面
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
8 deletions
src/router/guards.js
src/utils/axios.js
src/views/auth/LoginPage.vue
src/router/guards.js
View file @
34a3c16
/*
* @Date: 2025-03-20 20:36:36
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-0
5-23 14:21:22
* @LastEditTime: 2025-0
6-13 10:03:08
* @FilePath: /mlaj/src/router/guards.js
* @Description: 路由守卫逻辑
*/
...
...
@@ -67,8 +67,8 @@ export const checkAuth = (to) => {
if (needAuth && !currentUser) {
// 未登录时重定向到登录页面
//
return { path: '/login', query: { redirect: to.fullPath } }
return { path: '/login' }
return { path: '/login', query: { redirect: to.fullPath } }
//
return { path: '/login' }
}
return true
...
...
src/utils/axios.js
View file @
34a3c16
...
...
@@ -48,8 +48,8 @@ axios.interceptors.response.use(
localStorage
.
removeItem
(
'currentUser'
);
// 跳转到登录页面,并携带当前路由信息
const
currentPath
=
router
.
currentRoute
.
value
.
fullPath
;
//
router.push(`/login?redirect=${encodeURIComponent(currentPath)}`);
router
.
push
(
`/login`
);
router
.
push
(
`/login?redirect=
${
encodeURIComponent
(
currentPath
)}
`
);
//
router.push(`/login`);
}
return
response
;
},
...
...
src/views/auth/LoginPage.vue
View file @
34a3c16
...
...
@@ -287,9 +287,9 @@ const handleSubmit = async () => {
if (success) {
// 如果有重定向参数,登录成功后跳转到对应页面
//
const redirect = $route.query.redirect;
//
router.push(redirect || "/");
router.push("/");
const redirect = $route.query.redirect;
router.push(redirect || "/");
//
router.push("/");
} else {
error.value = "登录失败,请检查您的输入项";
}
...
...
Please
register
or
login
to post a comment