import { useSearch } from "@tanstack/react-router"; import { useRepoStore } from "../store"; import { useEffect, useState } from "react"; import { useShallow } from "zustand/shallow"; import BuildConfig from "../components/BuildConfig"; import { CommonRepoDialog } from "../page"; import { RepoCard } from "../components/RepoCard"; export const App = () => { const params = useSearch({ strict: false }) as { repo?: string, tab?: string }; const repoStore = useRepoStore(useShallow((state) => ({ getItem: state.getItem, editRepo: state.editRepo, refresh: state.refresh, loading: state.loading, }))); const [activeTab, setActiveTab] = useState(params.tab || "build"); const tabs = [ { key: "build", label: "构建配置" }, { key: "info", label: "基本信息" }, ] useEffect(() => { if (params.repo) { repoStore.getItem(params.repo); repoStore.refresh({ search: params.repo, showTips: false }); } else { console.log('no repo param') } }, [params]) if (!repoStore.editRepo) { return
Loading...
} return (
{tabs.map(tab => (
{ setActiveTab(tab.key) history.replaceState(null, '', `?repo=${params.repo}&tab=${tab.key}`) }} > {tab.label}
))}
{activeTab === 'build' && } {activeTab === 'info' && (
{JSON.stringify(repoStore.editRepo, null, 2)}
)}
) } export default App;