mirror of
https://github.com/Pandipipas/scoreko-electron-dev.git
synced 2026-06-06 05:32:06 +00:00
fix: use bundle dashboard loading screen instead of static loading file (#8)
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
|
## Qué hace
|
||||||
|
|
||||||
- Arranca `lib/nodecg/index.js` como proceso hijo desde Electron.
|
- Arranca `lib/nodecg/index.js` como proceso hijo desde Electron.
|
||||||
- Muestra una ventana de carga mientras NodeCG inicia.
|
- Muestra la pantalla de carga propia del bundle (`dashboard/loading.html`) mientras NodeCG inicia.
|
||||||
- Carga el dashboard del bundle en `http://localhost:<puerto>/bundles/<bundle>/<ruta-dashboard>`.
|
- Carga el dashboard del bundle en `http://localhost:<puerto>/bundles/<bundle>/<ruta-dashboard>`.
|
||||||
- Empaqueta NodeCG + assets dentro de la app final con `electron-builder`.
|
- Empaqueta NodeCG + assets dentro de la app final con `electron-builder`.
|
||||||
|
|
||||||
@@ -29,7 +29,6 @@ scoreko-electron-dev/
|
|||||||
│ └─ bundles/
|
│ └─ bundles/
|
||||||
│ └─ scoreko-dev/
|
│ └─ scoreko-dev/
|
||||||
├─ src/main/main.ts
|
├─ src/main/main.ts
|
||||||
├─ static/loading.html
|
|
||||||
└─ package.json
|
└─ package.json
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -68,3 +67,10 @@ Recompila nativos contra Electron 39.5.1:
|
|||||||
npm run rebuild:native
|
npm run rebuild:native
|
||||||
npm run rebuild:better-sqlite3:electron
|
npm run rebuild:better-sqlite3:electron
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Variables de entorno útiles
|
||||||
|
|
||||||
|
- `NODECG_BUNDLE_NAME` (default: `scoreko-dev`)
|
||||||
|
- `SCOREKO_DASHBOARD_ROUTE` (default: `dashboard/index.html`)
|
||||||
|
- `SCOREKO_LOADING_ROUTE` (default: `dashboard/loading.html`)
|
||||||
|
|||||||
+12
-1
@@ -7,6 +7,7 @@ const APP_TITLE = "Scoreko";
|
|||||||
const DEFAULT_NODECG_PORT = process.env.NODECG_PORT ?? "9090";
|
const DEFAULT_NODECG_PORT = process.env.NODECG_PORT ?? "9090";
|
||||||
const DEFAULT_BUNDLE_NAME = process.env.NODECG_BUNDLE_NAME ?? "scoreko-dev";
|
const DEFAULT_BUNDLE_NAME = process.env.NODECG_BUNDLE_NAME ?? "scoreko-dev";
|
||||||
const DEFAULT_DASHBOARD_ROUTE = process.env.SCOREKO_DASHBOARD_ROUTE ?? "dashboard/index.html";
|
const DEFAULT_DASHBOARD_ROUTE = process.env.SCOREKO_DASHBOARD_ROUTE ?? "dashboard/index.html";
|
||||||
|
const DEFAULT_LOADING_ROUTE = process.env.SCOREKO_LOADING_ROUTE ?? "dashboard/loading.html";
|
||||||
const LOAD_DELAY_MS = Number.parseInt(process.env.ELECTRON_LOAD_DELAY_MS ?? "2500", 10);
|
const LOAD_DELAY_MS = Number.parseInt(process.env.ELECTRON_LOAD_DELAY_MS ?? "2500", 10);
|
||||||
const STARTUP_TIMEOUT_MS = Number.parseInt(process.env.NODECG_STARTUP_TIMEOUT_MS ?? "30000", 10);
|
const STARTUP_TIMEOUT_MS = Number.parseInt(process.env.NODECG_STARTUP_TIMEOUT_MS ?? "30000", 10);
|
||||||
const USE_SYSTEM_NODE = (process.env.NODECG_USE_SYSTEM_NODE ?? "false").toLowerCase() === "true";
|
const USE_SYSTEM_NODE = (process.env.NODECG_USE_SYSTEM_NODE ?? "false").toLowerCase() === "true";
|
||||||
@@ -15,7 +16,7 @@ const NODE_BINARY = process.env.NODECG_NODE_BINARY ?? "node";
|
|||||||
const isDev = !app.isPackaged;
|
const isDev = !app.isPackaged;
|
||||||
const rootPath = isDev ? path.resolve(__dirname, "../..") : process.resourcesPath;
|
const rootPath = isDev ? path.resolve(__dirname, "../..") : process.resourcesPath;
|
||||||
const nodecgPath = path.resolve(rootPath, "lib", "nodecg");
|
const nodecgPath = path.resolve(rootPath, "lib", "nodecg");
|
||||||
const loadingPath = path.resolve(rootPath, "static", "loading.html");
|
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 dashboardUrl = `http://localhost:${DEFAULT_NODECG_PORT}/bundles/${DEFAULT_BUNDLE_NAME}/${DEFAULT_DASHBOARD_ROUTE}`;
|
||||||
const baseUrl = `http://127.0.0.1:${DEFAULT_NODECG_PORT}`;
|
const baseUrl = `http://127.0.0.1:${DEFAULT_NODECG_PORT}`;
|
||||||
@@ -125,6 +126,16 @@ function validateNodeCGInstall(): void {
|
|||||||
].join("\n"),
|
].join("\n"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
function enrichNodeCGFailureMessage(baseMessage: string): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user