update electron version

This commit is contained in:
Jeffrey Hsu 2025-02-12 02:36:47 +08:00
parent 74760db024
commit 34db5b8380
3 changed files with 24 additions and 11 deletions

9
package-lock.json generated
View File

@ -32,7 +32,7 @@
"@vitejs/plugin-vue": "^5.0.5", "@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0", "@vue/eslint-config-typescript": "^13.0.0",
"electron": "^31.0.2", "electron": "^34.1.1",
"electron-builder": "^24.13.3", "electron-builder": "^24.13.3",
"electron-devtools-installer": "^4.0.0", "electron-devtools-installer": "^4.0.0",
"electron-vite": "^2.3.0", "electron-vite": "^2.3.0",
@ -5089,11 +5089,10 @@
} }
}, },
"node_modules/electron": { "node_modules/electron": {
"version": "31.7.6", "version": "34.1.1",
"resolved": "https://registry.npmmirror.com/electron/-/electron-31.7.6.tgz", "resolved": "https://registry.npmmirror.com/electron/-/electron-34.1.1.tgz",
"integrity": "sha512-fc2kMaEc/zxGTW6oCxbuE7BQNOlDucSo+351AiovBAcp7G0iQkVu3k2kHIQolSsD38+tPdBj/N02DVpZTzi7rg==", "integrity": "sha512-1aDYk9Gsv1/fFeClMrxWGoVMl7uCUgl1pe26BiTnLXmAoqEXCa3f3sCKFWV+cuDzUjQGAZcpkWhGYTgWUSQrLA==",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT",
"dependencies": { "dependencies": {
"@electron/get": "^2.0.0", "@electron/get": "^2.0.0",
"@types/node": "^20.9.0", "@types/node": "^20.9.0",

View File

@ -44,7 +44,7 @@
"@vitejs/plugin-vue": "^5.0.5", "@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-typescript": "^13.0.0", "@vue/eslint-config-typescript": "^13.0.0",
"electron": "^31.0.2", "electron": "^34.1.1",
"electron-builder": "^24.13.3", "electron-builder": "^24.13.3",
"electron-devtools-installer": "^4.0.0", "electron-devtools-installer": "^4.0.0",
"electron-vite": "^2.3.0", "electron-vite": "^2.3.0",

View File

@ -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 { join } from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils' import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset' import icon from '../../resources/icon.png?asset'
@ -41,7 +41,8 @@ function createWindow(): void {
sandbox: false sandbox: false
}, },
vibrancy: 'fullscreen-ui', vibrancy: 'fullscreen-ui',
backgroundMaterial: 'mica' // bug trace: https://github.com/electron/electron/issues/38466#issuecomment-2576225294
backgroundMaterial: 'tabbed'
}) })
mainWindow.on('ready-to-show', () => { mainWindow.on('ready-to-show', () => {
@ -68,6 +69,10 @@ function createWindow(): void {
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
app.whenReady().then(() => { app.whenReady().then(() => {
const primaryDisplay = screen.getPrimaryDisplay()
const workAreaSize = primaryDisplay.workAreaSize
let previousBounds = { width: 1024, height: 728 } // Default previous size
// Install Vue Devtool // Install Vue Devtool
installExtension(VUEJS_DEVTOOLS) installExtension(VUEJS_DEVTOOLS)
.then((ext) => console.log(`Added Extension: ${ext.name}`)) .then((ext) => console.log(`Added Extension: ${ext.name}`))
@ -92,10 +97,19 @@ app.whenReady().then(() => {
} else if (ev === 'minimize') { } else if (ev === 'minimize') {
win.minimize() win.minimize()
} else if (ev === 'maximize') { } else if (ev === 'maximize') {
if (win.isMaximized()) { // if (win.isMaximized()) {
win.restore() // 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 { } else {
win.maximize() win.setBounds(previousBounds)
} }
} }
}) })