You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

125 lines
2.4 KiB

const {
app,
BrowserWindow,
globalShortcut,
shell,
autoUpdater,
} = require("electron");
const electronLocalshortcut = require("electron-localshortcut");
const Store = require("electron-store");
const store = new Store();
function initApp() {
store.set("init", true);
store.set("minimize", true);
store.set("startup", true);
}
const AutoLaunch = require("auto-launch");
4 years ago
// const server = 'https://cdn.g-vm.nl'
// const url = `${server}/update/${process.platform}/${app.getVersion()}`
// autoUpdater.setFeedURL({ url })
4 years ago
let loadingScreen;
function createLoadingScreen() {
loadingScreen = new BrowserWindow({
width: 200,
height: 400,
frame: false,
icon: "public/icon/icon.png",
backgroundColor: "#212121",
});
loadingScreen.setResizable(false);
loadingScreen.on("closed", () => (loadingScreen = null));
loadingScreen.loadFile("public/pages/loadscreen.html");
4 years ago
}
function createWindow() {
let win = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
webviewTag: true,
// enableBlinkFeatures: false,
enableRemoteModule: true,
},
frame: false,
show: false,
titleBarStyle: "hidden",
backgroundColor: "#212121",
minWidth: 600,
minHeight: 600,
icon: "public/icon/icon.png",
});
// autoUpdater.checkForUpdates()
win.loadFile("public/index.html");
win.webContents.on("new-window", function (e, url) {
e.preventDefault();
shell.openExternal(url);
});
electronLocalshortcut.register(win, "Ctrl+R", () => {
win.reload();
// app.relaunch()
// app.exit()
});
electronLocalshortcut.register(win, "Ctrl+Shift+I", () => {
win.webContents.openDevTools();
});
win.on("close", (e) => {
if (store.get("minimize")) {
e.preventDefault();
if (!app.isQuiting) {
win.hide();
}
}
});
4 years ago
win.once("ready-to-show", () => {
if (loadingScreen) {
loadingScreen.close();
4 years ago
}
win.show();
});
}
4 years ago
app.on("ready", () => {
createLoadingScreen();
createWindow();
if (!store.get("init")) {
initApp();
}
let autoLaunch = new AutoLaunch({
name: "Keyzo",
path: app.getPath("exe"),
});
if (store.get("startup")) {
autoLaunch.enable();
} else {
autoLaunch.disable();
}
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});