mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-09 16:19:25 -07:00
65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
interface SetupWindowConfig {
|
|
width: number;
|
|
height: number;
|
|
title: string;
|
|
resizable?: boolean;
|
|
minimizable?: boolean;
|
|
maximizable?: boolean;
|
|
}
|
|
|
|
function createSetupWindowHandler<TWindow>(
|
|
deps: { createBrowserWindow: (options: Electron.BrowserWindowConstructorOptions) => TWindow },
|
|
config: SetupWindowConfig,
|
|
) {
|
|
return (): TWindow => {
|
|
const options: Electron.BrowserWindowConstructorOptions = {
|
|
width: config.width,
|
|
height: config.height,
|
|
title: config.title,
|
|
show: true,
|
|
autoHideMenuBar: true,
|
|
webPreferences: {
|
|
nodeIntegration: false,
|
|
contextIsolation: true,
|
|
},
|
|
};
|
|
if (config.resizable !== undefined) options.resizable = config.resizable;
|
|
if (config.minimizable !== undefined) options.minimizable = config.minimizable;
|
|
if (config.maximizable !== undefined) options.maximizable = config.maximizable;
|
|
return deps.createBrowserWindow(options);
|
|
};
|
|
}
|
|
|
|
export function createCreateFirstRunSetupWindowHandler<TWindow>(deps: {
|
|
createBrowserWindow: (options: Electron.BrowserWindowConstructorOptions) => TWindow;
|
|
}) {
|
|
return createSetupWindowHandler(deps, {
|
|
width: 480,
|
|
height: 460,
|
|
title: 'SubMiner Setup',
|
|
resizable: false,
|
|
minimizable: false,
|
|
maximizable: false,
|
|
});
|
|
}
|
|
|
|
export function createCreateJellyfinSetupWindowHandler<TWindow>(deps: {
|
|
createBrowserWindow: (options: Electron.BrowserWindowConstructorOptions) => TWindow;
|
|
}) {
|
|
return createSetupWindowHandler(deps, {
|
|
width: 520,
|
|
height: 560,
|
|
title: 'Jellyfin Setup',
|
|
});
|
|
}
|
|
|
|
export function createCreateAnilistSetupWindowHandler<TWindow>(deps: {
|
|
createBrowserWindow: (options: Electron.BrowserWindowConstructorOptions) => TWindow;
|
|
}) {
|
|
return createSetupWindowHandler(deps, {
|
|
width: 1000,
|
|
height: 760,
|
|
title: 'Anilist Setup',
|
|
});
|
|
}
|