diff --git a/kernel/api/bazaar.go b/kernel/api/bazaar.go index e05ad04dd..d8fbcc73f 100644 --- a/kernel/api/bazaar.go +++ b/kernel/api/bazaar.go @@ -25,7 +25,7 @@ import ( "github.com/siyuan-note/siyuan/kernel/util" ) -func getBazaarPackages(c *gin.Context) { +func getUpdatedPackage(c *gin.Context) { ret := gulu.Ret.NewResult() defer c.JSON(http.StatusOK, ret) @@ -35,7 +35,7 @@ func getBazaarPackages(c *gin.Context) { } frontend := arg["frontend"].(string) - plugins, widgets, icons, themes, templates := model.BazaarPackages(frontend) + plugins, widgets, icons, themes, templates := model.UpdatedPackages(frontend) ret.Data = map[string]interface{}{ "plugins": plugins, "widgets": widgets, diff --git a/kernel/api/router.go b/kernel/api/router.go index fc6e51ee2..d4bc60b9b 100644 --- a/kernel/api/router.go +++ b/kernel/api/router.go @@ -330,7 +330,7 @@ func ServeAPI(ginServer *gin.Engine) { ginServer.Handle("POST", "/api/graph/getGraph", model.CheckAuth, getGraph) ginServer.Handle("POST", "/api/graph/getLocalGraph", model.CheckAuth, getLocalGraph) - ginServer.Handle("POST", "/api/bazaar/getBazaarPackages", model.CheckAuth, getBazaarPackages) + ginServer.Handle("POST", "/api/bazaar/getUpdatedPackage", model.CheckAuth, getUpdatedPackage) ginServer.Handle("POST", "/api/bazaar/getBazaarPlugin", model.CheckAuth, getBazaarPlugin) ginServer.Handle("POST", "/api/bazaar/getInstalledPlugin", model.CheckAuth, getInstalledPlugin) ginServer.Handle("POST", "/api/bazaar/installBazaarPlugin", model.CheckAuth, model.CheckReadonly, installBazaarPlugin) diff --git a/kernel/model/bazzar.go b/kernel/model/bazzar.go index f53e42e4f..6ec935baf 100644 --- a/kernel/model/bazzar.go +++ b/kernel/model/bazzar.go @@ -30,32 +30,57 @@ import ( "github.com/siyuan-note/siyuan/kernel/bazaar" ) -func BazaarPackages(frontend string) (plugins []*bazaar.Plugin, widgets []*bazaar.Widget, icons []*bazaar.Icon, themes []*bazaar.Theme, templates []*bazaar.Template) { +func UpdatedPackages(frontend string) (plugins []*bazaar.Plugin, widgets []*bazaar.Widget, icons []*bazaar.Icon, themes []*bazaar.Theme, templates []*bazaar.Template) { wg := &sync.WaitGroup{} wg.Add(5) go func() { defer wg.Done() - plugins = InstalledPlugins(frontend, "") + tmp := InstalledPlugins(frontend, "") + for _, plugin := range tmp { + if plugin.Outdated { + plugins = append(plugins, plugin) + } + } }() go func() { defer wg.Done() - widgets = InstalledWidgets("") + tmp := InstalledWidgets("") + for _, widget := range tmp { + if widget.Outdated { + widgets = append(widgets, widget) + } + } }() go func() { defer wg.Done() - icons = InstalledIcons("") + tmp := InstalledIcons("") + for _, icon := range tmp { + if icon.Outdated { + icons = append(icons, icon) + } + } }() go func() { defer wg.Done() - themes = InstalledThemes("") + tmp := InstalledThemes("") + for _, theme := range tmp { + if theme.Outdated { + themes = append(themes, theme) + } + } }() go func() { defer wg.Done() - templates = InstalledTemplates("") + tmp := InstalledTemplates("") + for _, template := range tmp { + if template.Outdated { + templates = append(templates, template) + } + } }() wg.Wait()