mirror of https://github.com/cloudreve/Cloudreve
feat(custom): custom sidebar items
parent
3cda4d1ef7
commit
ca57ca1ba0
2
assets
2
assets
|
@ -1 +1 @@
|
|||
Subproject commit ada49fd21d159563b21d29d7d3499a45c5ab1503
|
||||
Subproject commit d4819eeaf4ed3d443165def69cb89267d31b81da
|
|
@ -517,6 +517,7 @@ var DefaultSettings = map[string]string{
|
|||
"qq_login": `0`,
|
||||
"qq_login_config": `{"direct_sign_in":false}`,
|
||||
"license": "",
|
||||
"custom_nav_items": "[]",
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -198,6 +198,8 @@ type (
|
|||
LibRawThumbPath(ctx context.Context) string
|
||||
// CustomProps returns the custom props settings.
|
||||
CustomProps(ctx context.Context) []types.CustomProps
|
||||
// CustomNavItems returns the custom nav items settings.
|
||||
CustomNavItems(ctx context.Context) []CustomNavItem
|
||||
}
|
||||
UseFirstSiteUrlCtxKey = struct{}
|
||||
)
|
||||
|
@ -225,6 +227,14 @@ type (
|
|||
}
|
||||
)
|
||||
|
||||
func (s *settingProvider) CustomNavItems(ctx context.Context) []CustomNavItem {
|
||||
raw := s.getString(ctx, "custom_nav_items", "[]")
|
||||
var items []CustomNavItem
|
||||
if err := json.Unmarshal([]byte(raw), &items); err != nil {
|
||||
return []CustomNavItem{}
|
||||
}
|
||||
return items
|
||||
}
|
||||
func (s *settingProvider) CustomProps(ctx context.Context) []types.CustomProps {
|
||||
raw := s.getString(ctx, "custom_props", "[]")
|
||||
var props []types.CustomProps
|
||||
|
|
|
@ -209,3 +209,9 @@ type AvatarProcess struct {
|
|||
MaxFileSize int64 `json:"max_file_size"`
|
||||
MaxWidth int `json:"max_width"`
|
||||
}
|
||||
|
||||
type CustomNavItem struct {
|
||||
Icon string `json:"icon"`
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
|
|
@ -13,13 +13,14 @@ import (
|
|||
// SiteConfig 站点全局设置序列
|
||||
type SiteConfig struct {
|
||||
// Basic Section
|
||||
InstanceID string `json:"instance_id,omitempty"`
|
||||
SiteName string `json:"title,omitempty"`
|
||||
Themes string `json:"themes,omitempty"`
|
||||
DefaultTheme string `json:"default_theme,omitempty"`
|
||||
User *user.User `json:"user,omitempty"`
|
||||
Logo string `json:"logo,omitempty"`
|
||||
LogoLight string `json:"logo_light,omitempty"`
|
||||
InstanceID string `json:"instance_id,omitempty"`
|
||||
SiteName string `json:"title,omitempty"`
|
||||
Themes string `json:"themes,omitempty"`
|
||||
DefaultTheme string `json:"default_theme,omitempty"`
|
||||
User *user.User `json:"user,omitempty"`
|
||||
Logo string `json:"logo,omitempty"`
|
||||
LogoLight string `json:"logo_light,omitempty"`
|
||||
CustomNavItems []setting.CustomNavItem `json:"custom_nav_items,omitempty"`
|
||||
|
||||
// Login Section
|
||||
LoginCaptcha bool `json:"login_captcha,omitempty"`
|
||||
|
@ -128,7 +129,7 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) {
|
|||
reCaptcha := settings.ReCaptcha(c)
|
||||
capCaptcha := settings.CapCaptcha(c)
|
||||
appSetting := settings.AppSetting(c)
|
||||
|
||||
customNavItems := settings.CustomNavItems(c)
|
||||
return &SiteConfig{
|
||||
InstanceID: siteBasic.ID,
|
||||
SiteName: siteBasic.Name,
|
||||
|
@ -144,6 +145,7 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) {
|
|||
CapSiteKey: capCaptcha.SiteKey,
|
||||
CapAssetServer: capCaptcha.AssetServer,
|
||||
AppPromotion: appSetting.Promotion,
|
||||
CustomNavItems: customNavItems,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue