This commit is contained in:
Daniel 2023-11-03 11:25:53 +08:00
parent cf8e748260
commit 5fd8cb121b
No known key found for this signature in database
GPG Key ID: 86211BA83DF03017
2 changed files with 52 additions and 8 deletions

View File

@ -155,8 +155,18 @@ func getInstalledWidget(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
var keyword string
if keywordArg := arg["keyword"]; nil != keywordArg {
keyword = keywordArg.(string)
}
ret.Data = map[string]interface{}{
"packages": model.InstalledWidgets(),
"packages": model.InstalledWidgets(keyword),
}
}
@ -230,8 +240,18 @@ func getInstalledIcon(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
var keyword string
if keywordArg := arg["keyword"]; nil != keywordArg {
keyword = keywordArg.(string)
}
ret.Data = map[string]interface{}{
"packages": model.InstalledIcons(),
"packages": model.InstalledIcons(keyword),
}
}
@ -307,8 +327,18 @@ func getInstalledTemplate(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
var keyword string
if keywordArg := arg["keyword"]; nil != keywordArg {
keyword = keywordArg.(string)
}
ret.Data = map[string]interface{}{
"packages": model.InstalledTemplates(),
"packages": model.InstalledTemplates(keyword),
}
}
@ -383,8 +413,18 @@ func getInstalledTheme(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
var keyword string
if keywordArg := arg["keyword"]; nil != keywordArg {
keyword = keywordArg.(string)
}
ret.Data = map[string]interface{}{
"packages": model.InstalledThemes(),
"packages": model.InstalledThemes(keyword),
}
}

View File

@ -131,8 +131,9 @@ func filterWidgets(widgets []*bazaar.Widget, keyword string) (ret []*bazaar.Widg
return
}
func InstalledWidgets() (widgets []*bazaar.Widget) {
func InstalledWidgets(keyword string) (widgets []*bazaar.Widget) {
widgets = bazaar.InstalledWidgets()
widgets = filterWidgets(widgets, keyword)
return
}
@ -184,8 +185,9 @@ func filterIcons(icons []*bazaar.Icon, keyword string) (ret []*bazaar.Icon) {
return
}
func InstalledIcons() (icons []*bazaar.Icon) {
func InstalledIcons(keyword string) (icons []*bazaar.Icon) {
icons = bazaar.InstalledIcons()
icons = filterIcons(icons, keyword)
for _, icon := range icons {
icon.Current = icon.Name == Conf.Appearance.Icon
}
@ -245,8 +247,9 @@ func filterThemes(themes []*bazaar.Theme, keyword string) (ret []*bazaar.Theme)
return
}
func InstalledThemes() (ret []*bazaar.Theme) {
func InstalledThemes(keyword string) (ret []*bazaar.Theme) {
ret = bazaar.InstalledThemes()
ret = filterThemes(ret, keyword)
for _, theme := range ret {
theme.Current = theme.Name == Conf.Appearance.ThemeDark || theme.Name == Conf.Appearance.ThemeLight
}
@ -318,8 +321,9 @@ func filterTemplates(templates []*bazaar.Template, keyword string) (ret []*bazaa
return
}
func InstalledTemplates() (templates []*bazaar.Template) {
func InstalledTemplates(keyword string) (templates []*bazaar.Template) {
templates = bazaar.InstalledTemplates()
templates = filterTemplates(templates, keyword)
return
}