From 3f5c0762e89dc815eb7c40a22efa9cd22adcba62 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 27 Dec 2025 12:41:03 +0800 Subject: [PATCH] :art: Improve minimum version requirements for marketplace packages https://github.com/siyuan-note/siyuan/issues/16688 Signed-off-by: Daniel <845765@qq.com> --- kernel/bazaar/icon.go | 3 ++- kernel/bazaar/plugin.go | 5 ++++- kernel/bazaar/template.go | 3 ++- kernel/bazaar/theme.go | 3 ++- kernel/bazaar/widget.go | 3 ++- kernel/model/plugin.go | 8 +++++--- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/kernel/bazaar/icon.go b/kernel/bazaar/icon.go index aae5697dd..5372ea632 100644 --- a/kernel/bazaar/icon.go +++ b/kernel/bazaar/icon.go @@ -156,8 +156,9 @@ func InstalledIcons() (ret []*Icon) { continue } - installPath := filepath.Join(util.IconsPath, dirName) + icon.DisallowInstall = disallowInstallBazaarPackage(icon.Package) + installPath := filepath.Join(util.IconsPath, dirName) icon.Installed = true icon.RepoURL = icon.URL icon.PreviewURL = "/appearance/icons/" + dirName + "/preview.png" diff --git a/kernel/bazaar/plugin.go b/kernel/bazaar/plugin.go index 2d99d4f31..bfaa44c15 100644 --- a/kernel/bazaar/plugin.go +++ b/kernel/bazaar/plugin.go @@ -131,7 +131,7 @@ func Plugins(frontend string) (plugins []*Plugin) { return } -func ParseInstalledPlugin(name, frontend string) (found bool, displayName string, incompatible, disabledInPublish bool) { +func ParseInstalledPlugin(name, frontend string) (found bool, displayName string, incompatible, disabledInPublish, disallowInstall bool) { pluginsPath := filepath.Join(util.DataDir, "plugins") if !util.IsPathRegularDirOrSymlinkDir(pluginsPath) { return @@ -161,6 +161,7 @@ func ParseInstalledPlugin(name, frontend string) (found bool, displayName string displayName = GetPreferredName(plugin.Package) incompatible = isIncompatiblePlugin(plugin, frontend) disabledInPublish = plugin.DisabledInPublish + disallowInstall = disallowInstallBazaarPackage(plugin.Package) } return } @@ -195,6 +196,8 @@ func InstalledPlugins(frontend string, checkUpdate bool) (ret []*Plugin) { continue } + plugin.DisallowInstall = disallowInstallBazaarPackage(plugin.Package) + installPath := filepath.Join(util.DataDir, "plugins", dirName) plugin.Installed = true plugin.RepoURL = plugin.URL diff --git a/kernel/bazaar/template.go b/kernel/bazaar/template.go index b1f67b24f..519251efc 100644 --- a/kernel/bazaar/template.go +++ b/kernel/bazaar/template.go @@ -158,8 +158,9 @@ func InstalledTemplates() (ret []*Template) { continue } - installPath := filepath.Join(util.DataDir, "templates", dirName) + template.DisallowInstall = disallowInstallBazaarPackage(template.Package) + installPath := filepath.Join(util.DataDir, "templates", dirName) template.Installed = true template.RepoURL = template.URL template.PreviewURL = "/templates/" + dirName + "/preview.png" diff --git a/kernel/bazaar/theme.go b/kernel/bazaar/theme.go index ea8d957f2..12653318d 100644 --- a/kernel/bazaar/theme.go +++ b/kernel/bazaar/theme.go @@ -159,8 +159,9 @@ func InstalledThemes() (ret []*Theme) { continue } - installPath := filepath.Join(util.ThemesPath, dirName) + theme.DisallowInstall = disallowInstallBazaarPackage(theme.Package) + installPath := filepath.Join(util.ThemesPath, dirName) theme.Installed = true theme.RepoURL = theme.URL theme.PreviewURL = "/appearance/themes/" + dirName + "/preview.png" diff --git a/kernel/bazaar/widget.go b/kernel/bazaar/widget.go index 7f0a0cc88..2e8561fc7 100644 --- a/kernel/bazaar/widget.go +++ b/kernel/bazaar/widget.go @@ -155,8 +155,9 @@ func InstalledWidgets() (ret []*Widget) { continue } - installPath := filepath.Join(util.DataDir, "widgets", dirName) + widget.DisallowInstall = disallowInstallBazaarPackage(widget.Package) + installPath := filepath.Join(util.DataDir, "widgets", dirName) widget.Installed = true widget.RepoURL = widget.URL widget.PreviewURL = "/widgets/" + dirName + "/preview.png" diff --git a/kernel/model/plugin.go b/kernel/model/plugin.go index c35859380..900b0f03f 100644 --- a/kernel/model/plugin.go +++ b/kernel/model/plugin.go @@ -36,6 +36,7 @@ type Petal struct { Enabled bool `json:"enabled"` // Whether enabled Incompatible bool `json:"incompatible"` // Whether incompatible DisabledInPublish bool `json:"disabledInPublish"` // Whether disabled in publish mode + DisallowInstall bool `json:"disallowInstall"` // Whether disallow install JS string `json:"js"` // JS code CSS string `json:"css"` // CSS code @@ -45,7 +46,7 @@ type Petal struct { func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, err error) { petals := getPetals() - found, displayName, incompatible, disabledInPublish := bazaar.ParseInstalledPlugin(name, frontend) + found, displayName, incompatible, disabledInPublish, disallowInstall := bazaar.ParseInstalledPlugin(name, frontend) if !found { logging.LogErrorf("plugin [%s] not found", name) return @@ -62,6 +63,7 @@ func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, er ret.Enabled = enabled ret.Incompatible = incompatible ret.DisabledInPublish = disabledInPublish + ret.DisallowInstall = disallowInstall if incompatible { err = fmt.Errorf(Conf.Language(205)) @@ -100,8 +102,8 @@ func LoadPetals(frontend string, isPublish bool) (ret []*Petal) { petals := getPetals() for _, petal := range petals { - _, petal.DisplayName, petal.Incompatible, petal.DisabledInPublish = bazaar.ParseInstalledPlugin(petal.Name, frontend) - if !petal.Enabled || petal.Incompatible || (isPublish && petal.DisabledInPublish) { + _, petal.DisplayName, petal.Incompatible, petal.DisabledInPublish, petal.DisallowInstall = bazaar.ParseInstalledPlugin(petal.Name, frontend) + if !petal.Enabled || petal.Incompatible || (isPublish && petal.DisabledInPublish) || petal.DisallowInstall { continue }