修改问题
This commit is contained in:
@@ -49,16 +49,6 @@
|
||||
};
|
||||
}
|
||||
|
||||
function buildSmsLoginBody(values) {
|
||||
var source = values || {};
|
||||
|
||||
return {
|
||||
phone: String(source.phone || '').trim(),
|
||||
smsCode: String(source.smsCode || '').trim(),
|
||||
validToken: trimOrUndefined(source.validToken)
|
||||
};
|
||||
}
|
||||
|
||||
function buildDeactivateBody(values, hashFn) {
|
||||
var source = values || {};
|
||||
var hash = hashFn || hashPassword;
|
||||
@@ -154,25 +144,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function submitSmsLogin(form) {
|
||||
var api = getApi();
|
||||
var body = buildSmsLoginBody(getFormValues(form));
|
||||
|
||||
if (!api) return;
|
||||
if (!body.phone || !body.smsCode) {
|
||||
showMessage('请填写手机号和验证码');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await api.smsLogin(body);
|
||||
setStatus(form, '短信登录已通过');
|
||||
showMessage('短信登录已通过');
|
||||
} catch (error) {
|
||||
showMessage(error.message || '短信登录失败');
|
||||
}
|
||||
}
|
||||
|
||||
async function submitDeactivate(form) {
|
||||
var api = getApi();
|
||||
var values = getFormValues(form);
|
||||
@@ -191,7 +162,7 @@
|
||||
try {
|
||||
await api.deactivateAccount(buildDeactivateBody(values));
|
||||
showMessage('账号已提交注销');
|
||||
root.location.href = 'login.html';
|
||||
root.location.href = 'index.html';
|
||||
} catch (error) {
|
||||
showMessage(error.message || '账号注销失败');
|
||||
}
|
||||
@@ -200,14 +171,14 @@
|
||||
async function logout() {
|
||||
var api = getApi();
|
||||
|
||||
if (!api) return;
|
||||
if (root.confirm && !root.confirm('确认退出当前账号?')) return;
|
||||
|
||||
try {
|
||||
await api.logout();
|
||||
root.location.href = 'login.html';
|
||||
if (api) await api.logout();
|
||||
} catch (error) {
|
||||
showMessage(error.message || '退出登录失败');
|
||||
// ApiClient.logout 会在请求失败时清理本地 token,页面仍应离开受保护区域。
|
||||
} finally {
|
||||
root.location.href = 'index.html';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,7 +195,6 @@
|
||||
|
||||
if (formType === 'password') submitPassword(form);
|
||||
if (formType === 'phone') submitPhone(form);
|
||||
if (formType === 'sms-login') submitSmsLogin(form);
|
||||
if (formType === 'deactivate') submitDeactivate(form);
|
||||
});
|
||||
|
||||
@@ -246,7 +216,6 @@
|
||||
return {
|
||||
buildPasswordChangeBody: buildPasswordChangeBody,
|
||||
buildPhoneChangeBody: buildPhoneChangeBody,
|
||||
buildSmsLoginBody: buildSmsLoginBody,
|
||||
buildDeactivateBody: buildDeactivateBody,
|
||||
isDangerConfirmed: isDangerConfirmed,
|
||||
init: init
|
||||
|
||||
Reference in New Issue
Block a user