From 8a9bc1c3838c05e5c3a751fb2acf0ab66c3df58a Mon Sep 17 00:00:00 2001 From: xream Date: Sat, 24 Jan 2026 16:26:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8A=82=E7=82=B9=E5=8E=BB=E9=87=8D?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E5=AD=97=E5=BA=A6=E5=92=8C=20lodash?= =?UTF-8?q?=20get=20=E8=AF=AD=E6=B3=95(=E5=89=8D=E7=AB=AF=20>=3D=202.16.11?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- .../src/core/proxy-utils/processors/index.js | 34 +++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/backend/package.json b/backend/package.json index 9bdedfdd..12fceb64 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.21.14", + "version": "2.21.15", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/core/proxy-utils/processors/index.js b/backend/src/core/proxy-utils/processors/index.js index 9b04aa9f..4c386655 100644 --- a/backend/src/core/proxy-utils/processors/index.js +++ b/backend/src/core/proxy-utils/processors/index.js @@ -196,12 +196,13 @@ function FlagOperator({ mode, tw }) { // duplicate handler function HandleDuplicateOperator(arg) { - const { action, template, link, position } = { + const { action, template, link, position, field } = { ...{ action: 'rename', template: '0 1 2 3 4 5 6 7 8 9', link: '-', position: 'back', + field: ['name'], }, ...arg, }; @@ -211,10 +212,13 @@ function HandleDuplicateOperator(arg) { if (action === 'delete') { const chosen = {}; return proxies.filter((p) => { - if (chosen[p.name]) { + const key = field + .map((f) => lodash.get(p, f, '-')) + .join('_'); + if (chosen[key]) { return false; } - chosen[p.name] = true; + chosen[key] = true; return true; }); } else if (action === 'rename') { @@ -223,21 +227,23 @@ function HandleDuplicateOperator(arg) { const counter = {}; let maxLen = 0; proxies.forEach((p) => { - if (typeof counter[p.name] === 'undefined') - counter[p.name] = 1; - else counter[p.name]++; - maxLen = Math.max( - counter[p.name].toString().length, - maxLen, - ); + const key = field + .map((f) => lodash.get(p, f, '-')) + .join('_'); + if (typeof counter[key] === 'undefined') counter[key] = 1; + else counter[key]++; + maxLen = Math.max(counter[key].toString().length, maxLen); }); const increment = {}; return proxies.map((p) => { - if (counter[p.name] > 1) { - if (typeof increment[p.name] == 'undefined') - increment[p.name] = 1; + const key = field + .map((f) => lodash.get(p, f, '-')) + .join('_'); + if (counter[key] > 1) { + if (typeof increment[key] == 'undefined') + increment[key] = 1; let num = ''; - let cnt = increment[p.name]++; + let cnt = increment[key]++; let numDigits = 0; while (cnt > 0) { num = numbers[cnt % 10] + num;