优化代码
This commit is contained in:
parent
ccbba30ae2
commit
8a5fc02247
|
@ -28,14 +28,13 @@ func Init(fs embed.FS) {
|
||||||
logs.ErrPrintln(err, "解析colorscheme失败")
|
logs.ErrPrintln(err, "解析colorscheme失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
var detailPipe = common.HandlePipe(func(d *common.DetailHandle) {
|
var pipe = common.HandlePipe(common.Render, dispatch)
|
||||||
d.Render()
|
|
||||||
}, detail)
|
|
||||||
var indexPipe = common.HandlePipe(func(i *common.IndexHandle) {
|
|
||||||
i.Render()
|
|
||||||
}, index)
|
|
||||||
|
|
||||||
func Hook(h *common.Handle) {
|
func Hook(h *common.Handle) {
|
||||||
|
pipe(h)
|
||||||
|
}
|
||||||
|
|
||||||
|
func dispatch(next common.HandleFn[*common.Handle], h *common.Handle) {
|
||||||
h.WidgetAreaData()
|
h.WidgetAreaData()
|
||||||
h.GetPassword()
|
h.GetPassword()
|
||||||
h.AutoCal("colorScheme", colorSchemeCss)
|
h.AutoCal("colorScheme", colorSchemeCss)
|
||||||
|
@ -43,16 +42,16 @@ func Hook(h *common.Handle) {
|
||||||
h.PushHandleFn(customHeader)
|
h.PushHandleFn(customHeader)
|
||||||
switch h.Scene {
|
switch h.Scene {
|
||||||
case constraints.Detail:
|
case constraints.Detail:
|
||||||
detailPipe(common.NewDetailHandle(h))
|
detail(next, h.Detail)
|
||||||
default:
|
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()
|
i.Indexs()
|
||||||
}
|
}
|
||||||
|
|
||||||
func detail(fn common.HandleFn[*common.DetailHandle], d *common.DetailHandle) {
|
func detail(fn common.HandleFn[*common.Handle], d *common.DetailHandle) {
|
||||||
d.Details()
|
d.Details()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user