From 66269df739aaafa258f32a9ecea8aae43551465d Mon Sep 17 00:00:00 2001 From: saladday <1203511142@qq.com> Date: Fri, 7 Aug 2026 12:48:20 -0400 Subject: [PATCH] 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 --- src-tauri/tauri.conf.json | 3 ++- src/index.html | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 948727bf5..5ed6c78f3 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -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": [] diff --git a/src/index.html b/src/index.html index bdf8a15ef..2ee4c8960 100644 --- a/src/index.html +++ b/src/index.html @@ -4,6 +4,7 @@ Claude Code 供应商切换器 +