Skip to content

Commit a7f4ded

Browse files
authored
Add possibility to set a zoom factor to window API (#246)
1 parent ed09419 commit a7f4ded

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ router.post('/hide-dev-tools', (req, res) => {
5353
(_a = state.windows[id]) === null || _a === void 0 ? void 0 : _a.webContents.closeDevTools();
5454
res.sendStatus(200);
5555
});
56+
router.post('/set-zoom-factor', (req, res) => {
57+
var _a;
58+
const { id, zoomFactor } = req.body;
59+
(_a = state.windows[id]) === null || _a === void 0 ? void 0 : _a.webContents.setZoomFactor(parseFloat(zoomFactor));
60+
res.sendStatus(200);
61+
});
5662
router.post('/position', (req, res) => {
5763
var _a;
5864
const { id, x, y, animate } = req.body;
@@ -139,7 +145,7 @@ function getWindowData(id) {
139145
};
140146
}
141147
router.post('/open', (req, res) => {
142-
let { id, x, y, frame, width, height, minWidth, minHeight, maxWidth, maxHeight, focusable, skipTaskbar, hiddenInMissionControl, hasShadow, url, resizable, movable, minimizable, maximizable, closable, title, alwaysOnTop, titleBarStyle, trafficLightPosition, vibrancy, backgroundColor, transparency, showDevTools, fullscreen, fullscreenable, kiosk, autoHideMenuBar, webPreferences, } = req.body;
148+
let { id, x, y, frame, width, height, minWidth, minHeight, maxWidth, maxHeight, focusable, skipTaskbar, hiddenInMissionControl, hasShadow, url, resizable, movable, minimizable, maximizable, closable, title, alwaysOnTop, titleBarStyle, trafficLightPosition, vibrancy, backgroundColor, transparency, showDevTools, fullscreen, fullscreenable, kiosk, autoHideMenuBar, webPreferences, zoomFactor, } = req.body;
143149
if (state.windows[id]) {
144150
state.windows[id].show();
145151
state.windows[id].focus();
@@ -247,6 +253,9 @@ router.post('/open', (req, res) => {
247253
});
248254
url = appendWindowIdToUrl(url, id);
249255
window.loadURL(url);
256+
window.webContents.on('dom-ready', () => {
257+
window.webContents.setZoomFactor(parseFloat(zoomFactor));
258+
});
250259
window.webContents.on('did-finish-load', () => {
251260
window.show();
252261
});

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ router.post('/hide-dev-tools', (req, res) => {
7373
res.sendStatus(200);
7474
});
7575

76+
router.post('/set-zoom-factor', (req, res) => {
77+
const {id, zoomFactor} = req.body;
78+
79+
state.windows[id]?.webContents.setZoomFactor(parseFloat(zoomFactor));
80+
81+
res.sendStatus(200);
82+
});
83+
7684
router.post('/position', (req, res) => {
7785
const {id, x, y, animate} = req.body;
7886

@@ -225,6 +233,7 @@ router.post('/open', (req, res) => {
225233
kiosk,
226234
autoHideMenuBar,
227235
webPreferences,
236+
zoomFactor,
228237
} = req.body;
229238

230239
if (state.windows[id]) {
@@ -377,6 +386,10 @@ router.post('/open', (req, res) => {
377386

378387
window.loadURL(url);
379388

389+
window.webContents.on('dom-ready', () => {
390+
window.webContents.setZoomFactor(parseFloat(zoomFactor));
391+
});
392+
380393
window.webContents.on('did-finish-load', () => {
381394
window.show();
382395
});

0 commit comments

Comments
 (0)