|
|
@@ -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();
|