pwa: automatic update UX - no more hard refresh

- ui/version.json: server-side version marker, polled by pwa.js (load, 5 min,
  tab focus, network online); mismatch -> toast + auto reload once per version
- pwa.js: silent reload when tab hidden, guarded reload (sessionStorage) so a
  partial deploy cannot loop, ATUpdate.check() exposed for testing
- _shared.css: .mu-update-toast pill (bottom center, reduced-motion aware)
- shell js/css get ?v=<version> automatically (bump-version.py) so HTTP cache
  cannot serve stale files before the service worker takes control
- sw: cache fallback now ignores query string (precache still matches ?v= URLs)
- bump-version.py: writes version.json + verifies it in --check
- VERSION 2026.09.27.108
This commit is contained in:
Bkk1234 committed 2026-11-03 00:32:41 +07:00
1 parent 449afb923a
commit fcdab3ac80
8 files changed
+248 -50

No files matched your search

+43
View File
@@ -494,6 +494,49 @@ body:has(.mu-site-footer) .mu-footer { display: none; }
outline-offset: 2px;
}
/* =========================================================
Toast แจ้งอัปเดตเวอร์ชันใหม่ (inject จาก ui/pwa.js)
========================================================= */
.mu-update-toast {
position: fixed;
left: 50%;
bottom: calc(20px + env(safe-area-inset-bottom, 0px));
z-index: 1300;
display: inline-flex;
align-items: center;
gap: 10px;
max-width: calc(100vw - 32px);
padding: 10px 16px;
border-radius: 999px;
background: #1f2a44;
color: #fff;
font-size: .82rem;
font-weight: 600;
line-height: 1.35;
box-shadow: 0 10px 24px rgba(15, 23, 42, .22);
transform: translate(-50%, 12px);
opacity: 0;
pointer-events: none;
transition: opacity .25s ease, transform .25s ease;
}
.mu-update-toast.is-in { opacity: 1; transform: translate(-50%, 0); }
.mu-update-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: #b694f6;
flex: none;
animation: muUpdatePulse 1.1s ease-in-out infinite;
}
@keyframes muUpdatePulse {
0%, 100% { opacity: .35; transform: scale(.85); }
50% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
.mu-update-toast { transition: none; }
.mu-update-dot { animation: none; }
}
/* =========================================================
Motion — อนิเมชันร่วมทุกหน้า (ไฟล์ JS: ui/motion.js)
---------------------------------------------------------