mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-29 02:11:28 -06:00
Typescript - Fix main window position calculation logic (#643)
This commit is contained in:
parent
5adc162b2e
commit
5e5455157a
@ -39,7 +39,7 @@ export interface IConfig {
|
||||
permissions: IPermission;
|
||||
customFlags: ICustomFlag;
|
||||
crashReporter: ICrashReporter;
|
||||
mainWinPos: ICustomRectangle;
|
||||
mainWinPos?: ICustomRectangle;
|
||||
}
|
||||
|
||||
export interface IPermission {
|
||||
@ -69,7 +69,7 @@ export interface INotificationSetting {
|
||||
display: string;
|
||||
}
|
||||
|
||||
export interface ICustomRectangle extends Electron.Rectangle {
|
||||
export interface ICustomRectangle extends Partial<Electron.Rectangle> {
|
||||
isMaximized: boolean;
|
||||
isFullScreen: boolean;
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ export class WindowHandler {
|
||||
...this.windowOpts, ...getBounds(this.config.mainWinPos, DEFAULT_WIDTH, DEFAULT_HEIGHT),
|
||||
}) as ICustomBrowserWindow;
|
||||
this.mainWindow.winName = apiName.mainWindowName;
|
||||
const { isFullScreen, isMaximized } = this.config.mainWinPos;
|
||||
const { isFullScreen, isMaximized } = this.config.mainWinPos ? this.config.mainWinPos : { isFullScreen: false, isMaximized: false };
|
||||
if (isMaximized) {
|
||||
this.mainWindow.maximize();
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import { i18n, LocaleType } from '../common/i18n';
|
||||
import { logger } from '../common/logger';
|
||||
import { getGuid } from '../common/utils';
|
||||
import { whitelistHandler } from '../common/whitelist-handler';
|
||||
import { config } from './config-handler';
|
||||
import { config, ICustomRectangle } from './config-handler';
|
||||
import { screenSnippet } from './screen-snippet-handler';
|
||||
import { ICustomBrowserWindow, windowHandler } from './window-handler';
|
||||
|
||||
@ -286,8 +286,8 @@ export const sanitize = async (windowName: string): Promise<void> => {
|
||||
* @param defaultHeight
|
||||
* @return {x?: Number, y?: Number, width: Number, height: Number}
|
||||
*/
|
||||
export const getBounds = (winPos: Electron.Rectangle, defaultWidth: number, defaultHeight: number): Partial<Electron.Rectangle> => {
|
||||
if (!winPos) {
|
||||
export const getBounds = (winPos: ICustomRectangle | Electron.Rectangle | undefined, defaultWidth: number, defaultHeight: number): Partial<Electron.Rectangle> => {
|
||||
if (!winPos || !winPos.x || !winPos.y || !winPos.width || !winPos.height) {
|
||||
return { width: defaultWidth, height: defaultHeight };
|
||||
}
|
||||
const displays = electron.screen.getAllDisplays();
|
||||
|
Loading…
Reference in New Issue
Block a user