2018-06-03 01:02:20 +08:00
|
|
|
import server from "./server.js";
|
|
|
|
import utils from "./utils.js";
|
|
|
|
import optionsInitService from "./options_init.js";
|
|
|
|
|
|
|
|
function decreaseZoomFactor() {
|
|
|
|
const webFrame = require('electron').webFrame;
|
|
|
|
|
|
|
|
if (webFrame.getZoomFactor() > 0.2) {
|
|
|
|
const webFrame = require('electron').webFrame;
|
|
|
|
const newZoomFactor = webFrame.getZoomFactor() - 0.1;
|
|
|
|
|
|
|
|
webFrame.setZoomFactor(newZoomFactor);
|
|
|
|
|
|
|
|
server.put('options/zoomFactor/' + newZoomFactor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function increaseZoomFactor() {
|
|
|
|
const webFrame = require('electron').webFrame;
|
|
|
|
const newZoomFactor = webFrame.getZoomFactor() + 0.1;
|
|
|
|
|
|
|
|
webFrame.setZoomFactor(newZoomFactor);
|
|
|
|
|
|
|
|
server.put('options/zoomFactor/' + newZoomFactor);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setZoomFactor(zoomFactor) {
|
|
|
|
zoomFactor = parseFloat(zoomFactor);
|
|
|
|
|
|
|
|
const webFrame = require('electron').webFrame;
|
|
|
|
webFrame.setZoomFactor(zoomFactor);
|
|
|
|
}
|
|
|
|
|
2018-06-09 11:18:53 +08:00
|
|
|
async function setZoomFactorAndSave(zoomFactor) {
|
|
|
|
setZoomFactor(zoomFactor);
|
|
|
|
|
|
|
|
await server.put('options/zoomFactor/' + zoomFactor);
|
|
|
|
}
|
|
|
|
|
2018-06-03 01:02:20 +08:00
|
|
|
if (utils.isElectron()) {
|
|
|
|
optionsInitService.optionsReady.then(options => setZoomFactor(options.zoomFactor))
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
decreaseZoomFactor,
|
|
|
|
increaseZoomFactor,
|
2018-06-09 11:18:53 +08:00
|
|
|
setZoomFactor,
|
|
|
|
setZoomFactorAndSave
|
2018-06-03 01:02:20 +08:00
|
|
|
}
|