From e12a2655597c2698344cd4cc39b063a4db986e64 Mon Sep 17 00:00:00 2001 From: GAOANG <1140589958@qq.com> Date: Fri, 26 Jul 2024 18:17:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20pc=E7=AB=AF=E5=8D=95=E7=82=B9=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E8=B7=B3=E8=BD=AC=E5=88=B0=E8=AF=A5=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=20=E6=97=B6=E8=80=8C=E8=B7=B3=E5=88=B0=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/user.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 9e6435f..92195a2 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -136,14 +136,13 @@ export const useUserStore = defineStore({ const { token } = data; // save token this.setToken(token); - router.replace(params.targetURL || params.redirect || userInfo?.homePath || PageEnum.BASE_HOME) - return await this.afterLoginAction(false); + return await this.afterLoginAction(false, params.targetURL || params.redirect); } catch (error) { return Promise.reject(error); } }, - async afterLoginAction(goHome?: boolean): Promise { + async afterLoginAction(goHome?: boolean, redirect?): Promise { if (!this.getToken) return null; // get user info @@ -166,6 +165,7 @@ export const useUserStore = defineStore({ }); router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw); } + redirect && (await router.replace(decodeURIComponent(redirect))); goHome && (await router.replace(userInfo?.homePath || PageEnum.BASE_HOME)); }