From 29b126b188bf35b03ac455d24cc267de149cacdc Mon Sep 17 00:00:00 2001 From: Bkk1234 Date: Wed, 4 Nov 2026 01:17:39 +0700 Subject: [PATCH] theme & language: device-following auto theme, Thai default, dropdown sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ThemeSwitch: auto now follows the device (prefers-color-scheme) with a live matchMedia listener instead of a 06:00-18:00 clock rule; labels become 'ตามอุปกรณ์ / Device'; auto icon is a monitor - layout.tsx pre-paint script resolved with matchMedia (no theme flash) - i18n: default language is Thai (no navigator guess) in lib/ui/i18n.ts; new 'i18nready' event so LangSwitch syncs its label after runtime boot (button previously stuck on ไทย when the page loaded in English) - VERSION 2026.10.24.5 --- frontend/public/sw.js | 2 +- frontend/public/version.json | 4 +- frontend/src/app/layout.tsx | 2 +- frontend/src/components/LangSwitch.tsx | 10 ++++- frontend/src/components/ThemeSwitch.tsx | 59 ++++++++++++++++--------- frontend/src/lib/ui/i18n.ts | 7 ++- 6 files changed, 54 insertions(+), 30 deletions(-) diff --git a/frontend/public/sw.js b/frontend/public/sw.js index 69440b6..6ad58e9 100644 --- a/frontend/public/sw.js +++ b/frontend/public/sw.js @@ -15,7 +15,7 @@ - SW ใหม่ → skipWaiting + clients.claim + แจ้งหน้าเว็บ ============================================================ */ -const VERSION = "2026.10.24.3"; /* bump เมื่อแก้ UI เพื่อบังคับให้ cache เก่าถูกทิ้ง */ +const VERSION = "2026.10.24.5"; /* bump เมื่อแก้ UI เพื่อบังคับให้ cache เก่าถูกทิ้ง */ const CACHE = `atroute-${VERSION}`; const OFFLINE_URL = "/offline.html"; const VERSION_URL = "/version.json"; diff --git a/frontend/public/version.json b/frontend/public/version.json index 358417e..68ec699 100644 --- a/frontend/public/version.json +++ b/frontend/public/version.json @@ -1,6 +1,6 @@ { "app": "Atroute", - "version": "2026.10.24.3", - "builtAt": "2026-11-04T00:51:02", + "version": "2026.10.24.5", + "builtAt": "2026-11-04T01:16:49", "pwa": true } diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index f65e9e2..1d22777 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -133,7 +133,7 @@ export default function RootLayout({ children }: { children: React.ReactNode }) {/* ตั้งธีมก่อนวาดหน้าจอ (กันจอขาววูบตอนเปิดแอปในโหมดมืด) */}