From 75875606a2b4dc5f11d2601bdd3c7fa1eb95c964 Mon Sep 17 00:00:00 2001 From: OP Date: Sun, 28 Jun 2026 23:01:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20admin.html=20?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=87=BD=E6=95=B0=E5=BC=95=E5=8F=B7=E5=B5=8C?= =?UTF-8?q?=E5=A5=97=E9=94=99=E8=AF=AF=E5=AF=BC=E8=87=B4=20JS=20=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - renderNotifList/renderNotifBadge/loadNotifications 等函数使用了双引号嵌套 - 导致整个 script 块解析失败,所有函数(包括 loadStats/loadGroups/loadUsers)无法执行 - 统一改为单引号,修复管理后台数据不显示和退出按钮失效问题 --- frontend/admin.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/admin.html b/frontend/admin.html index d71fb01..5280d7a 100644 --- a/frontend/admin.html +++ b/frontend/admin.html @@ -504,15 +504,15 @@ let notifPage=1; function notifTypeIcon(type){const map={repayment_due:"📅",repayment_overdue:"⚠️",system:"📢",account:"👤"};return map[type]||"📩";} function timeAgo(dt){const diff=(Date.now()-new Date(dt).getTime())/1000;if(diff<60)return "刚刚";if(diff<3600)return Math.floor(diff/60)+"分钟前";if(diff<86400)return Math.floor(diff/3600)+"小时前";return Math.floor(diff/86400)+"天前";} -function toggleNotifDropdown(e){e.stopPropagation();const dd=$("notifDropdown");dd.classList.toggle("show");if(dd.classList.contains("show"))loadNotifications();} +function toggleNotifDropdown(e){e.stopPropagation();const dd=$('notifDropdown');dd.classList.toggle('show');if(dd.classList.contains('show'))loadNotifications();} document.addEventListener("click",function(){$("notifDropdown")?.classList.remove("show");}); -async function loadNotifications(){const res=await apiFetch("/notifications?size=20");if(!res||!res.ok)return;const data=await res.json();renderNotifBadge(data.unread);renderNotifList(data.items);} -function renderNotifBadge(unread){const badge=$("notifBadge");if(unread>0){badge.style.display="";badge.textContent=unread>99?"99+":unread;}else{badge.style.display="none";}} -function renderNotifList(items){const el=$("notifList");if(!items.length){el.innerHTML="
暂无通知
";return;}el.innerHTML=items.map(n=>`
${notifTypeIcon(n.type)}
${n.title}
${n.message}
${timeAgo(n.created_at)}
`).join("");} +async function loadNotifications(){const res=await apiFetch('/notifications?size=20');if(!res||!res.ok)return;const data=await res.json();renderNotifBadge(data.unread);renderNotifList(data.items);} +function renderNotifBadge(unread){const badge=$("notifBadge");if(unread>0){badge.style.display='';badge.textContent=unread>99?'99+':unread;}else{badge.style.display='none';}} +function renderNotifList(items){const el=$("notifList");if(!items.length){el.innerHTML='
暂无通知
';return;}el.innerHTML=items.map(n=>`
${notifTypeIcon(n.type)}
${n.title}
${n.message}
${timeAgo(n.created_at)}
`).join('');} -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 readNotif(id){await apiFetch('/notifications/'+id+'/read',{method:'PUT'});loadNotifications();} +async function markAllNotifRead(){await apiFetch('/notifications/read-all',{method:'PUT'});loadNotifications();} init();