From 9e717f1b69f055c2bbe03bb633765187ba5b232d Mon Sep 17 00:00:00 2001 From: x1ao4 Date: Mon, 15 Sep 2025 01:38:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8E=92=E5=BA=8F=E5=AF=BC=E8=87=B4=E7=9A=84=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=BB=BB=E5=8A=A1=E5=AE=9A=E4=BD=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复 addTask 函数中的任务定位逻辑,使用临时标识来准确定位新任务 - 解决非编号排序时新增任务后展开错误编辑模块的问题 - 确保无论使用何种排序方式,新增任务后都能正确定位到新任务的配置区域 - 保持向后兼容,不影响现有排序和编辑功能 问题:任务列表使用非编号排序时,点击添加任务后展开的是排在最后的任务而不是新添加的任务 解决:通过临时标识和排序后列表查找,确保始终展开新添加的任务 --- app/templates/index.html | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/templates/index.html b/app/templates/index.html index f45086b..8610c9b 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -6915,8 +6915,10 @@ // 应用全局插件配置到新任务 this.applyGlobalPluginConfig(newTask); + // 给新任务添加临时标识,用于后续定位 + newTask.__isNewlyAdded = true; this.formData.tasklist.push(newTask) - const index = this.formData.tasklist.length - 1; + const originalIndex = this.formData.tasklist.length - 1; // 清除之前任务的搜索记录,避免影响新任务 this.smart_param.taskSuggestions = { @@ -6926,9 +6928,16 @@ // 等Vue更新DOM后,自动展开新添加的任务 this.$nextTick(() => { - $(`#collapse_${index}`).collapse('show'); - // 滚动到底部 - this.scrollToX(); + // 找到新任务在排序后列表中的位置 + const sortedIndex = this.sortedTasklist.findIndex(task => task.__isNewlyAdded); + if (sortedIndex !== -1) { + // 展开新任务的编辑模块 + $(`#collapse_${sortedIndex}`).collapse('show'); + // 滚动到新任务位置 + this.scrollToX(); + // 移除临时标识 + delete newTask.__isNewlyAdded; + } }); }, focusTaskname(index, task) {