@@ -6,6 +6,7 @@ import { cn } from '../lib/utils';
66import { sitePath } from '../lib/routes' ;
77import { FileViewer , type DownloadFile } from './FileViewer' ;
88import { DownloadSection } from './DownloadSection' ;
9+ import { getSkillInstallCommand } from '../lib/skillInstall' ;
910
1011type SkillDetailData = {
1112 id : string ;
@@ -35,8 +36,7 @@ type SkillDetailData = {
3536// In a real app, this data would come from the astro page props (fetched from getCollection)
3637export function SkillDetailApp ( { skillId, skillData, lang = 'zh' } : { skillId : string , skillData : SkillDetailData , lang ?: 'zh' | 'en' } ) {
3738 const [ currentLang , setCurrentLang ] = React . useState ( lang ) ;
38- const [ isCopied1 , setIsCopied1 ] = React . useState ( false ) ;
39- const [ isCopied2 , setIsCopied2 ] = React . useState ( false ) ;
39+ const [ isInstallCommandCopied , setIsInstallCommandCopied ] = React . useState ( false ) ;
4040
4141 const [ isClient , setIsClient ] = React . useState ( false ) ;
4242
@@ -59,20 +59,15 @@ export function SkillDetailApp({ skillId, skillData, lang = 'zh' }: { skillId: s
5959
6060 const t = ( key : keyof typeof ui [ 'zh' ] ) => ui [ currentLang ] [ key ] ;
6161
62- const handleCopy1 = ( ) => {
63- navigator . clipboard . writeText ( `git clone https://github.com/MaaXYZ/MaaHub.git --depth=1` ) ;
64- setIsCopied1 ( true ) ;
65- setTimeout ( ( ) => setIsCopied1 ( false ) , 2000 ) ;
66- } ;
62+ const packageName = skillData . id . split ( '/' ) [ 1 ] || skillData . id ;
63+ const installCommand = getSkillInstallCommand ( skillData . skillName || packageName ) ;
6764
68- const handleCopy2 = ( ) => {
69- navigator . clipboard . writeText ( `cp -r MaaHub/Storage/skills/ ${ skillData . author } / ${ skillData . id . split ( '/' ) [ 1 ] } ./your_agent_skills/` ) ;
70- setIsCopied2 ( true ) ;
71- setTimeout ( ( ) => setIsCopied2 ( false ) , 2000 ) ;
65+ const handleCopyInstallCommand = ( ) => {
66+ navigator . clipboard . writeText ( installCommand ) ;
67+ setIsInstallCommandCopied ( true ) ;
68+ setTimeout ( ( ) => setIsInstallCommandCopied ( false ) , 2000 ) ;
7269 } ;
7370
74- const packageName = skillData . id . split ( '/' ) [ 1 ] || skillData . id ;
75-
7671 return (
7772 < >
7873 < Header lang = { currentLang } toggleLang = { toggleLang } />
@@ -141,28 +136,16 @@ export function SkillDetailApp({ skillId, skillData, lang = 'zh' }: { skillId: s
141136 < Terminal className = "mr-2 h-4 w-4 text-muted-foreground" />
142137 { t ( 'skill.install' ) }
143138 </ h3 >
144- < div className = "relative mb-2" >
145- < pre className = "overflow-x-auto rounded bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all pr-10" >
146- < code > { `git clone https://github.com/MaaXYZ/MaaHub.git --depth=1` } </ code >
147- </ pre >
148- < button
149- onClick = { handleCopy1 }
150- className = "absolute right-2 top-2 rounded bg-background p-1.5 text-muted-foreground hover:text-foreground border shadow-sm transition-colors"
151- title = "Copy clone command"
152- >
153- { isCopied1 ? < Check className = "h-3.5 w-3.5 text-green-500" /> : < Copy className = "h-3.5 w-3.5" /> }
154- </ button >
155- </ div >
156139 < div className = "relative" >
157140 < pre className = "overflow-x-auto rounded bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-all pr-10" >
158- < code > { `cp -r MaaHub/Storage/skills/ ${ skillData . author } / ${ skillData . id . split ( '/' ) [ 1 ] } ./your_agent_skills/` } </ code >
141+ < code > { installCommand } </ code >
159142 </ pre >
160143 < button
161- onClick = { handleCopy2 }
144+ onClick = { handleCopyInstallCommand }
162145 className = "absolute right-2 top-2 rounded bg-background p-1.5 text-muted-foreground hover:text-foreground border shadow-sm transition-colors"
163- title = "Copy copy command"
146+ title = "Copy install command"
164147 >
165- { isCopied2 ? < Check className = "h-3.5 w-3.5 text-green-500" /> : < Copy className = "h-3.5 w-3.5" /> }
148+ { isInstallCommandCopied ? < Check className = "h-3.5 w-3.5 text-green-500" /> : < Copy className = "h-3.5 w-3.5" /> }
166149 </ button >
167150 </ div >
168151 </ div >
0 commit comments