mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: use react-router
This commit is contained in:
47
web/src/router/index.tsx
Normal file
47
web/src/router/index.tsx
Normal file
@ -0,0 +1,47 @@
|
||||
import { createBrowserRouter } from "react-router-dom";
|
||||
import { userService } from "../services";
|
||||
import Auth from "../pages/Auth";
|
||||
import Explore from "../pages/Explore";
|
||||
import Home from "../pages/Home";
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
path: "/",
|
||||
element: <Home />,
|
||||
loader: async () => {
|
||||
try {
|
||||
await userService.initialState();
|
||||
} catch (error) {
|
||||
// do nth
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/auth",
|
||||
element: <Auth />,
|
||||
},
|
||||
{
|
||||
path: "/u/:userId",
|
||||
element: <Home />,
|
||||
loader: async () => {
|
||||
try {
|
||||
await userService.initialState();
|
||||
} catch (error) {
|
||||
// do nth
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/explore",
|
||||
element: <Explore />,
|
||||
loader: async () => {
|
||||
try {
|
||||
await userService.initialState();
|
||||
} catch (error) {
|
||||
// do nth
|
||||
}
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
export default router;
|
Reference in New Issue
Block a user