修复bug

This commit is contained in:
xing 2023-02-19 22:15:19 +08:00
parent 75c9a47799
commit ccfe077947
2 changed files with 21 additions and 23 deletions

View File

@ -44,7 +44,7 @@ func (h *handle) calColorSchemeCss() (r string) {
func (h *handle) calSidebarTextColorCss() (r string) {
colors := h.getColorScheme()
if h.IndexHandle.ThemeMods.SidebarTextcolor == colors[4] {
if h.IndexHandle.ThemeMods.SidebarTextcolor != "" && h.IndexHandle.ThemeMods.SidebarTextcolor == colors[4] {
return
}
linkColorRgb := Hex2RgbUint8(h.IndexHandle.ThemeMods.SidebarTextcolor)
@ -58,7 +58,7 @@ func (h *handle) calSidebarTextColorCss() (r string) {
func (h *handle) calHeaderBackgroundColorCss() (r string) {
colors := h.getColorScheme()
if h.IndexHandle.ThemeMods.HeaderBackgroundColor == colors[1] {
if h.IndexHandle.ThemeMods.HeaderBackgroundColor != "" && h.IndexHandle.ThemeMods.HeaderBackgroundColor == colors[1] {
return
}
r = fmt.Sprintf(headerBackgroundColorCssTemplate, h.IndexHandle.ThemeMods.HeaderBackgroundColor, h.IndexHandle.ThemeMods.HeaderBackgroundColor)

View File

@ -20,24 +20,24 @@ func SetTemplateFs(fs embed.FS) {
}
type ThemeMods struct {
CustomCssPostId int `json:"custom_css_post_id,omitempty"`
NavMenuLocations any `json:"nav_menu_locations,omitempty"`
CustomLogo int `json:"custom_logo,omitempty"`
HeaderImage string `json:"header_image,omitempty"`
BackgroundImage string `json:"background_image,omitempty"`
BackgroundSize string `json:"background_size,omitempty"`
BackgroundRepeat string `json:"background_repeat,omitempty"`
BackgroundColor string `json:"background_color,omitempty"`
BackgroundPreset string `json:"background_preset"`
BackgroundPositionX string `json:"background_position_x,omitempty"`
BackgroundPositionY string `json:"background_position_y"`
BackgroundAttachment string `json:"background_attachment"`
ColorScheme string `json:"color_scheme"`
SidebarTextcolor string `json:"sidebar_textcolor,omitempty"`
HeaderBackgroundColor string `json:"header_background_color,omitempty"`
HeaderTextcolor string `json:"header_textcolor,omitempty"`
HeaderImagData ImageData `json:"header_image_data,omitempty"`
SidebarsWidgets Sidebars `json:"sidebars_widgets,omitempty"`
CustomCssPostId int `json:"custom_css_post_id,omitempty"`
NavMenuLocations map[string]int `json:"nav_menu_locations,omitempty"`
CustomLogo int `json:"custom_logo,omitempty"`
HeaderImage string `json:"header_image,omitempty"`
BackgroundImage string `json:"background_image,omitempty"`
BackgroundSize string `json:"background_size,omitempty"`
BackgroundRepeat string `json:"background_repeat,omitempty"`
BackgroundColor string `json:"background_color,omitempty"`
BackgroundPreset string `json:"background_preset"`
BackgroundPositionX string `json:"background_position_x,omitempty"`
BackgroundPositionY string `json:"background_position_y"`
BackgroundAttachment string `json:"background_attachment"`
ColorScheme string `json:"color_scheme"`
SidebarTextcolor string `json:"sidebar_textcolor,omitempty"`
HeaderBackgroundColor string `json:"header_background_color,omitempty"`
HeaderTextcolor string `json:"header_textcolor,omitempty"`
HeaderImagData ImageData `json:"header_image_data,omitempty"`
SidebarsWidgets Sidebars `json:"sidebars_widgets,omitempty"`
ThemeSupport ThemeSupport
}
@ -121,10 +121,8 @@ func GetThemeMods(theme string) (r ThemeMods, err error) {
if !ok || mods == "" {
return
}
//这里在的err可以不用处理因为php的默认值和有设置过的类型可能不一样直接按有设置的类型处理就行
r, err = phphelper.UnPHPSerialize[ThemeMods](mods)
if err != nil {
return
}
r.setThemeSupport(theme)
themeModes.Store(theme, r)
return