generated from kevisual/vite-react-template
feat: 添加仓库信息卡片和仓库页面,优化仓库路由
This commit is contained in:
32
src/pages/repos/repo/page.tsx
Normal file
32
src/pages/repos/repo/page.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { useSearch } from "@tanstack/react-router";
|
||||
import { useRepoStore } from "../store";
|
||||
import { useEffect } from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { RepoInfoCard } from "../components/RepoInfoCard";
|
||||
|
||||
export const App = () => {
|
||||
const params = useSearch({ strict: false }) as { repo?: string };
|
||||
const repoStore = useRepoStore(useShallow((state) => ({
|
||||
getItem: state.getItem,
|
||||
editRepo: state.editRepo,
|
||||
})));
|
||||
useEffect(() => {
|
||||
if (params.repo) {
|
||||
repoStore.getItem(params.repo);
|
||||
} else {
|
||||
console.log('no repo param')
|
||||
}
|
||||
}, [params])
|
||||
if (!repoStore.editRepo) {
|
||||
return <div>Loading...</div>
|
||||
}
|
||||
return (
|
||||
<div className="p-2">
|
||||
<div className="px-4">
|
||||
<RepoInfoCard />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default App;
|
||||
Reference in New Issue
Block a user