bubblepipe42 5 mesi fa
parent
commit
a57a36a739
3 ha cambiato i file con 37 aggiunte e 37 eliminazioni
  1. 37 37
      electron/main.js
  2. BIN
      electron/tray-iconTemplate.png
  3. BIN
      electron/tray-iconTemplate@2x.png

+ 37 - 37
electron/main.js

@@ -110,8 +110,43 @@ function waitForServer(resolve, reject, retries = 30) {
   req.end();
 }
 
+function createWindow() {
+  mainWindow = new BrowserWindow({
+    width: 1400,
+    height: 900,
+    webPreferences: {
+      preload: path.join(__dirname, 'preload.js'),
+      nodeIntegration: false,
+      contextIsolation: true
+    },
+    title: 'New API',
+    icon: path.join(__dirname, 'icon.png')
+  });
+
+  mainWindow.loadURL(`http://localhost:${PORT}`);
+
+  if (process.env.NODE_ENV === 'development') {
+    mainWindow.webContents.openDevTools();
+  }
+
+  // Close to tray instead of quitting
+  mainWindow.on('close', (event) => {
+    if (!app.isQuitting) {
+      event.preventDefault();
+      mainWindow.hide();
+      if (process.platform === 'darwin') {
+        app.dock.hide();
+      }
+    }
+  });
+
+  mainWindow.on('closed', () => {
+    mainWindow = null;
+  });
+}
+
 function createTray() {
-  tray = new Tray(path.join(__dirname, 'tray-icon.png'));
+  tray = new Tray(path.join(__dirname, 'tray-iconTemplate.png'));
 
   const contextMenu = Menu.buildFromTemplate([
     {
@@ -140,7 +175,7 @@ function createTray() {
   tray.setToolTip('New API');
   tray.setContextMenu(contextMenu);
 
-  // On macOS, clicking the tray icon shows the menu
+  // On macOS, clicking the tray icon shows the window
   tray.on('click', () => {
     if (mainWindow === null) {
       createWindow();
@@ -153,41 +188,6 @@ function createTray() {
   });
 }
 
-function createWindow() {
-  mainWindow = new BrowserWindow({
-    width: 1400,
-    height: 900,
-    webPreferences: {
-      preload: path.join(__dirname, 'preload.js'),
-      nodeIntegration: false,
-      contextIsolation: true
-    },
-    title: 'New API',
-    icon: path.join(__dirname, 'icon.png')
-  });
-
-  mainWindow.loadURL(`http://localhost:${PORT}`);
-
-  if (process.env.NODE_ENV === 'development') {
-    mainWindow.webContents.openDevTools();
-  }
-
-  // Close to tray instead of quitting
-  mainWindow.on('close', (event) => {
-    if (!app.isQuitting) {
-      event.preventDefault();
-      mainWindow.hide();
-      if (process.platform === 'darwin') {
-        app.dock.hide();
-      }
-    }
-  });
-
-  mainWindow.on('closed', () => {
-    mainWindow = null;
-  });
-}
-
 app.whenReady().then(async () => {
   try {
     await startServer();

BIN
electron/tray-iconTemplate.png


BIN
electron/tray-iconTemplate@2x.png