From 42ed4f08b50b3c3d94321dd22ed381da7bc117a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E4=B8=83=E5=B9=B4=E5=A4=8F?= <2098833867@qq.com> Date: Fri, 3 Mar 2023 11:12:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E7=99=BB=E5=BD=95=E6=97=B6ro?= =?UTF-8?q?uter=E5=BC=82=E5=B8=B8=EF=BC=88=E5=8D=B3=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E6=94=B9=E4=B8=BA=E5=88=B7=E6=96=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/login/index.vue | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 5434adc..d6de782 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -46,6 +46,7 @@ import { useBasicStore } from "@/store/basic"; import { elMessage, useElement } from "@/hooks/use-element"; import { getMyRole, login } from "@/api/user"; import type { FormInstance, InputInstance } from "element-plus"; +import { settings as viteSettings } from "@/settings"; /* listen router change and set the query */ const { settings } = useBasicStore(); @@ -106,13 +107,22 @@ async function loginFunc() { const data = await login(subForm); elMessage("登录成功"); basicStore.setToken(data?.Authorization); - const role = await getMyRole() + const role = await getMyRole(); basicStore.setUserInfo({ userInfo: data, roles: [role.roleType], codes: [role.roleId] - }) - router.push("/").catch(e => console.error(e)); + }); + // router.push("/").catch(e => console.error(e)); + if (route.query?.redirect) { + let url = route.query.redirect as string; + if (viteSettings.viteBasePath.endsWith("/") && url.startsWith("/")) { + url = url.replace(/^\//, ""); + } + window.location.href = viteSettings.viteBasePath + url; + } else { + window.location.href = viteSettings.viteBasePath; + } } catch (e: Error | any) { tipMessage = e?.message; } finally {