feat: 公告推送提速 — 服务端缓存10min→60s, 页面每2分钟自动刷新公告(新弹窗公告无需刷新)
Publish Docker image to GHCR / build-push (push) Canceled after 0s
Publish Docker image to GHCR / build-push (push) Canceled after 0s
This commit is contained in:
1 parent
e44d2cb7a1
commit
7322a26fef
3 files changed
+5
-2
No files matched your search
+1
-1
@@ -28,7 +28,7 @@
|
||||
<script src="/js/gomoku_client.js?v=64"></script>
|
||||
<script src="/js/chess_client.js?v=64"></script>
|
||||
<script src="/js/junqi_client.js?v=64"></script>
|
||||
<script src="/js/common.js?v=64"></script>
|
||||
<script src="/js/common.js?v=65"></script>
|
||||
<script>
|
||||
const views = {
|
||||
chess: () => gameLobby('chess','象棋','🐟 楚河汉界,红先黑后,工作间隙杀一盘'),
|
||||
|
||||
@@ -1109,6 +1109,9 @@ function timerBadge() {
|
||||
_renderNotices(m.notices || []);
|
||||
} catch (e) { /* fail-open:接口挂了不影响游戏 */ }
|
||||
}
|
||||
window.__refreshMeta = initMeta; // 暴露手动刷新(测试/调试用)
|
||||
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initMeta);
|
||||
else initMeta();
|
||||
// 每 2 分钟自动拉一次:公告条实时更新,新弹窗公告不用刷新页面(同一条只弹一次)
|
||||
setInterval(initMeta, 120000);
|
||||
})();
|
||||
@@ -272,7 +272,7 @@ const AUTH = (() => {
|
||||
}
|
||||
// 公告(免 key,按本项目过滤,10 分钟缓存)
|
||||
async function noticeList() {
|
||||
if (notices && Date.now() - noticesAt < 10 * 60 * 1000) return notices;
|
||||
if (notices && Date.now() - noticesAt < 60 * 1000) return notices; // 公告缓存 60s:后台发公告后游戏 1 分钟内可见
|
||||
const c = cfg();
|
||||
const r = await request('GET', '/public/announcements');
|
||||
if (!(r && r.code === 200 && r.data)) return notices || []; // 失败不缓存空结果,下次继续重试
|
||||
|
||||
Reference in new issue
Block a user