Files
koodo-reader/main.ts
troyeguo 4925bc55c2 bug修复
Former-commit-id: 97c781670ff1452178c411bbea23c48018319c4f
2020-06-21 09:14:16 +08:00

52 lines
1.4 KiB
TypeScript
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);
});