From 4864f76a10d5a63ef1d31c2beae925be4b088bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=8A=E9=9F=AC?= <1075983130@qq.com> Date: Mon, 23 Nov 2026 19:57:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8F=B0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=8F=AF=E8=A7=86=E5=8C=96=EF=BC=9A=E5=85=A8=E5=B1=80=E6=9C=AA?= =?UTF-8?q?=E5=A4=84=E7=90=86Promise=E5=BC=82=E5=B8=B8=E5=BC=B9toast(?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=82=B9=E5=87=BB=E5=A4=B1=E8=B4=A5=E6=AD=A4?= =?UTF-8?q?=E5=89=8D=E9=9D=99=E9=BB=98=E6=97=A0=E5=8F=8D=E5=BA=94=EF=BC=8C?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=AE=9A=E4=BD=8D=E5=8E=9F=E5=9B=A0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app/admin.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/app/admin.html b/server/app/admin.html index af555a8..e4f635e 100644 --- a/server/app/admin.html +++ b/server/app/admin.html @@ -102,6 +102,12 @@ let TOKEN = localStorage.getItem('xl_admin_token') || ''; function toast(t){ const m=document.getElementById('msg'); m.textContent=t; m.style.display='block'; setTimeout(()=>m.style.display='none',2500); } +// 按钮处理器大多未 catch,接口报错/网络失败时页面此前静默无反应——统一弹 toast 让错误可见 +window.addEventListener('unhandledrejection', e => { + const r = e.reason; + toast('出错:' + (r && r.message ? r.message : (r && r.name === 'TypeError' ? '网络请求失败' : (r || '未知错误')))); +}); + async function api(path, opts={}){ const r = await fetch(path, {...opts, headers:{'X-Admin-Token':TOKEN,'Content-Type':'application/json',...(opts.headers||{})}}); if (r.status===403){