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": `0`,
|
||||||
"qq_login_config": `{"direct_sign_in":false}`,
|
"qq_login_config": `{"direct_sign_in":false}`,
|
||||||
"license": "",
|
"license": "",
|
||||||
|
"custom_nav_items": "[]",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -198,6 +198,8 @@ type (
|
||||||
LibRawThumbPath(ctx context.Context) string
|
LibRawThumbPath(ctx context.Context) string
|
||||||
// CustomProps returns the custom props settings.
|
// CustomProps returns the custom props settings.
|
||||||
CustomProps(ctx context.Context) []types.CustomProps
|
CustomProps(ctx context.Context) []types.CustomProps
|
||||||
|
// CustomNavItems returns the custom nav items settings.
|
||||||
|
CustomNavItems(ctx context.Context) []CustomNavItem
|
||||||
}
|
}
|
||||||
UseFirstSiteUrlCtxKey = struct{}
|
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 {
|
func (s *settingProvider) CustomProps(ctx context.Context) []types.CustomProps {
|
||||||
raw := s.getString(ctx, "custom_props", "[]")
|
raw := s.getString(ctx, "custom_props", "[]")
|
||||||
var props []types.CustomProps
|
var props []types.CustomProps
|
||||||
|
|
|
@ -209,3 +209,9 @@ type AvatarProcess struct {
|
||||||
MaxFileSize int64 `json:"max_file_size"`
|
MaxFileSize int64 `json:"max_file_size"`
|
||||||
MaxWidth int `json:"max_width"`
|
MaxWidth int `json:"max_width"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CustomNavItem struct {
|
||||||
|
Icon string `json:"icon"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ type SiteConfig struct {
|
||||||
User *user.User `json:"user,omitempty"`
|
User *user.User `json:"user,omitempty"`
|
||||||
Logo string `json:"logo,omitempty"`
|
Logo string `json:"logo,omitempty"`
|
||||||
LogoLight string `json:"logo_light,omitempty"`
|
LogoLight string `json:"logo_light,omitempty"`
|
||||||
|
CustomNavItems []setting.CustomNavItem `json:"custom_nav_items,omitempty"`
|
||||||
|
|
||||||
// Login Section
|
// Login Section
|
||||||
LoginCaptcha bool `json:"login_captcha,omitempty"`
|
LoginCaptcha bool `json:"login_captcha,omitempty"`
|
||||||
|
@ -128,7 +129,7 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) {
|
||||||
reCaptcha := settings.ReCaptcha(c)
|
reCaptcha := settings.ReCaptcha(c)
|
||||||
capCaptcha := settings.CapCaptcha(c)
|
capCaptcha := settings.CapCaptcha(c)
|
||||||
appSetting := settings.AppSetting(c)
|
appSetting := settings.AppSetting(c)
|
||||||
|
customNavItems := settings.CustomNavItems(c)
|
||||||
return &SiteConfig{
|
return &SiteConfig{
|
||||||
InstanceID: siteBasic.ID,
|
InstanceID: siteBasic.ID,
|
||||||
SiteName: siteBasic.Name,
|
SiteName: siteBasic.Name,
|
||||||
|
@ -144,6 +145,7 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) {
|
||||||
CapSiteKey: capCaptcha.SiteKey,
|
CapSiteKey: capCaptcha.SiteKey,
|
||||||
CapAssetServer: capCaptcha.AssetServer,
|
CapAssetServer: capCaptcha.AssetServer,
|
||||||
AppPromotion: appSetting.Promotion,
|
AppPromotion: appSetting.Promotion,
|
||||||
|
CustomNavItems: customNavItems,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue