fix: 剪贴板导入任务环境兼容,不支持读取时提供手动粘贴框

This commit is contained in:
Cp0204 2025-12-28 02:19:11 +08:00
parent 000618ac5e
commit 6fc0915117

View File

@ -1303,25 +1303,23 @@
_this.showToast("任务参数已复制到剪贴板", "success"); _this.showToast("任务参数已复制到剪贴板", "success");
}); });
}, },
addTaskForClipboard() { async addTaskForClipboard() {
// 读取剪贴板内容 text = null
navigator.clipboard.readText().then(text => { try {
if (text) { text = await navigator.clipboard.readText();
try { } catch (error) {
const task = JSON.parse(text); text = prompt("当前环境不支持自动读取粘贴板,请手动粘贴任务参数", "");
task.addition = config_data.task_plugins_config_default;; }
this.formData.tasklist.push(task); if (text) {
this.showToast("剪贴板参数已成功导入任务", "success"); try {
} catch (error) { const task = JSON.parse(text);
this.showToast("剪贴板内容不是有效的任务参数", "error"); task.addition = config_data.task_plugins_config_default;;
console.error("解析剪贴板内容失败:", error); this.formData.tasklist.push(task);
return; this.showToast("剪贴板参数已成功导入任务", "success");
} } catch (error) {
this.showToast("解析剪贴板内容失败", "error");
} }
}).catch(err => { }
this.showToast("读取剪贴板内容失败", "error");
console.error("读取剪贴板内容失败:", err);
});
}, },
showToast(message, type = 'info', duration = 3000) { showToast(message, type = 'info', duration = 3000) {
const id = Date.now(); const id = Date.now();