|
@@ -7,6 +7,7 @@
|
|
|
import '../app.css';
|
|
import '../app.css';
|
|
|
import { menuList, type MenuListChild } from '../data/menuList.js';
|
|
import { menuList, type MenuListChild } from '../data/menuList.js';
|
|
|
import ThemeSwitch from './components/ThemeSwitch.svelte';
|
|
import ThemeSwitch from './components/ThemeSwitch.svelte';
|
|
|
|
|
+ import { darkMode } from '$lib/theme/index.js';
|
|
|
|
|
|
|
|
let { children } = $props();
|
|
let { children } = $props();
|
|
|
|
|
|
|
@@ -41,16 +42,16 @@
|
|
|
let showLeft = $derived(!(isIframe === '1' || $page.url.pathname === '/' || isComponentMode));
|
|
let showLeft = $derived(!(isIframe === '1' || $page.url.pathname === '/' || isComponentMode));
|
|
|
|
|
|
|
|
let theme = $state(localStorage.getItem('theme') === 'dark' ? 'dark' : 'light');
|
|
let theme = $state(localStorage.getItem('theme') === 'dark' ? 'dark' : 'light');
|
|
|
- // 设置主题
|
|
|
|
|
- // Set theme
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 设置亮暗模式
|
|
|
|
|
+ // Set light and dark mode
|
|
|
if (localStorage.getItem('theme') === 'dark') {
|
|
if (localStorage.getItem('theme') === 'dark') {
|
|
|
- document.documentElement.classList.add('dark');
|
|
|
|
|
|
|
+ darkMode();
|
|
|
} else if (localStorage.getItem('theme') === 'light') {
|
|
} else if (localStorage.getItem('theme') === 'light') {
|
|
|
- document.documentElement.classList.remove('dark');
|
|
|
|
|
|
|
+ darkMode(false);
|
|
|
} else {
|
|
} else {
|
|
|
- document.documentElement.classList.remove('dark');
|
|
|
|
|
|
|
+ darkMode(false);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
//手动切换亮暗模式
|
|
//手动切换亮暗模式
|
|
|
// manually switch light and dark mode
|
|
// manually switch light and dark mode
|
|
|
const toggleFun = () => {
|
|
const toggleFun = () => {
|
|
@@ -59,13 +60,13 @@
|
|
|
// switch to light
|
|
// switch to light
|
|
|
theme = 'light';
|
|
theme = 'light';
|
|
|
localStorage.setItem('theme', 'light');
|
|
localStorage.setItem('theme', 'light');
|
|
|
- document.documentElement.classList.remove('dark');
|
|
|
|
|
|
|
+ darkMode(false);
|
|
|
} else {
|
|
} else {
|
|
|
// 切换到 dark
|
|
// 切换到 dark
|
|
|
// switch to dark
|
|
// switch to dark
|
|
|
theme = 'dark';
|
|
theme = 'dark';
|
|
|
localStorage.setItem('theme', 'dark');
|
|
localStorage.setItem('theme', 'dark');
|
|
|
- document.documentElement.classList.add('dark');
|
|
|
|
|
|
|
+ darkMode();
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|