Skip to content

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

:art: Brand new marketplace UI https://github.com/siyuan-note/siyuan/issues/8181

Liang Dinge3fbe9bae549
diff --git a/kernel/bazaar/plugin.go b/kernel/bazaar/plugin.go
index d19c1ce2d9..31e0fa76ad 100644
--- a/kernel/bazaar/plugin.go
+++ b/kernel/bazaar/plugin.go
@@ -34,6 +34,7 @@ import (
type Plugin struct {
*Package
+ Enabled bool `json:"enabled"`
}
func Plugins() (plugins []*Plugin) {
diff --git a/kernel/model/bazzar.go b/kernel/model/bazzar.go
index 3647a6c070..44a743a0f4 100644
--- a/kernel/model/bazzar.go
+++ b/kernel/model/bazzar.go
@@ -51,6 +51,15 @@ func BazaarPlugins() (plugins []*bazaar.Plugin) {
func InstalledPlugins() (plugins []*bazaar.Plugin) {
plugins = bazaar.InstalledPlugins()
+
+ petals := getPetals()
+ for _, plugin := range plugins {
+ petal := getPetalByName(plugin.Name, petals)
+ if nil != petal {
+ plugin.Enabled = petal.Enabled
+ break
+ }
+ }
return
}
diff --git a/kernel/model/plugin.go b/kernel/model/plugin.go
index f8e19a1c04..1052d8028f 100644
--- a/kernel/model/plugin.go
+++ b/kernel/model/plugin.go
@@ -68,7 +68,7 @@ func SetPetalEnabled(name string, enabled bool) {
return
}
- petal := getPetalByID(hash(plugin.Name), petals)
+ petal := getPetalByName(plugin.Name, petals)
if nil == petal {
petal = &Petal{
ID: hash(plugin.Name),
@@ -90,7 +90,7 @@ func SetPetalEnabled(name string, enabled bool) {
}
}
-func LoadPetals() (ret []*Petal) {
+func getPetals() (ret []*Petal) {
ret = []*Petal{}
petalDir := filepath.Join(util.DataDir, "storage", "petal")
@@ -123,11 +123,15 @@ func LoadPetals() (ret []*Petal) {
logging.LogErrorf("unmarshal petals failed: %s", err)
return
}
+ return
+}
+
+func LoadPetals() (ret []*Petal) {
+ ret = getPetals()
plugins := bazaar.InstalledPlugins()
for _, plugin := range plugins {
- id := hash(plugin.Name)
- petal := getPetalByID(id, ret)
+ petal := getPetalByName(plugin.Name, ret)
if nil == petal {
continue
}
@@ -168,9 +172,9 @@ func LoadPetals() (ret []*Petal) {
return
}
-func getPetalByID(id string, petals []*Petal) (ret *Petal) {
+func getPetalByName(name string, petals []*Petal) (ret *Petal) {
for _, p := range petals {
- if id == p.ID {
+ if name == p.Name {
ret = p
break
}