diff --git a/data.go b/data.go index 7a6d7b1..ff0aa7a 100644 --- a/data.go +++ b/data.go @@ -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 "" @@ -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)