feat(pwa): harden the auto-update chain and add a version tool
- ui/pwa.js: register with updateViaCache:'none', check for updates on load, every 30 min, on tab focus and on 'online'; controllerchange reloads the page itself but waits while the user is typing in a form (admin edits survive), retrying on blur/hide - sw.js: precache the maskable icon; bump VERSION -> 2026.11.24.2 - scripts/bump-version.mjs: bump sw.js VERSION + <meta app-version> together, --check fails on drift; wired into > [email protected] check > node --check ui/app.js && node --check ui/data.js && node --check ui/router.js && node --check ui/ui.js && node --check ui/pwa.js && node --check ui/views/home.js && node --check ui/views/admin.js && node --check sw.js && node --check server/publish.mjs && node --check server/db.mjs && node --check scripts/bump-version.mjs && node scripts/bump-version.mjs --check [version] ตรงกันที่ 2026.11.24.2, exposed as > [email protected] version > node scripts/bump-version.mjs [version] ตั้งเป็น 2026.11.24.3 แล้ว (sw.js + index.html) - README/AGENTS: document the PWA behaviour and the bump workflow Verified in Chrome: SPA route changes keep timeOrigin and navigation count at 1 (no reload), a simulated deploy (version bump -> reg.update) replaced the cache from hobbypj-2026.11.24.1 to .2 with the old cache deleted and the page reloading by itself, Page.getAppManifest errors: [], and with the network emulated offline the shell + 6 cards still render while an uncached file fails.
This commit is contained in:
1 parent
9258cdd09e
commit
634dc3ae3c
7 files changed
+173
-13
No files matched your search
@@ -10,7 +10,8 @@ Repository: `hobbypj-contents` (Gitea org `hobbyproject-list`) · deploy เป
|
||||
|
||||
```bash
|
||||
node server/publish.mjs # เซิร์ฟเวอร์ + หลังบ้าน → http://localhost:8090
|
||||
npm run check # ตรวจ syntax ทุกไฟล์ JS/MJS
|
||||
npm run check # ตรวจ syntax ทุกไฟล์ JS/MJS + เวอร์ชัน sw.js/index.html ตรงกัน
|
||||
npm run version # bump VERSION (sw.js) + <meta app-version> (index.html)
|
||||
PORT=8090 ADMIN_TOKEN=xxx node server/publish.mjs # โหมดมีรหัสเผยแพร่
|
||||
PUBLISH_PUSH=0 node server/publish.mjs # เขียน+commit แต่ไม่ push
|
||||
```
|
||||
@@ -23,7 +24,7 @@ PUBLISH_PUSH=0 node server/publish.mjs # เขียน+commit แต่ไ
|
||||
4. **สีต้องมาจาก `assets/css/theme.css`** — ห้ามใส่ hex ใหม่ในไฟล์ view; ถ้าต้องเพิ่มสี ให้เพิ่มเป็นโทเคน + อัปเดต `DESIGN.md`
|
||||
5. **ตัวอักษรต้อง ≥ 4.5:1** บนพื้นของตัวเอง — เพิ่มสีใหม่ต้องคำนวณคอนทราสต์ ไม่เดาจากสายตา
|
||||
6. **ปุ่ม/ลิงก์ต้องมีพื้นที่กด ≥ 44×44px** และมี `aria-label` เมื่อเป็นไอคอนเดี่ยว
|
||||
7. **แก้ `sw.js` หรือรายการ `PRECACHE` → bump `VERSION`** ใน `sw.js` และ `<meta name="app-version">` ใน `index.html` ให้ตรงกัน (แก้ HTML/CSS/JSON อย่างเดียวไม่ต้อง bump)
|
||||
7. **แก้ `sw.js` หรือรายการ `PRECACHE` → bump เวอร์ชันด้วย `npm run version`** (แก้ `VERSION` ใน `sw.js` + `<meta name="app-version">` ใน `index.html` พร้อมกัน) · `npm run check` มี `bump-version.mjs --check` ตรวจว่าไม่หลุดกัน · แก้ HTML/CSS/JS/JSON เนื้อหาอย่างเดียวไม่ต้อง bump (network-first จัดการ)
|
||||
8. **PWA boot บน plain HTTP ไม่ได้** — ต้อง HTTPS หรือ localhost
|
||||
9. การเปลี่ยนคำ/ค่าออกแบบ → อัปเดต `DESIGN.md` และ `README.md` (เครดิต) ด้วยในคอมมิตเดียวกัน
|
||||
|
||||
@@ -43,6 +44,7 @@ PUBLISH_PUSH=0 node server/publish.mjs # เขียน+commit แต่ไ
|
||||
| `ui/views/admin.js` | หลังบ้าน: ล็อกอิน → ฟอร์มแก้ไข, เรียงลำดับ, ลบ, เผยแพร่, ดาวน์โหลด JSON |
|
||||
| `server/publish.mjs` | static server + `GET/PUT api/projects` + git commit/push |
|
||||
| `server/db.mjs` | ชั้น SQLite (`node:sqlite`): schema, `readData`/`saveData` (ทรานแซกชัน), `backupDatabase` (VACUUM INTO), `exportJson`, `seedFromJson` |
|
||||
| `scripts/bump-version.mjs` | bump เวอร์ชันคู่ (`sw.js` VERSION + `<meta app-version>`) · `--check` ใช้ใน `npm run check` |
|
||||
| `data/hobbypj.sqlite` | ฐานข้อมูลจริง (ตาราง `site` 1 แถว + `projects`) — **ไม่ขึ้น git** |
|
||||
| `data/projects.json` | สำเนา export ของฐานข้อมูล (ขึ้น git, service worker precache, ใช้อ่านตอนไม่มีเซิร์ฟเวอร์) |
|
||||
|
||||
|
||||
Reference in new issue
Block a user