Update linux & windows builds

This commit is contained in:
olcxja 2026-05-10 13:54:26 +02:00
commit a8f8c4d7ad
40 changed files with 141 additions and 33 deletions

View file

@ -7,7 +7,8 @@ import {
import chokidar from 'chokidar';
import type { MenuItemConstructorOptions } from 'electron';
import { app, BrowserWindow, Menu, MenuItem, nativeImage, Tray, session } from 'electron';
import electronIsDev from 'electron-is-dev';
//import electronIsDev from 'electron-is-dev';
var electronIsDev = false;
import electronServe from 'electron-serve';
import windowStateKeeper from 'electron-window-state';
import { join } from 'path';
@ -99,8 +100,14 @@ export class ElectronCapacitorApp {
async init(): Promise<void> {
const icon = nativeImage.createFromPath(
join(app.getAppPath(), 'assets', process.platform === 'win32' ? 'appIcon.ico' : 'appIcon.png')
join(app.getAppPath(), 'assets', process.platform === 'win32' ? 'icon.ico' : 'icon.png')
);
const appName = "olcxja.miarven"
app.setName(appName);
app.setAppUserModelId(appName);
this.mainWindowState = windowStateKeeper({
defaultWidth: 1000,
defaultHeight: 800,
@ -114,6 +121,7 @@ export class ElectronCapacitorApp {
y: this.mainWindowState.y,
width: this.mainWindowState.width,
height: this.mainWindowState.height,
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: true,
@ -122,6 +130,7 @@ export class ElectronCapacitorApp {
preload: preloadPath,
},
});
this.mainWindowState.manage(this.MainWindow);
if (this.CapacitorFileConfig.backgroundColor) {
@ -163,31 +172,18 @@ export class ElectronCapacitorApp {
}
// Setup the main manu bar at the top of our window.
Menu.setApplicationMenu(Menu.buildFromTemplate(this.AppMenuBarMenuTemplate));
//Menu.setApplicationMenu(Menu.buildFromTemplate(this.AppMenuBarMenuTemplate));
Menu.setApplicationMenu(null);
// If the splashscreen is enabled, show it first while the main window loads then switch it out for the main window, or just load the main window from the start.
if (this.CapacitorFileConfig.electron?.splashScreenEnabled) {
this.SplashScreen = new CapacitorSplashScreen({
imageFilePath: join(
app.getAppPath(),
'assets',
this.CapacitorFileConfig.electron?.splashScreenImageName ?? 'splash.png'
),
windowWidth: 400,
windowHeight: 400,
});
this.SplashScreen.init(this.loadMainWindow, this);
} else {
this.loadMainWindow(this);
}
this.loadMainWindow(this);
// Security
this.MainWindow.webContents.setWindowOpenHandler((details) => {
if (!details.url.includes(this.customScheme)) {
return { action: 'deny' };
} else {
return { action: 'allow' };
}
});
this.MainWindow.webContents.on('will-navigate', (event, _newURL) => {
if (!this.MainWindow.webContents.getURL().includes(this.customScheme)) {
@ -207,12 +203,14 @@ export class ElectronCapacitorApp {
this.MainWindow.show();
}
setTimeout(() => {
if (electronIsDev) {
this.MainWindow.webContents.openDevTools();
}
CapElectronEventEmitter.emit('CAPELECTRON_DeeplinkListenerInitialized', '');
}, 400);
});
this.MainWindow.setMenu(null);
this.MainWindow.setAutoHideMenuBar(true);
this.MainWindow.removeMenu();
}
}