mirror of
https://github.com/iflytek/skillhub.git
synced 2026-09-07 08:26:00 +00:00
Refine skill install command layout
This commit is contained in:
parent
2170412bda
commit
c2b75bf961
1 changed files with 33 additions and 4 deletions
|
|
@ -1,4 +1,7 @@
|
|||
import { CopyButton } from '@/shared/components/copy-button'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Check, Copy } from 'lucide-react'
|
||||
import { Button } from '@/shared/ui/button'
|
||||
|
||||
interface InstallCommandProps {
|
||||
namespace: string
|
||||
|
|
@ -7,14 +10,40 @@ interface InstallCommandProps {
|
|||
}
|
||||
|
||||
export function InstallCommand({ namespace, slug, version }: InstallCommandProps) {
|
||||
const { t } = useTranslation()
|
||||
const [copied, setCopied] = useState(false)
|
||||
const command = version
|
||||
? `skillhub install ${namespace}/${slug}@${version}`
|
||||
: `skillhub install ${namespace}/${slug}`
|
||||
|
||||
const handleCopy = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(command)
|
||||
setCopied(true)
|
||||
window.setTimeout(() => setCopied(false), 2000)
|
||||
} catch (err) {
|
||||
console.error('Failed to copy:', err)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2 p-3 bg-muted rounded-lg">
|
||||
<code className="flex-1 text-sm font-mono">{command}</code>
|
||||
<CopyButton text={command} />
|
||||
<div className="relative overflow-hidden rounded-xl border border-border/60 bg-muted/50">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={handleCopy}
|
||||
title={copied ? t('copyButton.copied') : t('copyButton.copy')}
|
||||
aria-label={copied ? t('copyButton.copied') : t('copyButton.copy')}
|
||||
className="absolute right-2 top-2 z-10 h-8 w-8 rounded-md bg-background/80 backdrop-blur hover:bg-background"
|
||||
>
|
||||
{copied ? <Check className="h-4 w-4" /> : <Copy className="h-4 w-4" />}
|
||||
</Button>
|
||||
<pre className="p-4 pr-14 whitespace-pre-wrap break-words">
|
||||
<code className="font-mono text-sm leading-6 text-foreground whitespace-pre-wrap break-words">
|
||||
{command}
|
||||
</code>
|
||||
</pre>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue