mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 18:19:03 +08:00
feat(窗口管理): 添加自定义标题栏和窗口控制功能
实现自定义标题栏组件,包含最小化、最大化/还原和关闭按钮 添加窗口管理相关IPC通信接口 在设置页面增加开发者工具切换按钮 更新.gitignore忽略.trae目录
This commit is contained in:
@@ -62,6 +62,7 @@ export class WindowManager extends Service {
|
||||
height: 670,
|
||||
show: false,
|
||||
autoHideMenuBar: true,
|
||||
frame: false, // Custom title bar
|
||||
icon: this.opts.icon,
|
||||
title: input.title,
|
||||
webPreferences: {
|
||||
@@ -80,6 +81,14 @@ export class WindowManager extends Service {
|
||||
win.show()
|
||||
})
|
||||
|
||||
// Notify renderer about maximize state changes
|
||||
win.on('maximize', () => {
|
||||
win.webContents.send('window:maximized-changed', true)
|
||||
})
|
||||
win.on('unmaximize', () => {
|
||||
win.webContents.send('window:maximized-changed', false)
|
||||
})
|
||||
|
||||
win.webContents.setWindowOpenHandler((details) => {
|
||||
shell.openExternal(details.url)
|
||||
return { action: 'deny' }
|
||||
@@ -142,5 +151,46 @@ export class WindowManager extends Service {
|
||||
const ok = this.navigateWindow(win, route)
|
||||
return ok ? { success: true } : { success: false, message: 'Window not found' }
|
||||
})
|
||||
|
||||
// Window controls
|
||||
this.mainCtx.handle('window:minimize', (event) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender)
|
||||
if (win) win.minimize()
|
||||
})
|
||||
|
||||
this.mainCtx.handle('window:maximize', (event) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender)
|
||||
if (win) {
|
||||
if (win.isMaximized()) {
|
||||
win.unmaximize()
|
||||
return false
|
||||
} else {
|
||||
win.maximize()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
this.mainCtx.handle('window:close', (event) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender)
|
||||
if (win) win.close()
|
||||
})
|
||||
|
||||
this.mainCtx.handle('window:isMaximized', (event) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender)
|
||||
return win ? win.isMaximized() : false
|
||||
})
|
||||
|
||||
this.mainCtx.handle('window:toggle-devtools', (event) => {
|
||||
const win = BrowserWindow.fromWebContents(event.sender)
|
||||
if (win) {
|
||||
if (win.webContents.isDevToolsOpened()) {
|
||||
win.webContents.closeDevTools()
|
||||
} else {
|
||||
win.webContents.openDevTools()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user