File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ import { getCaptchaApi, loginApi } from "./apis"
99import Owl from " ./components/Owl.vue"
1010import { useFocus } from " ./composables/useFocus"
1111
12+ const route = useRoute ()
13+
1214const router = useRouter ()
1315
1416const userStore = useUserStore ()
@@ -57,7 +59,7 @@ function handleLogin() {
5759 loading .value = true
5860 loginApi (loginFormData ).then (({ data }) => {
5961 userStore .setToken (data .token )
60- router .push (" /" )
62+ router .push (route . query . redirect ? decodeURIComponent ( route . query . redirect as string ) : " /" )
6163 }).catch (() => {
6264 createCode ()
6365 loginFormData .password = " "
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export function registerNavigationGuard(router: Router) {
2525 // 如果在免登录的白名单中,则直接进入
2626 if ( isWhiteList ( to ) ) return true
2727 // 其他没有访问权限的页面将被重定向到登录页面
28- return LOGIN_PATH
28+ return ` ${ LOGIN_PATH } ?redirect= ${ encodeURIComponent ( to . fullPath ) } `
2929 }
3030 // 如果已经登录,并准备进入 Login 页面,则重定向到主页
3131 if ( to . path === LOGIN_PATH ) return "/"
You can’t perform that action at this time.
0 commit comments