-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
44 lines (39 loc) · 1.24 KB
/
init.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
const {app, session, protocol, ipcMain, BrowserWindow} = require("electron")
const config = require("./magius.config")
if (config.devMode) process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true"
app.whenReady().then(async () => {
if (config.devMode) {
await session["defaultSession"].loadExtension(__dirname + "/chrome-extensions/vue-devtools")
await session["defaultSession"].loadExtension(__dirname + "/chrome-extensions/surfingkeys")
protocol.registerFileProtocol("file", (request, cb) => {
const pathname = request.url.replace("file:///", "").replace("%20", " ")
cb(pathname)
})
}
const win = new BrowserWindow({
show: false,
backgroundColor: "#1E1E21",
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
webSecurity: !config.devMode,
},
})
if (config.devMode)
await win.loadURL("http://localhost:8080")
else
await win.loadFile("./dist/index.html")
win.setMenuBarVisibility(false)
win.maximize()
win.show()
if (config.devMode) {
win.setMenuBarVisibility(true)
win.webContents.openDevTools()
}
})
ipcMain.on('ondragstart', (event, filePaths) => {
event.sender.startDrag({
files: filePaths,
icon: __dirname + '/drag-icon.png'
})
})