|
@@ -138,9 +138,9 @@ const captchaBase64 = ref(); // 验证码图片Base64字符串
|
|
|
const loginFormRef = ref(ElForm); // 登录表单ref
|
|
|
const { height } = useWindowSize();
|
|
|
|
|
|
-const loginData = ref<any>({
|
|
|
- userName: "admin",
|
|
|
- password: "admin@123",
|
|
|
+const loginData = ref<LoginData>({
|
|
|
+ userName: "",
|
|
|
+ password: "",
|
|
|
});
|
|
|
|
|
|
const loginRules = computed?.(() => {
|
|
@@ -199,42 +199,46 @@ const route = useRoute();
|
|
|
function handleLogin() {
|
|
|
loginFormRef.value.validate((valid: boolean) => {
|
|
|
if (valid) {
|
|
|
- loading.value = true;
|
|
|
- userStore
|
|
|
- .login(loginData.value)
|
|
|
- .then(async () => {
|
|
|
- const query: LocationQuery = route.query;
|
|
|
- const redirect = (query.redirect as LocationQueryValue) ?? "/";
|
|
|
- const otherQueryParams = Object.keys(query).reduce(
|
|
|
- (acc: any, cur: string) => {
|
|
|
- if (cur !== "redirect") {
|
|
|
- acc[cur] = query[cur];
|
|
|
- }
|
|
|
- return acc;
|
|
|
- },
|
|
|
- {}
|
|
|
- );
|
|
|
- // 获取字典
|
|
|
- getUserDicts(dictStore.types).then((res) => {
|
|
|
- if (res.data) {
|
|
|
- dictStore.dicts = res?.data ?? [];
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // router.push({ path: redirect, query: otherQueryParams });
|
|
|
- router.push("/welcome");
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- // getCaptcha();
|
|
|
- console.log("catch");
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- loading.value = false;
|
|
|
- });
|
|
|
+ toLogin();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+const toLogin = () => {
|
|
|
+ loading.value = true;
|
|
|
+ userStore
|
|
|
+ .login(loginData.value)
|
|
|
+ .then(async () => {
|
|
|
+ const query: LocationQuery = route.query;
|
|
|
+ const redirect = (query.redirect as LocationQueryValue) ?? "/";
|
|
|
+ const otherQueryParams = Object.keys(query).reduce(
|
|
|
+ (acc: any, cur: string) => {
|
|
|
+ if (cur !== "redirect") {
|
|
|
+ acc[cur] = query[cur];
|
|
|
+ }
|
|
|
+ return acc;
|
|
|
+ },
|
|
|
+ {}
|
|
|
+ );
|
|
|
+ // 获取字典
|
|
|
+ getUserDicts(dictStore.types).then((res) => {
|
|
|
+ if (res.data) {
|
|
|
+ dictStore.dicts = res?.data ?? [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ router.push({ path: redirect, query: otherQueryParams });
|
|
|
+ // router.push("/welcome");
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ // getCaptcha();
|
|
|
+ console.log("catch");
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ loading.value = false;
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
/**
|
|
|
* 主题切换
|
|
|
*/
|
|
@@ -263,6 +267,23 @@ function checkCapslock(e: any) {
|
|
|
}
|
|
|
|
|
|
onMounted?.(() => {
|
|
|
+ // 处理SSO
|
|
|
+ const query: LocationQuery = route.query;
|
|
|
+ if (query.token) {
|
|
|
+ loginData.value.token = query.token + "";
|
|
|
+ toLogin();
|
|
|
+ // localStorage.setItem("token", query.token + "");
|
|
|
+ // const redirect = (query.redirect as LocationQueryValue) ?? "/";
|
|
|
+ // // 获取字典
|
|
|
+ // getUserDicts(dictStore.types).then((res) => {
|
|
|
+ // if (res.data) {
|
|
|
+ // dictStore.dicts = res?.data ?? [];
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ //
|
|
|
+ // router.push({ path: redirect });
|
|
|
+ }
|
|
|
+
|
|
|
getOrgList();
|
|
|
toggleTheme();
|
|
|
});
|