修正登录时router异常(即登录时改为刷新页面)
This commit is contained in:
parent
2a4ee647b6
commit
42ed4f08b5
|
@ -46,6 +46,7 @@ import { useBasicStore } from "@/store/basic";
|
||||||
import { elMessage, useElement } from "@/hooks/use-element";
|
import { elMessage, useElement } from "@/hooks/use-element";
|
||||||
import { getMyRole, login } from "@/api/user";
|
import { getMyRole, login } from "@/api/user";
|
||||||
import type { FormInstance, InputInstance } from "element-plus";
|
import type { FormInstance, InputInstance } from "element-plus";
|
||||||
|
import { settings as viteSettings } from "@/settings";
|
||||||
|
|
||||||
/* listen router change and set the query */
|
/* listen router change and set the query */
|
||||||
const { settings } = useBasicStore();
|
const { settings } = useBasicStore();
|
||||||
|
@ -106,13 +107,22 @@ async function loginFunc() {
|
||||||
const data = await login(subForm);
|
const data = await login(subForm);
|
||||||
elMessage("登录成功");
|
elMessage("登录成功");
|
||||||
basicStore.setToken(data?.Authorization);
|
basicStore.setToken(data?.Authorization);
|
||||||
const role = await getMyRole()
|
const role = await getMyRole();
|
||||||
basicStore.setUserInfo({
|
basicStore.setUserInfo({
|
||||||
userInfo: data,
|
userInfo: data,
|
||||||
roles: [role.roleType],
|
roles: [role.roleType],
|
||||||
codes: [role.roleId]
|
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) {
|
} catch (e: Error | any) {
|
||||||
tipMessage = e?.message;
|
tipMessage = e?.message;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user