sync from mock: motion, privacy-first search stats, auto-update UX
- frontend/src/lib/ui/motion.ts + components/MotionBoot.tsx: page-enter and scroll reveal per pathname change (ported from mock motion.js); IntersectionObserver plus sweep fallback for jump-scroll/hidden tabs, maps never transformed - frontend/src/lib/ui/analytics.ts: cookie-less local-first search analytics (localStorage at_stats_v1, DNT/GPC + opt-out, term sanitiser, 900ms debounce, caps 300 terms / 200 views / 120 days); optional Umami endpoint via AT_ANALYTICS - /stats page (StatsView + styles/pages/stats.css): KPIs, 14-day chart, top terms, top route/stop pages, no-result terms, JSON export, clear, opt-out - hooks: stops search apply(), stop detail route filter - remove footer visitor counter (lib/ui/visitors.ts, .mu-visitor/.mu-vreset, i18n keys) - remove floating install-app button; PwaBoot keeps SW + guarded version toast (sessionStorage guard, silent reload when tab hidden) - i18n th/en: nav.stats, update.applying, stats.* (public + src/data locales) - version.json + sw VERSION -> 2026.10.24.3; docs/UI-PORT.md section for this round
This commit is contained in:
1 parent
c0b70ff845
commit
4b5a4d33d3
22 files changed
+1473
-453
No files matched your search
+15
-1
@@ -84,7 +84,21 @@ npm run dev # http://localhost:3000
|
||||
```
|
||||
|
||||
- เปิดทุก route: `/`, `/stops`, `/stops/:code`, `/routes`, `/routes/:id`, `/check`,
|
||||
`/check/:id`, `/blog`, `/blog/:id`, `/about`, `/credits`
|
||||
`/check/:id`, `/blog`, `/blog/:id`, `/about`, `/credits`, `/stats`
|
||||
- เทียบภาพกับ mock ที่ viewport เดียวกัน (1280×900) — diff ที่วัดได้ 0.7–2.3%
|
||||
(ที่เหลือมาจาก marquee animation / ตัวเลขผู้เข้าชม)
|
||||
- ตรวจว่าไม่มี horizontal scroll และปุ่ม/ลิงก์กดได้จริง
|
||||
|
||||
## รอบล่าสุด — motion, สถิติ, auto-update (พอร์ตจาก mock)
|
||||
|
||||
| ของใน mock | ใน repo นี้ | หมายเหตุ |
|
||||
|---|---|---|
|
||||
| `ui/motion.js` (enter · reveal · loading bar) | `src/lib/ui/motion.ts` + `components/MotionBoot.tsx` + CSS ใน `src/styles/_shared.css` | MotionBoot เรียก `Motion.enter(#view)` ทุกครั้งที่ pathname เปลี่ยน (แทน router เดิม) · reveal ใช้ `IntersectionObserver` + sweep (กันค้างตอนกระโดดข้ามหน้า/แท็บถูกซ่อน) |
|
||||
| `ui/analytics.js` + `#/stats` | `src/lib/ui/analytics.ts` + `app/stats/page.tsx` + `components/views/StatsView.tsx` + `styles/pages/stats.css` | เก็บใน localStorage `at_stats_v1` · ไม่มีคุกกี้/IP/UA · `cleanTerm()` ตัดอีเมล/เบอร์/เลขยาว · debounce 900ms · opt-out + DNT/GPC · ค่าเริ่มต้นไม่ส่งออกเน็ต (จะส่งก็ต่อเมื่อตั้ง `window.AT_ANALYTICS = {endpoint, siteId}`) |
|
||||
| ปุ่มติดตั้งแอปลอยมุมขวาล่าง | **เอาออก** — `PwaBoot` เหลือ SW + version check | Chrome/Edge ยังมีไอคอนติดตั้งของเบราว์เซอร์เอง |
|
||||
| ตัวเลขผู้เข้าชม 12,834 ใน footer | **เอาออก** — ลบ `lib/ui/visitors.ts` + CSS `.mu-visitor/.mu-vreset` + คีย์ `visitors.*` | backend มี `/api/visits` (record_visit/visits_summary) แต่ frontend ยังไม่เรียก — ถ้าจะทำสถิติรวมศูนย์ ให้ต่อที่ `lib/api.ts` |
|
||||
| bump + `version.json` + toast อัปเดต | `PwaBoot` เทียบ `/version.json` กับ `<html data-app-version>` (อ่านตอน build) → toast + reload ครั้งเดียว/เวอร์ชัน | ต้อง bump `public/version.json` + `public/sw.js` VERSION แล้ว rebuild |
|
||||
|
||||
**ยังไม่พอร์ต (ตั้งใจ):** หน้ารวมศูนย์สถิติจาก backend — backend มีตาราง `visit_daily_stats`
|
||||
และ API `/visits/summary` แล้ว แต่ยังไม่มี UI/การเรียก; ถ้าจะทำต้องตัดสินใจเรื่อง visitor id
|
||||
เชิงความเป็นส่วนตัวก่อน (mock ใช้ local-only เพื่อไม่ต้องมี id ถาวร)
|
||||
Reference in new issue
Block a user