feat: 增加将订阅名称添加到节点名中的功能

feat: 增加地区模板变量
This commit is contained in:
2023-09-25 23:58:13 +08:00
parent 6a5cfd35c9
commit 6f075ea44e
5 changed files with 48 additions and 13 deletions

View File

@ -8,7 +8,7 @@ import (
"sub2clash/parser"
)
func GetContryName(proxy model.Proxy) string {
func GetContryName(countryKey string) string {
// 创建一个切片包含所有的国家映射
countryMaps := []map[string]string{
model.CountryFlag,
@ -25,7 +25,7 @@ func GetContryName(proxy model.Proxy) string {
splitChars := []string{"-", "_", " "}
key := make([]string, 0)
for _, splitChar := range splitChars {
slic := strings.Split(proxy.Name, splitChar)
slic := strings.Split(countryKey, splitChar)
for _, v := range slic {
if len(v) == 2 {
key = append(key, v)
@ -41,12 +41,11 @@ func GetContryName(proxy model.Proxy) string {
}
}
for k, v := range countryMap {
if strings.Contains(proxy.Name, k) {
if strings.Contains(countryKey, k) {
return v
}
}
}
return "其他地区"
}
@ -62,7 +61,7 @@ func AddProxy(
}
sub.Proxies = append(sub.Proxies, proxy)
haveProxyGroup := false
countryName := GetContryName(proxy)
countryName := GetContryName(proxy.Name)
for i := range sub.ProxyGroups {
group := &sub.ProxyGroups[i]