add electron webFrame API to preloadJS

pull/905/head
Brian Jian Zhao 5 years ago
parent b2322bae02
commit 7a0f2c9ce3

@ -2,6 +2,7 @@
/* global window: false */ /* global window: false */
const path = require('path'); const path = require('path');
const electron = require('electron'); const electron = require('electron');
const {webFrame} = electron;
const semver = require('semver'); const semver = require('semver');
const { deferredToPromise } = require('./js/modules/deferred_to_promise'); const { deferredToPromise } = require('./js/modules/deferred_to_promise');
@ -69,6 +70,7 @@ window.CONSTANTS = {
MAX_CONNECTION_DURATION: 5000, MAX_CONNECTION_DURATION: 5000,
}; };
window.versionInfo = { window.versionInfo = {
environment: window.getEnvironment(), environment: window.getEnvironment(),
version: window.getVersion(), version: window.getVersion(),
@ -82,10 +84,15 @@ const ipc = electron.ipcRenderer;
const localeMessages = ipc.sendSync('locale-data'); const localeMessages = ipc.sendSync('locale-data');
Window.updateScaling = (number) => { window.setScaling = (number) => {
ipc.s return webFrame.setZoomFactor(number);
}
window.getScaling = () => {
return webFrame.getZoomFactor();
} }
window.setBadgeCount = count => ipc.send('set-badge-count', count); window.setBadgeCount = count => ipc.send('set-badge-count', count);
// Set the password for the database // Set the password for the database
@ -185,7 +192,7 @@ ipc.on('set-up-as-standalone', () => {
// Settings-related events // Settings-related events
console.log(window.getSettingValue('zoom-factor-setting'), 'from preloadJS and get the setting value');
window.showSettings = () => ipc.send('show-settings'); window.showSettings = () => ipc.send('show-settings');
@ -229,6 +236,9 @@ window.setSettingValue = (settingID, value) => {
window.storage.put(settingID, value); window.storage.put(settingID, value);
}; };
installGetter('device-name', 'getDeviceName'); installGetter('device-name', 'getDeviceName');
installGetter('theme-setting', 'getThemeSetting'); installGetter('theme-setting', 'getThemeSetting');

Loading…
Cancel
Save