修复:将页面异步副作用绑定到当前归属
This commit is contained in:
1 parent
b3a66d97c8
commit
eca3aa8fe5
6 files changed
+623
-90
No files matched your search
@@ -11,6 +11,7 @@ definePageMeta({
|
||||
alias: [`/forgot_password`],
|
||||
});
|
||||
import { toDisplayString } from "vue";
|
||||
import { onScopeDispose } from "vue";
|
||||
import { normalizeClass } from "vue";
|
||||
import { createBlock } from "vue";
|
||||
import { ref } from "vue";
|
||||
@@ -30,7 +31,7 @@ import { useRoute } from "#app";
|
||||
import { useRouter } from "#app";
|
||||
import { useHead } from "#app";
|
||||
import { NuxtLink } from "#components";
|
||||
import { useApi } from "~/lib/auth.js";
|
||||
import { useApi, useAuth } from "~/lib/auth.js";
|
||||
import button from "openvue/button";
|
||||
import message from "openvue/message";
|
||||
import { n as auth_redirect_n } from "~/lib/auth-redirect.js";
|
||||
@@ -79,6 +80,12 @@ var D = {
|
||||
z = defineComponent({
|
||||
__name: `forgot-password`,
|
||||
setup(f) {
|
||||
const session = useAuth().prepareLogin();
|
||||
let disposed = false;
|
||||
const isCurrent = () => !disposed && session.isCurrent();
|
||||
onScopeDispose(() => {
|
||||
disposed = true;
|
||||
});
|
||||
(useHead({
|
||||
title: `找回密码 - 破碎工坊网络`,
|
||||
}),
|
||||
@@ -133,7 +140,7 @@ var D = {
|
||||
}
|
||||
// 校验账号、区号、验证码和两次密码后提交重置;失败交由验证码实例处理挑战刷新。
|
||||
async function pe() {
|
||||
if (G.value || Q.value) return;
|
||||
if (!isCurrent() || G.value || Q.value) return;
|
||||
W.value = ``;
|
||||
let e = U.account.trim();
|
||||
if (!e)
|
||||
@@ -145,26 +152,28 @@ var D = {
|
||||
return (W.value = `两次输入的密码不一致`);
|
||||
G.value = !0;
|
||||
try {
|
||||
(await z.post(`/account/password_reset`, {
|
||||
await z.post(`/account/password_reset`, {
|
||||
type: H.value,
|
||||
account: e,
|
||||
phone_code: `86`,
|
||||
code: U.code.trim(),
|
||||
password: U.password,
|
||||
re_password: U.re_password,
|
||||
}),
|
||||
await B.push({
|
||||
path: `/login`,
|
||||
query: {
|
||||
reset: `1`,
|
||||
...auth_redirect_n(V.query.redirect),
|
||||
},
|
||||
}));
|
||||
});
|
||||
if (!isCurrent()) return;
|
||||
await B.push({
|
||||
path: `/login`,
|
||||
query: {
|
||||
reset: `1`,
|
||||
...auth_redirect_n(V.query.redirect),
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
if (!isCurrent()) return;
|
||||
((W.value = e instanceof Error ? e.message : `重置失败`),
|
||||
await ue(e));
|
||||
} finally {
|
||||
G.value = !1;
|
||||
if (isCurrent()) G.value = !1;
|
||||
}
|
||||
}
|
||||
// 手机号/邮箱输入、验证码和密码表单共享提交锁;成功导航由 pe 负责,渲染层不直接建立会话。
|
||||
|
||||
Reference in new issue
Block a user