Add: Stream-Warnung beim Beenden der Electron App
Dialog "Stream laeuft noch!" erscheint nur wenn ein aktiver Video-Stream erkannt wird. Ohne Stream schliesst die App normal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5eab3c1956
commit
06ab7f523b
1 changed files with 22 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
const { app, BrowserWindow, session, shell, desktopCapturer, autoUpdater } = require('electron');
|
||||
const { app, BrowserWindow, session, shell, desktopCapturer, autoUpdater, dialog } = require('electron');
|
||||
const path = require('path');
|
||||
const { setupAdBlocker } = require('./ad-blocker');
|
||||
|
||||
|
|
@ -99,6 +99,27 @@ function createWindow() {
|
|||
shell.openExternal(url);
|
||||
}
|
||||
});
|
||||
|
||||
// Warn before closing if a stream is active
|
||||
let forceClose = false;
|
||||
mainWindow.on('close', (event) => {
|
||||
if (forceClose) return;
|
||||
event.preventDefault();
|
||||
mainWindow.webContents.executeJavaScript(
|
||||
`Array.from(document.querySelectorAll('video')).some(v => v.srcObject?.active)`
|
||||
).then((isStreaming) => {
|
||||
if (!isStreaming) { forceClose = true; mainWindow.close(); return; }
|
||||
const result = dialog.showMessageBoxSync(mainWindow, {
|
||||
type: 'warning',
|
||||
buttons: ['Beenden', 'Abbrechen'],
|
||||
defaultId: 1,
|
||||
cancelId: 1,
|
||||
title: 'Stream laeuft noch!',
|
||||
message: 'Ein Stream ist noch aktiv.\nBeim Beenden wird der Stream gestoppt.',
|
||||
});
|
||||
if (result === 0) { forceClose = true; mainWindow.close(); }
|
||||
}).catch(() => { forceClose = true; mainWindow.close(); });
|
||||
});
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue