mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 11:42:21 +08:00
feat: reduce the impact of the enhanced mode
This commit is contained in:
parent
b8b0c8fa63
commit
7fe94076c7
|
@ -101,6 +101,8 @@ class Enhance {
|
||||||
const payload = event.payload as CmdType.EnhancedPayload;
|
const payload = event.payload as CmdType.EnhancedPayload;
|
||||||
let pdata = payload.current || {};
|
let pdata = payload.current || {};
|
||||||
|
|
||||||
|
let hasScript = false;
|
||||||
|
|
||||||
for (const each of payload.chain) {
|
for (const each of payload.chain) {
|
||||||
const { uid, type = "" } = each.item;
|
const { uid, type = "" } = each.item;
|
||||||
|
|
||||||
|
@ -109,6 +111,7 @@ class Enhance {
|
||||||
if (type === "script") {
|
if (type === "script") {
|
||||||
// support async main function
|
// support async main function
|
||||||
pdata = await toScript(each.script!, { ...pdata });
|
pdata = await toScript(each.script!, { ...pdata });
|
||||||
|
hasScript = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// process merge
|
// process merge
|
||||||
|
@ -132,6 +135,29 @@ class Enhance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If script is never used
|
||||||
|
// filter other fields
|
||||||
|
if (!hasScript) {
|
||||||
|
const validKeys = [
|
||||||
|
"proxies",
|
||||||
|
"proxy-providers",
|
||||||
|
"proxy-groups",
|
||||||
|
"rule-providers",
|
||||||
|
"rules",
|
||||||
|
];
|
||||||
|
|
||||||
|
// to lowercase
|
||||||
|
const newData: any = {};
|
||||||
|
Object.keys(pdata).forEach((key) => {
|
||||||
|
const newKey = key.toLowerCase();
|
||||||
|
if (validKeys.includes(newKey)) {
|
||||||
|
newData[newKey] = (pdata as any)[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pdata = newData;
|
||||||
|
}
|
||||||
|
|
||||||
const result = { data: pdata, status: "ok" };
|
const result = { data: pdata, status: "ok" };
|
||||||
emit(payload.callback, JSON.stringify(result)).catch(console.error);
|
emit(payload.callback, JSON.stringify(result)).catch(console.error);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user