fix bug 优化
This commit is contained in:
parent
ca94295eb7
commit
3f96c09d36
|
@ -34,13 +34,13 @@ func Init(fs embed.FS) {
|
||||||
logs.ErrPrintln(err, "解析colorscheme失败")
|
logs.ErrPrintln(err, "解析colorscheme失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
var pipe = wp.HandlePipe(wp.Render, widget.MiddleWare(dispatch)...)
|
var pipe = wp.HandlePipe(wp.Render, widget.MiddleWare(ready)...)
|
||||||
|
|
||||||
func Hook(h *wp.Handle) {
|
func Hook(h *wp.Handle) {
|
||||||
pipe(h)
|
pipe(h)
|
||||||
}
|
}
|
||||||
|
|
||||||
func dispatch(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
|
func ready(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
|
||||||
components.WidgetArea(h)
|
components.WidgetArea(h)
|
||||||
h.GetPassword()
|
h.GetPassword()
|
||||||
h.PushComponentFilterFn(widgets.Search, func(h *wp.Handle, s string) string {
|
h.PushComponentFilterFn(widgets.Search, func(h *wp.Handle, s string) string {
|
||||||
|
@ -50,18 +50,7 @@ func dispatch(next wp.HandleFn[*wp.Handle], h *wp.Handle) {
|
||||||
|
|
||||||
h.PushCacheGroupHeadScript("CalCustomBackGround", 10, CalCustomBackGround, colorSchemeCss)
|
h.PushCacheGroupHeadScript("CalCustomBackGround", 10, CalCustomBackGround, colorSchemeCss)
|
||||||
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(customHeader, 10))
|
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(customHeader, 10))
|
||||||
switch h.Scene() {
|
h.PushHandleFn(constraints.AllStats, wp.NewHandleFn(wp.Indexs, 100))
|
||||||
case constraints.Detail:
|
h.PushHandleFn(constraints.Detail, wp.NewHandleFn(wp.Details, 100))
|
||||||
detail(next, h.Detail)
|
next(h)
|
||||||
default:
|
|
||||||
index(next, h.Index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func index(next wp.HandleFn[*wp.Handle], i *wp.IndexHandle) {
|
|
||||||
i.Indexs()
|
|
||||||
}
|
|
||||||
|
|
||||||
func detail(fn wp.HandleFn[*wp.Handle], d *wp.DetailHandle) {
|
|
||||||
d.Details()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,6 @@ func (d *DetailHandle) ContextPost() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DetailHandle) Render() {
|
func (d *DetailHandle) Render() {
|
||||||
PreCodeAndStats(d.Handle)
|
|
||||||
PreTemplate(d.Handle)
|
|
||||||
reply := ""
|
reply := ""
|
||||||
if d.Post.CommentStatus == "open" && wpconfig.GetOption("thread_comments") == "1" {
|
if d.Post.CommentStatus == "open" && wpconfig.GetOption("thread_comments") == "1" {
|
||||||
reply = `<script src='/wp-includes/js/comment-reply.min.js' id='comment-reply-js'></script>`
|
reply = `<script src='/wp-includes/js/comment-reply.min.js' id='comment-reply-js'></script>`
|
||||||
|
@ -118,7 +116,8 @@ func (d *DetailHandle) Render() {
|
||||||
d.Handle.Render()
|
d.Handle.Render()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DetailHandle) Details() {
|
func Details(h *Handle) {
|
||||||
_ = d.BuildDetailData()
|
_ = h.Detail.BuildDetailData()
|
||||||
d.Render()
|
PreCodeAndStats(h)
|
||||||
|
PreTemplate(h)
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,8 +148,6 @@ func (i *IndexHandle) ExecPostsPlugin(calls ...func(*models.Posts)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *IndexHandle) Render() {
|
func (i *IndexHandle) Render() {
|
||||||
PreCodeAndStats(i.Handle)
|
|
||||||
PreTemplate(i.Handle)
|
|
||||||
i.PushHandleFn(constraints.Ok, NewHandleFn(func(h *Handle) {
|
i.PushHandleFn(constraints.Ok, NewHandleFn(func(h *Handle) {
|
||||||
i.ExecPostsPlugin()
|
i.ExecPostsPlugin()
|
||||||
i.Pagination()
|
i.Pagination()
|
||||||
|
@ -159,7 +157,11 @@ func (i *IndexHandle) Render() {
|
||||||
i.Handle.Render()
|
i.Handle.Render()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *IndexHandle) Indexs() {
|
func Indexs(h *Handle) {
|
||||||
|
if h.Scene() != constraints.Detail {
|
||||||
|
i := h.Index
|
||||||
_ = i.BuildIndexData(NewIndexParams(i.C))
|
_ = i.BuildIndexData(NewIndexParams(i.C))
|
||||||
i.Render()
|
PreCodeAndStats(h)
|
||||||
|
PreTemplate(h)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
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"
|
||||||
|
@ -229,10 +228,6 @@ func (h *Handle) PushGroupFooterScript(order int, fns ...string) {
|
||||||
h.PushGroupComponentStrs(constraints.FooterScript, order, fns...)
|
h.PushGroupComponentStrs(constraints.FooterScript, order, fns...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) componentKey(name string) string {
|
|
||||||
return fmt.Sprintf("theme_%d_%s", h.scene, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *Handle) PushCacheGroupFooterScript(key string, order int, fns ...func(*Handle) string) {
|
func (h *Handle) PushCacheGroupFooterScript(key string, order int, fns ...func(*Handle) string) {
|
||||||
h.PushGroupCacheComponentFn(constraints.FooterScript, key, order, fns...)
|
h.PushGroupCacheComponentFn(constraints.FooterScript, key, order, fns...)
|
||||||
}
|
}
|
||||||
|
@ -312,8 +307,7 @@ func (h *Handle) CommonComponents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) PushComponents(name string, components ...Components) {
|
func (h *Handle) PushComponents(name string, components ...Components) {
|
||||||
k := h.componentKey(name)
|
h.components[name] = append(h.components[name], components...)
|
||||||
h.components[k] = append(h.components[k], components...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) PushGroupComponentStrs(name string, order int, fns ...string) {
|
func (h *Handle) PushGroupComponentStrs(name string, order int, fns ...string) {
|
||||||
|
@ -324,8 +318,7 @@ func (h *Handle) PushGroupComponentStrs(name string, order int, fns ...string) {
|
||||||
Order: order,
|
Order: order,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
k := h.componentKey(name)
|
h.components[name] = append(h.components[name], calls...)
|
||||||
h.components[k] = append(h.components[k], calls...)
|
|
||||||
}
|
}
|
||||||
func (h *Handle) PushGroupComponentFns(name string, order int, fns ...func(*Handle) string) {
|
func (h *Handle) PushGroupComponentFns(name string, order int, fns ...func(*Handle) string) {
|
||||||
var calls []Components
|
var calls []Components
|
||||||
|
@ -335,8 +328,7 @@ func (h *Handle) PushGroupComponentFns(name string, order int, fns ...func(*Hand
|
||||||
Order: order,
|
Order: order,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
k := h.componentKey(name)
|
h.components[name] = append(h.components[name], calls...)
|
||||||
h.components[k] = append(h.components[k], calls...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) CalMultipleComponents() {
|
func (h *Handle) CalMultipleComponents() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user