This commit is contained in:
bubblepipe42
2025-09-29 13:25:22 +08:00
parent 834ab29a46
commit 11f50478a7
3 changed files with 43 additions and 43 deletions

View File

@@ -110,49 +110,6 @@ function waitForServer(resolve, reject, retries = 30) {
req.end(); req.end();
} }
function createTray() {
tray = new Tray(path.join(__dirname, 'tray-icon.png'));
const contextMenu = Menu.buildFromTemplate([
{
label: 'Show New API',
click: () => {
if (mainWindow === null) {
createWindow();
} else {
mainWindow.show();
if (process.platform === 'darwin') {
app.dock.show();
}
}
}
},
{ type: 'separator' },
{
label: 'Quit',
click: () => {
app.isQuitting = true;
app.quit();
}
}
]);
tray.setToolTip('New API');
tray.setContextMenu(contextMenu);
// On macOS, clicking the tray icon shows the menu
tray.on('click', () => {
if (mainWindow === null) {
createWindow();
} else {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
if (mainWindow.isVisible() && process.platform === 'darwin') {
app.dock.show();
}
}
});
}
function createWindow() { function createWindow() {
mainWindow = new BrowserWindow({ mainWindow = new BrowserWindow({
width: 1400, width: 1400,
@@ -188,6 +145,49 @@ function createWindow() {
}); });
} }
function createTray() {
tray = new Tray(path.join(__dirname, 'tray-iconTemplate.png'));
const contextMenu = Menu.buildFromTemplate([
{
label: 'Show New API',
click: () => {
if (mainWindow === null) {
createWindow();
} else {
mainWindow.show();
if (process.platform === 'darwin') {
app.dock.show();
}
}
}
},
{ type: 'separator' },
{
label: 'Quit',
click: () => {
app.isQuitting = true;
app.quit();
}
}
]);
tray.setToolTip('New API');
tray.setContextMenu(contextMenu);
// On macOS, clicking the tray icon shows the window
tray.on('click', () => {
if (mainWindow === null) {
createWindow();
} else {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
if (mainWindow.isVisible() && process.platform === 'darwin') {
app.dock.show();
}
}
});
}
app.whenReady().then(async () => { app.whenReady().then(async () => {
try { try {
await startServer(); await startServer();

Binary file not shown.

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B