f0292acbb7
抽取 themeSnapshot 工具模块,异步恢复与跨窗同步时写回 snapshot;HTML 内联脚本与 useLayoutEffect 消除 dark 类首帧闪烁;避免 storage 恢复覆盖用户操作及 setState 嵌套更新。 Co-authored-by: Cursor <cursoragent@cursor.com>
50 lines
1.4 KiB
HTML
50 lines
1.4 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Testing Tools - 标签页</title>
|
|
<meta name="manifest.type" content="browser_action" />
|
|
<script>
|
|
(function () {
|
|
try {
|
|
var raw = localStorage.getItem('snapshot/app/themeMode');
|
|
var mode = raw ? JSON.parse(raw) : 'system';
|
|
if (mode !== 'light' && mode !== 'dark' && mode !== 'system') mode = 'system';
|
|
var isDark =
|
|
mode === 'dark' ||
|
|
(mode === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
|
if (isDark) document.documentElement.classList.add('dark');
|
|
} catch (_error) {}
|
|
})();
|
|
</script>
|
|
<style>
|
|
/* Force initial popup size before React hydration */
|
|
html, body {
|
|
width: 400px;
|
|
height: 600px;
|
|
margin: 0;
|
|
padding: 0;
|
|
overflow: hidden;
|
|
background-color: hsl(var(--background));
|
|
}
|
|
/* Ensure full size for the root container */
|
|
#root {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
/* If opened in a tab (mode=tab), reset the fixed size */
|
|
@media screen and (min-width: 600px) {
|
|
html, body {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="root"></div>
|
|
<script type="module" src="./main.tsx"></script>
|
|
</body>
|
|
</html>
|