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();