fix(window): force dark native title bar
Apply Electron nativeTheme dark mode before creating the main window so the Windows title bar remains dark across local, server, and Remote Desktop profiles. Add focused regression coverage for the native theme contract.
This commit is contained in:
+4
-1
@@ -1,7 +1,7 @@
|
|||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { pathToFileURL } from "node:url";
|
import { pathToFileURL } from "node:url";
|
||||||
import { app, BrowserWindow, clipboard, dialog, ipcMain, Menu, safeStorage, shell, Tray, type IpcMainEvent, type IpcMainInvokeEvent } from "electron";
|
import { app, BrowserWindow, clipboard, dialog, ipcMain, Menu, nativeTheme, safeStorage, shell, Tray, type IpcMainEvent, type IpcMainInvokeEvent } from "electron";
|
||||||
import { AddLinksPayload, AppSettings, DebridProvider, EnableRemoteDiagnosticsInput, RendererSettingsUpdate, UpdateInstallProgress } from "../shared/types";
|
import { AddLinksPayload, AppSettings, DebridProvider, EnableRemoteDiagnosticsInput, RendererSettingsUpdate, UpdateInstallProgress } from "../shared/types";
|
||||||
import { AppController } from "./app-controller";
|
import { AppController } from "./app-controller";
|
||||||
import { IPC_CHANNELS } from "../shared/ipc";
|
import { IPC_CHANNELS } from "../shared/ipc";
|
||||||
@@ -23,6 +23,9 @@ import { applyMainWindowSecurity, createMainWindowWebPreferences, MAIN_WINDOW_EX
|
|||||||
import { assertTrustedIpcSender, type TrustedIpcOptions } from "./ipc-security";
|
import { assertTrustedIpcSender, type TrustedIpcOptions } from "./ipc-security";
|
||||||
import { validateRealDebridLoginRequest } from "../shared/preload-api";
|
import { validateRealDebridLoginRequest } from "../shared/preload-api";
|
||||||
import { migrateProductUserDataDirectory } from "./storage";
|
import { migrateProductUserDataDirectory } from "./storage";
|
||||||
|
import { forceDarkNativeTheme } from "./native-theme";
|
||||||
|
|
||||||
|
forceDarkNativeTheme(nativeTheme);
|
||||||
|
|
||||||
function validateString(value: unknown, name: string): string {
|
function validateString(value: unknown, name: string): string {
|
||||||
if (typeof value !== "string") {
|
if (typeof value !== "string") {
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export interface NativeThemeTarget {
|
||||||
|
themeSource: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function forceDarkNativeTheme(theme: NativeThemeTarget): void {
|
||||||
|
theme.themeSource = "dark";
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { forceDarkNativeTheme } from "../src/main/native-theme";
|
||||||
|
|
||||||
|
describe("native window theme", () => {
|
||||||
|
it("forces the native Windows title bar to use the dark theme", () => {
|
||||||
|
const theme = { themeSource: "system" };
|
||||||
|
|
||||||
|
forceDarkNativeTheme(theme);
|
||||||
|
|
||||||
|
expect(theme.themeSource).toBe("dark");
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user