import { Suspense, useEffect, lazy } from "react"; import { Route, Routes, HashRouter } from "react-router-dom"; import { Provider } from "react-redux"; import toast from "react-hot-toast"; import { isEqual } from "lodash"; import NotFoundPage from "./404"; // import Welcome from './Welcome' // const HomePage = lazy(() => import("./home")); // const ChatPage = lazy(() => import("./chat")); const RegBasePage = lazy(() => import("./reg")); const RegWithUsernamePage = lazy(() => import("./reg/RegWithUsername")); const SendMagicLinkPage = lazy(() => import("./sendMagicLink")); const RegPage = lazy(() => import("./reg/Register")); const LoginPage = lazy(() => import("./login")); const OAuthPage = lazy(() => import("./oauth")); const UsersPage = lazy(() => import("./users")); const CallbackPage = lazy(() => import("./callback")); const FavoritesPage = lazy(() => import("./favs")); const OnboardingPage = lazy(() => import("./onboarding")); const InvitePage = lazy(() => import("./invite")); const SettingChannelPage = lazy(() => import("./settingChannel")); const SettingPage = lazy(() => import("./setting")); const ResourceManagement = lazy(() => import("./resources")); const GuestLogin = lazy(() => import("./guest")); import RequireAuth from "../common/component/RequireAuth"; import RequireNoAuth from "../common/component/RequireNoAuth"; import Meta from "../common/component/Meta"; import HomePage from "./home"; import ChatPage from "./chat"; import Loading from "../common/component/Loading"; import store, { useAppSelector } from "../app/store"; let toastId: string; const PageRoutes = () => { const { ui: { online }, fileMessages } = useAppSelector((store) => { return { ui: store.ui, fileMessages: store.fileMessage }; }, isEqual); // 掉线检测 useEffect(() => { if (!online) { toastId = toast.error("Network Offline!", { duration: Infinity }); } else if (toastId) { toast.dismiss(toastId); } }, [online]); return ( }> } /> } /> } /> } /> } /> } > } /> } /> } /> } /> } /> } /> } > }> } /> } /> }> // } /> } /> }> // } /> }> // } /> }> } /> }> } /> }> } > }> } > } /> ); }; export default function ReduxRoutes() { return ( ); }