feat: allow only a single instance

This commit is contained in:
leukipp
2024-12-17 21:54:49 +01:00
parent 99d3eea20d
commit 926bcdfab8
2 changed files with 18 additions and 5 deletions
+13 -5
View File
@@ -24,12 +24,10 @@ const init = async (args) => {
const theme = args.web_theme ? args.web_theme : "dark";
const zoom = args.web_zoom ? parseFloat(args.web_zoom) : 1.25;
// Set app theme and name
nativeTheme.themeSource = theme;
app.setName("TouchKio");
// Init global root window
nativeTheme.themeSource = theme;
WEBVIEW.window = new BaseWindow({
title: `TouchKio - ${url.host}`,
icon: path.join(__dirname, "..", "img", "icon.png"),
});
WEBVIEW.window.setMenuBarVisibility(false);
@@ -106,18 +104,28 @@ const windowEvents = (window, zoom) => {
WEBVIEW.locked = false;
});
// Update window status
// Handle window status updates
window.on("minimize", update);
window.on("restore", update);
window.on("maximize", update);
window.on("unmaximize", update);
window.on("enter-full-screen", update);
window.on("leave-full-screen", update);
// Handle signal and exit events
process.on("SIGINT", app.quit);
app.on("before-quit", () => {
WEBVIEW.status = "Terminated";
integration.update();
});
// Handle multiple instances
app.on("second-instance", () => {
if (window.isMinimized()) {
window.restore();
}
window.focus();
});
};
/**