diff --git a/forge.config.ts b/forge.config.ts index cf527ef..9c1ea9f 100644 --- a/forge.config.ts +++ b/forge.config.ts @@ -97,6 +97,11 @@ if (!process.env.PLATFORM) { } const customVitePluginBuild: VitePluginBuildConfig[] = [ + { + entry: "about.html", + config: "vite.main.config.ts", + target: "main", + }, { entry: "src/main.ts", config: "vite.main.config.ts", diff --git a/src/native/about.ts b/src/native/about.ts new file mode 100644 index 0000000..7e0d58f --- /dev/null +++ b/src/native/about.ts @@ -0,0 +1,42 @@ +import { join } from "node:path"; + +import { BrowserWindow } from "electron"; + +import { mainWindow } from "./window"; + +// global reference to about window +export let aboutWindow: BrowserWindow; + +// Create our about window +export function createAboutWindow() { + aboutWindow = new BrowserWindow({ + minWidth: 300, + minHeight: 300, + width: 1280, + height: 720, + center: true, + backgroundColor: "#191919", + frame: true, + resizable: false, + parent: mainWindow, + paintWhenInitiallyHidden: true, + webPreferences: { + preload: join(__dirname, "preload.js"), + contextIsolation: true, + nodeIntegration: false, + spellcheck: false, + devTools: false, + }, + }); + + aboutWindow.loadFile("about.html"); + + aboutWindow.on("ready-to-show", () => { + aboutWindow.show(); + }); + + aboutWindow.on("close", (e) => { + e.preventDefault(); + aboutWindow.hide(); + }); +} diff --git a/src/native/window.ts b/src/native/window.ts index 356ab2d..1a55b9d 100644 --- a/src/native/window.ts +++ b/src/native/window.ts @@ -11,6 +11,7 @@ import { import windowIconAsset from "../../avia_assets/icon.png?asset"; +import { aboutWindow, createAboutWindow } from "./about"; import { config } from "./config"; import { updateTrayMenu } from "./tray"; @@ -145,6 +146,13 @@ export function createMainWindow() { // reset zoom to default. event.preventDefault(); mainWindow.webContents.setZoomLevel(0); + } else if (input.key === "F1") { + event.preventDefault(); + if (!aboutWindow) { + createAboutWindow(); + } else { + aboutWindow.show(); + } } else if ( input.key === "F5" || ((input.control || input.meta) && input.key.toLowerCase() === "r")