-
Notifications
You must be signed in to change notification settings - Fork 0
/
electron.ts
39 lines (33 loc) · 876 Bytes
/
electron.ts
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
import { app, BrowserWindow, protocol } from "electron"
import { resolve } from "path"
import { info } from "electron-log"
import { createWindow } from "./main/create-window"
import appProtocol from "./main/app.protocol"
info("Logging Directory", resolve(app.getPath("logs")))
let win: BrowserWindow | undefined
protocol.registerSchemesAsPrivileged([
{
scheme: "app",
privileges: { secure: true, standard: true },
},
])
app.on("ready", () => {
protocol.registerFileProtocol("app", appProtocol(resolve(__dirname)))
win = createWindow()
win.on("closed", () => {
win = undefined
})
})
app.on("activate", () => {
if (!win) {
win = createWindow()
win.on("closed", () => {
win = undefined
})
}
})
app.on("web-contents-created", (event, contents) => {
contents.on("will-navigate", (event) => {
event.preventDefault()
})
})