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.

119 lines
2.7 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);
}
4 years ago
const AutoLaunch = require('auto-launch');
// 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() {
4 years ago
loadingScreen = new BrowserWindow({
width: 200,
height: 400,
frame: false,
icon: "public/icon/icon.png",
4 years ago
backgroundColor: '#212121'
});
4 years ago
loadingScreen.setResizable(false);
loadingScreen.on('closed', () => loadingScreen = null);
4 years ago
loadingScreen.loadFile('public/pages/loadscreen.html')
};
function createWindow() {
let win = new BrowserWindow({
4 years ago
webPreferences: {
nodeIntegration: true,
webviewTag: true,
// enableBlinkFeatures: false,
4 years ago
enableRemoteModule: true
},
frame: false,
show: false,
titleBarStyle: "hidden",
4 years ago
backgroundColor: '#212121',
'minWidth': 600,
'minHeight': 600,
icon: "public/icon/icon.png"
4 years ago
})
// autoUpdater.checkForUpdates()
4 years ago
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();
}
}
})
win.once('ready-to-show', () => {
4 years ago
if (loadingScreen) {
loadingScreen.close();
}
win.show()
})
}
app.on('ready', () => {
4 years ago
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();
}
4 years ago
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})