feat: ProxyUtils.produce 增加第二个参数 type, 暂时仅支持目标为 ClashMetainternal 输出节点数组供开发者使用

This commit is contained in:
xream
2023-12-05 21:51:43 +08:00
parent 75f802f607
commit 6d11ea0fcc
3 changed files with 131 additions and 131 deletions

View File

@@ -139,7 +139,7 @@ async function process(proxies, operators = [], targetPlatform, source) {
return proxies;
}
function produce(proxies, targetPlatform) {
function produce(proxies, targetPlatform, type) {
const producer = PROXY_PRODUCERS[targetPlatform];
if (!producer) {
throw new Error(`Target platform: ${targetPlatform} is not supported!`);
@@ -157,7 +157,7 @@ function produce(proxies, targetPlatform) {
return proxies
.map((proxy) => {
try {
let line = producer.produce(proxy);
let line = producer.produce(proxy, type);
if (
line.length > 0 &&
line.includes('__SubStoreLocalPort__')
@@ -182,7 +182,7 @@ function produce(proxies, targetPlatform) {
.filter((line) => line.length > 0)
.join('\n');
} else if (producer.type === 'ALL') {
return producer.produce(proxies);
return producer.produce(proxies, type);
}
}