From 5b50e7ec27706e29c9552ec81f33eb98cd0fa9d7 Mon Sep 17 00:00:00 2001 From: v6ole Date: Wed, 24 Jun 2026 19:39:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20AI=20=E6=91=98=E8=A6=81=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=A4=B1=E8=B4=A5=20=E2=80=94=20HTTP=20=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=20Clipboard=20API=20=E4=B8=8D=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit navigator.clipboard 需要安全上下文(HTTPS/localhost), 内网 HTTP 部署时自动降级为 textarea + execCommand('copy') --- frontend/src/views/desktop/WeeklyReport.vue | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/desktop/WeeklyReport.vue b/frontend/src/views/desktop/WeeklyReport.vue index 1dab369..4d266fe 100644 --- a/frontend/src/views/desktop/WeeklyReport.vue +++ b/frontend/src/views/desktop/WeeklyReport.vue @@ -120,10 +120,21 @@ async function generateAISummary() { async function copySummary() { if (!aiSummary.value) return + const plain = aiSummary.value.replace(/^#{1,4}\s+/gm, '').replace(/\*\*/g, '').replace(/\*/g, '') try { - // Strip markdown markers for plain text - const plain = aiSummary.value.replace(/^#{1,4}\s+/gm, '').replace(/\*\*/g, '').replace(/\*/g, '') - await navigator.clipboard.writeText(plain) + // Prefer Clipboard API (requires HTTPS or localhost) + if (navigator.clipboard && window.isSecureContext) { + await navigator.clipboard.writeText(plain) + } else { + // Fallback for HTTP environments + const ta = document.createElement('textarea') + ta.value = plain + ta.style.position = 'fixed'; ta.style.left = '-9999px'; ta.style.top = '-9999px' + document.body.appendChild(ta) + ta.focus(); ta.select() + document.execCommand('copy') + document.body.removeChild(ta) + } ElMessage.success('摘要已复制到剪贴板') } catch { ElMessage.error('复制失败')