🎨 Add marketplace package config item minAppVersion https://github.com/siyuan-note/siyuan/issues/8330

This commit is contained in:
Daniel 2023-05-24 10:34:15 +08:00
parent d26bb04110
commit 7379ff1e27
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 57 additions and 13 deletions

View file

@ -30,6 +30,7 @@ import (
"github.com/siyuan-note/httpclient"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
"golang.org/x/mod/semver"
)
type Template struct {
@ -63,8 +64,15 @@ func Templates() (templates []*Template) {
logging.LogErrorf("get bazaar package [%s] failed: %d", innerU, innerResp.StatusCode)
return
}
template.URL = strings.TrimSuffix(template.URL, "/")
if "" == template.MinAppVersion {
template.MinAppVersion = defaultMinAppVersion
}
if 0 < semver.Compare("v"+template.MinAppVersion, "v"+util.Ver) {
return
}
template.URL = strings.TrimSuffix(template.URL, "/")
repoURLHash := strings.Split(repoURL, "@")
template.RepoURL = "https://github.com/" + repoURLHash[0]
template.RepoHash = repoURLHash[1]