mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-03 19:30:04 +08:00
feat(WindowService): add maximize functionality and disable electron-window-state maxmize (#5292)
* feat(WindowService): add maximize functionality and clean up window close logic - Introduced a new `maximize` option in the window state configuration. - Added `setupMaximize` method to handle window maximization based on the launch state. - Removed redundant logic from the window close event handler for clarity. * add code * update code
This commit is contained in:
parent
3094adcb03
commit
b9e50fa08d
@ -41,7 +41,8 @@ export class WindowService {
|
|||||||
const mainWindowState = windowStateKeeper({
|
const mainWindowState = windowStateKeeper({
|
||||||
defaultWidth: 1080,
|
defaultWidth: 1080,
|
||||||
defaultHeight: 670,
|
defaultHeight: 670,
|
||||||
fullScreen: false
|
fullScreen: false,
|
||||||
|
maximize: false
|
||||||
})
|
})
|
||||||
|
|
||||||
const theme = configManager.getTheme()
|
const theme = configManager.getTheme()
|
||||||
@ -86,6 +87,7 @@ export class WindowService {
|
|||||||
private setupMainWindow(mainWindow: BrowserWindow, mainWindowState: any) {
|
private setupMainWindow(mainWindow: BrowserWindow, mainWindowState: any) {
|
||||||
mainWindowState.manage(mainWindow)
|
mainWindowState.manage(mainWindow)
|
||||||
|
|
||||||
|
this.setupMaximize(mainWindow, mainWindowState.isMaximized)
|
||||||
this.setupContextMenu(mainWindow)
|
this.setupContextMenu(mainWindow)
|
||||||
this.setupWindowEvents(mainWindow)
|
this.setupWindowEvents(mainWindow)
|
||||||
this.setupWebContentsHandlers(mainWindow)
|
this.setupWebContentsHandlers(mainWindow)
|
||||||
@ -93,6 +95,17 @@ export class WindowService {
|
|||||||
this.loadMainWindowContent(mainWindow)
|
this.loadMainWindowContent(mainWindow)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private setupMaximize(mainWindow: BrowserWindow, isMaximized: boolean) {
|
||||||
|
if (isMaximized) {
|
||||||
|
// 如果是从托盘启动,则需要延迟最大化,否则显示的就不是重启前的最大化窗口了
|
||||||
|
configManager.getLaunchToTray()
|
||||||
|
? mainWindow.once('show', () => {
|
||||||
|
mainWindow.maximize()
|
||||||
|
})
|
||||||
|
: mainWindow.maximize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private setupContextMenu(mainWindow: BrowserWindow) {
|
private setupContextMenu(mainWindow: BrowserWindow) {
|
||||||
if (!this.contextMenu) {
|
if (!this.contextMenu) {
|
||||||
const locale = locales[configManager.getLanguage()]
|
const locale = locales[configManager.getLanguage()]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user