refactor: Refactor the arguments of the Flag Operator

This commit is contained in:
Peng-YM 2022-07-06 18:06:49 +08:00
parent acd0a62496
commit a420c126c2
6 changed files with 20 additions and 13 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

@ -104,12 +104,12 @@ function QuickSettingOperator(args) {
}
// add or remove flag for proxies
function FlagOperator(add = true) {
function FlagOperator({ mode }) {
return {
name: 'Flag Operator',
func: (proxies) => {
return proxies.map((proxy) => {
if (!add) {
if (mode === 'remove') {
// no flag
proxy.name = removeFlag(proxy.name);
} else {

View File

@ -57,7 +57,7 @@ function doMigrationV2() {
// 5. delete builtin rules
delete $.cache.builtin;
$.info('Migration complete!');
$.info('Migration complete!');
function migrateDisplayName(item) {
const displayName = item['display-name'];
@ -110,6 +110,13 @@ function doMigrationV2() {
}
} else if (p.type.indexOf('Keyword') !== -1) {
// drop keyword operators and keyword filters
} else if (p.type === 'Flag Operator') {
// set default args
const add = typeof p.args === 'undefined' ? true : p.args;
p.args = {
mode: add ? 'add' : 'remove',
};
newProcesses.push(p);
} else {
newProcesses.push(p);
}

File diff suppressed because one or more lines are too long