chore: Entfernen der veralteten WindowVariablesInitializer-Komponente
- Alte Initialisierung von window-basierten Variablen entfernt - Script-Loading über DOM-Elemente wird nicht mehr benötigt - Umstellung auf saubere Datenverwaltung über Services und Redux abgeschlossen - Projektstruktur weiter aufgeräumt
This commit is contained in:
@@ -1,60 +0,0 @@
|
|||||||
// components/WindowVariables/WindowVariablesInitializer.tsx
|
|
||||||
"use client";
|
|
||||||
|
|
||||||
import { useEffect } from "react";
|
|
||||||
import { useDispatch } from "react-redux";
|
|
||||||
import { setInputs } from "../redux/slices/digitalInputsSlice";
|
|
||||||
|
|
||||||
const WindowVariablesInitializer = () => {
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const loadScriptsAndInitialize = async () => {
|
|
||||||
try {
|
|
||||||
const isDevelopment = window.location.hostname === "localhost";
|
|
||||||
const scriptPath = isDevelopment
|
|
||||||
? "/CPLmockData/SERVICE/de.js"
|
|
||||||
: "/CPL/SERVICE/de.js";
|
|
||||||
|
|
||||||
await loadScript(scriptPath);
|
|
||||||
|
|
||||||
const winDeState = window.win_de_state || [];
|
|
||||||
const winDeLabel = window.win_de_label || [];
|
|
||||||
|
|
||||||
const initialInputs = winDeState.map(
|
|
||||||
(status: number, index: number) => ({
|
|
||||||
id: index + 1,
|
|
||||||
label: winDeLabel[index] || `Eingang ${index + 1}`,
|
|
||||||
status: status === 1,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
dispatch(setInputs(initialInputs));
|
|
||||||
} catch (error) {
|
|
||||||
console.error(
|
|
||||||
"Fehler beim Laden der Skripte oder Initialisieren der Inputs:",
|
|
||||||
error
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
loadScriptsAndInitialize();
|
|
||||||
}, [dispatch]);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default WindowVariablesInitializer;
|
|
||||||
|
|
||||||
// Hilfsfunktion zum Laden eines Skripts
|
|
||||||
const loadScript = (src: string): Promise<void> => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const script = document.createElement("script");
|
|
||||||
script.src = src;
|
|
||||||
script.async = true;
|
|
||||||
script.onload = () => resolve();
|
|
||||||
script.onerror = () =>
|
|
||||||
reject(new Error(`Fehler beim Laden des Skripts: ${src}`));
|
|
||||||
document.head.appendChild(script);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -6,5 +6,5 @@
|
|||||||
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
2: Patch oder Hotfix (Bugfixes oder kleine Änderungen).
|
||||||
|
|
||||||
*/
|
*/
|
||||||
const webVersion = "1.6.295";
|
const webVersion = "1.6.296";
|
||||||
export default webVersion;
|
export default webVersion;
|
||||||
|
|||||||
Reference in New Issue
Block a user