From e4f9787c16c2af82492aa8d3c91f4465f23139e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=B7=E7=B3=8A=E8=99=AB?= Date: Mon, 30 Dec 2024 17:13:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=8E=9F=E7=94=9Fdocument?= =?UTF-8?q?=E6=9E=84=E5=BB=BAinput=E5=86=8D=E6=AC=A1=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/helpers/utils.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/web/src/helpers/utils.js b/web/src/helpers/utils.js index a216eacc..a40b2079 100644 --- a/web/src/helpers/utils.js +++ b/web/src/helpers/utils.js @@ -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; }