Skip to content

Commit

Permalink
优化汉化补丁下载
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Feb 28, 2022
1 parent 31ab2ce commit 74e8ea7
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions data.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,20 @@ func transDownloadUrl() string {
if transWay == "" {
return ""
}
exchange := func() {
if transWay == "BoyceLig/Clash_Chinese_Patch" {
transWay = "ender-zhao/Clash-for-Windows_Chinese"
} else {
transWay = "BoyceLig/Clash_Chinese_Patch"
}
}
tagMap := make(map[string]string)
tagMap["BoyceLig/Clash_Chinese_Patch"] = cfwVersion
tagMap["ender-zhao/Clash-for-Windows_Chinese"] = fmt.Sprintf("CFW-V%s_CN", cfwVersion)
fmt.Println(fmt.Sprintf("正在获取%s的%s版本汉化包...", transWay, cfwVersion))
if cfwVersion == cfwVersionList[0] && webSearch(fmt.Sprintf("https://github.com/%s/tags", transWay), cfwVersion) == "" {
fmt.Println(fmt.Sprintf("%s的%s汉化补丁尚未发布, 正在切换到另一种汉化补丁..", transWay, cfwVersion))
if transWay == "BoyceLig/Clash_Chinese_Patch" {
transWay = "ender-zhao/Clash-for-Windows_Chinese"
} else {
transWay = "BoyceLig/Clash_Chinese_Patch"
}
exchange()
if webSearch(fmt.Sprintf("https://github.com/%s/tags", transWay), cfwVersion) == "" {
fmt.Println(fmt.Sprintf("%s的汉化补丁尚未发布, 若要汉化等后续补丁发布后重新运行工具来更新即可\n", cfwVersion))
return ""
Expand All @@ -136,8 +139,14 @@ func transDownloadUrl() string {
keyName := webFirstMatchKey(fmt.Sprintf("https://github.com/%s/releases/tag/%s", transWay, tagMap[transWay]),
path.Join(tagMap[transWay], "app.7z"), path.Join(tagMap[transWay], "app.asar"))
if keyName == "" {
fmt.Println(fmt.Sprintf("%s的翻译包不存在\n", transWay))
return ""
fmt.Println(fmt.Sprintf("%s的%s汉化补丁不存在, 正在切换到另一种汉化补丁..", transWay, cfwVersion))
exchange()
keyName = webFirstMatchKey(fmt.Sprintf("https://github.com/%s/releases/tag/%s", transWay, tagMap[transWay]),
path.Join(tagMap[transWay], "app.7z"), path.Join(tagMap[transWay], "app.asar"))
if keyName == "" {
fmt.Println(fmt.Sprintf("%s版本的汉化补丁不存在\n", cfwVersion))
return ""
}
}
updateTrans = true
return fmt.Sprintf("https://github.com/%s/releases/download/%s", transWay, keyName)
Expand Down

0 comments on commit 74e8ea7

Please sign in to comment.