- 生成过程中两栏布局始终可见,结构化字段实时更新 - 流式阶段显示在两栏上方,完成后仅隐藏流式指示器 - 复制功能增加 navigator.clipboard 存在性检查 - HTTP 环境降级为 textarea + execCommand fallback
This commit is contained in:
@@ -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;
|
||||
}
|
||||
// Clipboard API requires HTTPS; fallback to textarea for HTTP
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(markdown).then(() => {
|
||||
showToast('已复制到剪贴板', 'success');
|
||||
}).catch(() => {
|
||||
// Fallback for non-HTTPS or permission-denied contexts
|
||||
fallbackCopy(markdown);
|
||||
});
|
||||
} else {
|
||||
fallbackCopy(markdown);
|
||||
}
|
||||
}
|
||||
|
||||
function fallbackCopy(text) {
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = markdown;
|
||||
textarea.style.position = 'fixed';
|
||||
textarea.style.opacity = '0';
|
||||
textarea.value = text;
|
||||
textarea.style.cssText = 'position:fixed;left:0;top:0;opacity:0;';
|
||||
document.body.appendChild(textarea);
|
||||
textarea.focus();
|
||||
textarea.select();
|
||||
try {
|
||||
document.execCommand('copy');
|
||||
showToast('已复制到剪贴板', 'success');
|
||||
const ok = document.execCommand('copy');
|
||||
showToast(ok ? '已复制到剪贴板' : '复制失败,请手动选择文本复制', ok ? 'success' : 'error');
|
||||
} catch (e) {
|
||||
showToast('复制失败,请手动选择文本复制', 'error');
|
||||
}
|
||||
document.body.removeChild(textarea);
|
||||
});
|
||||
}
|
||||
|
||||
loadRefs();
|
||||
|
||||
Reference in New Issue
Block a user