feat(theme): add system theme support

close #13
This commit is contained in:
Elysia
2026-02-13 14:49:41 +08:00
parent 1d808b035a
commit 7aeb3d5dd4
4 changed files with 87 additions and 22 deletions

View File

@@ -1,4 +1,12 @@
import { app, BrowserWindow, ipcMain, Menu, shell, Tray } from "electron";
import {
app,
BrowserWindow,
ipcMain,
Menu,
shell,
Tray,
nativeTheme,
} from "electron";
import { fileURLToPath } from "node:url";
import path from "node:path";
import os from "node:os";
@@ -116,6 +124,10 @@ ipcMain.on("renderer-ready", (event, args) => {
logger.info(`isLoaded set to: ${isLoaded.value}`);
});
ipcMain.on("set-theme-source", (event, theme: "system" | "light" | "dark") => {
nativeTheme.themeSource = theme;
});
app.whenReady().then(() => {
createWindow();
handleCommandLine(process.argv);