-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch.js
93 lines (76 loc) · 1.97 KB
/
launch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//
// launch.js
// matter
//
// Created by Wess Cope ([email protected]) on 03/24/20
// Copyright 2019 Wess Cope
//
const path = require('path')
const url = require('url')
const isDev = require("electron-is-dev")
const WindowState = require('electron-window-state')
const {autoUpdater} = require('electron-updater')
const {
ipcMain,
BrowserWindow,
app
} = require('electron')
if(isDev) {
require('electron-reload')(path.join(__dirname, 'dist'))
}
const createWindow = () => {
const windowState = WindowState({
defaultWidth: 1000,
defaultHeight: 800
})
var window = new BrowserWindow({
x: windowState.x,
y: windowState.y,
width: windowState.width,
height: windowState.height,
minWidth: 760,
minHeight: 600,
title: "Ande",
webPreferences: {
nodeIntegration: true,
preload: 'preload.js',
webviewTag: true
}
})
if(isDev) {
window.webContents.openDevTools()
}
window.loadURL(
isDev
? "http://localhost:1234"
: url.format({
pathname: path.join(__dirname, "dist", "index.html"),
protocol: 'file:',
slashes: true
})
)
window.webContents.session.clearCache()
windowState.manage(window)
window.on('page-title-updated', (e) => e.preventDefault())
window.on('closed', () => window = null)
window.on('ready-to-show', () => {
autoUpdater.checkForUpdatesAndNotify()
window.show()
})
autoUpdater.on('update-available', () => window.webContents.send('update-available'))
autoUpdater.on('update-downloaded', () => window.webContents.send('update-downloaded'))
}
ipcMain.on('install-update', () => {
autoUpdater.quitAndInstall()
})
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if(process.platform.toLowerCase().includes('darwin')) {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})