语音优化
This commit is contained in:
@@ -10,6 +10,7 @@ import TikhubService, { InterfaceType, MethodType } from '@/api/tikhub/index.js'
|
||||
import { useBenchmarkData } from './composables/useBenchmarkData'
|
||||
import { useBenchmarkAnalysis } from './composables/useBenchmarkAnalysis'
|
||||
import { formatTime } from './utils/benchmarkUtils'
|
||||
import { copyToClipboard } from '@/utils/clipboard'
|
||||
import BenchmarkForm from './components/BenchmarkForm.vue'
|
||||
import BenchmarkTable from './components/BenchmarkTable.vue'
|
||||
import BatchAnalyzeModal from './components/BatchAnalyzeModal.vue'
|
||||
@@ -231,17 +232,18 @@ async function handleLoadMore() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleCopyBatchPrompt(prompt) {
|
||||
async function handleCopyBatchPrompt(prompt) {
|
||||
if (!prompt?.trim()) {
|
||||
message.warning('没有提示词可复制')
|
||||
return
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(prompt).then(() => {
|
||||
const success = await copyToClipboard(prompt)
|
||||
if (success) {
|
||||
message.success('提示词已复制到剪贴板')
|
||||
}).catch(() => {
|
||||
} else {
|
||||
message.error('复制失败')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function handleUseBatchPrompt(prompt) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { useUserStore } from '@/stores/user'
|
||||
import GradientButton from '@/components/GradientButton.vue'
|
||||
import PromptSelector from '@/components/PromptSelector.vue'
|
||||
import { setJSON, getJSON } from '@/utils/storage'
|
||||
import { copyToClipboard } from '@/utils/clipboard'
|
||||
import BasicLayout from '@/layouts/components/BasicLayout.vue'
|
||||
|
||||
const promptStore = usePromptStore()
|
||||
@@ -328,48 +329,19 @@ function cancelEdit() {
|
||||
message.info('已取消编辑')
|
||||
}
|
||||
|
||||
// 复制内容(编辑模式复制编辑区,否则复制生成内容),带降级方案
|
||||
function copyContent() {
|
||||
// 复制内容(编辑模式复制编辑区,否则复制生成内容)
|
||||
async function copyContent() {
|
||||
const text = isEditMode.value ? (editableContent.value || '') : (generatedContent.value || '')
|
||||
if (!text.trim()) {
|
||||
message.warning('没有可复制的内容')
|
||||
return
|
||||
}
|
||||
|
||||
// 优先使用异步 Clipboard API
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
message.success('文案已复制到剪贴板')
|
||||
}).catch(() => {
|
||||
// 降级到选中复制
|
||||
fallbackCopy(text)
|
||||
})
|
||||
return
|
||||
}
|
||||
// 直接降级
|
||||
fallbackCopy(text)
|
||||
}
|
||||
|
||||
function fallbackCopy(text) {
|
||||
try {
|
||||
const textarea = document.createElement('textarea')
|
||||
textarea.value = text
|
||||
textarea.style.position = 'fixed'
|
||||
textarea.style.opacity = '0'
|
||||
textarea.style.left = '-9999px'
|
||||
document.body.appendChild(textarea)
|
||||
textarea.focus()
|
||||
textarea.select()
|
||||
const ok = document.execCommand('copy')
|
||||
document.body.removeChild(textarea)
|
||||
if (ok) {
|
||||
message.success('文案已复制到剪贴板')
|
||||
} else {
|
||||
message.error('复制失败,请手动复制')
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('fallback copy failed:', e)
|
||||
message.error('复制失败,请手动复制')
|
||||
const success = await copyToClipboard(text)
|
||||
if (success) {
|
||||
message.success('文案已复制到剪贴板')
|
||||
} else {
|
||||
message.error('复制失败')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user