From 2b0f5bc7c7de4cf9f1381a5e868e51f3b971b5ee Mon Sep 17 00:00:00 2001 From: mengyxu Date: Sat, 17 May 2025 20:31:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A4=8D=E5=88=B6=E5=AD=98?= =?UTF-8?q?=E6=A1=A3=E5=A4=B1=E8=B4=A5BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/archive.vue | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/views/archive.vue b/src/views/archive.vue index bf5cd77..dc56177 100644 --- a/src/views/archive.vue +++ b/src/views/archive.vue @@ -47,12 +47,23 @@ const showMenu = () => { } const copyArchive = () => { - navigator.clipboard.writeText(archive.value).then(() => { + if (navigator.clipboard && window.isSecureContext) { + navigator.clipboard.writeText(archive.value).then(() => { + commit('set_sys_info', { msg: t('copyArchive.1'), type: 'win' }) + showMenu(); + }).catch(() => { + commit('set_sys_info', { msg: t('copyArchive.2'), type: 'waring' }) + }); + } else { + const textField = document.createElement("textarea"); + textField.innerText = archive.value; + document.body.appendChild(textField); + textField.select(); + document.execCommand("copy"); + textField.remove(); commit('set_sys_info', { msg: t('copyArchive.1'), type: 'win' }) - }, () => { - commit('set_sys_info', { msg: t('copyArchive.2'), type: 'waring' }) - }); - showMenu(); + showMenu(); + } } const pasteArchive = () => {