fix 修复bug
This commit is contained in:
@@ -101,6 +101,7 @@ const bindBtn = $("bindBtn");
|
||||
const deleteWechatBtn = $("deleteWechatBtn");
|
||||
const logoutBtn = $("logoutBtn");
|
||||
const changePwdBtn = $("changePwdBtn");
|
||||
const regenResetCodeBtn = $("regenResetCodeBtn");
|
||||
const deleteAccountBtn = $("deleteAccountBtn");
|
||||
const modelSelect = $("modelSelect");
|
||||
const saveModelBtn = $("saveModelBtn");
|
||||
@@ -347,6 +348,42 @@ if (changePwdBtn) {
|
||||
});
|
||||
}
|
||||
|
||||
if (regenResetCodeBtn) {
|
||||
regenResetCodeBtn.addEventListener("click", async () => {
|
||||
const pwd = await window.uiPrompt("请输入当前登录密码,用于生成新的重置码:", "重新生成重置码", "", "请输入当前密码");
|
||||
if (!pwd) return;
|
||||
setLoading(regenResetCodeBtn, true, "重新生成重置码", "生成中...");
|
||||
try {
|
||||
const out = await postJSON("/api/auth/reset-code/regenerate", { password: pwd });
|
||||
if (!out.ok) {
|
||||
setStatus(out.detail || "生成失败", true);
|
||||
return;
|
||||
}
|
||||
const code = String(out.reset_code || "").trim();
|
||||
if (!code) {
|
||||
setStatus("生成失败,请稍后再试", true);
|
||||
return;
|
||||
}
|
||||
await window.uiAlert(
|
||||
`新的重置码如下(仅展示这一次):\n\n${code}\n\n请立即复制并妥善保存,旧重置码已失效。`,
|
||||
"重置码已更新"
|
||||
);
|
||||
try {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
await navigator.clipboard.writeText(code);
|
||||
}
|
||||
} catch {
|
||||
// ignore clipboard failure
|
||||
}
|
||||
setStatus("新重置码已生成并展示一次,请妥善保存。");
|
||||
} catch (e) {
|
||||
setStatus(e.message || "生成失败", true);
|
||||
} finally {
|
||||
setLoading(regenResetCodeBtn, false, "重新生成重置码", "生成中...");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (deleteAccountBtn) {
|
||||
deleteAccountBtn.addEventListener("click", async () => {
|
||||
const pwd = ($("deletePassword") && $("deletePassword").value) || "";
|
||||
|
||||
Reference in New Issue
Block a user