From 6fc0915117bcce10efa36d25f335d1440c38c4ee Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Sun, 28 Dec 2025 02:19:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=89=AA=E8=B4=B4=E6=9D=BF=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E4=BB=BB=E5=8A=A1=E7=8E=AF=E5=A2=83=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E6=94=AF=E6=8C=81=E8=AF=BB=E5=8F=96=E6=97=B6?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E6=89=8B=E5=8A=A8=E7=B2=98=E8=B4=B4=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/index.html | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/templates/index.html b/app/templates/index.html index 8513aff..fa1f646 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1303,25 +1303,23 @@ _this.showToast("任务参数已复制到剪贴板", "success"); }); }, - addTaskForClipboard() { - // 读取剪贴板内容 - navigator.clipboard.readText().then(text => { - if (text) { - try { - const task = JSON.parse(text); - task.addition = config_data.task_plugins_config_default;; - this.formData.tasklist.push(task); - this.showToast("剪贴板参数已成功导入任务", "success"); - } catch (error) { - this.showToast("剪贴板内容不是有效的任务参数", "error"); - console.error("解析剪贴板内容失败:", error); - return; - } + async addTaskForClipboard() { + text = null + try { + text = await navigator.clipboard.readText(); + } catch (error) { + text = prompt("当前环境不支持自动读取粘贴板,请手动粘贴任务参数", ""); + } + if (text) { + try { + const task = JSON.parse(text); + task.addition = config_data.task_plugins_config_default;; + this.formData.tasklist.push(task); + this.showToast("剪贴板参数已成功导入任务", "success"); + } catch (error) { + this.showToast("解析剪贴板内容失败", "error"); } - }).catch(err => { - this.showToast("读取剪贴板内容失败", "error"); - console.error("读取剪贴板内容失败:", err); - }); + } }, showToast(message, type = 'info', duration = 3000) { const id = Date.now();