|
@ -45,23 +45,26 @@ const ruleForm = reactive({ |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const onLogin = async (formEl: FormInstance | undefined) => { |
|
|
const onLogin = async (formEl: FormInstance | undefined) => { |
|
|
loading.value = true; |
|
|
|
|
|
if (!formEl) return; |
|
|
if (!formEl) return; |
|
|
await formEl.validate((valid, fields) => { |
|
|
await formEl.validate((valid, fields) => { |
|
|
if (valid) { |
|
|
if (valid) { |
|
|
|
|
|
loading.value = true; |
|
|
useUserStoreHook() |
|
|
useUserStoreHook() |
|
|
.loginByUsername({ username: ruleForm.username, password: "admin123" }) |
|
|
.loginByUsername({ username: ruleForm.username, password: "admin123" }) |
|
|
.then(res => { |
|
|
.then(res => { |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
// 获取后端路由 |
|
|
// 获取后端路由 |
|
|
initRouter().then(() => { |
|
|
|
|
|
router.push(getTopMenu(true).path); |
|
|
|
|
|
message("登录成功", { type: "success" }); |
|
|
|
|
|
|
|
|
return initRouter().then(() => { |
|
|
|
|
|
router.push(getTopMenu(true).path).then(() => { |
|
|
|
|
|
message(t("login.pureLoginSuccess"), { type: "success" }); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
}); |
|
|
}); |
|
|
} else { |
|
|
} else { |
|
|
loading.value = false; |
|
|
|
|
|
|
|
|
message(t("login.pureLoginFail"), { type: "error" }); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.finally(() => (loading.value = false)); |
|
|
|
|
|
} else { |
|
|
return fields; |
|
|
return fields; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|