-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathaboutWindow.ts
More file actions
64 lines (53 loc) · 1.64 KB
/
aboutWindow.ts
File metadata and controls
64 lines (53 loc) · 1.64 KB
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
import { BrowserWindow, ipcMain, shell } from "electron"
import path from "path"
let aboutPopoutWin: BrowserWindow | null = null
const VITE_DEV_SERVER_URL = process.env["VITE_DEV_SERVER_URL"]
export function openAboutPopout() {
if (aboutPopoutWin === null) {
aboutPopoutWin = new BrowserWindow({
width: 400,
height: 300,
frame: true,
icon: path.join(process.env.VITE_PUBLIC, "app_icon.ico"),
show: false,
title: "About FGCS",
webPreferences: {
preload: path.join(__dirname, "preload.js"),
contextIsolation: true,
},
fullscreen: false,
fullscreenable: false,
})
}
if (VITE_DEV_SERVER_URL) {
aboutPopoutWin?.loadURL(VITE_DEV_SERVER_URL + "aboutWindow.html")
} else {
aboutPopoutWin?.loadFile(path.join(process.env.DIST, "aboutWindow.html"))
}
// Open links in browser, not within the electron window.
// Note, links must have target="_blank"
aboutPopoutWin.webContents.setWindowOpenHandler((details) => {
shell.openExternal(details.url)
return { action: "deny" }
})
aboutPopoutWin.on("close", () => {
aboutPopoutWin = null
})
aboutPopoutWin.setMenuBarVisibility(false)
aboutPopoutWin.show()
}
export function closeAboutPopout() {
destroyAboutWindow()
}
export function destroyAboutWindow() {
aboutPopoutWin?.close()
aboutPopoutWin = null
}
export default function registerAboutIPC() {
ipcMain.removeHandler("app:open-about-window")
ipcMain.removeHandler("app:close-about-window")
ipcMain.handle("app:open-about-window", () => {
openAboutPopout()
})
ipcMain.handle("app:close-about-window", () => closeAboutPopout())
}