Skip to content

Commit 149789c

Browse files
authored
Feature/add native theme getter setter (#190)
* Add theme management routes to handle theme source changes * Build electron plugin dist folder
1 parent 36ebe46 commit 149789c

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

resources/js/electron-plugin/dist/server/api/system.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
88
});
99
};
1010
import express from 'express';
11-
import { BrowserWindow, systemPreferences, safeStorage } from 'electron';
11+
import { BrowserWindow, systemPreferences, safeStorage, nativeTheme } from 'electron';
1212
const router = express.Router();
1313
router.get('/can-prompt-touch-id', (req, res) => {
1414
res.json({
@@ -107,4 +107,16 @@ router.post('/print-to-pdf', (req, res) => __awaiter(void 0, void 0, void 0, fun
107107
});
108108
yield printWindow.loadURL(`data:text/html;charset=UTF-8,${html}`);
109109
}));
110+
router.get('/theme', (req, res) => {
111+
res.json({
112+
result: nativeTheme.themeSource,
113+
});
114+
});
115+
router.post('/theme', (req, res) => {
116+
const { theme } = req.body;
117+
nativeTheme.themeSource = theme;
118+
res.json({
119+
result: theme,
120+
});
121+
});
110122
export default router;

resources/js/electron-plugin/src/server/api/system.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import express from 'express';
2-
import { BrowserWindow, systemPreferences, safeStorage } from 'electron';
2+
import {BrowserWindow, systemPreferences, safeStorage, nativeTheme} from 'electron';
33

44
const router = express.Router();
55

@@ -113,4 +113,20 @@ router.post('/print-to-pdf', async (req, res) => {
113113
await printWindow.loadURL(`data:text/html;charset=UTF-8,${html}`);
114114
});
115115

116+
router.get('/theme', (req, res) => {
117+
res.json({
118+
result: nativeTheme.themeSource,
119+
});
120+
});
121+
122+
router.post('/theme', (req, res) => {
123+
const { theme } = req.body;
124+
125+
nativeTheme.themeSource = theme;
126+
127+
res.json({
128+
result: theme,
129+
});
130+
});
131+
116132
export default router;

0 commit comments

Comments
 (0)