theme & language: device-following auto theme, Thai default, dropdown sync

- 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
This commit is contained in:
Bkk1234 committed 2026-11-04 01:17:39 +07:00
1 parent 4b5a4d33d3
commit 29b126b188
6 files changed
+54 -30

No files matched your search

+1 -1
View File
@@ -133,7 +133,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
{/* ตั้งธีมก่อนวาดหน้าจอ (กันจอขาววูบตอนเปิดแอปในโหมดมืด) */}
<script
dangerouslySetInnerHTML={{
__html: `(function(){try{var m=localStorage.getItem('at_theme')||'auto';var h=new Date().getHours();var r=m==='auto'?(h>=6&&h<18?'light':'dark'):m;document.documentElement.dataset.theme=r;document.documentElement.dataset.themeMode=m;document.documentElement.style.colorScheme=r;}catch(e){}})();`,
__html: `(function(){try{var m=localStorage.getItem('at_theme')||'auto';var d=window.matchMedia&&window.matchMedia('(prefers-color-scheme: dark)').matches;var r=m==='auto'?(d?'dark':'light'):m;document.documentElement.dataset.theme=r;document.documentElement.dataset.themeMode=m;document.documentElement.style.colorScheme=r;}catch(e){}})();`,
}}
/>
<script src="/vendor/leaflet/leaflet.js" defer />