Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

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

Daniel7379ff1e278c
diff --git a/kernel/bazaar/icon.go b/kernel/bazaar/icon.go
index 88cf3d1981..07115ed8e2 100644
--- a/kernel/bazaar/icon.go
+++ b/kernel/bazaar/icon.go
@@ -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 Icon struct {
@@ -62,8 +63,15 @@ func Icons() (icons []*Icon) {
logging.LogErrorf("get bazaar package [%s] failed: %d", innerU, innerResp.StatusCode)
return
}
- icon.URL = strings.TrimSuffix(icon.URL, "/")
+ if "" == icon.MinAppVersion {
+ icon.MinAppVersion = defaultMinAppVersion
+ }
+ if 0 < semver.Compare("v"+icon.MinAppVersion, "v"+util.Ver) {
+ return
+ }
+
+ icon.URL = strings.TrimSuffix(icon.URL, "/")
repoURLHash := strings.Split(repoURL, "@")
icon.RepoURL = "https://github.com/" + repoURLHash[0]
icon.RepoHash = repoURLHash[1]
diff --git a/kernel/bazaar/package.go b/kernel/bazaar/package.go
index 44f5a10cf0..ed00d6a64d 100644
--- a/kernel/bazaar/package.go
+++ b/kernel/bazaar/package.go
@@ -64,14 +64,14 @@ type Funding struct {
}
type Package struct {
- Author string `json:"author"`
- URL string `json:"url"`
- Version string `json:"version"`
- DisplayName *DisplayName `json:"displayName"`
- Description *Description `json:"description"`
- Readme *Readme `json:"readme"`
- Funding *Funding `json:"funding"`
- I18N []string `json:"i18n"`
+ Author string `json:"author"`
+ URL string `json:"url"`
+ Version string `json:"version"`
+ MinAppVersion string `json:"minAppVersion"`
+ DisplayName *DisplayName `json:"displayName"`
+ Description *Description `json:"description"`
+ Readme *Readme `json:"readme"`
+ Funding *Funding `json:"funding"`
PreferredFunding string `json:"preferredFunding"`
PreferredName string `json:"preferredName"`
@@ -649,3 +649,7 @@ func getBazaarIndex() map[string]*bazaarPackage {
bazaarIndexCacheTime = now
return cachedBazaarIndex
}
+
+// defaultMinAppVersion 如果集市包中缺失 minAppVersion 项,则使用该值作为最低支持的版本号,小于该版本号时不显示集市包
+// Add marketplace package config item `minAppVersion` https://github.com/siyuan-note/siyuan/issues/8330
+const defaultMinAppVersion = "2.9.0"
diff --git a/kernel/bazaar/plugin.go b/kernel/bazaar/plugin.go
index b80ee6d268..61a82d71fd 100644
--- a/kernel/bazaar/plugin.go
+++ b/kernel/bazaar/plugin.go
@@ -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 Plugin struct {
@@ -64,8 +65,15 @@ func Plugins() (plugins []*Plugin) {
logging.LogErrorf("get bazaar package [%s] failed: %d", innerU, innerResp.StatusCode)
return
}
- plugin.URL = strings.TrimSuffix(plugin.URL, "/")
+ if "" == plugin.MinAppVersion {
+ plugin.MinAppVersion = defaultMinAppVersion
+ }
+ if 0 < semver.Compare("v"+plugin.MinAppVersion, "v"+util.Ver) {
+ return
+ }
+
+ plugin.URL = strings.TrimSuffix(plugin.URL, "/")
repoURLHash := strings.Split(repoURL, "@")
plugin.RepoURL = "https://github.com/" + repoURLHash[0]
plugin.RepoHash = repoURLHash[1]
diff --git a/kernel/bazaar/template.go b/kernel/bazaar/template.go
index 17eb4c02d8..420d659bf9 100644
--- a/kernel/bazaar/template.go
+++ b/kernel/bazaar/template.go
@@ -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]
diff --git a/kernel/bazaar/theme.go b/kernel/bazaar/theme.go
index 93635b5ad1..c1768cbcb7 100644
--- a/kernel/bazaar/theme.go
+++ b/kernel/bazaar/theme.go
@@ -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 Theme struct {
@@ -64,8 +65,15 @@ func Themes() (ret []*Theme) {
logging.LogErrorf("get bazaar package [%s] failed: %d", innerU, innerResp.StatusCode)
return
}
- theme.URL = strings.TrimSuffix(theme.URL, "/")
+ if "" == theme.MinAppVersion {
+ theme.MinAppVersion = defaultMinAppVersion
+ }
+ if 0 < semver.Compare("v"+theme.MinAppVersion, "v"+util.Ver) {
+ return
+ }
+
+ theme.URL = strings.TrimSuffix(theme.URL, "/")
repoURLHash := strings.Split(repoURL, "@")
theme.RepoURL = "https://github.com/" + repoURLHash[0]
theme.RepoHash = repoURLHash[1]
diff --git a/kernel/bazaar/widget.go b/kernel/bazaar/widget.go
index b78586ccdb..e56ff030b3 100644
--- a/kernel/bazaar/widget.go
+++ b/kernel/bazaar/widget.go
@@ -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]