refactor: lade OPC UA Daten direkt in NetworkInfo-Komponente statt global in _app.tsx
- Thunk `fetchOpcUaSettingsThunk` wird jetzt nur bei Anzeige von NetworkInfo ausgeführt - Reduzierte Netzwerklast und bessere Trennung von Zuständigkeiten - Entfernt globalen OPC UA-Aufruf aus _app.tsx
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// /services/fetchLast20Messages.ts
|
||||
export async function fetchLast20MessagesFromWindow(): Promise<string | null> {
|
||||
return new Promise((resolve) => {
|
||||
if (typeof window !== "undefined" && (window as any).win_last20Messages) {
|
||||
|
||||
21
services/fetchOpcUaSettings.ts
Normal file
21
services/fetchOpcUaSettings.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// ✅ 1. Service: /services/fetchOpcUaSettings.ts
|
||||
export const fetchOpcUaSettings = async () => {
|
||||
try {
|
||||
const win = window as any;
|
||||
|
||||
if (!win) return null;
|
||||
|
||||
const data = {
|
||||
zustand: win.win_opcUaZustand || "Offline",
|
||||
encryption: win.win_opcUaEncryption || "None",
|
||||
clientCount: win.win_opcUaActiveClientCount || 0,
|
||||
nodesetName: win.win_opcUaNodesetName || "DefaultNodeset",
|
||||
users: Array.isArray(win.win_opcUaUsers) ? win.win_opcUaUsers : [],
|
||||
};
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Laden der OPC UA Daten:", error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user