Merge pull request #679 from kingxjs/main

fix: use document to build input fix copy command
This commit is contained in:
Calcium-Ion
2024-12-30 18:02:21 +08:00
committed by GitHub

View File

@@ -49,8 +49,18 @@ export async function copy(text) {
try { try {
await navigator.clipboard.writeText(text); await navigator.clipboard.writeText(text);
} catch (e) { } catch (e) {
okay = false; try {
console.error(e); // 构建input 执行 复制命令
var _input = window.document.createElement("input");
_input.value = text;
window.document.body.appendChild(_input);
_input.select();
window.document.execCommand("Copy");
window.document.body.removeChild(_input);
} catch (e) {
okay = false;
console.error(e);
}
} }
return okay; return okay;
} }