From 4fef8608621453d718f84949a543f49fb1d63e0a Mon Sep 17 00:00:00 2001 From: WINBIGFOX Date: Sun, 30 Mar 2025 19:29:25 +0200 Subject: [PATCH 1/2] Add theme management routes to handle theme source changes --- .../electron-plugin/src/server/api/system.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/resources/js/electron-plugin/src/server/api/system.ts b/resources/js/electron-plugin/src/server/api/system.ts index 6076ca06..8c6fa213 100644 --- a/resources/js/electron-plugin/src/server/api/system.ts +++ b/resources/js/electron-plugin/src/server/api/system.ts @@ -1,5 +1,5 @@ import express from 'express'; -import { BrowserWindow, systemPreferences, safeStorage } from 'electron'; +import {BrowserWindow, systemPreferences, safeStorage, nativeTheme} from 'electron'; const router = express.Router(); @@ -113,4 +113,20 @@ router.post('/print-to-pdf', async (req, res) => { await printWindow.loadURL(`data:text/html;charset=UTF-8,${html}`); }); +router.get('/theme', (req, res) => { + res.json({ + result: nativeTheme.themeSource, + }); +}); + +router.post('/theme', (req, res) => { + const { theme } = req.body; + + nativeTheme.themeSource = theme; + + res.json({ + result: theme, + }); +}); + export default router; From d90e6b55fe2118264f345b29bfd8d3baf4258680 Mon Sep 17 00:00:00 2001 From: WINBIGFOX Date: Sun, 30 Mar 2025 19:30:37 +0200 Subject: [PATCH 2/2] Build electron plugin dist folder --- .../js/electron-plugin/dist/server/api/system.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resources/js/electron-plugin/dist/server/api/system.js b/resources/js/electron-plugin/dist/server/api/system.js index 76490bcb..6cb9594a 100644 --- a/resources/js/electron-plugin/dist/server/api/system.js +++ b/resources/js/electron-plugin/dist/server/api/system.js @@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; import express from 'express'; -import { BrowserWindow, systemPreferences, safeStorage } from 'electron'; +import { BrowserWindow, systemPreferences, safeStorage, nativeTheme } from 'electron'; const router = express.Router(); router.get('/can-prompt-touch-id', (req, res) => { res.json({ @@ -107,4 +107,16 @@ router.post('/print-to-pdf', (req, res) => __awaiter(void 0, void 0, void 0, fun }); yield printWindow.loadURL(`data:text/html;charset=UTF-8,${html}`); })); +router.get('/theme', (req, res) => { + res.json({ + result: nativeTheme.themeSource, + }); +}); +router.post('/theme', (req, res) => { + const { theme } = req.body; + nativeTheme.themeSource = theme; + res.json({ + result: theme, + }); +}); export default router;