fix bug
This commit is contained in:
parent
e3d57830b0
commit
282e0c26e0
|
@ -177,7 +177,7 @@ func calClass(h *wp.Handle, s string, _ ...any) string {
|
|||
|
||||
func videoHeader(h *wp.Handle) {
|
||||
h.PushComponentFilterFn("videoSetting", videoPlay)
|
||||
wp.CustomVideo(h)
|
||||
wp.CustomVideo(h, constraints.Home)
|
||||
}
|
||||
|
||||
func videoPlay(h *wp.Handle, _ string, a ...any) string {
|
||||
|
|
|
@ -35,7 +35,6 @@ func CalComponents(h *Handle) {
|
|||
})
|
||||
for k, components := range componentss {
|
||||
key := str.Join("calComponents-", h.scene, "-", k)
|
||||
key = h.ComponentFilterFnHook("calComponents", key, k)
|
||||
ss := reload.GetAnyValMapBy("calComponents", key, h, func(h *Handle) []Components[string] {
|
||||
r := slice.FilterAndMap(components, func(t Components[string]) (Components[string], bool) {
|
||||
fns, ok := h.componentHook[k]
|
||||
|
@ -88,15 +87,18 @@ func (h *Handle) PushComponents(scene, componentType string, components ...Compo
|
|||
}
|
||||
|
||||
func (h *Handle) PushGroupComponentStr(scene, componentType, name string, order int, strs ...string) {
|
||||
var components []Components[string]
|
||||
for _, val := range strs {
|
||||
components = append(components, Components[string]{
|
||||
Val: val,
|
||||
var component = Components[string]{
|
||||
Val: strings.Join(slice.FilterAndMap(strs, func(t string) (string, bool) {
|
||||
t = strings.Trim(t, "\n\r\t\v\x00")
|
||||
if t == "" {
|
||||
return "", false
|
||||
}
|
||||
return t, true
|
||||
}), "\n"),
|
||||
Order: order,
|
||||
Name: name,
|
||||
})
|
||||
}
|
||||
h.PushComponents(scene, componentType, components...)
|
||||
h.PushComponents(scene, componentType, component)
|
||||
}
|
||||
|
||||
func (h *Handle) PushCacheGroupHeadScript(scene, name string, order int, fns ...func(*Handle) string) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"github.com/fthvgb1/wp-go/app/cmd/reload"
|
||||
"github.com/fthvgb1/wp-go/app/pkg/cache"
|
||||
"github.com/fthvgb1/wp-go/app/pkg/constraints"
|
||||
"github.com/fthvgb1/wp-go/app/pkg/logs"
|
||||
"github.com/fthvgb1/wp-go/app/pkg/models"
|
||||
"github.com/fthvgb1/wp-go/app/wpconfig"
|
||||
|
@ -96,7 +95,7 @@ func GetVideoSetting(h *Handle, u string) (string, error) {
|
|||
return script, nil
|
||||
}
|
||||
|
||||
func CustomVideo(h *Handle) (ok bool) {
|
||||
func CustomVideo(h *Handle, scene ...string) (ok bool) {
|
||||
mod, err := wpconfig.GetThemeMods(h.theme)
|
||||
if err != nil {
|
||||
logs.Error(err, "getThemeMods fail", h.theme)
|
||||
|
@ -144,7 +143,7 @@ func CustomVideo(h *Handle) (ok bool) {
|
|||
{"wp-", ""},
|
||||
}))
|
||||
})
|
||||
h.PushGroupFooterScript(constraints.Home, "wp-custom-header", 10, scripts[0:len(scripts)-2]...)
|
||||
|
||||
var tr = `<script id="wp-i18n-js-after">
|
||||
wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );
|
||||
</script>
|
||||
|
@ -157,11 +156,15 @@ wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );
|
|||
</script>
|
||||
<script src='/wp-includes/js/dist/a11y.min.js?ver=ecce20f002eda4c19664' id='wp-a11y-js'></script>
|
||||
`
|
||||
h.PushFooterScript(constraints.Home,
|
||||
c := []Components[string]{
|
||||
NewComponent("wp-a11y-js-translations", tr, true, 10, nil),
|
||||
NewComponent("VideoSetting", hs, true, 10, nil),
|
||||
NewComponent("header-script", scripts[len(scripts)-1], true, 10, nil),
|
||||
)
|
||||
}
|
||||
for _, s := range scene {
|
||||
h.PushGroupFooterScript(s, "wp-custom-header", 10, scripts[0:len(scripts)-2]...)
|
||||
h.PushFooterScript(s, c...)
|
||||
}
|
||||
ok = true
|
||||
return
|
||||
}
|
||||
|
|
|
@ -103,12 +103,12 @@ func InitHandle(fn func(*Handle), h *Handle) {
|
|||
h.ginH = gin.H{}
|
||||
fnMap = map[string]map[string]any{}
|
||||
fnHook = map[string]map[string]any{}
|
||||
fn(h)
|
||||
v := apply.UsePlugins()
|
||||
pluginFn, ok := v.(func(*Handle))
|
||||
if ok {
|
||||
pluginFn(h)
|
||||
}
|
||||
fn(h)
|
||||
h.C.Set("inited", true)
|
||||
inited = true
|
||||
return *h
|
||||
|
|
Loading…
Reference in New Issue
Block a user