fix(app): Keep the dark theme's background under a fast window resize

splash.css painted html light and only switched body to dark, so the page
canvas showed the light colour wherever a live resize outran relayout.
Leave html unpainted so the canvas takes body's themed background.

Also set the webview's background (not just the native window's) on a
theme change; it otherwise kept the colour the window was created with.
Цей коміт міститься в:
l0ng-ai committed 2026-10-23 21:29:45 +08:00
1 джерело ee99b3641f
коміт b1bb4a69cd
3 files changed
+10 -4

No files matched your search

+2 -1
Переглянути файл
@@ -2,7 +2,8 @@
which voids style-src 'unsafe-inline' and blocks the editor's runtime-injected styles. */
/* Start-up splash over the page until the window's launch project is open (platform/splash.ts).
Tokens aren't loaded yet, so the colours mirror --bg-frame / --fg-muted / --accent. */
html, body, .splash { background: #e9eaee; }
/* Not on html: the canvas then takes body's (themed) background, which a fast resize shows before relayout. */
body, .splash { background: #e9eaee; }
:root[data-theme="dark"] :is(body, .splash) { background: #26282c; }
:root:is([data-theme="dark-hc"], [data-theme="dark"][data-contrast="high"]) :is(body, .splash) { background: #1a1b1e; }
.splash {
+1
Переглянути файл
@@ -16,6 +16,7 @@
"core:window:allow-set-title",
"core:window:allow-set-background-color",
"core:webview:allow-set-webview-zoom",
"core:webview:allow-set-webview-background-color",
"opener:default",
"opener:allow-reveal-item-in-dir",
"dialog:default",
+7 -3
Переглянути файл
@@ -1,6 +1,6 @@
/** Applies `data-theme` and the accent colour from appearance settings. */
import { useEffect, useSyncExternalStore } from "react";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
import { create } from "zustand";
import { call, commands, isTauri } from "@/platform/ipc";
import { useProject } from "@/platform/project";
@@ -88,12 +88,16 @@ export function useApplyTheme() {
}, [pending, theme, id, accent]);
}
/** The native window shows its own colour where a live resize outruns the webview; match the frame. */
/**
* Where a live resize outruns the page, the native window and the webview (WebView2's default
* background) show their own colours; match both to the frame. The webview one is only set at
* window creation otherwise, so a theme switched later left it light.
*/
function syncWindowBackground() {
if (!isTauri()) return;
const color = getComputedStyle(document.documentElement).getPropertyValue("--bg-frame").trim();
if (!color) return;
getCurrentWindow()
getCurrentWebviewWindow()
.setBackgroundColor(color)
.catch(() => {});
}