This commit is contained in:
xing 2023-03-03 19:11:27 +08:00
parent 5665e0021b
commit f3595874ae

View File

@ -1,6 +1,7 @@
package wp package wp
import ( import (
"fmt"
"github.com/fthvgb1/wp-go/helper/maps" "github.com/fthvgb1/wp-go/helper/maps"
"github.com/fthvgb1/wp-go/helper/slice" "github.com/fthvgb1/wp-go/helper/slice"
str "github.com/fthvgb1/wp-go/helper/strings" str "github.com/fthvgb1/wp-go/helper/strings"
@ -218,7 +219,8 @@ func (h *Handle) Render() {
} }
func (h *Handle) PushComponents(name string, components ...Components) { func (h *Handle) PushComponents(name string, components ...Components) {
h.components[name] = append(h.components[name], components...) k := h.componentKey(name)
h.components[k] = append(h.components[k], components...)
} }
func (h *Handle) PushGroupComponents(name string, order int, fns ...func(*Handle) string) { func (h *Handle) PushGroupComponents(name string, order int, fns ...func(*Handle) string) {
@ -226,7 +228,12 @@ func (h *Handle) PushGroupComponents(name string, order int, fns ...func(*Handle
for _, fn := range fns { for _, fn := range fns {
calls = append(calls, Components{fn, order}) calls = append(calls, Components{fn, order})
} }
h.components[name] = append(h.components[name], calls...) k := h.componentKey(name)
h.components[k] = append(h.components[k], calls...)
}
func (h *Handle) componentKey(name string) string {
return fmt.Sprintf("%d_%s", h.scene, name)
} }
func (h *Handle) CalMultipleComponents() { func (h *Handle) CalMultipleComponents() {
@ -242,7 +249,8 @@ func (h *Handle) CalMultipleComponents() {
}), "\n") }), "\n")
reload.SetStr(k, v) reload.SetStr(k, v)
} }
h.ginH[k] = v key := strings.Split(k, "_")[1]
h.ginH[key] = v
} }
} }