-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
86 lines (77 loc) · 2.29 KB
/
main.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
const {app, BrowserWindow, dialog, Menu, MenuItem} = require('electron')
const {autoUpdater} = require("electron-updater");
const log = require('electron-log');
autoUpdater.logger = log;
if (process.platform == 'darwin') {
app.whenReady().then(() => {
global.frame = false;
global.titleBarStyle = 'hiddenInset';
})}
else if(process.platform == 'win32'){
app.whenReady().then(() => {
global.frame = false;
global.titleBarStyle = 'hidden';
})}
else{
app.whenReady().then(() => {
global.frame = true;
})}
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Update Ready',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new update is ready!'
}
dialog.showMessageBox(dialogOpts).then((returnValue) => {if (returnValue.response === 0) autoUpdater.quitAndInstall()})
})
const launch = () => {
const mainWindow = new BrowserWindow({
width: 1200,
height: 800,
autoHideMenuBar: true,
transparent: true,
frame: global.frame,
titleBarStyle: global.titleBarStyle,
trafficLightPosition: { x: 10, y: 10 },
titleBarOverlay: {
color: '#303136',
symbolColor: 'white'
},
webPreferences: {
webviewTag: true
}
})
mainWindow.loadFile('index.html')
const menu = new Menu()
menu.append(new MenuItem({
label: 'Penpot',
submenu: [
{
label: 'Open Settings',
accelerator: process.platform === 'darwin' ? 'Cmd+.' : 'Ctrl+.',
click: () => {
mainWindow.webContents.executeJavaScript(`
document.querySelector('#for-settings').style.display = 'inherit'; document.querySelector('body > div.settings').style.display = 'inherit';
`)
}
},
{ type: 'separator'},
{ role: 'reload' },
{ role: 'toggleDevTools' },
{ role: 'resetZoom' },
{ role: 'zoomIn' },
{ role: 'zoomOut' },
{ type: 'separator'},
{
label: 'Quit',
accelerator: process.platform === 'darwin' ? 'Cmd+Q' : 'Ctrl+Q',
hide: true,
click: () => { app.quit() }
}
],
}))
Menu.setApplicationMenu(menu)
}
app.whenReady().then(() => {launch();autoUpdater.checkForUpdatesAndNotify();})