Files
CPLv4.0/services/fetchSystemSettings.ts
ISA 9e282c9ae5 refactor: Lade alle window-basierten .js-Dateien dynamisch und umgebungsabhängig
- Alle Services (ae.js, de.js, da.js, kueData.js, Start.js, System.js, opcua.js) laden ihre Scripte abhängig von der Umgebung
- Vermeidet unnötige globale Script-Ladung über loadWindowVariables.ts
- Reduziert Netzwerklast und verbessert Modularität und Performance
2025-03-26 14:13:18 +01:00

37 lines
1.1 KiB
TypeScript

// /services/fetchSystemSettings.ts
export const fetchSystemSettings = async () => {
if (typeof window === "undefined") return null;
// ✅ System.js nur bei Bedarf nachladen (Pfad abhängig von Umgebung)
const scriptSrc =
process.env.NODE_ENV === "production"
? "/CPL?/CPL/SERVICE/System.js"
: "/CPLmockData/SERVICE/System.js";
await new Promise<void>((resolve, reject) => {
const script = document.createElement("script");
script.src = scriptSrc;
script.async = true;
script.onload = () => resolve();
script.onerror = () => reject("❌ Fehler beim Laden von System.js");
document.body.appendChild(script);
});
const win = window as any;
return {
deviceName: win.win_deviceName || "",
mac1: win.win_mac1 || "",
ip: win.win_ip || "",
subnet: win.win_subnet || "",
gateway: win.win_gateway || "",
cplInternalTimestamp: win.win_cplInternalTimestamp || "",
ntp1: win.win_ntp1 || "",
ntp2: win.win_ntp2 || "",
ntp3: win.win_ntp3 || "",
ntpTimezone: win.win_ntpTimezone || "",
ntpActive: win.win_ntpActive || false,
};
};