fix(windows): eliminate startup white-black flash (FOUC)

Set window backgroundColor to match the dark theme surface so WebView2's
native window layer is dark before any web content paints. Add an inline
anti-FOUC script in index.html to apply the theme class synchronously
before first paint, reading from localStorage with system fallback.
Update CSP script-src to allow the inline script via SHA-256 base64 hash
alongside the existing 'self' source.

Fixes #6182
This commit is contained in:
saladday committed 2026-08-07 13:00:08 -04:00
1 parent 413c09e079
commit 66269df739
2 files changed
+3 -1

No files matched your search

+2 -1
View File
@@ -20,13 +20,14 @@
"minWidth": 900,
"minHeight": 600,
"visible": false,
"backgroundColor": "#1e1e22",
"resizable": true,
"fullscreen": false,
"center": true
}
],
"security": {
"csp": "default-src 'self'; img-src 'self' data: https: http:; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' ipc: http://ipc.localhost https: http:",
"csp": "default-src 'self'; img-src 'self' data: https: http:; script-src 'self' 'sha256-ls27Lc1OytcVawXPVMplz6LyKz2i9KYAVBw3u79qyB4='; style-src 'self' 'unsafe-inline'; connect-src 'self' ipc: http://ipc.localhost https: http:",
"assetProtocol": {
"enable": true,
"scope": []
+1
View File
@@ -4,6 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Claude Code 供应商切换器</title>
<script>(function(){try{var t=localStorage.getItem("cc-switch-theme")||"system";var d=t==="dark"||(t==="system"&&matchMedia("(prefers-color-scheme: dark)").matches);document.documentElement.classList.toggle("dark",d);}catch(e){}})()</script>
</head>
<body>
<div id="root"></div>