wp-go/internal/theme/twentyfifteen/twentyfifteen.go

64 lines
1.4 KiB
Go
Raw Normal View History

2023-02-09 12:49:33 +00:00
package twentyfifteen
import (
2023-02-18 15:35:39 +00:00
"embed"
"encoding/json"
2023-02-10 13:23:30 +00:00
"github.com/fthvgb1/wp-go/internal/pkg/constraints"
2023-02-18 15:35:39 +00:00
"github.com/fthvgb1/wp-go/internal/pkg/logs"
2023-02-09 12:49:33 +00:00
"github.com/fthvgb1/wp-go/internal/theme/common"
)
const ThemeName = "twentyfifteen"
2023-02-18 15:35:39 +00:00
func Init(fs embed.FS) {
b, err := fs.ReadFile("twentyfifteen/themesupport.json")
if err != nil {
return
}
err = json.Unmarshal(b, &themesupport)
logs.ErrPrintln(err, "解析themesupport失败")
bytes, err := fs.ReadFile("twentyfifteen/colorscheme.json")
if err != nil {
return
}
err = json.Unmarshal(bytes, &colorscheme)
if err != nil {
return
}
logs.ErrPrintln(err, "解析colorscheme失败")
}
type handle struct {
*common.IndexHandle
*common.DetailHandle
2023-02-09 12:49:33 +00:00
}
func newHandle(iHandle *common.IndexHandle, dHandle *common.DetailHandle) *handle {
return &handle{iHandle, dHandle}
}
func Hook(h *common.Handle) {
h.WidgetAreaData()
h.GetPassword()
handle := newHandle(common.NewIndexHandle(h), common.NewDetailHandle(h))
2023-02-10 13:23:30 +00:00
if h.Scene == constraints.Detail {
handle.Detail()
2023-02-09 12:49:33 +00:00
return
}
handle.Index()
2023-02-09 12:49:33 +00:00
}
func (h *handle) Index() {
h.CustomHeader()
2023-02-18 16:14:33 +00:00
h.IndexHandle.AutoCal("colorScheme", h.colorSchemeCss)
h.IndexHandle.AutoCal("customBackground", h.CalCustomBackGround)
h.Indexs()
2023-02-09 12:49:33 +00:00
}
func (h *handle) Detail() {
h.CustomHeader()
2023-02-18 16:14:33 +00:00
h.IndexHandle.AutoCal("colorScheme", h.colorSchemeCss)
h.IndexHandle.AutoCal("customBackground", h.CalCustomBackGround)
h.Details()
2023-02-09 12:49:33 +00:00
}