From 908bab811e9c79394b548988ab0e0e8be54d481e Mon Sep 17 00:00:00 2001 From: OP Date: Thu, 2 Jul 2026 20:53:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=8C=E6=AD=A5=E4=B8=A4=E4=B8=AA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E5=BC=B9=E7=AA=97=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - index.html 添加 profileModal HTML - analysis.html 移除错误位置的 twofaBindModal - analysis.html 添加 twofaBindModal 到正确位置 - analysis.html profileModal 添加完整 2FA 设置部分 - 两个页面的 header/menu/modal 现在一致 不打包,等用户确认后再打包 --- frontend/admin.html | 25 ++++- frontend/analysis.html | 55 ++++++++-- frontend/index.html | 240 +++++++++++++++++++++++------------------ 3 files changed, 204 insertions(+), 116 deletions(-) diff --git a/frontend/admin.html b/frontend/admin.html index 5280d7a..52813f4 100644 --- a/frontend/admin.html +++ b/frontend/admin.html @@ -147,7 +147,7 @@ tr:hover{background:#f8fafc}
- +
账号昵称邮箱角色债务状态操作
账号昵称邮箱角色债务状态2FA操作
@@ -348,7 +348,9 @@ async function loadUsers(){ actions+=` `; actions+=` `; } - return`${escapeHtml(u.account)}${escapeHtml(u.nickname)}${emailDisplay}${roleBadge}${groupBadge}${u.debt_count}笔${statusBadge}${actions}`; + return`${escapeHtml(u.account)}${escapeHtml(u.nickname)}${emailDisplay}${roleBadge}${groupBadge}${u.debt_count}笔${statusBadge} + ${u.role==='admin'?'-':(u.two_factor_enabled?'已启用 ':'未启用 ')} + ${actions}`; }).join(''); } @@ -514,6 +516,25 @@ function renderNotifList(items){const el=$("notifList");if(!items.length){el.inn async function readNotif(id){await apiFetch('/notifications/'+id+'/read',{method:'PUT'});loadNotifications();} async function markAllNotifRead(){await apiFetch('/notifications/read-all',{method:'PUT'});loadNotifications();} + +async function toggleUser2FA(userId, enabled) { + const action = enabled ? '启用' : '禁用'; + if (!confirm(`确定${action}该用户的双因素认证?`)) return; + + const res = await apiFetch('/admin/users/' + userId + '/2fa', { + method: 'PUT', + body: JSON.stringify({enabled}) + }); + + if (res && res.ok) { + alert(`用户 2FA 已${action}`); + loadUsers(); + } else { + const data = await res.json().catch(() => ({})); + alert(data.detail || '操作失败'); + } +} + init(); diff --git a/frontend/analysis.html b/frontend/analysis.html index 1f3bf59..6770a9f 100644 --- a/frontend/analysis.html +++ b/frontend/analysis.html @@ -5,6 +5,33 @@ 数据分析 +
+

双因素认证

+

请使用验证器应用扫描二维码

+
+

密钥:

+
+ +
+ +
+ +
+
+ + + +

债务统计报表 - ${today()}

`;vl.forEach(l=>{const ti=l.schedule.reduce((s,r)=>s+r.it,0);const st=l.paid.length>=l.periods;h+=`

${escapeHtml(l.name)} - ${l.date} - ¥${fmt(l.amount)}${st?' 已还清':''}

年化率 ${l.rate}% · ${methodLabel(l.method)} · ${l.periods}期 · 总利息 ¥${ti.toFixed(2)}

`;l.schedule.forEach(r=>{h+=``;});h+=`
期数日期还款额本金利息剩余本金状态用途
${r.p}${r.date}¥${fmt(r.pay)}¥${fmt(r.pr)}¥${fmt(r.it)}¥${fmt(r.rp)}${l.paid.includes(r.p)?'✓ 已还':'待还'}
`;});h+=` + - -