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('复制失败')