From 8a5fc0224722ffa354b48ea19c8c7c9e26a6d91b Mon Sep 17 00:00:00 2001 From: xing Date: Fri, 24 Feb 2023 19:43:12 +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/twentyfifteen/twentyfifteen.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/internal/theme/twentyfifteen/twentyfifteen.go b/internal/theme/twentyfifteen/twentyfifteen.go index 6cb7838..d73ac20 100644 --- a/internal/theme/twentyfifteen/twentyfifteen.go +++ b/internal/theme/twentyfifteen/twentyfifteen.go @@ -28,14 +28,13 @@ func Init(fs embed.FS) { logs.ErrPrintln(err, "解析colorscheme失败") } -var detailPipe = common.HandlePipe(func(d *common.DetailHandle) { - d.Render() -}, detail) -var indexPipe = common.HandlePipe(func(i *common.IndexHandle) { - i.Render() -}, index) +var pipe = common.HandlePipe(common.Render, dispatch) func Hook(h *common.Handle) { + pipe(h) +} + +func dispatch(next common.HandleFn[*common.Handle], h *common.Handle) { h.WidgetAreaData() h.GetPassword() h.AutoCal("colorScheme", colorSchemeCss) @@ -43,16 +42,16 @@ func Hook(h *common.Handle) { h.PushHandleFn(customHeader) switch h.Scene { case constraints.Detail: - detailPipe(common.NewDetailHandle(h)) + detail(next, h.Detail) default: - indexPipe(common.NewIndexHandle(h)) + index(next, h.Index) } } -func index(next common.HandleFn[*common.IndexHandle], i *common.IndexHandle) { +func index(next common.HandleFn[*common.Handle], i *common.IndexHandle) { i.Indexs() } -func detail(fn common.HandleFn[*common.DetailHandle], d *common.DetailHandle) { +func detail(fn common.HandleFn[*common.Handle], d *common.DetailHandle) { d.Details() }