Remove main window opening on imexmedia URL call.
This commit is contained in:
@@ -78,7 +78,7 @@ function createWindow(): void {
|
||||
// { role: 'appMenu' }
|
||||
// @ts-ignore
|
||||
...(isMac
|
||||
? [
|
||||
? [
|
||||
{
|
||||
label: app.name,
|
||||
submenu: [
|
||||
@@ -94,7 +94,7 @@ function createWindow(): void {
|
||||
],
|
||||
},
|
||||
]
|
||||
: []),
|
||||
: []),
|
||||
// { role: 'fileMenu' }
|
||||
{
|
||||
label: "File",
|
||||
@@ -117,7 +117,7 @@ function createWindow(): void {
|
||||
{ role: "paste" },
|
||||
// @ts-ignore
|
||||
...(isMac
|
||||
? [
|
||||
? [
|
||||
{ role: "pasteAndMatchStyle" },
|
||||
{ role: "delete" },
|
||||
{ role: "selectAll" },
|
||||
@@ -127,7 +127,7 @@ function createWindow(): void {
|
||||
submenu: [{ role: "startSpeaking" }, { role: "stopSpeaking" }],
|
||||
},
|
||||
]
|
||||
: [{ role: "delete" }, { type: "separator" }, { role: "selectAll" }]),
|
||||
: [{ role: "delete" }, { type: "separator" }, { role: "selectAll" }]),
|
||||
],
|
||||
},
|
||||
// { role: 'viewMenu' }
|
||||
@@ -202,13 +202,13 @@ function createWindow(): void {
|
||||
click: (): void => {
|
||||
/* action for item 1 */
|
||||
shell
|
||||
.openPath(log.transports.file.getFile().path)
|
||||
.catch((error) => {
|
||||
log.error(
|
||||
"Failed to open log file:",
|
||||
errorTypeCheck(error),
|
||||
);
|
||||
});
|
||||
.openPath(log.transports.file.getFile().path)
|
||||
.catch((error) => {
|
||||
log.error(
|
||||
"Failed to open log file:",
|
||||
errorTypeCheck(error),
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -222,8 +222,8 @@ function createWindow(): void {
|
||||
click: (): void => {
|
||||
shell.openPath(path.dirname(store.path)).catch((error) => {
|
||||
log.error(
|
||||
"Failed to open config folder:",
|
||||
errorTypeCheck(error),
|
||||
"Failed to open config folder:",
|
||||
errorTypeCheck(error),
|
||||
);
|
||||
});
|
||||
},
|
||||
@@ -232,7 +232,7 @@ function createWindow(): void {
|
||||
label: "Log the Store",
|
||||
click: (): void => {
|
||||
log.debug(
|
||||
"Store Contents" + JSON.stringify(store.store, null, 4),
|
||||
"Store Contents" + JSON.stringify(store.store, null, 4),
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -265,7 +265,7 @@ function createWindow(): void {
|
||||
await updateKeepAliveMenuItem();
|
||||
} catch (error) {
|
||||
log.error(
|
||||
`Failed to install keep-alive: ${error instanceof Error ? error.message : String(error)}`,
|
||||
`Failed to install keep-alive: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
// Optionally notify user (e.g., via dialog or log)
|
||||
}
|
||||
@@ -289,13 +289,13 @@ function createWindow(): void {
|
||||
{ role: "zoom" },
|
||||
// @ts-ignore
|
||||
...(isMac
|
||||
? [
|
||||
? [
|
||||
{ type: "separator" },
|
||||
{ role: "front" },
|
||||
{ type: "separator" },
|
||||
{ role: "window" },
|
||||
]
|
||||
: [{ role: "close" }]),
|
||||
: [{ role: "close" }]),
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -304,29 +304,29 @@ function createWindow(): void {
|
||||
const updateKeepAliveMenuItem = async (): Promise<void> => {
|
||||
try {
|
||||
const isInstalled = platform.isWindows
|
||||
? await isKeepAliveTaskInstalled()
|
||||
: platform.isMacOS
|
||||
? await isKeepAliveAgentInstalled()
|
||||
: false;
|
||||
? await isKeepAliveTaskInstalled()
|
||||
: platform.isMacOS
|
||||
? await isKeepAliveAgentInstalled()
|
||||
: false;
|
||||
const developmentMenu = template
|
||||
.find((item) => item.label === "Application")
|
||||
// @ts-ignore
|
||||
?.submenu?.find((item: { id: string }) => item.id === "development")
|
||||
?.submenu as Electron.MenuItemConstructorOptions[];
|
||||
.find((item) => item.label === "Application")
|
||||
// @ts-ignore
|
||||
?.submenu?.find((item: { id: string }) => item.id === "development")
|
||||
?.submenu as Electron.MenuItemConstructorOptions[];
|
||||
const keepAliveItem = developmentMenu?.find(
|
||||
(item) => item.label === "Install Keep Alive",
|
||||
(item) => item.label === "Install Keep Alive",
|
||||
);
|
||||
if (keepAliveItem) {
|
||||
keepAliveItem.enabled = !isInstalled; // Enable if not installed, disable if installed
|
||||
const menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
||||
log.debug(
|
||||
`Updated Install Keep Alive menu item: enabled=${keepAliveItem.enabled}`,
|
||||
`Updated Install Keep Alive menu item: enabled=${keepAliveItem.enabled}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(
|
||||
`Error updating Keep Alive menu item: ${error instanceof Error ? error.message : String(error)}`,
|
||||
`Error updating Keep Alive menu item: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -336,7 +336,7 @@ function createWindow(): void {
|
||||
// Update menu item enabled state on app start
|
||||
updateKeepAliveMenuItem().catch((error) => {
|
||||
log.error(
|
||||
`Error updating Keep Alive menu item: ${error instanceof Error ? error.message : String(error)}`,
|
||||
`Error updating Keep Alive menu item: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -349,7 +349,7 @@ function createWindow(): void {
|
||||
const fileMenu = template.find((item) => item.label === "Application");
|
||||
// @ts-ignore
|
||||
const hiddenItem = fileMenu?.submenu?.find(
|
||||
(item: { id: string }) => item.id === "development",
|
||||
(item: { id: string }) => item.id === "development",
|
||||
);
|
||||
//Adjust the development menu as well.
|
||||
|
||||
@@ -406,10 +406,10 @@ function createWindow(): void {
|
||||
});
|
||||
} else {
|
||||
mainWindow
|
||||
.loadFile(join(__dirname, "../renderer/index.html"))
|
||||
.catch((error) => {
|
||||
log.error("Failed to load file:", errorTypeCheck(error));
|
||||
});
|
||||
.loadFile(join(__dirname, "../renderer/index.html"))
|
||||
.catch((error) => {
|
||||
log.error("Failed to load file:", errorTypeCheck(error));
|
||||
});
|
||||
}
|
||||
if (import.meta.env.DEV) {
|
||||
mainWindow.webContents.openDevTools();
|
||||
@@ -444,9 +444,9 @@ app.whenReady().then(async () => {
|
||||
// Set the path of electron.exe and your app.
|
||||
// These two additional parameters are only available on windows.
|
||||
isDefaultProtocolClient = app.setAsDefaultProtocolClient(
|
||||
protocol,
|
||||
process.execPath,
|
||||
[path.resolve(process.argv[1])],
|
||||
protocol,
|
||||
process.execPath,
|
||||
[path.resolve(process.argv[1])],
|
||||
);
|
||||
} else {
|
||||
isDefaultProtocolClient = app.setAsDefaultProtocolClient(protocol);
|
||||
@@ -467,7 +467,6 @@ app.whenReady().then(async () => {
|
||||
return; // Skip openMainWindow to avoid focusing the window
|
||||
} else {
|
||||
openInExplorer(url);
|
||||
openMainWindow(); // Focus window for non-keep-alive URLs
|
||||
}
|
||||
} else {
|
||||
openMainWindow(); // Focus window if no URL
|
||||
@@ -543,8 +542,8 @@ app.whenReady().then(async () => {
|
||||
log.info(`Total downloaded ${progress.transferred}/${progress.total}`);
|
||||
const mainWindow = BrowserWindow.getAllWindows()[0];
|
||||
mainWindow?.webContents.send(
|
||||
ipcTypes.toRenderer.updates.downloading,
|
||||
progress,
|
||||
ipcTypes.toRenderer.updates.downloading,
|
||||
progress,
|
||||
);
|
||||
});
|
||||
autoUpdater.on("update-downloaded", (info) => {
|
||||
@@ -580,7 +579,6 @@ app.on("open-url", (event: Electron.Event, url: string) => {
|
||||
return; // Skip openMainWindow to avoid focusing the window
|
||||
} else {
|
||||
openInExplorer(url);
|
||||
openMainWindow(); // Focus window for non-keep-alive URLs
|
||||
}
|
||||
});
|
||||
|
||||
@@ -638,4 +636,4 @@ function openInExplorer(url: string): void {
|
||||
shell.openPath(folderPath).catch((error) => {
|
||||
log.error("Failed to open folder in explorer:", errorTypeCheck(error));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user