From 10193ff17a2eca2c0553b8e407a2bbd578fccb50 Mon Sep 17 00:00:00 2001 From: Lan Date: Sat, 15 Mar 2025 22:56:43 +0800 Subject: [PATCH] fix: https://github.com/vastsa/FileCodeBox/issues/292 --- src/views/RetrievewFileView.vue | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/views/RetrievewFileView.vue b/src/views/RetrievewFileView.vue index 14fd7bc..564c916 100644 --- a/src/views/RetrievewFileView.vue +++ b/src/views/RetrievewFileView.vue @@ -266,6 +266,7 @@ import api from '@/utils/api' import { saveAs } from 'file-saver' import { marked } from 'marked' import { useAlertStore } from '@/stores/alertStore' +import { copyToClipboard } from '@/utils/clipboard' const alertStore = useAlertStore() const baseUrl = window.location.origin @@ -304,12 +305,10 @@ watch(code, (newVal) => { // 在其他代码后添加复制功能 const copyContent = async () => { if (selectedRecord.value && selectedRecord.value.content) { - try { - await navigator.clipboard.writeText(selectedRecord.value.content) - alertStore.showAlert('内容已复制到剪贴板', 'success') - } catch (err) { - alertStore.showAlert('复制失败,请重试', 'error') - } + await copyToClipboard(selectedRecord.value.content, { + successMsg: '内容已复制到剪贴板', + errorMsg: '复制失败,请重试' + }) } } const handleSubmit = async () => {