mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-25 01:14:42 -05:00
8d06ab3175
fix: 修复当订阅链接有多个 clash 配置时丢失节点的问题 update: 增加检测更新 modify: 修改数据库路径 modify: 修改短链生成逻辑 modify: 统一输出信息
34 lines
702 B
Go
34 lines
702 B
Go
package utils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"io"
|
|
"sub2clash/config"
|
|
"sub2clash/model"
|
|
)
|
|
|
|
func CheckUpdate() (bool, string, error) {
|
|
get, err := Get("https://api.github.com/repos/nitezs/sub2clash/tags")
|
|
if err != nil {
|
|
return false, "", errors.New("get version info failed" + err.Error())
|
|
|
|
}
|
|
var version model.Tags
|
|
all, err := io.ReadAll(get.Body)
|
|
if err != nil {
|
|
return false, "", errors.New("get version info failed" + err.Error())
|
|
|
|
}
|
|
err = json.Unmarshal(all, &version)
|
|
if err != nil {
|
|
return false, "", errors.New("get version info failed" + err.Error())
|
|
|
|
}
|
|
if version[0].Name == config.Version {
|
|
return false, "", nil
|
|
} else {
|
|
return true, version[0].Name, nil
|
|
}
|
|
}
|