import Login from "@/pages/Login"; import App from "@/App"; import Home from "@/pages/Home"; import Monitor from "@/pages/Monitor"; import Energy from "@/pages/Energy"; import History from "@/pages/History"; import Alert from "@/pages/Alert"; import Operation from "@/pages/Operation"; import GraphManagement from "@/pages/GraphManagement"; import AccountManagement from "@/pages/AccountManagement"; import { redirect } from "react-router-dom"; import { setUserAccountByBaja, userLogin } from "@UTIL/index"; const monitor = [{}, {}]; const routes = [ { path: "/", element: , loader: async () => { let JWT_Authorization = document.cookie.replace( /(?:(?:^|.*;\s*)JWT-Authorization\s*\=\s*([^;]*).*$)|^.*$/, "$1", ); console.log(JWT_Authorization); if (window.location.href.includes("localhost:3000") && !JWT_Authorization) { return redirect("/login"); } else if (window.location.href.includes("http://220.132.206.5") && !JWT_Authorization) { const account = await setUserAccountByBaja(); console.log("account", account); await userLogin( null, { account, password: "rJ2T5Kkj", }, null, ); return null; } return null; }, children: [ { index: true, element: , }, { path: "monitor/:systemId", element: , children: monitor, }, { path: "energy", element: , }, { path: "history", element: , }, { path: "alert", element: , }, { path: "operation", element: , }, { path: "graphManagement", element: , }, { path: "accountManagement", element: , }, ], }, { path: "/login", element: , }, ]; export default routes;