区域过滤和协议过滤支持保留模式和过滤模式(后端需 >= 2.17.0, 前端需 >= 2.15.0)

This commit is contained in:
xream 2025-03-02 10:07:38 +08:00
parent 9426f128c4
commit ff1dacda87
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
2 changed files with 19 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.16.63",
"version": "2.17.0",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {

View File

@ -849,7 +849,12 @@ function UselessFilter() {
}
// filter by regions
function RegionFilter(regions) {
function RegionFilter(input) {
let regions = input?.value || input;
if (!Array.isArray(regions)) {
regions = [];
}
const keep = input?.keep ?? true;
const REGION_MAP = {
HK: '🇭🇰',
TW: '🇹🇼',
@ -866,7 +871,8 @@ function RegionFilter(regions) {
// this would be high memory usage
return proxies.map((proxy) => {
const flag = getFlag(proxy.name);
return regions.some((r) => REGION_MAP[r] === flag);
const selected = regions.some((r) => REGION_MAP[r] === flag);
return keep ? selected : !selected;
});
},
};
@ -898,11 +904,19 @@ function buildRegex(str, ...options) {
}
// filter by proxy types
function TypeFilter(types) {
function TypeFilter(input) {
let types = input?.value || input;
if (!Array.isArray(types)) {
types = [];
}
const keep = input?.keep ?? true;
return {
name: 'Type Filter',
func: (proxies) => {
return proxies.map((proxy) => types.some((t) => proxy.type === t));
return proxies.map((proxy) => {
const selected = types.some((t) => proxy.type === t);
return keep ? selected : !selected;
});
},
};
}