Lan
2025-03-15 22:56:43 +08:00
parent 6e11f03a12
commit 10193ff17a
+5 -6
View File
@@ -266,6 +266,7 @@ import api from '@/utils/api'
import { saveAs } from 'file-saver' import { saveAs } from 'file-saver'
import { marked } from 'marked' import { marked } from 'marked'
import { useAlertStore } from '@/stores/alertStore' import { useAlertStore } from '@/stores/alertStore'
import { copyToClipboard } from '@/utils/clipboard'
const alertStore = useAlertStore() const alertStore = useAlertStore()
const baseUrl = window.location.origin const baseUrl = window.location.origin
@@ -304,12 +305,10 @@ watch(code, (newVal) => {
// 在其他代码后添加复制功能 // 在其他代码后添加复制功能
const copyContent = async () => { const copyContent = async () => {
if (selectedRecord.value && selectedRecord.value.content) { if (selectedRecord.value && selectedRecord.value.content) {
try { await copyToClipboard(selectedRecord.value.content, {
await navigator.clipboard.writeText(selectedRecord.value.content) successMsg: '内容已复制到剪贴板',
alertStore.showAlert('内容已复制到剪贴板', 'success') errorMsg: '复制失败,请重试'
} catch (err) { })
alertStore.showAlert('复制失败,请重试', 'error')
}
} }
} }
const handleSubmit = async () => { const handleSubmit = async () => {