mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
chore(site): rename website to site
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
---
|
||||
import { THEME_KEY } from '@/consts';
|
||||
---
|
||||
|
||||
{/* Dark mode initialization script - runs before paint to prevent FOUC */}
|
||||
<script is:inline define:vars={{ localStorageKey: THEME_KEY }}>
|
||||
if (
|
||||
typeof localStorage !== 'undefined' &&
|
||||
typeof document !== 'undefined' &&
|
||||
typeof document.documentElement !== 'undefined'
|
||||
) {
|
||||
let localStorageValue = localStorage[localStorageKey];
|
||||
const isValidKey = localStorageValue === 'light' || localStorageValue === 'dark' || localStorageValue === 'system';
|
||||
if (!localStorageValue || !isValidKey) {
|
||||
localStorage[localStorageKey] = 'system';
|
||||
localStorageValue = 'system';
|
||||
}
|
||||
let isDark = false;
|
||||
if (localStorageValue === 'dark') {
|
||||
document.documentElement.classList.add('dark');
|
||||
isDark = true;
|
||||
} else if (localStorageValue === 'system') {
|
||||
if (typeof window.matchMedia !== 'undefined' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
document.documentElement.classList.add('dark');
|
||||
isDark = true;
|
||||
}
|
||||
}
|
||||
const themeColorMeta = document.querySelector('meta[name="theme-color"]');
|
||||
if (themeColorMeta) {
|
||||
themeColorMeta.setAttribute('content', isDark ? '#393836' : '#ebe4c1');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user