mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-30 06:12:06 -07:00
refactor: consolidate 3 near-identical setup window factories
Extract shared createSetupWindowHandler with a config parameter. Public API unchanged.
This commit is contained in:
@@ -1,16 +1,26 @@
|
||||
export function createCreateFirstRunSetupWindowHandler<TWindow>(deps: {
|
||||
createBrowserWindow: (options: Electron.BrowserWindowConstructorOptions) => TWindow;
|
||||
}) {
|
||||
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 =>
|
||||
deps.createBrowserWindow({
|
||||
width: 480,
|
||||
height: 460,
|
||||
title: 'SubMiner Setup',
|
||||
width: config.width,
|
||||
height: config.height,
|
||||
title: config.title,
|
||||
show: true,
|
||||
autoHideMenuBar: true,
|
||||
resizable: false,
|
||||
minimizable: false,
|
||||
maximizable: false,
|
||||
resizable: config.resizable,
|
||||
minimizable: config.minimizable,
|
||||
maximizable: config.maximizable,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
@@ -18,36 +28,35 @@ export function createCreateFirstRunSetupWindowHandler<TWindow>(deps: {
|
||||
});
|
||||
}
|
||||
|
||||
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 (): TWindow =>
|
||||
deps.createBrowserWindow({
|
||||
width: 520,
|
||||
height: 560,
|
||||
title: 'Jellyfin Setup',
|
||||
show: true,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
},
|
||||
});
|
||||
return createSetupWindowHandler(deps, {
|
||||
width: 520,
|
||||
height: 560,
|
||||
title: 'Jellyfin Setup',
|
||||
});
|
||||
}
|
||||
|
||||
export function createCreateAnilistSetupWindowHandler<TWindow>(deps: {
|
||||
createBrowserWindow: (options: Electron.BrowserWindowConstructorOptions) => TWindow;
|
||||
}) {
|
||||
return (): TWindow =>
|
||||
deps.createBrowserWindow({
|
||||
width: 1000,
|
||||
height: 760,
|
||||
title: 'Anilist Setup',
|
||||
show: true,
|
||||
autoHideMenuBar: true,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
},
|
||||
});
|
||||
return createSetupWindowHandler(deps, {
|
||||
width: 1000,
|
||||
height: 760,
|
||||
title: 'Anilist Setup',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user