浏览代码

refac: theme

Timothy Jaeryang Baek 2 月之前
父节点
当前提交
e4d6fc65ca
共有 2 个文件被更改,包括 14 次插入5 次删除
  1. 10 5
      src/lib/components/chat/Settings/General.svelte
  2. 4 0
      src/routes/+layout.svelte

+ 10 - 5
src/lib/components/chat/Settings/General.svelte

@@ -141,12 +141,10 @@
 			}
 		}
 
-		console.log(_theme);
-	};
+		if (typeof window !== 'undefined' && window.applyTheme) {
+			window.applyTheme();
+		}
 
-	const themeChangeHandler = (_theme: string) => {
-		theme.set(_theme);
-		localStorage.setItem('theme', _theme);
 		if (_theme.includes('oled')) {
 			document.documentElement.style.setProperty('--color-gray-800', '#101010');
 			document.documentElement.style.setProperty('--color-gray-850', '#050505');
@@ -154,6 +152,13 @@
 			document.documentElement.style.setProperty('--color-gray-950', '#000000');
 			document.documentElement.classList.add('dark');
 		}
+
+		console.log(_theme);
+	};
+
+	const themeChangeHandler = (_theme: string) => {
+		theme.set(_theme);
+		localStorage.setItem('theme', _theme);
 		applyTheme(_theme);
 	};
 </script>

+ 4 - 0
src/routes/+layout.svelte

@@ -396,6 +396,10 @@
 	};
 
 	onMount(async () => {
+		if (typeof window !== 'undefined' && window.applyTheme) {
+			window.applyTheme();
+		}
+
 		if (window?.electronAPI) {
 			const info = await window.electronAPI.send({
 				type: 'app:info'