This commit is contained in:
zh
2025-11-06 16:10:33 +08:00
parent b582f4a366
commit 909dd090e6
10 changed files with 181 additions and 59 deletions

View File

@ -276,6 +276,25 @@ function createWindow(): void {
mainWindow.on('leave-full-screen', () => {
mainWindow.webContents.send('fullscreen-status-changed', false)
});
mainWindow.on("close", (e) => {
e.preventDefault();
dialog
.showMessageBox(mainWindow, {
type: "warning",
title: "提示",
message: "是否确认退出系统?",
buttons: ["cancel", "ok"],
})
.then((res) => {
if (res.response) {
setTimeout(() => {
mainWindow.destroy()
mainWindow = null;
}, 200);
windowAllClosed();
}
});
});
let recorder;
ipcMain.on("startRecoder", () => {
@ -498,8 +517,10 @@ function forceQuit() {
app.relaunch();
}
console.log('------退出-------');
app.exit();
app.quit();
setTimeout(() => {
app.exit();
app.quit();
}, 500);
} else {
// 其他系统
process.exit(0);
@ -518,14 +539,12 @@ function closeAllWindows() {
});
}
const gotTheLock = app.requestSingleInstanceLock();
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
} else {
if (app.isReady()) {
}
app.on("ready", createWindow);
app.whenReady().then(() => {
// alert(devSplashURL)
// alert(prodSplashURL)
@ -549,26 +568,18 @@ if (!gotTheLock) {
});
// Set app user model id for windows
electronApp.setAppUserModelId('com.electron')
// Default open or close DevTools by F12 in development
// and ignore CommandOrControl + R in production.
// see https://github.com/alex8088/electron-toolkit/tree/master/packages/utils
app.on('browser-window-created', (_, window) => {
optimizer.watchWindowShortcuts(window)
})
// IPC test
ipcMain.on('ping', () => console.log('pong'))
createWindow()
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
// 退出时注销所有快捷键
app.on('will-quit', () => {
globalShortcut.unregisterAll()
@ -586,7 +597,7 @@ if (!gotTheLock) {
}
});
// testNapi()
global.sharedObject = {
hasService: false,