🎨 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

@ -29,6 +29,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 Widget struct {
@ -63,8 +64,15 @@ func Widgets() (widgets []*Widget) {
logging.LogErrorf("get bazaar package [%s] failed: %d", innerU, innerResp.StatusCode)
return
}
widget.URL = strings.TrimSuffix(widget.URL, "/")
if "" == widget.MinAppVersion {
widget.MinAppVersion = defaultMinAppVersion
}
if 0 < semver.Compare("v"+widget.MinAppVersion, "v"+util.Ver) {
return
}
widget.URL = strings.TrimSuffix(widget.URL, "/")
repoURLHash := strings.Split(repoURL, "@")
widget.RepoURL = "https://github.com/" + repoURLHash[0]
widget.RepoHash = repoURLHash[1]