chore: add user profile page (#2175)

chore: some enhancements
This commit is contained in:
boojack
2023-08-25 23:10:51 +08:00
committed by GitHub
parent 8c312e647d
commit 4af0d03e93
18 changed files with 173 additions and 132 deletions

View File

@ -13,6 +13,7 @@ const Auth = lazy(() => import("@/pages/Auth"));
const AuthCallback = lazy(() => import("@/pages/AuthCallback"));
const Explore = lazy(() => import("@/pages/Explore"));
const Home = lazy(() => import("@/pages/Home"));
const UserProfile = lazy(() => import("@/pages/UserProfile"));
const MemoDetail = lazy(() => import("@/pages/MemoDetail"));
const EmbedMemo = lazy(() => import("@/pages/EmbedMemo"));
const NotFound = lazy(() => import("@/pages/NotFound"));
@ -78,28 +79,6 @@ const router = createBrowserRouter([
return redirect("/explore");
},
},
{
path: "u/:username",
element: <Home />,
loader: async () => {
await initialGlobalStateLoader();
try {
await initialUserState();
} catch (error) {
// do nth
}
const { user } = store.getState().user;
const { systemStatus } = store.getState().global;
if (isNullorUndefined(user) && systemStatus.disablePublicMemos) {
return redirect("/auth");
}
return null;
},
},
{
path: "explore",
element: <Explore />,
@ -238,6 +217,20 @@ const router = createBrowserRouter([
return null;
},
},
{
path: "u/:username",
element: <UserProfile />,
loader: async () => {
await initialGlobalStateLoader();
try {
await initialUserState();
} catch (error) {
// do nth
}
return null;
},
},
{
path: "*",
element: <NotFound />,