diff --git a/frontend/index.html b/frontend/index.html index dcfe289..7ee387a 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -7,21 +7,10 @@ SFDAP — Akıllı Tarım Dashboard - + transition tetiklenmez → gündüz/gece statik gelir). Toggle yine animasyonlu. + HARİCİ + render-blocking KLASİK script (inline DEĞİL → asset-split/CSP kuralı; + type=module DEĞİL → boyamadan önce koşar). Kaynak: src/theme-init.js --> + diff --git a/frontend/src/theme-init.js b/frontend/src/theme-init.js new file mode 100644 index 0000000..e181cb5 --- /dev/null +++ b/frontend/src/theme-init.js @@ -0,0 +1,19 @@ +// SFDAP — tema ilk-boya senkronu (FOUC önleme). +// index.html 'inde HARİCİ + render-blocking KLASİK script olarak yüklenir: +// - inline değil → asset-split / CSP kuralına (TestAssetSplit) takılmaz, +// - type=module DEĞİL → modüller defer'lı koşup boyamadan SONRA çalışırdı; bu +// dosya senkron çalışıp temayı CSS boyamadan ÖNCE uygular (aksi halde welcome'da +// ilk yüklemede gün/gece geçiş animasyonu oynar). +// Temayı üzerine yazar; durum değişmediği için transition tetiklenmez. +(function () { + try { + var t = localStorage.getItem('sfdap-theme'); + if (!t) { + // İlk açılış: saat 06:00–20:00 arası GÜNDÜZ, 20:00–06:00 arası GECE. + var h = new Date().getHours(); + t = (h >= 6 && h < 20) ? 'light' : 'dark'; + localStorage.setItem('sfdap-theme', t); // sabitle → refresh değiştirmez + } + if (t === 'light') document.documentElement.dataset.theme = 'light'; + } catch (e) {} +})();