@@ -22,8 +22,6 @@ export default function MarketplaceDetailPage() {
2222 const fetchVersionSnapshot = useMarketplaceStore ( ( s ) => s . fetchVersionSnapshot ) ;
2323 const clearSnapshot = useMarketplaceStore ( ( s ) => s . clearSnapshot ) ;
2424 const [ installOpen , setInstallOpen ] = useState ( false ) ;
25- const [ activeTab , setActiveTab ] = useState < "overview" | "versions" | "files" > ( "overview" ) ;
26- const tabLabels : Record < string , string > = { overview : "概览" , versions : "版本" , files : "文件" } ;
2725
2826 useEffect ( ( ) => {
2927 if ( id ) {
@@ -34,11 +32,11 @@ export default function MarketplaceDetailPage() {
3432 } , [ id , fetchDetail , fetchLineage , clearDetail ] ) ;
3533
3634 useEffect ( ( ) => {
37- if ( activeTab === "files" && detail && detail . versions . length > 0 ) {
35+ if ( detail && detail . versions . length > 0 && ( detail . type === "skill" || detail . type === "agent" ) ) {
3836 fetchVersionSnapshot ( detail . id , detail . versions [ 0 ] . version ) ;
3937 }
4038 return ( ) => clearSnapshot ( ) ;
41- } , [ activeTab , detail ?. id , fetchVersionSnapshot , clearSnapshot ] ) ;
39+ } , [ detail ?. id , detail ?. type , fetchVersionSnapshot , clearSnapshot ] ) ;
4240
4341 if ( detailLoading ) {
4442 return (
@@ -68,11 +66,11 @@ export default function MarketplaceDetailPage() {
6866 < div className = "max-w-3xl mx-auto py-6 px-4 md:px-6" >
6967 { /* Back button */ }
7068 < button
71- onClick = { ( ) => navigate ( "/marketplace" ) }
69+ onClick = { ( ) => navigate ( - 1 ) }
7270 className = "flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors duration-fast mb-6"
7371 >
7472 < ArrowLeft className = "w-3.5 h-3.5" />
75- 返回 Marketplace
73+ 返回
7674 </ button >
7775
7876 { /* Header */ }
@@ -108,89 +106,40 @@ export default function MarketplaceDetailPage() {
108106 </ div >
109107 ) }
110108
111- { /* Tabs */ }
112- < div className = "flex gap-4 border-b border-border mb-6" >
113- { ( [ "overview" , "versions" , ...( detail . type === "skill" || detail . type === "agent" ? [ "files" as const ] : [ ] ) ] as const ) . map ( ( tab ) => (
114- < button
115- key = { tab }
116- onClick = { ( ) => setActiveTab ( tab ) }
117- className = { `pb-2 text-sm font-medium transition-colors duration-fast border-b-2 ${
118- activeTab === tab ? "border-primary text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"
119- } `}
120- >
121- { tabLabels [ tab ] ?? tab }
122- </ button >
123- ) ) }
124- </ div >
125-
126- { /* Tab content */ }
127- { activeTab === "overview" && (
128- < div className = "space-y-6" >
129- { /* Lineage */ }
130- < LineageTree
131- ancestors = { lineage . ancestors }
132- children = { lineage . children }
133- currentName = { detail . name }
134- onNodeClick = { ( nodeId ) => navigate ( `/marketplace/${ nodeId } ` ) }
135- />
136-
137- { /* Latest version info */ }
138- { detail . versions . length > 0 && (
139- < div className = "surface-card p-4 space-y-2" >
140- < h3 className = "text-sm font-medium text-foreground" > 最新版本</ h3 >
141- < p className = "text-xs font-mono text-primary" > v{ detail . versions [ 0 ] . version } </ p >
142- { detail . versions [ 0 ] . release_notes && (
143- < p className = "text-sm text-muted-foreground whitespace-pre-wrap" > { detail . versions [ 0 ] . release_notes } </ p >
144- ) }
145- </ div >
146- ) }
147- </ div >
148- ) }
109+ < div className = "space-y-6" >
110+ { /* Lineage */ }
111+ < LineageTree
112+ ancestors = { lineage . ancestors }
113+ children = { lineage . children }
114+ currentName = { detail . name }
115+ onNodeClick = { ( nodeId ) => navigate ( `/marketplace/${ nodeId } ` ) }
116+ />
149117
150- { activeTab === "versions" && (
151- < div className = "space-y-3" >
152- { detail . versions . map ( ( v ) => (
153- < div key = { v . id } className = "surface-card p-4" >
154- < div className = "flex items-center justify-between mb-1" >
155- < span className = "text-sm font-mono font-medium text-foreground" > v{ v . version } </ span >
156- < span className = "text-2xs text-muted-foreground" > { new Date ( v . created_at ) . toLocaleDateString ( ) } </ span >
118+ { /* Version history */ }
119+ { detail . versions . length > 0 && (
120+ < div className = "space-y-2" >
121+ < h3 className = "text-sm font-medium text-foreground" > 版本历史</ h3 >
122+ { detail . versions . map ( ( v ) => (
123+ < div key = { v . id } className = "surface-card p-4" >
124+ < div className = "flex items-center justify-between mb-1" >
125+ < span className = "text-sm font-mono font-medium text-primary" > v{ v . version } </ span >
126+ < span className = "text-2xs text-muted-foreground" > { new Date ( v . created_at ) . toLocaleDateString ( ) } </ span >
127+ </ div >
128+ { v . release_notes && (
129+ < p className = "text-xs text-muted-foreground whitespace-pre-wrap" > { v . release_notes } </ p >
130+ ) }
157131 </ div >
158- { v . release_notes && (
159- < p className = "text-xs text-muted-foreground whitespace-pre-wrap" > { v . release_notes } </ p >
160- ) }
161- </ div >
162- ) ) }
163- { detail . versions . length === 0 && (
164- < p className = "text-sm text-muted-foreground text-center py-8" > 暂无已发布的版本</ p >
165- ) }
166- </ div >
167- ) }
168-
169- { activeTab === "files" && (
170- < div className = "space-y-4" >
171- { /* File tree */ }
172- < div className = "surface-card p-4" >
173- < h3 className = "text-sm font-medium text-foreground mb-3" > 文件结构</ h3 >
174- < div className = "font-mono text-xs text-muted-foreground space-y-1" >
175- < div className = "flex items-center gap-2 text-foreground font-medium" >
176- < span > 📁</ span >
177- < span > { detail . slug } /</ span >
178- </ div >
179- < div className = "flex items-center gap-2 ml-5" >
180- < span > 📄</ span >
181- < span className = "text-primary" > SKILL.md</ span >
182- </ div >
183- < div className = "flex items-center gap-2 ml-5" >
184- < span > 📄</ span >
185- < span > meta.json</ span >
186- </ div >
187- </ div >
132+ ) ) }
188133 </ div >
134+ ) }
189135
190- { /* SKILL.md preview */ }
136+ { /* File content for skill / agent */ }
137+ { ( detail . type === "skill" || detail . type === "agent" ) && (
191138 < div className = "surface-card p-4" >
192139 < div className = "flex items-center gap-2 mb-3" >
193- < span className = "text-xs font-mono text-muted-foreground px-2 py-0.5 rounded bg-muted" > SKILL.md</ span >
140+ < span className = "text-xs font-mono text-muted-foreground px-2 py-0.5 rounded bg-muted" >
141+ { detail . type === "skill" ? "SKILL.md" : "agent.md" }
142+ </ span >
194143 </ div >
195144 { snapshotLoading ? (
196145 < div className = "flex items-center justify-center py-8" >
@@ -204,8 +153,8 @@ export default function MarketplaceDetailPage() {
204153 < p className = "text-sm text-muted-foreground text-center py-6" > 暂无内容</ p >
205154 ) }
206155 </ div >
207- </ div >
208- ) }
156+ ) }
157+ </ div >
209158 </ div >
210159
211160 { /* Install dialog */ }
0 commit comments