Files
koodo-reader/main.js
troyeguo 2adb78d648 使用typescript重构
Former-commit-id: 10f9b6dee814275a1078267253f725c378e15310
2020-04-25 23:08:44 +08:00

52 lines
1.4 KiB
JavaScript
Vendored
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const { app, BrowserWindow, dialog, shell, remote } = require("electron");
const isDev = require("electron-is-dev");
const path = require("path");
const { autoUpdater } = require("electron-updater");
let mainWindow;
app.on("ready", () => {
// console.log("before message box");
autoUpdater.on("update-available", () => {
dialog
.showMessageBox({
title: "更新提示",
message: "Koodo Reader发布新版本啦",
buttons: ["前往下载", "稍后提醒"],
defaultId: 0, // bound to buttons array
cancelId: 1, // bound to buttons array
})
.then((result) => {
if (result.response === 0) {
// bound to buttons array
shell.openExternal(
"https://github.com/troyeguo/koodo-reader/releases"
);
} else if (result.response === 1) {
// bound to buttons array
console.log("Cancel button clicked.");
}
})
.catch((err) => {
console.log("Error occurs");
});
console.log("after message box");
});
mainWindow = new BrowserWindow({
width: 1024,
height: 660,
webPreferences: {
nodeIntegration: false,
},
});
if (!isDev) {
const { Menu } = require("electron");
Menu.setApplicationMenu(null);
}
const urlLocation = isDev
? "http://localhost:3000/"
: `file://${path.join(__dirname, "./build/index.html")}`;
mainWindow.loadURL(urlLocation);
});