Add isTest to settings and ability to redirect to test env. Add rome/imex specific builds.

This commit is contained in:
Patrick Fic
2025-04-02 15:23:34 -07:00
parent 15f8733280
commit da43ade088
15 changed files with 170 additions and 58 deletions

View File

@@ -1,6 +1,14 @@
import { electronApp, is, optimizer } from "@electron-toolkit/utils";
import Sentry from "@sentry/electron/main";
import { app, BrowserWindow, Menu, nativeImage, shell, Tray } from "electron";
import {
app,
BrowserWindow,
globalShortcut,
Menu,
nativeImage,
shell,
Tray,
} from "electron";
import log from "electron-log/main";
import { autoUpdater } from "electron-updater";
import path, { join } from "path";
@@ -138,6 +146,20 @@ function createWindow(): void {
}
},
},
{
label: "Connect to Test",
checked: store.get("app.isTest") as boolean,
visible: false,
type: "checkbox",
id: "toggleTest",
click: (): void => {
const currentSetting = store.get("app.isTest") as boolean;
store.set("app.isTest", !currentSetting);
log.info("Setting isTest to: ", !currentSetting);
app.relaunch(); // Relaunch the app
app.exit(0); // Exit the current instance
},
},
],
},
// { role: 'windowMenu' }
@@ -219,6 +241,23 @@ function createWindow(): void {
const menu: Electron.Menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
// Register a global shortcut to show the hidden item
globalShortcut.register("CommandOrControl+Shift+T", () => {
console.log("Shortcut pressed! Revealing hidden item.");
// Update the menu to make the hidden item visible
// Find the menu item dynamically by its id
const fileMenu = template.find((item) => item.label === "Application");
const hiddenItem = fileMenu?.submenu?.find(
(item) => item.id === "toggleTest",
);
if (hiddenItem) {
hiddenItem.visible = true; // Update the visibility dynamically
const menu: Electron.Menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
}
});
// Store window properties for later
const storeWindowState = (): void => {
const [width, height] = mainWindow.getSize();
@@ -388,7 +427,7 @@ app.on("before-quit", () => {
openAtLogin: !currentSetting,
});
}
globalShortcut.unregisterAll();
isAppQuitting = true;
});