From 4d50f60c6230be6ce54ca32272e07b3c589b3b80 Mon Sep 17 00:00:00 2001 From: xing Date: Tue, 28 Feb 2023 23:59:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/theme/common/common.go | 14 +++++--- internal/theme/common/detail.go | 9 +++-- internal/theme/common/index.go | 34 ++++++++++++++----- .../theme/twentyseventeen/twentyseventeen.go | 6 ++-- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/internal/theme/common/common.go b/internal/theme/common/common.go index b904aab..62eb143 100644 --- a/internal/theme/common/common.go +++ b/internal/theme/common/common.go @@ -174,11 +174,17 @@ func (h *Handle) PreCodeAndStats() { func (h *Handle) Render() { h.PreCodeAndStats() h.PreTemplate() - h.ExecHandleFns() - h.PushHeadScript(Components{CalSiteIcon, 10}, Components{CalCustomCss, -1}) h.AddComponent("customLogo", CalCustomLogo) - h.CalMultipleComponents() - h.CalBodyClass() + + h.PushHeadScript(Components{CalSiteIcon, 100}, Components{CalCustomCss, 0}) + + h.PushHandleFn(constraints.AllStats, NewHandleFn(func(h *Handle) { + h.CalMultipleComponents() + h.CalBodyClass() + }, 5)) + + h.ExecHandleFns() + h.C.HTML(h.Code, h.templ, h.ginH) } diff --git a/internal/theme/common/detail.go b/internal/theme/common/detail.go index b640ae1..11954ff 100644 --- a/internal/theme/common/detail.go +++ b/internal/theme/common/detail.go @@ -101,9 +101,12 @@ func (d *DetailHandle) ContextPost() { } func (d *DetailHandle) Render() { - d.PasswordProject() - d.RenderComment() - d.ginH["post"] = d.Post + d.PushHandleFn(constraints.Ok, NewHandleFn(func(h *Handle) { + d.PasswordProject() + d.RenderComment() + d.ginH["post"] = d.Post + }, 10)) + d.Handle.Render() } diff --git a/internal/theme/common/index.go b/internal/theme/common/index.go index 02dc4cd..fbe5b02 100644 --- a/internal/theme/common/index.go +++ b/internal/theme/common/index.go @@ -18,9 +18,25 @@ type IndexHandle struct { *Handle Param *IndexParams Posts []models.Posts - PageEle pagination.Elements + pageEle pagination.Elements TotalRows int - PostsPlugins map[string]Plugin[models.Posts, *Handle] + postsPlugins map[string]Plugin[models.Posts, *Handle] +} + +func (i *IndexHandle) PageEle() pagination.Elements { + return i.pageEle +} + +func (i *IndexHandle) SetPageEle(pageEle pagination.Elements) { + i.pageEle = pageEle +} + +func (i *IndexHandle) PostsPlugins() map[string]Plugin[models.Posts, *Handle] { + return i.postsPlugins +} + +func (i *IndexHandle) SetPostsPlugins(postsPlugins map[string]Plugin[models.Posts, *Handle]) { + i.postsPlugins = postsPlugins } func NewIndexHandle(handle *Handle) *IndexHandle { @@ -80,15 +96,15 @@ func (i *IndexHandle) GetIndexData() (posts []models.Posts, totalRaw int, err er } func (i *IndexHandle) Pagination() { - if i.PageEle == nil { - i.PageEle = plugins.TwentyFifteenPagination() + if i.pageEle == nil { + i.pageEle = plugins.TwentyFifteenPagination() } q := i.C.Request.URL.Query().Encode() if q != "" { q = fmt.Sprintf("?%s", q) } paginations := pagination.NewParsePagination(i.TotalRows, i.Param.PageSize, i.Param.Page, i.Param.PaginationStep, q, i.C.Request.URL.Path) - i.ginH["pagination"] = pagination.Paginate(i.PageEle, paginations) + i.ginH["pagination"] = pagination.Paginate(i.pageEle, paginations) } @@ -115,7 +131,7 @@ func (i *IndexHandle) ExecPostsPlugin(calls ...func(*models.Posts)) { pluginConf := config.GetConfig().ListPagePlugins - postsPlugins := i.PostsPlugins + postsPlugins := i.postsPlugins if postsPlugins == nil { postsPlugins = pluginFns } @@ -126,8 +142,10 @@ func (i *IndexHandle) ExecPostsPlugin(calls ...func(*models.Posts)) { } func (i *IndexHandle) Render() { - i.ExecPostsPlugin() - i.Pagination() + i.PushHandleFn(constraints.Ok, NewHandleFn(func(h *Handle) { + i.ExecPostsPlugin() + i.Pagination() + }, 10)) i.Handle.Render() } diff --git a/internal/theme/twentyseventeen/twentyseventeen.go b/internal/theme/twentyseventeen/twentyseventeen.go index cc01983..846d2fd 100644 --- a/internal/theme/twentyseventeen/twentyseventeen.go +++ b/internal/theme/twentyseventeen/twentyseventeen.go @@ -36,7 +36,7 @@ func Hook(h *common.Handle) { func ready(next common.HandleFn[*common.Handle], h *common.Handle) { h.WidgetAreaData() h.GetPassword() - h.PushHandleFn(constraints.AllStats, common.NewHandleFn(calClass, 10)) + h.PushHandleFn(constraints.AllStats, common.NewHandleFn(calClass, 15)) h.PushHeadScript( common.NewComponents(colorScheme, 10), common.NewComponents(customHeader, 10), @@ -68,8 +68,8 @@ func index(next common.HandleFn[*common.Handle], i *common.IndexHandle) { i.Render() return } - i.PostsPlugins = listPostsPlugins - i.PageEle = paginate + i.SetPageEle(paginate) + i.SetPostsPlugins(listPostsPlugins) next(i.Handle) }