feat: 调整登录

This commit is contained in:
duanshuwen
2025-09-29 21:47:18 +08:00
parent 3aa8e85054
commit 02b85f3251
3 changed files with 37 additions and 17 deletions

View File

@@ -3,13 +3,18 @@ import { join } from 'path'
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
import icon from '../../resources/icon.png?asset'
let mainWindow: BrowserWindow | null = null
function createWindow(): void {
// Create the browser window.
const mainWindow = new BrowserWindow({
mainWindow = new BrowserWindow({
width: 900,
height: 670,
show: false,
autoHideMenuBar: true,
resizable: false, // 禁止拖拽放大缩小
maximizable: false, // 禁止最大化
minimizable: true, // 允许最小化
...(process.platform === 'linux' ? { icon } : {}),
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
@@ -18,7 +23,7 @@ function createWindow(): void {
})
mainWindow.on('ready-to-show', () => {
mainWindow.show()
mainWindow?.show()
})
mainWindow.webContents.setWindowOpenHandler((details) => {
@@ -52,6 +57,15 @@ app.whenReady().then(() => {
// IPC test
ipcMain.on('ping', () => console.log('pong'))
// 监听登录成功事件,恢复窗口拖拽功能
ipcMain.on('login-success', () => {
if (mainWindow) {
mainWindow.setResizable(true)
mainWindow.setMaximizable(true)
console.log('窗口拖拽功能已恢复')
}
})
createWindow()
app.on('activate', function () {