From bc4e0e005e7ce213cc3796b4ae345a52a45510b9 Mon Sep 17 00:00:00 2001 From: gitea Date: Fri, 20 Nov 2026 15:58:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E7=BE=A4=E5=BC=B9=E7=AA=97=E6=9B=B4?= =?UTF-8?q?=E5=8F=AF=E9=9D=A0=EF=BC=9A=E9=A1=B6=E6=A0=8F=E5=B8=B8=E9=A9=BB?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=20+=20=E6=AF=8F=E6=AC=A1=E6=89=93=E5=BC=80?= =?UTF-8?q?=E9=83=BD=E6=8F=90=E9=86=92=20+=20=E9=9D=99=E6=80=81=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=BC=BA=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - qq-group.js: 登录后必弹(同一次加载内关掉才不再弹),顶栏加常驻「🎁 加群领 500」按钮,DB.auth.onChange 联动 - server.mjs: html/js/css 改为 no-cache, must-revalidate(其余仍 24h),避免 WebView 拿旧 index.html 导致新脚本不加载 --- css/style.css | 3 +++ js/qq-group.js | 43 +++++++++++++++++++++++++++++++++++-------- server.mjs | 2 +- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/css/style.css b/css/style.css index 4ae0231..214a30e 100644 --- a/css/style.css +++ b/css/style.css @@ -910,3 +910,6 @@ html, body { overflow-x: hidden; } .qq-later:hover{color:#a9b8d6} @keyframes qqPop{from{transform:scale(.94) translateY(6px);opacity:0}to{transform:none;opacity:1}} @keyframes qqIn{from{opacity:0}to{opacity:1}} + +.qq-chip{margin-left:10px;padding:6px 12px;border-radius:999px;border:1px solid rgba(255,190,90,.45);background:rgba(255,176,64,.12);color:#ffcf8a;font-size:12.5px;cursor:pointer} +.qq-chip:hover{background:rgba(255,176,64,.2)} diff --git a/js/qq-group.js b/js/qq-group.js index cf9abe6..766ecce 100644 --- a/js/qq-group.js +++ b/js/qq-group.js @@ -72,6 +72,7 @@ const later = el('button', 'qq-later', '以后再说') later.addEventListener('click', () => { + dismissed = true try { localStorage.setItem(SEEN, '1') } catch {} close(mask) }) @@ -84,16 +85,42 @@ document.body.append(mask) } + let dismissed = false + function maybeShow(user) { - if (!user || user.qqClaim) return - let seen = false - try { seen = localStorage.getItem(SEEN) === '1' } catch {} - // 每次登录都提醒一次,但 30 分钟内不再重复弹 - const last = Number(localStorage.getItem(SEEN + '.at') || 0) - if (seen && Date.now() - last < 30 * 60 * 1000) return - try { localStorage.setItem(SEEN + '.at', String(Date.now())) } catch {} - setTimeout(() => show(user), 600) + if (!user || user.qqClaim) { dropChip(); return } + if (dismissed) return + dismissed = false + setTimeout(() => { if (!document.querySelector('.qq-mask')) show(user) }, 500) + addChip() } + /* 顶栏常驻入口:万一弹窗被系统/缓存挡掉,也能点出来 */ + function addChip() { + if (document.getElementById('qqChip')) return + const who = document.getElementById('who') + if (!who) return + const a = document.createElement('button') + a.id = 'qqChip' + a.className = 'qq-chip' + a.textContent = '🎁 加群领 500' + a.addEventListener('click', () => { + const u = DB.auth.state ? DB.auth.state.user : null + show(u || {}) + }) + who.append(a) + } + + function dropChip() { + const n = document.getElementById('qqChip') + if (n) n.remove() + } + + document.addEventListener('DOMContentLoaded', () => { + const u = window.DB && DB.auth && DB.auth.state ? DB.auth.state.user : null + if (u) maybeShow(u) + }) + if (window.DB && DB.auth && DB.auth.onChange) DB.auth.onChange((u) => { if (u) maybeShow(u); else dropChip() }) + DB.qq = { show, maybeShow, url: GROUP_URL } })() diff --git a/server.mjs b/server.mjs index 1452ba6..9500ab0 100644 --- a/server.mjs +++ b/server.mjs @@ -128,7 +128,7 @@ async function serveStatic(req, res, pathname) { } res.writeHead(200, { 'content-type': MIME[extname(file).toLowerCase()] || 'application/octet-stream', - 'cache-control': rel.endsWith('.html') ? 'no-cache' : 'public, max-age=3600', + 'cache-control': /\.(html|js|css)$/.test(rel) ? 'no-cache, must-revalidate' : 'public, max-age=86400', etag, 'x-content-type-options': 'nosniff' })