-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
69 lines (54 loc) · 1.57 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
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('path')
let mainWindow
// const iconPath = path.join(__dirname, 'logo.png')
function createWindow () {
mainWindow = new BrowserWindow({
nodeIntegration: false,
nodeIntegrationInWorker: false,
contextIsolation: true,
webviewTag: true,
preload: path.join(__dirname, 'preload.js'),
icon: __dirname + '/AppIcon.icns'
})
mainWindow.maximize();
mainWindow.loadURL('file://' + __dirname + '/index.html')
// mainWindow.webContents.openDevTools()
mainWindow.on('closed', () => {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('web-contents-created', (event, contents) => {
contents.on('will-attach-webview', (event, webPreferences, params) => {
webPreferences.nodeIntegration = false
})
})
app.on('activate', () => {
if (mainWindow === null) {
createWindow()
}
})
ipcMain.on('getLinks', (event, message) => {
mainWindow.webContents.send('getLinks', message)
})
ipcMain.on('getNavLinks', (event, message) => {
mainWindow.webContents.send('getNavLinks', message)
})
ipcMain.on('loadBookmark', (event, message) => {
mainWindow.webContents.send('loadBookmark', message)
})
ipcMain.on('closeBookmarks', (event, message) => {
mainWindow.webContents.send('closeBookmarks', message)
})
ipcMain.on('hideScrollUp', () => {
mainWindow.webContents.send('hideScrollUp')
})
ipcMain.on('showScrollUp', () => {
mainWindow.webContents.send('showScrollUp')
})