Compare commits

..

No commits in common. "1ecb338af573ed140b02474665509dbac463b26c" and "e7e643f5d33330e28264e27514def453ab2751a5" have entirely different histories.

3 changed files with 5 additions and 26 deletions

View File

@ -12,7 +12,7 @@ import (
) )
func CalBodyClass(h *Handle) { func CalBodyClass(h *Handle) {
h.ginH["bodyClass"] = h.BodyClass(h.bodyClass...) h.ginH["bodyClass"] = h.BodyClass(h.class...)
} }
func (h *Handle) BodyClass(class ...string) string { func (h *Handle) BodyClass(class ...string) string {

View File

@ -70,6 +70,7 @@ func Search(h *wp.Handle, id string) string {
return args return args
}) })
args = maps.Copy(args)
s := strings.ReplaceAll(searchTemplate, "{$form}", form) s := strings.ReplaceAll(searchTemplate, "{$form}", form)
val := "" val := ""
if h.Scene() == constraints.Search { if h.Scene() == constraints.Search {

View File

@ -12,7 +12,6 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"net/http" "net/http"
"strings" "strings"
"sync"
) )
type Handle struct { type Handle struct {
@ -27,7 +26,7 @@ type Handle struct {
Code int Code int
Stats int Stats int
templ string templ string
bodyClass []string class []string
components map[string][]Components[string] components map[string][]Components[string]
themeMods wpconfig.ThemeMods themeMods wpconfig.ThemeMods
handleFns map[int][]HandleCall handleFns map[int][]HandleCall
@ -37,9 +36,6 @@ type Handle struct {
componentFilterFn map[string][]func(*Handle, string, ...any) string componentFilterFn map[string][]func(*Handle, string, ...any) string
} }
var configHandle = reload.Vars(&Handle{})
var configHandleMux = sync.Mutex{}
type HandlePlugins map[string]HandleFn[*Handle] type HandlePlugins map[string]HandleFn[*Handle]
// Components Order 为执行顺序,降序执行 // Components Order 为执行顺序,降序执行
@ -59,24 +55,6 @@ type HandleCall struct {
Order int Order int
} }
func InitThemeArgAndConfig(fn func(*Handle) *Handle, h *Handle) {
hh := configHandle.Load()
if len(hh.handleFns) < 1 {
configHandleMux.Lock()
hh = configHandle.Load()
if len(hh.handleFns) < 1 {
hh = fn(h)
configHandle.Store(hh)
}
configHandleMux.Unlock()
}
h.components = hh.components
h.handleFns = hh.handleFns
h.componentsArgs = hh.componentsArgs
h.componentFilterFn = hh.componentFilterFn
h.ginH = maps.Copy(hh.ginH)
}
func (h *Handle) ComponentFilterFn(name string) ([]func(*Handle, string, ...any) string, bool) { func (h *Handle) ComponentFilterFn(name string) ([]func(*Handle, string, ...any) string, bool) {
fn, ok := h.componentFilterFn[name] fn, ok := h.componentFilterFn[name]
return fn, ok return fn, ok
@ -131,7 +109,7 @@ func (h *Handle) SetData(k string, v any) {
} }
func (h *Handle) PushClass(class ...string) { func (h *Handle) PushClass(class ...string) {
h.bodyClass = append(h.bodyClass, class...) h.class = append(h.class, class...)
} }
func GetComponentsArgs[T any](h *Handle, k string, defaults T) T { func GetComponentsArgs[T any](h *Handle, k string, defaults T) T {
@ -224,7 +202,7 @@ func (h *Handle) PushGroupHandleFn(statsOrScene, order int, fns ...HandleFn[*Han
} }
func (h *Handle) AddCacheComponent(name string, fn func(*Handle) string) { func (h *Handle) AddCacheComponent(name string, fn func(*Handle) string) {
h.components[name] = append(h.components[name], h.NewCacheComponent(name, 10, fn)) h.ginH[name] = reload.GetAnyValBys(name, h, fn)
} }
func (h *Handle) PushHeadScript(fn ...Components[string]) { func (h *Handle) PushHeadScript(fn ...Components[string]) {