feat: add maximize api for plugins

This commit is contained in:
tiddlygit-test 2022-09-25 02:36:37 +08:00
parent 1979ce92f3
commit da2be1f1ed
2 changed files with 14 additions and 6 deletions

View file

@ -374,12 +374,7 @@ export class Window implements IWindowService {
}
: {
label: 'Zoom',
click: () => {
const mainWindow = this.get(WindowNames.main);
if (mainWindow !== undefined) {
mainWindow.maximize();
}
},
click: async () => await this.maximize(),
},
{ role: 'resetZoom' },
{ role: 'togglefullscreen' },
@ -609,4 +604,15 @@ export class Window implements IWindowService {
newWindow.setBackgroundColor('#000000');
}
}
public async maximize(): Promise<void> {
const mainWindow = this.get(WindowNames.main);
if (mainWindow !== undefined) {
if (mainWindow.isMaximized()) {
mainWindow.maximize();
} else {
mainWindow.unmaximize();
}
}
}
}

View file

@ -19,6 +19,7 @@ export interface IWindowService {
isFullScreen(windowName?: WindowNames): Promise<boolean | undefined>;
isMenubarOpen(): Promise<boolean>;
loadURL(windowName: WindowNames, newUrl?: string): Promise<void>;
maximize(): Promise<void>;
open<N extends WindowNames>(
windowName: N,
meta?: WindowMeta[N],
@ -47,6 +48,7 @@ export const WindowServiceIPCDescriptor = {
isFullScreen: ProxyPropertyType.Function,
isMenubarOpen: ProxyPropertyType.Function,
loadURL: ProxyPropertyType.Function,
maximize: ProxyPropertyType.Function,
open: ProxyPropertyType.Function,
reload: ProxyPropertyType.Function,
requestRestart: ProxyPropertyType.Function,