diff --git a/pkg/cache/driver_test.go b/pkg/cache/driver_test.go index d30a67f..da4b844 100644 --- a/pkg/cache/driver_test.go +++ b/pkg/cache/driver_test.go @@ -1,8 +1,9 @@ package cache import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestSet(t *testing.T) { diff --git a/pkg/setting/provider.go b/pkg/setting/provider.go index 0deb6da..3f1a8bd 100644 --- a/pkg/setting/provider.go +++ b/pkg/setting/provider.go @@ -776,6 +776,16 @@ func (s *settingProvider) PWA(ctx context.Context) *PWASetting { } } +// AnnouncementEnabled returns true if announcement is enabled. +func (s *settingProvider) AnnouncementEnabled(ctx context.Context) bool { + return s.getBoolean(ctx, "announcement_enabled", false) +} + +// Announcement returns the site announcement content. +func (s *settingProvider) Announcement(ctx context.Context) string { + return s.getString(ctx, "announcement", "") +} + func IsTrueValue(val string) bool { return val == "1" || val == "true" } diff --git a/service/basic/site.go b/service/basic/site.go index 5c34a50..004ea38 100644 --- a/service/basic/site.go +++ b/service/basic/site.go @@ -60,6 +60,10 @@ type SiteConfig struct { // App settings AppPromotion bool `json:"app_promotion,omitempty"` + // Announcement settings + AnnouncementEnabled bool `json:"announcement_enabled,omitempty"` + Announcement string `json:"announcement,omitempty"` + //EmailActive bool `json:"emailActive"` //QQLogin bool `json:"QQLogin"` //ScoreEnabled bool `json:"score_enabled"` @@ -183,22 +187,24 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) { customNavItems := settings.CustomNavItems(c) customHTML := settings.CustomHTML(c) return &SiteConfig{ - InstanceID: siteBasic.ID, - SiteName: siteBasic.Name, - Themes: themes.Themes, - DefaultTheme: themes.DefaultTheme, - User: &userRes, - Logo: logo.Normal, - LogoLight: logo.Light, - CaptchaType: settings.CaptchaType(c), - TurnstileSiteID: settings.TurnstileCaptcha(c).Key, - ReCaptchaKey: reCaptcha.Key, - CapInstanceURL: capCaptcha.InstanceURL, - CapSiteKey: capCaptcha.SiteKey, - CapAssetServer: capCaptcha.AssetServer, - AppPromotion: appSetting.Promotion, - CustomNavItems: customNavItems, - CustomHTML: customHTML, + InstanceID: siteBasic.ID, + SiteName: siteBasic.Name, + Themes: themes.Themes, + DefaultTheme: themes.DefaultTheme, + User: &userRes, + Logo: logo.Normal, + LogoLight: logo.Light, + CaptchaType: settings.CaptchaType(c), + TurnstileSiteID: settings.TurnstileCaptcha(c).Key, + ReCaptchaKey: reCaptcha.Key, + CapInstanceURL: capCaptcha.InstanceURL, + CapSiteKey: capCaptcha.SiteKey, + CapAssetServer: capCaptcha.AssetServer, + AppPromotion: appSetting.Promotion, + CustomNavItems: customNavItems, + CustomHTML: customHTML, + AnnouncementEnabled: settings.AnnouncementEnabled(c), + Announcement: settings.Announcement(c), }, nil }