mirror of
https://github.com/NovaOSS/nova-betterchat.git
synced 2024-11-25 18:33:59 +01:00
parent
90a4e3669b
commit
815bb19c72
|
@ -1,6 +1,6 @@
|
|||
const path = require('path');
|
||||
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const { app, BrowserWindow, Tray, Menu } = require('electron');
|
||||
const isDev = require('electron-is-dev');
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
|
||||
|
@ -9,9 +9,9 @@ if (require('electron-squirrel-startup')) app.quit();
|
|||
function createWindow() {
|
||||
let iconPath = '';
|
||||
if (isDev) {
|
||||
iconPath = path.join(__dirname, '../public/favicon-516x516.png');
|
||||
iconPath = path.join(__dirname, '../public/icon-rounded.png');
|
||||
} else {
|
||||
iconPath = path.join(__dirname, '../dist/favicon-516x516.png');
|
||||
iconPath = path.join(__dirname, '../dist/icon-rounded.png');
|
||||
}
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
|
||||
|
@ -19,6 +19,14 @@ function createWindow() {
|
|||
show: false,
|
||||
icon: iconPath,
|
||||
});
|
||||
|
||||
createTray(win);
|
||||
|
||||
win.on('minimize', (event) => {
|
||||
event.preventDefault();
|
||||
win.hide();
|
||||
});
|
||||
|
||||
win.maximize();
|
||||
win.show();
|
||||
|
||||
|
@ -31,8 +39,35 @@ function createWindow() {
|
|||
if (isDev) {
|
||||
win.webContents.openDevTools({ mode: 'detach' });
|
||||
}
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
const createTray = (window) => {
|
||||
const tray = new Tray(
|
||||
path.join(
|
||||
__dirname,
|
||||
isDev ? '../public/icon-rounded.png' : '../dist/icon-rounded.png'
|
||||
)
|
||||
);
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: 'Show', click: () => window.show() },
|
||||
{
|
||||
label: 'Exit',
|
||||
click: () => {
|
||||
app.isQuiting = true;
|
||||
app.quit();
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
tray.on('click', () => window.show());
|
||||
tray.setToolTip('Better ChatGPT');
|
||||
tray.setContextMenu(contextMenu);
|
||||
|
||||
return tray;
|
||||
};
|
||||
|
||||
app.whenReady().then(createWindow);
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
},
|
||||
"dmg": {
|
||||
"title": "${productName} ${version}",
|
||||
"icon": "dist/favicon-516x516.png"
|
||||
"icon": "dist/icon-rounded.png"
|
||||
},
|
||||
"linux": {
|
||||
"target": [
|
||||
|
@ -32,11 +32,11 @@
|
|||
"AppImage"
|
||||
],
|
||||
"category": "Chat",
|
||||
"icon": "dist/favicon-516x516.png"
|
||||
"icon": "dist/icon-rounded.png"
|
||||
},
|
||||
"win": {
|
||||
"target": "NSIS",
|
||||
"icon": "dist/favicon-516x516.png"
|
||||
"icon": "dist/icon-rounded.png"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
BIN
public/icon-rounded.png
Normal file
BIN
public/icon-rounded.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
Loading…
Reference in a new issue