mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Brand new marketplace UI https://github.com/siyuan-note/siyuan/issues/8181
This commit is contained in:
parent
99c01fc931
commit
e3fbe9bae5
3 changed files with 20 additions and 6 deletions
|
|
@ -34,6 +34,7 @@ import (
|
||||||
|
|
||||||
type Plugin struct {
|
type Plugin struct {
|
||||||
*Package
|
*Package
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Plugins() (plugins []*Plugin) {
|
func Plugins() (plugins []*Plugin) {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,15 @@ func BazaarPlugins() (plugins []*bazaar.Plugin) {
|
||||||
|
|
||||||
func InstalledPlugins() (plugins []*bazaar.Plugin) {
|
func InstalledPlugins() (plugins []*bazaar.Plugin) {
|
||||||
plugins = bazaar.InstalledPlugins()
|
plugins = bazaar.InstalledPlugins()
|
||||||
|
|
||||||
|
petals := getPetals()
|
||||||
|
for _, plugin := range plugins {
|
||||||
|
petal := getPetalByName(plugin.Name, petals)
|
||||||
|
if nil != petal {
|
||||||
|
plugin.Enabled = petal.Enabled
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ func SetPetalEnabled(name string, enabled bool) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
petal := getPetalByID(hash(plugin.Name), petals)
|
petal := getPetalByName(plugin.Name, petals)
|
||||||
if nil == petal {
|
if nil == petal {
|
||||||
petal = &Petal{
|
petal = &Petal{
|
||||||
ID: hash(plugin.Name),
|
ID: hash(plugin.Name),
|
||||||
|
|
@ -90,7 +90,7 @@ func SetPetalEnabled(name string, enabled bool) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadPetals() (ret []*Petal) {
|
func getPetals() (ret []*Petal) {
|
||||||
ret = []*Petal{}
|
ret = []*Petal{}
|
||||||
|
|
||||||
petalDir := filepath.Join(util.DataDir, "storage", "petal")
|
petalDir := filepath.Join(util.DataDir, "storage", "petal")
|
||||||
|
|
@ -123,11 +123,15 @@ func LoadPetals() (ret []*Petal) {
|
||||||
logging.LogErrorf("unmarshal petals failed: %s", err)
|
logging.LogErrorf("unmarshal petals failed: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadPetals() (ret []*Petal) {
|
||||||
|
ret = getPetals()
|
||||||
|
|
||||||
plugins := bazaar.InstalledPlugins()
|
plugins := bazaar.InstalledPlugins()
|
||||||
for _, plugin := range plugins {
|
for _, plugin := range plugins {
|
||||||
id := hash(plugin.Name)
|
petal := getPetalByName(plugin.Name, ret)
|
||||||
petal := getPetalByID(id, ret)
|
|
||||||
if nil == petal {
|
if nil == petal {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -168,9 +172,9 @@ func LoadPetals() (ret []*Petal) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getPetalByID(id string, petals []*Petal) (ret *Petal) {
|
func getPetalByName(name string, petals []*Petal) (ret *Petal) {
|
||||||
for _, p := range petals {
|
for _, p := range petals {
|
||||||
if id == p.ID {
|
if name == p.Name {
|
||||||
ret = p
|
ret = p
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue