-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
44 lines (36 loc) · 1.29 KB
/
index.html
File metadata and controls
44 lines (36 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>VibeBase</title>
<!-- 🔥 在 React 加载前同步设置主题,避免闪烁 -->
<script>
(function() {
try {
// 读取保存的主题设置
const savedTheme = localStorage.getItem('vibebase_theme') || 'system';
let effectiveTheme;
if (savedTheme === 'system') {
// 检测系统主题
effectiveTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
} else {
effectiveTheme = savedTheme;
}
// 立即应用主题类到 html 元素
document.documentElement.classList.add(effectiveTheme);
console.log('⚡ Initial theme applied (sync):', effectiveTheme);
} catch (e) {
console.error('Failed to apply initial theme:', e);
// 默认应用 dark 主题
document.documentElement.classList.add('dark');
}
})();
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>