mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-05 21:22:07 +00:00
fix: treat loading as nodecg dashboard route (#9)
This commit is contained in:
@@ -14,7 +14,7 @@ Wrapper de Electron para empaquetar una instalación de NodeCG que incluya el bu
|
||||
## Qué hace
|
||||
|
||||
- Arranca `lib/nodecg/index.js` como proceso hijo desde Electron.
|
||||
- Muestra la pantalla de carga propia del bundle (`dashboard/loading.html`) mientras NodeCG inicia.
|
||||
- Muestra la ruta de dashboard de carga del bundle (`/bundles/<bundle>/dashboard/loading.html`) servida por NodeCG mientras inicia (no usa un archivo local del wrapper).
|
||||
- Carga el dashboard del bundle en `http://localhost:<puerto>/bundles/<bundle>/<ruta-dashboard>`.
|
||||
- Empaqueta NodeCG + assets dentro de la app final con `electron-builder`.
|
||||
|
||||
|
||||
+7
-12
@@ -16,9 +16,8 @@ const NODE_BINARY = process.env.NODECG_NODE_BINARY ?? "node";
|
||||
const isDev = !app.isPackaged;
|
||||
const rootPath = isDev ? path.resolve(__dirname, "../..") : process.resourcesPath;
|
||||
const nodecgPath = path.resolve(rootPath, "lib", "nodecg");
|
||||
const loadingPath = path.join(rootPath, "lib", "nodecg", "bundles", DEFAULT_BUNDLE_NAME, DEFAULT_LOADING_ROUTE);
|
||||
|
||||
const dashboardUrl = `http://localhost:${DEFAULT_NODECG_PORT}/bundles/${DEFAULT_BUNDLE_NAME}/${DEFAULT_DASHBOARD_ROUTE}`;
|
||||
const loadingUrl = `http://localhost:${DEFAULT_NODECG_PORT}/bundles/${DEFAULT_BUNDLE_NAME}/${DEFAULT_LOADING_ROUTE}`;
|
||||
const baseUrl = `http://127.0.0.1:${DEFAULT_NODECG_PORT}`;
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
@@ -127,15 +126,6 @@ function validateNodeCGInstall(): void {
|
||||
);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(loadingPath)) {
|
||||
throw new Error(
|
||||
[
|
||||
"No se encontró el loading del dashboard dentro del bundle.",
|
||||
`Ruta esperada: ${loadingPath}`,
|
||||
"Ajusta SCOREKO_LOADING_ROUTE o verifica que exista dashboard/loading.html en el bundle.",
|
||||
].join("\n"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function enrichNodeCGFailureMessage(baseMessage: string): string {
|
||||
@@ -245,7 +235,6 @@ async function launch(): Promise<void> {
|
||||
mainWindow = createMainWindow();
|
||||
loadingWindow = createLoadingWindow();
|
||||
|
||||
await loadingWindow.loadFile(loadingPath);
|
||||
loadingWindow.show();
|
||||
|
||||
lastNodeCGOutput = "";
|
||||
@@ -254,6 +243,12 @@ async function launch(): Promise<void> {
|
||||
await sleep(Math.max(0, LOAD_DELAY_MS));
|
||||
await waitForNodeCGReady(Date.now());
|
||||
|
||||
try {
|
||||
await loadingWindow.loadURL(loadingUrl);
|
||||
} catch (error) {
|
||||
log("No se pudo cargar la ruta de loading del bundle", loadingUrl, error);
|
||||
}
|
||||
|
||||
if (!mainWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user