fix: 完善移动端订阅生成并同步分流配置文档

This commit is contained in:
2026-10-04 12:11:40 +08:00
parent 349ab8329e
commit 812d8a9441
25 changed files with 791 additions and 67 deletions

View File

@@ -44,7 +44,7 @@ function shadowrocketGeneral(surgeGeneral: string): string {
return lines.join('\n');
}
/** ShadowRocket 不认识的规则类型 */
/** 尚未验证 Shadowrocket 配置语法的类型;这是生成器的保守范围,不是客户端能力断言。 */
const SR_UNSUPPORTED_RULE_TYPES = new Set(['DOMAIN-SET', 'AND', 'OR', 'NOT', 'URL-REGEX', 'PROTOCOL']);
export interface ShadowrocketConfOutput {
@@ -70,14 +70,12 @@ export function generateShadowrocketConf(ir: ProfileIR): ShadowrocketConfOutput
lines.push('', '[Proxy Group]');
for (const g of ir.groups) {
const parts: string[] = [g.type];
if (!g.filterRegex && !g.includeAllNodes) {
const members = g.members.map((m) => policyName(m.name));
parts.push(...(members.length ? members : ['DIRECT']));
}
const members = [...new Set(g.members.map((m) => policyName(m.name)))];
parts.push(...(members.length ? members : !g.filterRegex && !g.includeAllNodes ? ['DIRECT'] : []));
if (g.type !== 'select') {
parts.push(`url=${g.testUrl || 'http://cp.cloudflare.com/generate_204'}`);
if (g.interval) parts.push(`interval=${g.interval}`);
if (g.tolerance) parts.push(`tolerance=${g.tolerance}`);
if (g.type === 'url-test' && g.tolerance !== null) parts.push(`tolerance=${g.tolerance}`);
}
// policy-regex-filter 从 App 内全部节点里筛选;「收纳全部节点」用全匹配正则
if (g.filterRegex) parts.push(`policy-regex-filter=${g.filterRegex}`);