This repository has been archived by the owner on Feb 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
81 lines (70 loc) · 1.92 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
// Modules to control application life and create native browser window
const { app, BrowserWindow, globalShortcut, ipcMain } = require('electron')
const path = require('path')
const contextMenu = require('electron-context-menu')
const menu = require('./menu.js')
const { autoUpdater } = require('electron-updater')
const windowStateKeeper = require('electron-window-state')
let mainWindow, mainWindowState
try {
require('electron-reloader')(module)
} catch (_) {}
function createWindow() {
mainWindowState = windowStateKeeper({
defaultWidth: 1200,
defaultHeight: 700,
})
// Create the browser window.
mainWindow = new BrowserWindow({
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
minWidth: 1200,
minHeight: 700,
titleBarStyle: 'hidden',
trafficLightPosition: { x: 15, y: 35 },
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
webviewTag: true,
affinity: 'githubProcess',
},
})
// and load the index.html of the app.
mainWindow.loadFile('index.html')
// Open the DevTools.
// mainWindow.webContents.openDevTools()
}
contextMenu({
prepend: (defaultActions, params, browserWindow) => [
{
label: 'Unpin Tab',
visible:
params.linkURL.length && params.linkURL.includes('#pinned'),
click: () => {
browserWindow.webContents.send('unpintab', params.linkURL)
},
},
{
label: 'Pin Tab',
visible:
params.linkURL.length && params.linkURL.includes('#unpinned'),
click: () => {
browserWindow.webContents.send('pintab', params.linkURL)
},
},
],
})
app.whenReady().then(() => {
menu.createMenu()
createWindow()
autoUpdater.checkForUpdatesAndNotify()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
ipcMain.on('rebuild-menu', (event, titles) => {
menu.createMenu(titles)
})
mainWindowState.manage(mainWindow)
})