mirror of
https://gitee.com/mlogclub/bbs-go.git
synced 2025-12-06 13:59:05 +08:00
Optimize captcha dialog
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
<a @click="toSignup">没有账号?点击这里去注册>></a>
|
||||
</div>
|
||||
|
||||
<CaptchaDialog ref="captchaDialog" @confirm="captchaConfirm" />
|
||||
<CaptchaDialog ref="captchaDialog" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -59,28 +59,24 @@ const clickLogin = async () => {
|
||||
useMsgError("请输入密码");
|
||||
return;
|
||||
}
|
||||
captchaDialog.value.show();
|
||||
};
|
||||
|
||||
const captchaConfirm = async (captcha, callback) => {
|
||||
form.captchaId = captcha.captchaId;
|
||||
form.captchaCode = captcha.captchaCode;
|
||||
captchaDialog.value.show().then(async (captcha) => {
|
||||
form.captchaId = captcha.captchaId;
|
||||
form.captchaCode = captcha.captchaCode;
|
||||
|
||||
try {
|
||||
const userStore = useUserStore();
|
||||
const { user, redirect } = await userStore.signin(form);
|
||||
try {
|
||||
const userStore = useUserStore();
|
||||
const { user, redirect } = await userStore.signin(form);
|
||||
|
||||
callback(true);
|
||||
|
||||
if (redirect) {
|
||||
useLinkTo(redirect);
|
||||
} else {
|
||||
useLinkTo(`/user/${user.id}`);
|
||||
if (redirect) {
|
||||
useLinkTo(redirect);
|
||||
} else {
|
||||
useLinkTo(`/user/${user.id}`);
|
||||
}
|
||||
} catch (e) {
|
||||
useCatchError(e);
|
||||
}
|
||||
} catch (e) {
|
||||
callback(false);
|
||||
useCatchError(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const toSignup = async () => {
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CaptchaDialog ref="captchaDialog" @confirm="publishSubmit" />
|
||||
<CaptchaDialog ref="captchaDialog" />
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -166,13 +166,15 @@ const publish = () => {
|
||||
}
|
||||
|
||||
if (topicCaptchaEnabled) {
|
||||
captchaDialog.value.show();
|
||||
captchaDialog.value.show().then((captcha) => {
|
||||
publishSubmit(captcha);
|
||||
});
|
||||
} else {
|
||||
publishSubmit();
|
||||
}
|
||||
};
|
||||
|
||||
const publishSubmit = async (captcha, callback) => {
|
||||
const publishSubmit = async (captcha) => {
|
||||
if (publishing.value) {
|
||||
return;
|
||||
}
|
||||
@@ -197,8 +199,6 @@ const publishSubmit = async (captcha, callback) => {
|
||||
} catch (e) {
|
||||
useMsgError(e.message || e);
|
||||
publishing.value = false;
|
||||
} finally {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CaptchaDialog ref="captchaDialog" @confirm="captchaConfirm" />
|
||||
<CaptchaDialog ref="captchaDialog" />
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -120,28 +120,24 @@ const clickSignup = async () => {
|
||||
useMsgError("两次输入密码不一致");
|
||||
return;
|
||||
}
|
||||
captchaDialog.value.show();
|
||||
};
|
||||
captchaDialog.value.show().then(async (captcha) => {
|
||||
form.captchaId = captcha.captchaId;
|
||||
form.captchaCode = captcha.captchaCode;
|
||||
|
||||
async function captchaConfirm(captcha, callback) {
|
||||
form.captchaId = captcha.captchaId;
|
||||
form.captchaCode = captcha.captchaCode;
|
||||
try {
|
||||
const userStore = useUserStore();
|
||||
const { user, redirect } = await userStore.signup(form);
|
||||
|
||||
try {
|
||||
const userStore = useUserStore();
|
||||
const { user, redirect } = await userStore.signup(form);
|
||||
|
||||
callback(true);
|
||||
if (redirect) {
|
||||
useLinkTo(redirect);
|
||||
} else {
|
||||
useLinkTo(`/user/${user.id}`);
|
||||
if (redirect) {
|
||||
useLinkTo(redirect);
|
||||
} else {
|
||||
useLinkTo(`/user/${user.id}`);
|
||||
}
|
||||
} catch (err) {
|
||||
useCatchError(err);
|
||||
}
|
||||
} catch (err) {
|
||||
callback(false);
|
||||
useCatchError(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function toSignin() {
|
||||
if (form.redirect) {
|
||||
|
||||
Reference in New Issue
Block a user