This commit is contained in:
Liang Ding 2023-05-05 23:42:32 +08:00
parent 1731d2b6ef
commit 99c01fc931
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -56,15 +56,28 @@ func SetPetalEnabled(name string, enabled bool) {
} }
plugins := bazaar.InstalledPlugins() plugins := bazaar.InstalledPlugins()
for _, plugin := range plugins { var plugin *bazaar.Plugin
id := hash(plugin.URL) for _, p := range plugins {
petal := getPetalByID(id, petals) if p.Name == name {
if nil == petal { plugin = p
continue break
} }
}
if nil == plugin {
logging.LogErrorf("plugin [%s] not found", name)
return
}
petal := getPetalByID(hash(plugin.Name), petals)
if nil == petal {
petal = &Petal{
ID: hash(plugin.Name),
Name: plugin.Name,
Enabled: enabled,
}
petals = append(petals, petal)
} else {
petal.Enabled = enabled petal.Enabled = enabled
break
} }
if data, err = gulu.JSON.MarshalIndentJSON(petals, "", "\t"); nil != err { if data, err = gulu.JSON.MarshalIndentJSON(petals, "", "\t"); nil != err {
@ -113,7 +126,7 @@ func LoadPetals() (ret []*Petal) {
plugins := bazaar.InstalledPlugins() plugins := bazaar.InstalledPlugins()
for _, plugin := range plugins { for _, plugin := range plugins {
id := hash(plugin.URL) id := hash(plugin.Name)
petal := getPetalByID(id, ret) petal := getPetalByID(id, ret)
if nil == petal { if nil == petal {
continue continue