From 3455839213a5d074584475f6bdd627e22c06cc69 Mon Sep 17 00:00:00 2001 From: wonder Date: Sun, 21 Jun 2026 15:49:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A6=E5=8F=B3=E4=B8=A4=E6=A0=8F?= =?UTF-8?q?=E5=AE=9E=E6=97=B6=E6=B8=B2=E6=9F=93=E3=80=81=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20HTTP=20=E7=8E=AF=E5=A2=83=E5=A4=8D=E5=88=B6=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 生成过程中两栏布局始终可见,结构化字段实时更新 - 流式阶段显示在两栏上方,完成后仅隐藏流式指示器 - 复制功能增加 navigator.clipboard 存在性检查 - HTTP 环境降级为 textarea + execCommand fallback --- templates/pages/generate.html | 47 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/templates/pages/generate.html b/templates/pages/generate.html index 64af0b5..394d7bc 100644 --- a/templates/pages/generate.html +++ b/templates/pages/generate.html @@ -217,7 +217,6 @@ btn.textContent = '生成中...'; btn.classList.add('opacity-70', 'cursor-not-allowed'); output.classList.remove('hidden'); - outputContent.classList.add('hidden'); streaming.classList.remove('hidden'); document.getElementById('streaming-text').textContent = ''; document.getElementById('streaming-status').textContent = ''; @@ -281,9 +280,8 @@ // Assemble full markdown from structured fields markdownContent = buildMarkdown(fields); document.getElementById('pr-markdown').textContent = markdownContent; - // Switch from streaming to structured display + // Hide streaming indicator; columns already visible streaming.classList.add('hidden'); - outputContent.classList.remove('hidden'); btn.disabled = false; btn.textContent = '生成 PR 描述'; btn.classList.remove('opacity-70', 'cursor-not-allowed'); @@ -291,7 +289,6 @@ error(data) { showToast('生成失败: ' + (data.message || '未知错误'), 'error'); streaming.classList.add('hidden'); - output.classList.add('hidden'); btn.disabled = false; btn.textContent = '生成 PR 描述'; btn.classList.remove('opacity-70', 'cursor-not-allowed'); @@ -320,24 +317,32 @@ showToast('没有可复制的内容,请先生成 PR 描述', 'warning'); return; } - navigator.clipboard.writeText(markdown).then(() => { - showToast('已复制到剪贴板', 'success'); - }).catch(() => { - // Fallback for non-HTTPS or permission-denied contexts - const textarea = document.createElement('textarea'); - textarea.value = markdown; - textarea.style.position = 'fixed'; - textarea.style.opacity = '0'; - document.body.appendChild(textarea); - textarea.select(); - try { - document.execCommand('copy'); + // Clipboard API requires HTTPS; fallback to textarea for HTTP + if (navigator.clipboard && navigator.clipboard.writeText) { + navigator.clipboard.writeText(markdown).then(() => { showToast('已复制到剪贴板', 'success'); - } catch (e) { - showToast('复制失败,请手动选择文本复制', 'error'); - } - document.body.removeChild(textarea); - }); + }).catch(() => { + fallbackCopy(markdown); + }); + } else { + fallbackCopy(markdown); + } + } + + function fallbackCopy(text) { + const textarea = document.createElement('textarea'); + textarea.value = text; + textarea.style.cssText = 'position:fixed;left:0;top:0;opacity:0;'; + document.body.appendChild(textarea); + textarea.focus(); + textarea.select(); + try { + const ok = document.execCommand('copy'); + showToast(ok ? '已复制到剪贴板' : '复制失败,请手动选择文本复制', ok ? 'success' : 'error'); + } catch (e) { + showToast('复制失败,请手动选择文本复制', 'error'); + } + document.body.removeChild(textarea); } loadRefs();