加群弹窗更可靠:顶栏常驻入口 + 每次打开都提醒 + 静态资源强校验
- qq-group.js: 登录后必弹(同一次加载内关掉才不再弹),顶栏加常驻「🎁 加群领 500」按钮,DB.auth.onChange 联动
- server.mjs: html/js/css 改为 no-cache, must-revalidate(其余仍 24h),避免 WebView 拿旧 index.html 导致新脚本不加载
This commit is contained in:
1 parent
92f286880c
commit
bc4e0e005e
3 files changed
+39
-9
No files matched your search
@@ -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)}
|
||||
+35
-8
@@ -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 }
|
||||
})()
|
||||
+1
-1
@@ -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'
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user