perf: 优化接口处理逻辑

This commit is contained in:
xiaoxian521
2026-01-12 09:22:26 +08:00
parent f2616fdfaf
commit 42076a2247
3 changed files with 30 additions and 24 deletions

View File

@@ -73,23 +73,21 @@ const onLogin = async (formEl: FormInstance | undefined) => {
username: ruleForm.username,
password: ruleForm.password
})
.then(res => {
if (res.code === 0) {
// 获取后端路由
return initRouter().then(() => {
disabled.value = true;
router
.push(getTopMenu(true).path)
.then(() => {
message(t("login.pureLoginSuccess"), { type: "success" });
})
.finally(() => (disabled.value = false));
});
} else {
message(t("login.pureLoginFail"), { type: "error" });
}
.then(async () => {
// 获取后端路由
await initRouter();
disabled.value = true;
router.push(getTopMenu(true).path).then(() => {
message(t("login.pureLoginSuccess"), { type: "success" });
});
})
.finally(() => (loading.value = false));
.catch(_err => {
message(t("login.pureLoginFail"), { type: "error" });
})
.finally(() => {
disabled.value = false;
loading.value = false;
});
}
});
};