mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
🎨 Add plugin name to command palette https://github.com/siyuan-note/siyuan/issues/8644
This commit is contained in:
parent
d94893f9a6
commit
ba3f5fe5e5
2 changed files with 6 additions and 3 deletions
|
|
@ -108,7 +108,7 @@ func Plugins(frontend string) (plugins []*Plugin) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsIncompatibleInstalledPlugin(name, frontend string) (found, incompatible bool) {
|
func ParseInstalledPlugin(name, frontend string) (found bool, displayName string, incompatible bool) {
|
||||||
pluginsPath := filepath.Join(util.DataDir, "plugins")
|
pluginsPath := filepath.Join(util.DataDir, "plugins")
|
||||||
if !util.IsPathRegularDirOrSymlinkDir(pluginsPath) {
|
if !util.IsPathRegularDirOrSymlinkDir(pluginsPath) {
|
||||||
return
|
return
|
||||||
|
|
@ -135,6 +135,7 @@ func IsIncompatibleInstalledPlugin(name, frontend string) (found, incompatible b
|
||||||
}
|
}
|
||||||
|
|
||||||
found = true
|
found = true
|
||||||
|
displayName = getPreferredName(plugin.Package)
|
||||||
incompatible = isIncompatiblePlugin(plugin, frontend)
|
incompatible = isIncompatiblePlugin(plugin, frontend)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import (
|
||||||
// Petal represents a plugin's management status.
|
// Petal represents a plugin's management status.
|
||||||
type Petal struct {
|
type Petal struct {
|
||||||
Name string `json:"name"` // Plugin name
|
Name string `json:"name"` // Plugin name
|
||||||
|
DisplayName string `json:"displayName"` // Plugin display name
|
||||||
Enabled bool `json:"enabled"` // Whether enabled
|
Enabled bool `json:"enabled"` // Whether enabled
|
||||||
Incompatible bool `json:"incompatible"` // Whether incompatible
|
Incompatible bool `json:"incompatible"` // Whether incompatible
|
||||||
|
|
||||||
|
|
@ -43,7 +44,7 @@ type Petal struct {
|
||||||
func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, err error) {
|
func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, err error) {
|
||||||
petals := getPetals()
|
petals := getPetals()
|
||||||
|
|
||||||
found, incompatible := bazaar.IsIncompatibleInstalledPlugin(name, frontend)
|
found, displayName, incompatible := bazaar.ParseInstalledPlugin(name, frontend)
|
||||||
if !found {
|
if !found {
|
||||||
logging.LogErrorf("plugin [%s] not found", name)
|
logging.LogErrorf("plugin [%s] not found", name)
|
||||||
return
|
return
|
||||||
|
|
@ -56,6 +57,7 @@ func SetPetalEnabled(name string, enabled bool, frontend string) (ret *Petal, er
|
||||||
}
|
}
|
||||||
petals = append(petals, ret)
|
petals = append(petals, ret)
|
||||||
}
|
}
|
||||||
|
ret.DisplayName = displayName
|
||||||
ret.Enabled = enabled
|
ret.Enabled = enabled
|
||||||
ret.Incompatible = incompatible
|
ret.Incompatible = incompatible
|
||||||
|
|
||||||
|
|
@ -78,7 +80,7 @@ func LoadPetals(frontend string) (ret []*Petal) {
|
||||||
|
|
||||||
petals := getPetals()
|
petals := getPetals()
|
||||||
for _, petal := range petals {
|
for _, petal := range petals {
|
||||||
_, petal.Incompatible = bazaar.IsIncompatibleInstalledPlugin(petal.Name, frontend)
|
_, petal.DisplayName, petal.Incompatible = bazaar.ParseInstalledPlugin(petal.Name, frontend)
|
||||||
if !petal.Enabled || petal.Incompatible {
|
if !petal.Enabled || petal.Incompatible {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue