完善站点运营设置:分路由管理、登录可见评论、邮件模板内联与关闭注册 SSR。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -28,6 +28,10 @@ const (
|
||||
BrandMarkImage = "image"
|
||||
BrandMarkText = "text"
|
||||
|
||||
FooterLinkAlignLeft = "left"
|
||||
FooterLinkAlignCenter = "center"
|
||||
FooterLinkAlignRight = "right"
|
||||
|
||||
BrandLogoSizeSQ = "sq"
|
||||
BrandLogoSize2x1 = "2x1"
|
||||
BrandLogoSize3x1 = "3x1"
|
||||
@@ -53,6 +57,7 @@ type FooterLink struct {
|
||||
Label string `json:"label"`
|
||||
URL string `json:"url"`
|
||||
NewTab bool `json:"new_tab"`
|
||||
Align string `json:"align"`
|
||||
}
|
||||
|
||||
// 仅接受本站品牌目录;Logo 不含 ico,Favicon 含 ico
|
||||
@@ -219,6 +224,19 @@ type footerLinkIn struct {
|
||||
Label string `json:"label"`
|
||||
URL string `json:"url"`
|
||||
NewTab *bool `json:"new_tab"`
|
||||
Align string `json:"align"`
|
||||
}
|
||||
|
||||
// NormalizeFooterLinkAlign 单条页脚链接所属栏位;空串视为居右。
|
||||
func NormalizeFooterLinkAlign(raw string) (string, bool) {
|
||||
switch strings.TrimSpace(raw) {
|
||||
case "", FooterLinkAlignRight:
|
||||
return FooterLinkAlignRight, true
|
||||
case FooterLinkAlignLeft, FooterLinkAlignCenter:
|
||||
return strings.TrimSpace(raw), true
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
// NormalizeFooterLinks 校验并截断页脚链接;外链未显式指定时默认新标签
|
||||
@@ -236,7 +254,11 @@ func NormalizeFooterLinks(raw []FooterLink) ([]FooterLink, error) {
|
||||
if !ok {
|
||||
return nil, ErrInvalidSiteSetting
|
||||
}
|
||||
out = append(out, FooterLink{Label: label, URL: u, NewTab: item.NewTab})
|
||||
align, ok := NormalizeFooterLinkAlign(item.Align)
|
||||
if !ok {
|
||||
return nil, ErrInvalidSiteSetting
|
||||
}
|
||||
out = append(out, FooterLink{Label: label, URL: u, NewTab: item.NewTab, Align: align})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
@@ -266,7 +288,11 @@ func parseFooterLinksJSON(raw string) ([]FooterLink, error) {
|
||||
} else if isExternalFooterURL(u) {
|
||||
newTab = true
|
||||
}
|
||||
out = append(out, FooterLink{Label: label, URL: u, NewTab: newTab})
|
||||
align, ok := NormalizeFooterLinkAlign(item.Align)
|
||||
if !ok {
|
||||
align = FooterLinkAlignRight
|
||||
}
|
||||
out = append(out, FooterLink{Label: label, URL: u, NewTab: newTab, Align: align})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
@@ -467,6 +493,8 @@ func (s *SettingService) SetFooterLinks(raw []FooterLink) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 去掉曾用的站级对齐键(现改为逐条 align)
|
||||
_ = s.deleteKey("footer_links_align")
|
||||
if len(list) == 0 {
|
||||
return s.deleteKey(SettingKeyFooterLinks)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user