From a52f8e0976c2e59cd185ffb3d44da3feaa01e81b Mon Sep 17 00:00:00 2001 From: sight <1453017105@qq.com> Date: Fri, 3 Nov 2023 06:44:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20`lay.clipboard.writeText`?= =?UTF-8?q?=EF=BC=8C=E6=B2=A1=E6=9C=89=E5=89=AA=E8=B4=B4=E6=9D=BF=E5=86=99?= =?UTF-8?q?=E5=85=A5=E6=9D=83=E9=99=90=E6=97=B6=E4=BD=BF=E7=94=A8=20legacy?= =?UTF-8?q?=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/lay.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/modules/lay.js b/src/modules/lay.js index 4339217d..33ffd829 100644 --- a/src/modules/lay.js +++ b/src/modules/lay.js @@ -468,11 +468,16 @@ writeText: function(options) { var text = String(options.text); - try { - navigator.clipboard.writeText(text).then( - options.done - )['catch'](options.error); - } catch(e) { + if(navigator && 'clipboard' in navigator){ + navigator.clipboard.writeText(text) + .then(options.done, function(){ + legacyCopy(); + }); + }else{ + legacyCopy(); + } + + function legacyCopy(){ var elem = document.createElement('textarea'); elem.value = text;