surgioproject / surgio

Generating rules for Surge, Clash, Quantumult like a PRO
https://surgio.js.org
MIT License
1.6k stars 141 forks source link

生成clash配置中的代理格式化方式选功能,是否有相应的选择器可选 #189

Open fbigun opened 2 years ago

fbigun commented 2 years ago

我的clash模板相应片段

proxies: {{ getClashNodes(nodeList) | json }}

选择yaml,结果有异常。

proxies: {{ getClashNodes(nodeList) | yaml }}

默认生成clash配置文件的的代理格式化形式为

proxies: [{"type":"ss","cipher":"chacha20-ietf-poly1305","name":"🇭🇰HKG ********","password":"9e35519d-c736-4f4f-809f-09b8776a6518","port":21001,"server":"***************","udp":true},{"type":"ss","cipher":"chacha20-ietf-poly1305","name":"🇭🇰HKG CM.B ******","password":"9e35519d-c736-4f4f-809f-09b8776a6518","port":21001,"server":"******","udp":true},{"type":"ss","cipher":"chacha20-ietf-poly1305","name":"🇭🇰HKG CM.C/01 x0.3","password":"9e35519d-c736-4f4f-809f-09b8776a6518","port":21001,"server":"******","udp":true},{"type":"ss","cipher":"chacha20-ietf-poly1305","name":"🇭🇰HKG CN2/01 x0.3","password":"9e35519d-c736-4f4f-809f-09b8776a6518","port":21001,"server":"******","udp":true}]

有没有有格式化为这种的

proxies:
- {"type":"ss","cipher":"chacha20-ietf-poly1305","name":"🇭🇰HKG CM.A HKBN******","password":"9e35519d-c736-4f4f-809f-09b8776a6518","port":21001,"server":"******","udp":true}
- {"type":"ss","cipher":"chacha20-ietf-poly1305","name":"🇭🇰HKG CM.B HKBN******","password":"9e35519d-c736-4f4f-809f-09b8776a6518","port":21001,"server":"******","udp":true}
- {"type":"ss","cipher":"chacha20-ietf-poly1305","name":"🇭🇰HKG CM.C/01 x0.3","password":"9e35519d-c736-4f4f-809f-09b8776a6518","port":21001,"server":"******","udp":true}
- {"type":"ss","cipher":"chacha20-ietf-poly1305","name":"🇭🇰HKG CN2/01 x0.3","password":"9e35519d-c736-4f4f-809f-09b8776a6518","port":21001,"server":"******","udp":true}
geekdada commented 2 years ago

因为你指出的这种各式存在缩进的问题,所以我采用了写在一行里的形式。这里不可以使用 yaml。请问为什么要格式化成后面这种各式?

fbigun commented 2 years ago

前一种方式不便于查看配置问题,在部分编辑器打开时也容易完成编辑器卡顿。 主要的优点在于 1 查看配置节点清晰 2 编辑器打开速度快

geekdada commented 2 years ago

一开始我的考虑是订阅一般不存在二次编辑的情况,因为编辑会在下次刷新订阅时丢失。我再考虑一下有没有更好的办法支持这个格式。

miniers commented 2 years ago

把 | json 替换为 | dump(4) 就可以了

fbigun commented 2 years ago

把 | json 替换为 | dump(4) 就可以了

你说的这个方法实际上一些情况下,基本无法使用

miniers commented 2 years ago

把 | json 替换为 | dump(4) 就可以了

你说的这个方法实际上一些情况下,基本无法使用

需求不同吧,暂时对我来说还算可用,你可以等等大佬的优化,或者可以使用自定义函数自己实现输出也是可以的

joeblowout commented 2 years ago

同求,我也发现自建节点用你说的方法输出来的clash.yaml不能导入到clash for android, windows 没问题

把 | json 替换为 | dump(4) 就可以了

你说的这个方法实际上一些情况下,基本无法使用

fbigun commented 4 months ago

没有办法可以改进