From 9a6c0db65c4da8cb38298414cdfcbd4f7da154ac Mon Sep 17 00:00:00 2001 From: butubb <1422726308@qq.com> Date: Tue, 15 Sep 2026 13:59:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=80=9A=E7=9F=A5):=20=E6=96=B0=E5=BB=BA/?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=BC=B9=E7=AA=97=E7=BC=BA=E3=80=8C=E4=BF=9D?= =?UTF-8?q?=E5=AD=98/=E5=85=B3=E9=97=AD=E3=80=8D=E6=95=B4=E6=9D=A1?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=A0=8F=EF=BC=88=E7=82=B9=E8=BF=9B=E5=8E=BB?= =?UTF-8?q?=E5=87=BA=E4=B8=8D=E6=9D=A5=E3=80=81=E4=B9=9F=E5=AD=98=E4=B8=8D?= =?UTF-8?q?=E4=BA=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户报:新建 webhook 弹窗**没有关闭按钮**——点进去不想建就出不来了(只能刷新页面)。 顺着查发现更严重的一处:**底部操作栏整个漏了**——「创建/保存」「预览」「取消」全都没有, 只是靠"以为有保存按钮所以先点开看看"才没被立刻发现:其实填完也提交不了。 修(static/admin/notify.js + monitor.html): - 弹窗顶部加「✕ 关闭」,底部加「创建/保存 · 预览请求体 · 取消」操作栏 - 四条关闭路径都可用:✕ / 取消 / **Esc** / **点空白处**(overlay 的 onclick) 同批复核出的其它问题: - 通配订阅区被我上一版写成永远隐藏(`display:none` 且没人改回来)→ 恢复可见 (任何格式都适用,标签补成「通配订阅(可选,任何格式都适用)」) - `_notifyFormatChanged` 里残留 `(f === 'json' || true)` 的无意义判断 → 清掉 - 工具条上一个 input 写了**两个 style 属性**(后者会被浏览器忽略)→ 合并成一个 复核方式(这次全部**走页面按钮**,不再只测接口): - UI 全流程 13 项:四条关闭路径 + 底部按钮存在 + 页面创建(列出/打码 URL/事件数) + 编辑回填与改名 + 发送测试(假接收端真收到)+ 页面删除,无 JS 报错 - 通配订阅 6 项:区可见 / 非法通配被拒 / 芯片渲染 / 保存后列出 / 编辑回填 / 清理 - 接口边界 10 项:提交打码 URL 不覆盖真实值、只传 enabled 的局部更新、非法模板被拒、 预览字节数、limit 非法值兜底、404 分支、未登录被挡 教训:交付物是界面时,自测必须走界面点一遍——上一轮我用接口建的 webhook, 把「按钮不存在」整类问题漏掉了。 --- static/admin/notify.js | 26 +++++++++++++++++++++----- templates/admin/monitor.html | 10 ++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/static/admin/notify.js b/static/admin/notify.js index 96ea5b2..12985ab 100644 --- a/static/admin/notify.js +++ b/static/admin/notify.js @@ -107,8 +107,11 @@ function openNotifyModal(id){ const box = document.getElementById('notify-modal-box'); if(!box) return; box.innerHTML = - '
' - + (id ? '编辑 Webhook' : '新建 Webhook') + '
' + '
' + + '
' + + (id ? '编辑 Webhook' : '新建 Webhook') + '
' + + '' + + '
' + '
' + '
' + '
' @@ -136,7 +139,7 @@ function openNotifyModal(id){ + '带 ★ 的是建议开启的。也可以直接写通配(如 task.*)——在下面的芯片框里加。
' + '
' + '' - + '' + '
' + '
点「预览请求体」看真实会发出去的内容与字节数。
' + + '
' + // 底部操作栏(缺了它就只能靠刷新页面逃出去) + + '
' + + '' + + '' + + '' + + 'Esc 或点空白处也能关' + '
'; box.querySelector('#nf-body').value = h.body_template || ''; renderEventTree(checked); @@ -157,12 +167,18 @@ function openNotifyModal(id){ function _notifyFormatChanged(){ const f = (document.getElementById('nf-format') || {}).value; + // 只有「通用 JSON」才需要自定义请求体模板 const bodyWrap = document.getElementById('nf-body-wrap'); if(bodyWrap) bodyWrap.style.display = (f === 'json') ? 'block' : 'none'; - const patWrap = document.getElementById('nf-pattern-wrap'); - if(patWrap) patWrap.style.display = (f === 'json' || true) ? 'block' : 'none'; } +// Esc 关闭弹窗(点空白处关闭在 overlay 的 onclick 上) +document.addEventListener('keydown', function(ev){ + if(ev.key !== 'Escape') return; + const ov = document.getElementById('notify-modal-overlay'); + if(ov && ov.style.display !== 'none') closeNotifyModal(); +}); + function renderEventTree(checked){ const box = document.getElementById('nf-events'); if(!box) return; diff --git a/templates/admin/monitor.html b/templates/admin/monitor.html index 0c46a84..6cfb923 100644 --- a/templates/admin/monitor.html +++ b/templates/admin/monitor.html @@ -1169,9 +1169,10 @@ body{background:var(--bg);font-family:var(--body);color:var(--text);font-size:14 启用通知 默认聚合 - 秒 · - 限流 条/分 + 秒 · + 限流 条/分 @@ -1193,7 +1194,8 @@ body{background:var(--bg);font-family:var(--body);color:var(--text);font-size:14 -