chore: update page routes (#1790)

chore: update routers
This commit is contained in:
boojack
2023-06-03 13:03:22 +08:00
committed by GitHub
parent 69225b507b
commit 32e2f1d339
22 changed files with 324 additions and 611 deletions

View File

@ -5,6 +5,8 @@ import store from "@/store";
import { initialGlobalState, initialUserState } from "@/store/module";
import DailyReview from "@/pages/DailyReview";
import ResourcesDashboard from "@/pages/ResourcesDashboard";
import Setting from "@/pages/Setting";
import Archived from "@/pages/Archived";
const Root = lazy(() => import("@/layouts/Root"));
const Auth = lazy(() => import("@/pages/Auth"));
@ -138,6 +140,44 @@ const router = createBrowserRouter([
// do nth
}
const { host } = store.getState().user;
if (isNullorUndefined(host)) {
return redirect("/auth");
}
return null;
},
},
{
path: "archived",
element: <Archived />,
loader: async () => {
await initialGlobalStateLoader();
try {
await initialUserState();
} catch (error) {
// do nth
}
const { host } = store.getState().user;
if (isNullorUndefined(host)) {
return redirect("/auth");
}
return null;
},
},
{
path: "setting",
element: <Setting />,
loader: async () => {
await initialGlobalStateLoader();
try {
await initialUserState();
} catch (error) {
// do nth
}
const { host } = store.getState().user;
if (isNullorUndefined(host)) {
return redirect("/auth");