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失败")
|
|
|
|
}
|
|
|
|
|
2023-02-16 06:36:43 +00:00
|
|
|
type handle struct {
|
2023-02-11 15:51:07 +00:00
|
|
|
*common.IndexHandle
|
2023-02-16 06:36:43 +00:00
|
|
|
*common.DetailHandle
|
2023-02-09 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
2023-02-16 06:36:43 +00:00
|
|
|
func newHandle(iHandle *common.IndexHandle, dHandle *common.DetailHandle) *handle {
|
|
|
|
return &handle{iHandle, dHandle}
|
2023-02-11 15:51:07 +00:00
|
|
|
}
|
2023-02-10 16:32:46 +00:00
|
|
|
|
2023-02-11 15:51:07 +00:00
|
|
|
func Hook(h *common.Handle) {
|
|
|
|
h.WidgetAreaData()
|
|
|
|
h.GetPassword()
|
2023-02-16 06:36:43 +00:00
|
|
|
handle := newHandle(common.NewIndexHandle(h), common.NewDetailHandle(h))
|
2023-02-10 13:23:30 +00:00
|
|
|
if h.Scene == constraints.Detail {
|
2023-02-16 06:36:43 +00:00
|
|
|
handle.Detail()
|
2023-02-09 12:49:33 +00:00
|
|
|
return
|
|
|
|
}
|
2023-02-16 06:36:43 +00:00
|
|
|
handle.Index()
|
2023-02-09 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
2023-02-16 06:36:43 +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)
|
2023-02-16 06:36:43 +00:00
|
|
|
h.Indexs()
|
2023-02-09 12:49:33 +00:00
|
|
|
}
|
|
|
|
|
2023-02-16 06:36:43 +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)
|
2023-02-16 06:36:43 +00:00
|
|
|
h.Details()
|
2023-02-09 12:49:33 +00:00
|
|
|
}
|