diff --git a/assets b/assets index ada49fd..d4819ee 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit ada49fd21d159563b21d29d7d3499a45c5ab1503 +Subproject commit d4819eeaf4ed3d443165def69cb89267d31b81da diff --git a/inventory/setting.go b/inventory/setting.go index cf5c2dd..1a31699 100644 --- a/inventory/setting.go +++ b/inventory/setting.go @@ -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() { diff --git a/pkg/setting/provider.go b/pkg/setting/provider.go index b234c3d..4b00c66 100644 --- a/pkg/setting/provider.go +++ b/pkg/setting/provider.go @@ -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 diff --git a/pkg/setting/types.go b/pkg/setting/types.go index 6c389c2..759dea1 100644 --- a/pkg/setting/types.go +++ b/pkg/setting/types.go @@ -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"` +} diff --git a/service/basic/site.go b/service/basic/site.go index 5af8fae..ec295d1 100644 --- a/service/basic/site.go +++ b/service/basic/site.go @@ -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 }