diff --git a/package-lock.json b/package-lock.json index 5263da2..81d6a05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "@vitejs/plugin-vue": "^5.0.5", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", - "electron": "^31.0.2", + "electron": "^34.1.1", "electron-builder": "^24.13.3", "electron-devtools-installer": "^4.0.0", "electron-vite": "^2.3.0", @@ -5089,11 +5089,10 @@ } }, "node_modules/electron": { - "version": "31.7.6", - "resolved": "https://registry.npmmirror.com/electron/-/electron-31.7.6.tgz", - "integrity": "sha512-fc2kMaEc/zxGTW6oCxbuE7BQNOlDucSo+351AiovBAcp7G0iQkVu3k2kHIQolSsD38+tPdBj/N02DVpZTzi7rg==", + "version": "34.1.1", + "resolved": "https://registry.npmmirror.com/electron/-/electron-34.1.1.tgz", + "integrity": "sha512-1aDYk9Gsv1/fFeClMrxWGoVMl7uCUgl1pe26BiTnLXmAoqEXCa3f3sCKFWV+cuDzUjQGAZcpkWhGYTgWUSQrLA==", "hasInstallScript": true, - "license": "MIT", "dependencies": { "@electron/get": "^2.0.0", "@types/node": "^20.9.0", diff --git a/package.json b/package.json index 2f6e9ae..2828808 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@vitejs/plugin-vue": "^5.0.5", "@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-typescript": "^13.0.0", - "electron": "^31.0.2", + "electron": "^34.1.1", "electron-builder": "^24.13.3", "electron-devtools-installer": "^4.0.0", "electron-vite": "^2.3.0", diff --git a/src/main/index.ts b/src/main/index.ts index 0d73d12..2d42d11 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -17,7 +17,7 @@ * */ -import { app, shell, BrowserWindow, ipcMain, dialog } from 'electron' +import { app, shell, BrowserWindow, ipcMain, dialog, screen } from 'electron' import { join } from 'path' import { electronApp, optimizer, is } from '@electron-toolkit/utils' import icon from '../../resources/icon.png?asset' @@ -41,7 +41,8 @@ function createWindow(): void { sandbox: false }, vibrancy: 'fullscreen-ui', - backgroundMaterial: 'mica' + // bug trace: https://github.com/electron/electron/issues/38466#issuecomment-2576225294 + backgroundMaterial: 'tabbed' }) mainWindow.on('ready-to-show', () => { @@ -68,6 +69,10 @@ function createWindow(): void { // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.whenReady().then(() => { + const primaryDisplay = screen.getPrimaryDisplay() + const workAreaSize = primaryDisplay.workAreaSize + let previousBounds = { width: 1024, height: 728 } // Default previous size + // Install Vue Devtool installExtension(VUEJS_DEVTOOLS) .then((ext) => console.log(`Added Extension: ${ext.name}`)) @@ -92,10 +97,19 @@ app.whenReady().then(() => { } else if (ev === 'minimize') { win.minimize() } else if (ev === 'maximize') { - if (win.isMaximized()) { - win.restore() + // if (win.isMaximized()) { + // win.restore() + // } else { + // win.maximize() + // } + if ( + win.getBounds().width < workAreaSize.width && + win.getBounds().height < workAreaSize.height + ) { + previousBounds = win.getBounds() + win.setBounds({ x: 0, y: 0, width: workAreaSize.width, height: workAreaSize.height }) } else { - win.maximize() + win.setBounds(previousBounds) } } })