fix: QuickSettingOperator does not respect default settings

This commit is contained in:
Peng-YM 2022-07-05 15:36:20 +08:00
parent b2a797cd25
commit 7468089f04
3 changed files with 13 additions and 10 deletions

View File

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

View File

@ -8,31 +8,34 @@ function QuickSettingOperator(args) {
return {
name: 'Quick Setting Operator',
func: (proxies) => {
if (convert(args.useless)) {
if (get(args.useless)) {
const filter = UselessFilter();
proxies = filter.func(proxies);
}
return proxies.map((proxy) => {
proxy.udp = convert(args.udp);
proxy.tfo = convert(args.tfo);
proxy['skip-cert-verify'] = convert(args.scert);
proxy.udp = get(args.udp, proxy.udp);
proxy.tfo = get(args.tfo, proxy.tfo);
proxy['skip-cert-verify'] = get(
args.scert,
proxy['skip-cert-verify'],
);
if (proxy.type === 'vmess') {
proxy.aead = convert(args['vmess aead']);
proxy.aead = get(args['vmess aead'], proxy.aead);
}
return proxy;
});
},
};
function convert(value) {
function get(value, defaultValue) {
switch (value) {
case 'ENABLED':
return true;
case 'DISABLED':
return false;
default:
return undefined;
return defaultValue;
}
}
}

View File

@ -3,8 +3,8 @@ import $ from '@/core/app';
import { success } from '@/restful/response';
export default function register($app) {
$app.post('/api/sort/sub', sortSubs);
$app.post('/api/sort/collection', sortCollections);
$app.post('/api/sort/subs', sortSubs);
$app.post('/api/sort/collections', sortCollections);
$app.post('/api/sort/artifacts', sortArtifacts);
}