mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
test(main): completar fase 2 con cobertura de iconos y timing
This commit is contained in:
+2
-1
@@ -4,6 +4,7 @@ import path from "node:path";
|
||||
import { getRuntimeConfig } from "./config/runtime-config";
|
||||
import { showFatalError, log } from "./errors/error-presenter";
|
||||
import { createNodecgProcessManager } from "./nodecg/process-manager";
|
||||
import { getRemainingDelayMs } from "./utils/timing";
|
||||
import { createLoadingWindow, createMainWindow } from "./windows/window-factory";
|
||||
|
||||
const runtimeConfig = getRuntimeConfig();
|
||||
@@ -50,7 +51,7 @@ async function launch(): Promise<void> {
|
||||
|
||||
await mainWindow.loadURL(dashboardUrl);
|
||||
|
||||
const remainingLoadingDelay = Math.max(0, runtimeConfig.loadDelayMs - (Date.now() - loadingShownAt));
|
||||
const remainingLoadingDelay = getRemainingDelayMs(runtimeConfig.loadDelayMs, loadingShownAt);
|
||||
if (remainingLoadingDelay > 0) {
|
||||
await sleep(remainingLoadingDelay);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export function getRemainingDelayMs(targetDelayMs: number, startedAtMs: number, currentTimeMs: number = Date.now()): number {
|
||||
return Math.max(0, targetDelayMs - (currentTimeMs - startedAtMs));
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import { AppRuntimeConfig } from "../config/runtime-config";
|
||||
|
||||
export function resolveAppIconPath(
|
||||
runtimeConfig: AppRuntimeConfig,
|
||||
rootPath: string,
|
||||
pathExists: (candidatePath: string) => boolean = fs.existsSync,
|
||||
): string | undefined {
|
||||
const iconCandidates = [
|
||||
runtimeConfig.iconPathOverride,
|
||||
path.join(rootPath, "static", "icons", "icon.ico"),
|
||||
path.join(rootPath, "static", "icons", "icon.png"),
|
||||
path.join(rootPath, "static", "icon.ico"),
|
||||
path.join(rootPath, "static", "icon.png"),
|
||||
].filter((candidate): candidate is string => Boolean(candidate));
|
||||
|
||||
return iconCandidates.find((candidate) => pathExists(candidate));
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
import { BrowserWindow, BrowserWindowConstructorOptions, shell } from "electron";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import { AppRuntimeConfig } from "../config/runtime-config";
|
||||
import { DEFAULT_WINDOW_BACKGROUND, DEFAULT_WINDOW_SIZE, LOADING_WINDOW_SIZE } from "../constants";
|
||||
import { resolveAppIconPath } from "./icon-path";
|
||||
|
||||
type WindowFactoryDependencies = {
|
||||
runtimeConfig: AppRuntimeConfig;
|
||||
@@ -90,15 +88,3 @@ function createWindowOptions({
|
||||
minHeight: DEFAULT_WINDOW_SIZE.minHeight,
|
||||
};
|
||||
}
|
||||
|
||||
function resolveAppIconPath(runtimeConfig: AppRuntimeConfig, rootPath: string): string | undefined {
|
||||
const iconCandidates = [
|
||||
runtimeConfig.iconPathOverride,
|
||||
path.join(rootPath, "static", "icons", "icon.ico"),
|
||||
path.join(rootPath, "static", "icons", "icon.png"),
|
||||
path.join(rootPath, "static", "icon.ico"),
|
||||
path.join(rootPath, "static", "icon.png"),
|
||||
].filter((candidate): candidate is string => Boolean(candidate));
|
||||
|
||||
return iconCandidates.find((candidate) => fs.existsSync(candidate));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user