better button

This commit is contained in:
songtianlun 2025-08-01 22:13:01 +08:00
parent 2d092a06d6
commit 57c1f12893
3 changed files with 51 additions and 19 deletions

View File

@ -15,6 +15,10 @@
"edit": "Edit",
"create": "Create",
"duplicate": "Duplicate",
"copyContent": "Copy Content",
"copyToClipboard": "Copy to Clipboard",
"duplicatePrompt": "Duplicate Prompt",
"createCopy": "Create Copy",
"search": "Search",
"filter": "Filter",
"close": "Close",
@ -159,7 +163,9 @@
"debugPrompt": "Debug Prompt",
"promptEditor": "Prompt Editor",
"testResults": "Test Results",
"versionHistory": "Version History"
"versionHistory": "Version History",
"copyPromptContent": "Copy Content",
"duplicateThisPrompt": "Create Copy"
},
"home": {
"hero": {

View File

@ -15,6 +15,10 @@
"edit": "编辑",
"create": "创建",
"duplicate": "复制",
"copyContent": "复制内容",
"copyToClipboard": "复制到剪贴板",
"duplicatePrompt": "复制提示词",
"createCopy": "创建副本",
"search": "搜索",
"filter": "筛选",
"close": "关闭",
@ -159,7 +163,9 @@
"debugPrompt": "调试提示词",
"promptEditor": "提示词编辑器",
"testResults": "测试结果",
"versionHistory": "版本历史"
"versionHistory": "版本历史",
"copyPromptContent": "复制内容",
"duplicateThisPrompt": "创建副本"
},
"home": {
"hero": {

View File

@ -14,10 +14,11 @@ import { FullScreenLoading } from '@/components/ui/full-screen-loading'
import { VersionTimeline, VersionTimelineRef } from '@/components/studio/VersionTimeline'
import {
Save,
Copy,
ArrowLeft,
FileText,
Clock
Clock,
Files,
Clipboard
} from 'lucide-react'
interface PromptPageProps {
@ -182,9 +183,21 @@ export default function PromptPage({ params }: PromptPageProps) {
}
}
const copyToClipboard = (text: string) => {
navigator.clipboard.writeText(text)
// Show success message
const copyToClipboard = async (text: string) => {
try {
await navigator.clipboard.writeText(text)
// Could add toast notification here in the future
console.log('Content copied to clipboard')
} catch (error) {
console.error('Failed to copy to clipboard:', error)
// Fallback for older browsers
const textArea = document.createElement('textarea')
textArea.value = text
document.body.appendChild(textArea)
textArea.select()
document.execCommand('copy')
document.body.removeChild(textArea)
}
}
const handleVersionSelect = (version: PromptVersion) => {
@ -318,20 +331,21 @@ export default function PromptPage({ params }: PromptPageProps) {
</div>
</div>
<div className="flex items-center space-x-2">
<div className="flex items-center space-x-3">
<Button
variant="outline"
size="sm"
onClick={handleDuplicatePrompt}
disabled={!prompt || isLoading || isDuplicating}
className="flex items-center space-x-1"
className="flex items-center space-x-2 hover:bg-blue-50 hover:border-blue-200 dark:hover:bg-blue-950/30"
title={t('duplicateThisPrompt')}
>
{isDuplicating ? (
<LoadingSpinner size="sm" className="mr-1" />
) : (
<Copy className="h-4 w-4" />
<Files className="h-4 w-4" />
)}
<span className="hidden sm:inline">{tCommon('duplicate')}</span>
<span className="hidden sm:inline">{t('duplicateThisPrompt')}</span>
</Button>
</div>
</div>
@ -382,7 +396,7 @@ export default function PromptPage({ params }: PromptPageProps) {
{/* Action Bar (Mobile) */}
<div className="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-4">
<div className="flex items-center space-x-2">
<div className="flex items-center space-x-3">
<Button
onClick={handleSavePrompt}
disabled={isSaving}
@ -396,14 +410,17 @@ export default function PromptPage({ params }: PromptPageProps) {
{tCommon('save')}
</Button>
<div className="h-6 w-px bg-border hidden sm:block"></div>
<Button
variant="outline"
onClick={() => copyToClipboard(promptContent)}
className="flex items-center space-x-2"
className="flex items-center space-x-2 hover:bg-green-50 hover:border-green-200 dark:hover:bg-green-950/30"
size="sm"
title={t('copyPromptContent')}
>
<Copy className="h-4 w-4 mr-2" />
Copy
<Clipboard className="h-4 w-4" />
<span className="hidden sm:inline ml-2">{t('copyPromptContent')}</span>
</Button>
</div>
@ -481,7 +498,7 @@ export default function PromptPage({ params }: PromptPageProps) {
<div className="col-span-2 space-y-6">
{/* Action Bar */}
<div className="flex items-center justify-between">
<div className="flex items-center space-x-3">
<div className="flex items-center space-x-4">
<Button
onClick={handleSavePrompt}
disabled={isSaving}
@ -495,13 +512,16 @@ export default function PromptPage({ params }: PromptPageProps) {
{tCommon('save')}
</Button>
<div className="h-6 w-px bg-border"></div>
<Button
variant="outline"
onClick={() => copyToClipboard(promptContent)}
className="flex items-center space-x-2"
className="flex items-center space-x-2 hover:bg-green-50 hover:border-green-200 dark:hover:bg-green-950/30"
title={t('copyPromptContent')}
>
<Copy className="h-4 w-4 mr-2" />
Copy
<Clipboard className="h-4 w-4 mr-2" />
{t('copyPromptContent')}
</Button>
</div>