Skip to content

Commit 8a9bc1c

Browse files
committed
feat: 节点去重支持多字度和 lodash get 语法(前端 >= 2.16.11)
1 parent 5cea099 commit 8a9bc1c

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.21.14",
3+
"version": "2.21.15",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/core/proxy-utils/processors/index.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,13 @@ function FlagOperator({ mode, tw }) {
196196

197197
// duplicate handler
198198
function HandleDuplicateOperator(arg) {
199-
const { action, template, link, position } = {
199+
const { action, template, link, position, field } = {
200200
...{
201201
action: 'rename',
202202
template: '0 1 2 3 4 5 6 7 8 9',
203203
link: '-',
204204
position: 'back',
205+
field: ['name'],
205206
},
206207
...arg,
207208
};
@@ -211,10 +212,13 @@ function HandleDuplicateOperator(arg) {
211212
if (action === 'delete') {
212213
const chosen = {};
213214
return proxies.filter((p) => {
214-
if (chosen[p.name]) {
215+
const key = field
216+
.map((f) => lodash.get(p, f, '-'))
217+
.join('_');
218+
if (chosen[key]) {
215219
return false;
216220
}
217-
chosen[p.name] = true;
221+
chosen[key] = true;
218222
return true;
219223
});
220224
} else if (action === 'rename') {
@@ -223,21 +227,23 @@ function HandleDuplicateOperator(arg) {
223227
const counter = {};
224228
let maxLen = 0;
225229
proxies.forEach((p) => {
226-
if (typeof counter[p.name] === 'undefined')
227-
counter[p.name] = 1;
228-
else counter[p.name]++;
229-
maxLen = Math.max(
230-
counter[p.name].toString().length,
231-
maxLen,
232-
);
230+
const key = field
231+
.map((f) => lodash.get(p, f, '-'))
232+
.join('_');
233+
if (typeof counter[key] === 'undefined') counter[key] = 1;
234+
else counter[key]++;
235+
maxLen = Math.max(counter[key].toString().length, maxLen);
233236
});
234237
const increment = {};
235238
return proxies.map((p) => {
236-
if (counter[p.name] > 1) {
237-
if (typeof increment[p.name] == 'undefined')
238-
increment[p.name] = 1;
239+
const key = field
240+
.map((f) => lodash.get(p, f, '-'))
241+
.join('_');
242+
if (counter[key] > 1) {
243+
if (typeof increment[key] == 'undefined')
244+
increment[key] = 1;
239245
let num = '';
240-
let cnt = increment[p.name]++;
246+
let cnt = increment[key]++;
241247
let numDigits = 0;
242248
while (cnt > 0) {
243249
num = numbers[cnt % 10] + num;

0 commit comments

Comments
 (0)