Skip to content

Commit

Permalink
Merge pull request #679 from kingxjs/main
Browse files Browse the repository at this point in the history
fix: use document to build input fix copy command
  • Loading branch information
Calcium-Ion authored Dec 30, 2024
2 parents 1ae0a3f + e4f9787 commit 65af1a4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions web/src/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ export async function copy(text) {
try {
await navigator.clipboard.writeText(text);
} catch (e) {
okay = false;
console.error(e);
try {
// 构建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;
}
Expand Down

0 comments on commit 65af1a4

Please sign in to comment.