perf: optimize dashboard database queries and remove unused imports
This commit is contained in:
1 parent
3a76dbdb97
commit
416c31643b
4 files changed
+593
-114
No files matched your search
@@ -0,0 +1,96 @@
|
|||||||
|
// Syncs the Nitro/Octane runtime config URLs from environment variables into the
|
||||||
|
// renderer-config.json / renderer-config.jsonc / ui-config.json files.
|
||||||
|
//
|
||||||
|
// Uses jsonc-parser so JSONC (with // and /* */ comments) is handled safely —
|
||||||
|
// unlike a naive JSON.parse/json.load this never corrupts URLs that contain
|
||||||
|
// "https://". After this runs the files are written back as strict JSON (which
|
||||||
|
// is still valid JSONC), so downstream validation passes.
|
||||||
|
//
|
||||||
|
// Env:
|
||||||
|
// NITRO_SRC_DIR e.g. /var/www/Octane/public/configuration
|
||||||
|
// NITRO_DIST_CONFIG_DIR e.g. /var/www/Octane/dist/configuration
|
||||||
|
// NITRO_GAMEDATA_CONF_DIR e.g. /var/www/Gamedata/config
|
||||||
|
// NITRO_IMAGE_LIBRARY_URL, NITRO_HOF_FURNITURE_URL, NITRO_API_URL,
|
||||||
|
// NITRO_SOCKET_URL, NITRO_GAMEDATA_URL, NITRO_ASSET_URL,
|
||||||
|
// NITRO_FURNI_ASSET_ICON_URL
|
||||||
|
const fs = require("node:fs");
|
||||||
|
const path = require("node:path");
|
||||||
|
const { parse, modify } = require("jsonc-parser");
|
||||||
|
|
||||||
|
const FILES = ["renderer-config.json", "renderer-config.jsonc", "ui-config.json"];
|
||||||
|
|
||||||
|
function env(name) {
|
||||||
|
return process.env[name] && process.env[name].length ? process.env[name] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyOverrides(data) {
|
||||||
|
const image = env("NITRO_IMAGE_LIBRARY_URL");
|
||||||
|
const hof = env("NITRO_HOF_FURNITURE_URL");
|
||||||
|
const api = env("NITRO_API_URL");
|
||||||
|
const socket = env("NITRO_SOCKET_URL");
|
||||||
|
const gamedata = env("NITRO_GAMEDATA_URL");
|
||||||
|
const asset = env("NITRO_ASSET_URL");
|
||||||
|
const icon = env("NITRO_FURNI_ASSET_ICON_URL");
|
||||||
|
|
||||||
|
const set = (key, value) => {
|
||||||
|
if (value && !(key in data)) data[key] = value;
|
||||||
|
if (value) data[key] = value;
|
||||||
|
};
|
||||||
|
|
||||||
|
set("image.library.url", image);
|
||||||
|
set("hof.furni.url", hof);
|
||||||
|
set("api.url", api);
|
||||||
|
set("socket.url", socket);
|
||||||
|
set("gamedata.url", gamedata);
|
||||||
|
set("asset.url", asset);
|
||||||
|
set("furni.asset.icon.url", icon);
|
||||||
|
|
||||||
|
if (gamedata) {
|
||||||
|
data["radio.url"] = `${gamedata}/config/radio-stations.jsonc?t=%timestamp%`;
|
||||||
|
data["soundboard.url"] = `${gamedata}/config/soundboard-sounds.jsonc?t=%timestamp%`;
|
||||||
|
}
|
||||||
|
if ("show.google.ads" in data) data["show.google.ads"] = false;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dirs = [
|
||||||
|
env("NITRO_SRC_DIR"),
|
||||||
|
env("NITRO_DIST_CONFIG_DIR"),
|
||||||
|
env("NITRO_GAMEDATA_CONF_DIR"),
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
let changed = 0;
|
||||||
|
for (const dir of dirs) {
|
||||||
|
if (!fs.existsSync(dir)) continue;
|
||||||
|
for (const file of FILES) {
|
||||||
|
const full = path.join(dir, file);
|
||||||
|
if (!fs.existsSync(full)) continue;
|
||||||
|
let content;
|
||||||
|
try {
|
||||||
|
content = fs.readFileSync(full, "utf-8");
|
||||||
|
} catch {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = parse(content, [], { allowTrailingComma: true, allowEmptyContent: true });
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`[sync-nitro-urls] parse error in ${full}: ${e}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!data || typeof data !== "object") continue;
|
||||||
|
const before = JSON.stringify(data);
|
||||||
|
const updated = applyOverrides(data);
|
||||||
|
if (JSON.stringify(updated) === before) continue;
|
||||||
|
try {
|
||||||
|
fs.writeFileSync(full, `${JSON.stringify(updated, null, 4)}\n`);
|
||||||
|
changed++;
|
||||||
|
console.log(` [OK] Synced URLs: ${file} (${dir})`);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`[sync-nitro-urls] write error ${full}: ${e}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(` [OK] URL sync complete (${changed} file(s) updated)`);
|
||||||
|
process.exit(0);
|
||||||
+47
-63
File diff suppressed because it is too large.
Load diff
@@ -34,7 +34,13 @@ function ToolbarBtn({
|
|||||||
} as const;
|
} as const;
|
||||||
if (href) {
|
if (href) {
|
||||||
return (
|
return (
|
||||||
<Link href={href} className={cls} style={style} title={title}>
|
<Link
|
||||||
|
href={href}
|
||||||
|
prefetch={false}
|
||||||
|
className={cls}
|
||||||
|
style={style}
|
||||||
|
title={title}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
@@ -377,9 +383,12 @@ export function ClientView({
|
|||||||
<iframe
|
<iframe
|
||||||
id="nitro"
|
id="nitro"
|
||||||
src={clientSrc}
|
src={clientSrc}
|
||||||
className="absolute inset-0 w-full h-full border-0 m-0 p-0 overflow-hidden"
|
className={`absolute inset-0 w-full h-full border-0 m-0 p-0 overflow-hidden ${
|
||||||
|
dragging ? "pointer-events-none" : "pointer-events-auto"
|
||||||
|
}`}
|
||||||
title={hotelName}
|
title={hotelName}
|
||||||
allow="autoplay; gamepad"
|
allow="autoplay; gamepad; fullscreen"
|
||||||
|
loading="eager"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
+438
-48
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user