修复web后台HTTP环境下审批通过后剪切板无内容
navigator.clipboard.writeText 需要 HTTPS 安全上下文, HTTP 环境下静默失败。增加 textarea+execCommand 降级方案。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a0e5120c7d
commit
2fc03af75f
@ -216,7 +216,18 @@ async function handleApprove(result) {
|
||||
const text = buildProcurementText();
|
||||
if (text) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} else {
|
||||
const ta = document.createElement("textarea");
|
||||
ta.value = text;
|
||||
ta.style.position = "fixed";
|
||||
ta.style.left = "-9999px";
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(ta);
|
||||
}
|
||||
toast.success("采购信息已复制到剪切板");
|
||||
} catch (e) {
|
||||
console.warn("剪切板写入失败:", e);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user