mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 17:33:59 +01:00
Fixed 2 Electron Crashes (#288)
Fixes #277 * fixed crash on attempting to open new instance, required refactoring BrowserWindow to global Uncaught Exception: ReferenceError: win is not defined at click (C:\Users\jacks\AppData\Local\Programs\better-chatgpt\resources\app.asar\electron\index.cjs:53:9) at MenuItem.click (node:electron/js2c/browser_init:2:30166) at a._executeCommand (node:electron/js2c/browser_init:2:35562) * fixed crash on attempting to open new instance, required refactoring BrowserWindow to global Uncaught Exception: ReferenceError: win is not defined at click (C:\Users\jacks\AppData\Local\Programs\better-chatgpt\resources\app.asar\electron\index.cjs:53:9) at MenuItem.click (node:electron/js2c/browser_init:2:30166) at a._executeCommand (node:electron/js2c/browser_init:2:35562) * fixed Electron process not closing on crash previously left the process still existing on crash (only viewable in task manager). error behavior is the same as it was before, just now must be explicitly defined.
This commit is contained in:
parent
58cafd20a5
commit
82f8761397
|
@ -1,8 +1,10 @@
|
|||
const path = require('path');
|
||||
|
||||
const { app, BrowserWindow, Tray, Menu } = require('electron');
|
||||
const {dialog, app, BrowserWindow, Tray, Menu } = require('electron');
|
||||
const isDev = require('electron-is-dev');
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
let win = null;
|
||||
const instanceLock = app.requestSingleInstanceLock();
|
||||
|
||||
if (require('electron-squirrel-startup')) app.quit();
|
||||
|
||||
|
@ -17,7 +19,7 @@ function createWindow() {
|
|||
}
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
|
||||
const win = new BrowserWindow({
|
||||
win = new BrowserWindow({
|
||||
autoHideMenuBar: true,
|
||||
show: false,
|
||||
icon: iconPath,
|
||||
|
@ -73,20 +75,35 @@ const createTray = (window) => {
|
|||
return tray;
|
||||
};
|
||||
|
||||
app.whenReady().then(createWindow);
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
process.on('uncaughtException', (error) => {
|
||||
// Perform any necessary cleanup tasks here
|
||||
dialog.showErrorBox('An error occurred', error.stack);
|
||||
|
||||
// Exit the app
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
if (!instanceLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||
if (win) {
|
||||
if (win.isMinimized()) win.restore()
|
||||
win.focus()
|
||||
}
|
||||
})
|
||||
|
||||
app.whenReady().then(() => {
|
||||
win = createWindow()
|
||||
})
|
||||
}
|
||||
|
||||
const createServer = () => {
|
||||
// Dependencies
|
||||
const http = require('http');
|
||||
|
|
Loading…
Reference in a new issue