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

Daniel8cbe54c2aba2
diff --git a/kernel/bazaar/icon.go b/kernel/bazaar/icon.go
index 07115ed8e2..d065598c46 100644
--- a/kernel/bazaar/icon.go
+++ b/kernel/bazaar/icon.go
@@ -29,7 +29,6 @@ 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 {
@@ -64,10 +63,7 @@ func Icons() (icons []*Icon) {
return
}
- if "" == icon.MinAppVersion {
- icon.MinAppVersion = defaultMinAppVersion
- }
- if 0 < semver.Compare("v"+icon.MinAppVersion, "v"+util.Ver) {
+ if disallowDisplayBazaarPackage(icon.MinAppVersion) {
return
}
diff --git a/kernel/bazaar/package.go b/kernel/bazaar/package.go
index ed00d6a64d..037b8a0537 100644
--- a/kernel/bazaar/package.go
+++ b/kernel/bazaar/package.go
@@ -19,6 +19,7 @@ package bazaar
import (
"bytes"
"errors"
+ "golang.org/x/mod/semver"
"os"
"path/filepath"
"strings"
@@ -653,3 +654,10 @@ func getBazaarIndex() map[string]*bazaarPackage {
// defaultMinAppVersion 如果集市包中缺失 minAppVersion 项,则使用该值作为最低支持的版本号,小于该版本号时不显示集市包
// Add marketplace package config item `minAppVersion` https://github.com/siyuan-note/siyuan/issues/8330
const defaultMinAppVersion = "2.9.0"
+
+func disallowDisplayBazaarPackage(minAppVersion string) bool {
+ if "" == minAppVersion {
+ return false
+ }
+ return 0 > semver.Compare("v"+minAppVersion, "v"+util.Ver)
+}
diff --git a/kernel/bazaar/plugin.go b/kernel/bazaar/plugin.go
index 61a82d71fd..c5b9826479 100644
--- a/kernel/bazaar/plugin.go
+++ b/kernel/bazaar/plugin.go
@@ -29,7 +29,6 @@ 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 {
@@ -66,10 +65,7 @@ func Plugins() (plugins []*Plugin) {
return
}
- if "" == plugin.MinAppVersion {
- plugin.MinAppVersion = defaultMinAppVersion
- }
- if 0 < semver.Compare("v"+plugin.MinAppVersion, "v"+util.Ver) {
+ if disallowDisplayBazaarPackage(plugin.MinAppVersion) {
return
}
diff --git a/kernel/bazaar/template.go b/kernel/bazaar/template.go
index 420d659bf9..211f0f6021 100644
--- a/kernel/bazaar/template.go
+++ b/kernel/bazaar/template.go
@@ -30,7 +30,6 @@ 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 {
@@ -65,10 +64,7 @@ func Templates() (templates []*Template) {
return
}
- if "" == template.MinAppVersion {
- template.MinAppVersion = defaultMinAppVersion
- }
- if 0 < semver.Compare("v"+template.MinAppVersion, "v"+util.Ver) {
+ if disallowDisplayBazaarPackage(template.MinAppVersion) {
return
}
diff --git a/kernel/bazaar/theme.go b/kernel/bazaar/theme.go
index c1768cbcb7..8ef724e88d 100644
--- a/kernel/bazaar/theme.go
+++ b/kernel/bazaar/theme.go
@@ -29,7 +29,6 @@ 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 {
@@ -66,10 +65,7 @@ func Themes() (ret []*Theme) {
return
}
- if "" == theme.MinAppVersion {
- theme.MinAppVersion = defaultMinAppVersion
- }
- if 0 < semver.Compare("v"+theme.MinAppVersion, "v"+util.Ver) {
+ if disallowDisplayBazaarPackage(theme.MinAppVersion) {
return
}
diff --git a/kernel/bazaar/widget.go b/kernel/bazaar/widget.go
index e56ff030b3..c3a7f61da7 100644
--- a/kernel/bazaar/widget.go
+++ b/kernel/bazaar/widget.go
@@ -29,7 +29,6 @@ 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 {
@@ -65,10 +64,7 @@ func Widgets() (widgets []*Widget) {
return
}
- if "" == widget.MinAppVersion {
- widget.MinAppVersion = defaultMinAppVersion
- }
- if 0 < semver.Compare("v"+widget.MinAppVersion, "v"+util.Ver) {
+ if disallowDisplayBazaarPackage(widget.MinAppVersion) {
return
}