mirror of
https://github.com/cloudreve/cloudreve.git
synced 2025-12-15 10:04:01 +08:00
feat(ui): custom HTML content in predefined locations (#2621)
This commit is contained in:
2
assets
2
assets
Submodule assets updated: d4819eeaf4...aa80ca5bb2
@@ -518,6 +518,9 @@ var DefaultSettings = map[string]string{
|
||||
"qq_login_config": `{"direct_sign_in":false}`,
|
||||
"license": "",
|
||||
"custom_nav_items": "[]",
|
||||
"headless_footer_html": "",
|
||||
"headless_bottom_html": "",
|
||||
"sidebar_bottom_html": "",
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -200,6 +200,8 @@ type (
|
||||
CustomProps(ctx context.Context) []types.CustomProps
|
||||
// CustomNavItems returns the custom nav items settings.
|
||||
CustomNavItems(ctx context.Context) []CustomNavItem
|
||||
// CustomHTML returns the custom HTML settings.
|
||||
CustomHTML(ctx context.Context) *CustomHTML
|
||||
}
|
||||
UseFirstSiteUrlCtxKey = struct{}
|
||||
)
|
||||
@@ -227,6 +229,13 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (s *settingProvider) CustomHTML(ctx context.Context) *CustomHTML {
|
||||
return &CustomHTML{
|
||||
HeadlessFooter: s.getString(ctx, "headless_footer_html", ""),
|
||||
HeadlessBody: s.getString(ctx, "headless_bottom_html", ""),
|
||||
SidebarBottom: s.getString(ctx, "sidebar_bottom_html", ""),
|
||||
}
|
||||
}
|
||||
func (s *settingProvider) CustomNavItems(ctx context.Context) []CustomNavItem {
|
||||
raw := s.getString(ctx, "custom_nav_items", "[]")
|
||||
var items []CustomNavItem
|
||||
|
||||
@@ -215,3 +215,9 @@ type CustomNavItem struct {
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
type CustomHTML struct {
|
||||
HeadlessFooter string `json:"headless_footer,omitempty"`
|
||||
HeadlessBody string `json:"headless_bottom,omitempty"`
|
||||
SidebarBottom string `json:"sidebar_bottom,omitempty"`
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ type SiteConfig struct {
|
||||
Logo string `json:"logo,omitempty"`
|
||||
LogoLight string `json:"logo_light,omitempty"`
|
||||
CustomNavItems []setting.CustomNavItem `json:"custom_nav_items,omitempty"`
|
||||
CustomHTML *setting.CustomHTML `json:"custom_html,omitempty"`
|
||||
|
||||
// Login Section
|
||||
LoginCaptcha bool `json:"login_captcha,omitempty"`
|
||||
@@ -130,6 +131,7 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) {
|
||||
capCaptcha := settings.CapCaptcha(c)
|
||||
appSetting := settings.AppSetting(c)
|
||||
customNavItems := settings.CustomNavItems(c)
|
||||
customHTML := settings.CustomHTML(c)
|
||||
return &SiteConfig{
|
||||
InstanceID: siteBasic.ID,
|
||||
SiteName: siteBasic.Name,
|
||||
@@ -146,6 +148,7 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) {
|
||||
CapAssetServer: capCaptcha.AssetServer,
|
||||
AppPromotion: appSetting.Promotion,
|
||||
CustomNavItems: customNavItems,
|
||||
CustomHTML: customHTML,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user