From ea81c69c7d8f73b822e872323b769ed58492951d Mon Sep 17 00:00:00 2001 From: yan Date: Fri, 23 Jan 2026 11:29:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor(FullyAutoAndSemiAutoTools):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=94=AE=E5=80=BC=E7=94=9F=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 generatedKey 函数支持 useParent 参数控制键值生成方式 - 优先处理 rootName->parentName->name 格式的键值生成 - 添加 useParent 模式下的父级键值生成逻辑 - 在 groupByParentAndName 函数中同时生成普通键值和父级键值 - 为每个项目创建两套分组键值以支持不同层级的分组需求 --- repo/js/FullyAutoAndSemiAutoTools/main.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/repo/js/FullyAutoAndSemiAutoTools/main.js b/repo/js/FullyAutoAndSemiAutoTools/main.js index ab16c8df6..4f396a767 100644 --- a/repo/js/FullyAutoAndSemiAutoTools/main.js +++ b/repo/js/FullyAutoAndSemiAutoTools/main.js @@ -699,25 +699,32 @@ async function initRun(config_run) { // const {label} = multiCheckboxMap.get(settingsName); // const as_name = getBracketContent(label)//父名称 如:晶蝶 - function generatedKey(item) { + function generatedKey(item, useParent = false) { const separator = "->"; - if (item.parentName) { - if (item.rootName && item.parentName !== item.rootName) { - return `${item.rootName}${separator}${item.parentName}${separator}${item.name}`; - } + // 优先处理 rootName->parentName->name 格式的情况 + if (!useParent && item.rootName && item.parentName && item.parentName !== item.rootName && item.rootName !== "") { + return `${item.rootName}${separator}${item.parentName}${separator}${item.name}`; + } + // 然后处理 useParent 或 parentName 存在的情况 + if (useParent || item.parentName) { return `${item.parentName}${separator}${item.name}`; } + // 默认返回 name return item.name; } + function groupByParentAndName(list) { const map = new Map(); list.forEach(item => { // const key = `${item.parentName}->${item.name}`; const key = generatedKey(item); + const key_parent = generatedKey(item, true); if (!map.has(key)) map.set(key, []); map.get(key).push(item); + if (!map.has(key_parent)) map.set(key_parent, []); + map.get(key_parent).push(item); }); return Array.from(map.values()); // 转成二维数组 [[], []]