From 9410a70a2b6213d2080eca46e11e3f3fca6dd038 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 4 Sep 2025 10:22:57 +0800 Subject: [PATCH 1/2] :art: Add marketplace package config item `minAppVersion` https://github.com/siyuan-note/siyuan/issues/8330 --- kernel/bazaar/package.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/bazaar/package.go b/kernel/bazaar/package.go index 6e130377d..c71fba4fd 100644 --- a/kernel/bazaar/package.go +++ b/kernel/bazaar/package.go @@ -875,9 +875,10 @@ func getBazaarIndex() map[string]*bazaarPackage { const defaultMinAppVersion = "2.9.0" func disallowDisplayBazaarPackage(pkg *Package) bool { - if "" == pkg.MinAppVersion { // TODO: 目前暂时放过所有不带 minAppVersion 的集市包,后续版本会使用 defaultMinAppVersion - return false + if "" == pkg.MinAppVersion { + pkg.MinAppVersion = defaultMinAppVersion } + if 0 < semver.Compare("v"+pkg.MinAppVersion, "v"+util.Ver) { return true } From 6ff4439be3dc147b3abee24f39f9b8405f997f38 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Thu, 4 Sep 2025 10:29:58 +0800 Subject: [PATCH 2/2] :technologist: Add field `disabledInPublish` to the marketplace package metadata to indicate whether it is disabled in the publishing service https://github.com/siyuan-note/siyuan/issues/11730 --- kernel/api/petal.go | 4 ++-- kernel/bazaar/package.go | 23 ++++++++++++----------- kernel/bazaar/plugin.go | 3 ++- kernel/model/plugin.go | 18 ++++++++++-------- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/kernel/api/petal.go b/kernel/api/petal.go index 7534da587..93206ef31 100644 --- a/kernel/api/petal.go +++ b/kernel/api/petal.go @@ -35,9 +35,9 @@ func loadPetals(c *gin.Context) { } frontend := arg["frontend"].(string) + isPublish := model.IsReadOnlyRole(model.GetGinContextRole(c)) - petals := model.LoadPetals(frontend) - ret.Data = petals + ret.Data = model.LoadPetals(frontend, isPublish) } func setPetalEnabled(c *gin.Context) { diff --git a/kernel/bazaar/package.go b/kernel/bazaar/package.go index c71fba4fd..165785b53 100644 --- a/kernel/bazaar/package.go +++ b/kernel/bazaar/package.go @@ -99,17 +99,18 @@ type Funding struct { } type Package struct { - Author string `json:"author"` - URL string `json:"url"` - Version string `json:"version"` - MinAppVersion string `json:"minAppVersion"` - Backends []string `json:"backends"` - Frontends []string `json:"frontends"` - DisplayName *DisplayName `json:"displayName"` - Description *Description `json:"description"` - Readme *Readme `json:"readme"` - Funding *Funding `json:"funding"` - Keywords []string `json:"keywords"` + Author string `json:"author"` + URL string `json:"url"` + Version string `json:"version"` + MinAppVersion string `json:"minAppVersion"` + DisabledInPublish bool `json:"disabledInPublish"` + Backends []string `json:"backends"` + Frontends []string `json:"frontends"` + DisplayName *DisplayName `json:"displayName"` + Description *Description `json:"description"` + Readme *Readme `json:"readme"` + Funding *Funding `json:"funding"` + Keywords []string `json:"keywords"` PreferredFunding string `json:"preferredFunding"` PreferredName string `json:"preferredName"` diff --git a/kernel/bazaar/plugin.go b/kernel/bazaar/plugin.go index fa145591e..0d1e7a06c 100644 --- a/kernel/bazaar/plugin.go +++ b/kernel/bazaar/plugin.go @@ -134,7 +134,7 @@ func Plugins(frontend string) (plugins []*Plugin) { return } -func ParseInstalledPlugin(name, frontend string) (found bool, displayName string, incompatible bool) { +func ParseInstalledPlugin(name, frontend string) (found bool, displayName string, incompatible, disabledInPublish bool) { pluginsPath := filepath.Join(util.DataDir, "plugins") if !util.IsPathRegularDirOrSymlinkDir(pluginsPath) { return @@ -163,6 +163,7 @@ func ParseInstalledPlugin(name, frontend string) (found bool, displayName string found = true displayName = GetPreferredName(plugin.Package) incompatible = isIncompatiblePlugin(plugin, frontend) + disabledInPublish = plugin.DisabledInPublish } return } diff --git a/kernel/model/plugin.go b/kernel/model/plugin.go index 2af31d7bd..77d0345fd 100644 --- a/kernel/model/plugin.go +++ b/kernel/model/plugin.go @@ -31,10 +31,11 @@ import ( // Petal represents a plugin's management status. type Petal struct { - Name string `json:"name"` // Plugin name - DisplayName string `json:"displayName"` // Plugin display name - Enabled bool `json:"enabled"` // Whether enabled - Incompatible bool `json:"incompatible"` // Whether incompatible + Name string `json:"name"` // Plugin name + DisplayName string `json:"displayName"` // Plugin display name + Enabled bool `json:"enabled"` // Whether enabled + Incompatible bool `json:"incompatible"` // Whether incompatible + DisabledInPublish bool `json:"disabledInPublish"` // Whether disabled in publish mode JS string `json:"js"` // JS code CSS string `json:"css"` // CSS code @@ -44,7 +45,7 @@ type Petal struct { func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, err error) { petals := getPetals() - found, displayName, incompatible := bazaar.ParseInstalledPlugin(name, frontend) + found, displayName, incompatible, disabledInPublish := bazaar.ParseInstalledPlugin(name, frontend) if !found { logging.LogErrorf("plugin [%s] not found", name) return @@ -60,6 +61,7 @@ func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, er ret.DisplayName = displayName ret.Enabled = enabled ret.Incompatible = incompatible + ret.DisabledInPublish = disabledInPublish if incompatible { err = fmt.Errorf(Conf.Language(205)) @@ -72,7 +74,7 @@ func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, er return } -func LoadPetals(frontend string) (ret []*Petal) { +func LoadPetals(frontend string, isPublish bool) (ret []*Petal) { ret = []*Petal{} if Conf.Bazaar.PetalDisabled { @@ -93,8 +95,8 @@ func LoadPetals(frontend string) (ret []*Petal) { continue } - _, petal.DisplayName, petal.Incompatible = bazaar.ParseInstalledPlugin(petal.Name, frontend) - if !petal.Enabled || petal.Incompatible { + _, petal.DisplayName, petal.Incompatible, petal.DisabledInPublish = bazaar.ParseInstalledPlugin(petal.Name, frontend) + if !petal.Enabled || petal.Incompatible || (isPublish && petal.DisabledInPublish) { continue }