feat(custom): custom sidebar items
This commit is contained in:
2
assets
2
assets
Submodule assets updated: ada49fd21d...d4819eeaf4
@@ -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"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ import (
|
|||||||
// SiteConfig 站点全局设置序列
|
// SiteConfig 站点全局设置序列
|
||||||
type SiteConfig struct {
|
type SiteConfig struct {
|
||||||
// Basic Section
|
// Basic Section
|
||||||
InstanceID string `json:"instance_id,omitempty"`
|
InstanceID string `json:"instance_id,omitempty"`
|
||||||
SiteName string `json:"title,omitempty"`
|
SiteName string `json:"title,omitempty"`
|
||||||
Themes string `json:"themes,omitempty"`
|
Themes string `json:"themes,omitempty"`
|
||||||
DefaultTheme string `json:"default_theme,omitempty"`
|
DefaultTheme string `json:"default_theme,omitempty"`
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user