小优化
This commit is contained in:
parent
ec4dfad86a
commit
00c16c03a4
@ -22,11 +22,6 @@ var widgetFn = map[string]wp.Components[string]{
|
|||||||
"meta": {Fn: widget.Meta, CacheKey: "widgetMeta"},
|
"meta": {Fn: widget.Meta, CacheKey: "widgetMeta"},
|
||||||
}
|
}
|
||||||
|
|
||||||
type Widget struct {
|
|
||||||
Fn func(*wp.Handle) string
|
|
||||||
CacheKey string
|
|
||||||
}
|
|
||||||
|
|
||||||
func WidgetArea(h *wp.Handle) {
|
func WidgetArea(h *wp.Handle) {
|
||||||
sidebar := reload.GetAnyValBys("sidebarWidgets", h, sidebars)
|
sidebar := reload.GetAnyValBys("sidebarWidgets", h, sidebars)
|
||||||
h.PushComponents(constraints.SidebarsWidgets, sidebar...)
|
h.PushComponents(constraints.SidebarsWidgets, sidebar...)
|
||||||
@ -48,7 +43,9 @@ func sidebars(h *wp.Handle) []wp.Components[string] {
|
|||||||
id := ss[len(ss)-1]
|
id := ss[len(ss)-1]
|
||||||
name := strings.Join(ss[0:len(ss)-1], "-")
|
name := strings.Join(ss[0:len(ss)-1], "-")
|
||||||
components, ok := widgetFn[name]
|
components, ok := widgetFn[name]
|
||||||
if ok {
|
if !ok {
|
||||||
|
return components, false
|
||||||
|
}
|
||||||
if id != "2" {
|
if id != "2" {
|
||||||
wp.SetComponentsArgsForMap(h, name, "{$id}", id)
|
wp.SetComponentsArgsForMap(h, name, "{$id}", id)
|
||||||
}
|
}
|
||||||
@ -64,7 +61,5 @@ func sidebars(h *wp.Handle) []wp.Components[string] {
|
|||||||
}
|
}
|
||||||
components.Order = 10
|
components.Order = 10
|
||||||
return components, true
|
return components, true
|
||||||
}
|
|
||||||
return components, false
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user