|
@@ -115,7 +115,7 @@ import { getCaptchaApi, getOrgListApi } from "@/api/auth";
|
|
|
import { LoginData } from "@/api/auth/types";
|
|
|
import { Sunny, Moon } from "@element-plus/icons-vue";
|
|
|
import { LocationQuery, LocationQueryValue, useRoute } from "vue-router";
|
|
|
-import router from "@/router";
|
|
|
+
|
|
|
import defaultSettings from "@/settings";
|
|
|
import { ThemeEnum } from "@/enums/ThemeEnum";
|
|
|
import { usePermissionStore } from "@/store/modules/permission";
|
|
@@ -194,6 +194,7 @@ function getOrgList() {
|
|
|
* 登录
|
|
|
*/
|
|
|
const route = useRoute();
|
|
|
+const router = useRouter();
|
|
|
function handleLogin() {
|
|
|
loginFormRef.value.validate((valid: boolean) => {
|
|
|
if (valid) {
|
|
@@ -201,9 +202,8 @@ function handleLogin() {
|
|
|
userStore
|
|
|
.login(loginData.value)
|
|
|
.then(async (res) => {
|
|
|
- localStorage.setItem("token", res.data + "");
|
|
|
- const query: LocationQuery = route.query;
|
|
|
- const redirect = (query.redirect as LocationQueryValue) ?? "/";
|
|
|
+ const query: LocationQuery = route?.query;
|
|
|
+ const redirect = (query?.redirect as LocationQueryValue) ?? "/";
|
|
|
const otherQueryParams = Object.keys(query).reduce(
|
|
|
(acc: any, cur: string) => {
|
|
|
if (cur !== "redirect") {
|
|
@@ -213,12 +213,15 @@ function handleLogin() {
|
|
|
},
|
|
|
{}
|
|
|
);
|
|
|
- router.push({ path: redirect, query: otherQueryParams });
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- // getCaptcha();
|
|
|
- console.log("catch");
|
|
|
+ router.push({
|
|
|
+ path: redirect,
|
|
|
+ query: { ...otherQueryParams, date: new Date() },
|
|
|
+ });
|
|
|
})
|
|
|
+ // .catch(() => {
|
|
|
+ // // getCaptcha();
|
|
|
+ // console.log("catch");
|
|
|
+ // })
|
|
|
.finally(() => {
|
|
|
loading.value = false;
|
|
|
});
|
|
@@ -231,8 +234,8 @@ const toLogin = () => {
|
|
|
userStore
|
|
|
.login(loginData.value)
|
|
|
.then(async () => {
|
|
|
- const query: LocationQuery = route.query;
|
|
|
- const redirect = (query.redirect as LocationQueryValue) ?? "/";
|
|
|
+ const query: LocationQuery = route?.query;
|
|
|
+ const redirect = (query?.redirect as LocationQueryValue) ?? "/";
|
|
|
const otherQueryParams = Object.keys(query).reduce(
|
|
|
(acc: any, cur: string) => {
|
|
|
if (cur !== "redirect") {
|
|
@@ -242,7 +245,10 @@ const toLogin = () => {
|
|
|
},
|
|
|
{}
|
|
|
);
|
|
|
- router.push({ path: redirect, query: otherQueryParams });
|
|
|
+ router.push({
|
|
|
+ path: redirect,
|
|
|
+ query: { ...otherQueryParams, date: new Date() },
|
|
|
+ });
|
|
|
})
|
|
|
.catch(() => {
|
|
|
// getCaptcha();
|