From 1b2b158e73a2d4ac84b0b4d990d8a6d681557059 Mon Sep 17 00:00:00 2001 From: sakurai Date: Wed, 7 Jan 2026 19:47:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dissue=EF=BC=8CCOPY-01?= =?UTF-8?q?=09=E5=A4=8D=E5=88=B6=E7=9B=B4=E9=93=BE=E5=8A=9F=E8=83=BD=09FAI?= =?UTF-8?q?LED=09=E6=8E=A7=E5=88=B6=E5=8F=B0=E6=8A=A5=E9=94=99=EF=BC=9ACan?= =?UTF-8?q?not=20read=20properties=20of=20undefined=20(reading=20'writeTex?= =?UTF-8?q?t')=09=E5=89=AA=E8=B4=B4=E6=9D=BFAPI=E5=85=BC=E5=AE=B9=E6=80=A7?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=81=E6=94=B9=E8=BF=9B=E5=89=AA=E8=B4=B4?= =?UTF-8?q?=E6=9D=BF=E5=A4=8D=E5=88=B6=E5=8A=9F=E8=83=BD=E4=BB=A5=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=97=A7=E6=B5=8F=E8=A7=88=E5=99=A8=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9=E6=97=A7=E6=B5=8F=E8=A7=88=E5=99=A8=E7=9A=84?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=80=A7=E5=A4=84=E7=90=86=EF=BC=8C=E5=BD=93?= =?UTF-8?q?navigator.clipboard=E4=B8=8D=E5=8F=AF=E7=94=A8=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8document.execCommand=E4=BD=9C?= =?UTF-8?q?=E4=B8=BA=E5=A4=87=E9=80=89=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index eb1aa7e..bd3a1fd 100644 --- a/script.js +++ b/script.js @@ -298,7 +298,35 @@ function copyDirectLink(appId, fileName) { const directLink = `${API_BASE_URL}/apps/${appId}`; // 生成直链URL // 复制到剪贴板 - navigator.clipboard.writeText(directLink) + const copyToClipboard = (text) => { + if (navigator.clipboard && navigator.clipboard.writeText) { + return navigator.clipboard.writeText(text); + } else { + return new Promise((resolve, reject) => { + const textarea = document.createElement('textarea'); + textarea.value = text; + textarea.style.position = 'fixed'; + textarea.style.opacity = '0'; + document.body.appendChild(textarea); + textarea.select(); + + try { + const successful = document.execCommand('copy'); + document.body.removeChild(textarea); + if (successful) { + resolve(); + } else { + reject(new Error('复制命令执行失败')); + } + } catch (err) { + document.body.removeChild(textarea); + reject(err); + } + }); + } + }; + + copyToClipboard(directLink) .then(() => { // 显示复制成功提示 const message = document.createElement('div');