Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix(theme): Set a default theme config

LinkinStar1110a97ee1eb
diff --git a/internal/migrations/init.go b/internal/migrations/init.go
index e1a6a829..dad2028a 100644
--- a/internal/migrations/init.go
+++ b/internal/migrations/init.go
@@ -155,6 +155,16 @@ func initSiteInfo(engine *xorm.Engine, language, siteName, siteURL, contactEmail
return err
}
+ themeConfig := `{"theme":"default","theme_config":{"default":{"navbar_style":"colored","primary_color":"#0033ff"}}}`
+ _, err = engine.InsertOne(&entity.SiteInfo{
+ Type: "theme",
+ Content: themeConfig,
+ Status: 1,
+ })
+ if err != nil {
+ return err
+ }
+
seoData := map[string]string{
"robots": defaultSEORobotTxt + siteURL + "/sitemap.xml",
}
diff --git a/internal/migrations/v5.go b/internal/migrations/v5.go
index fc4b057a..d9cb2c83 100644
--- a/internal/migrations/v5.go
+++ b/internal/migrations/v5.go
@@ -26,5 +26,19 @@ func addThemeAndPrivateMode(x *xorm.Engine) error {
if !exist {
_, err = x.InsertOne(siteInfo)
}
+
+ themeConfig := `{"theme":"default","theme_config":{"default":{"navbar_style":"colored","primary_color":"#0033ff"}}}`
+ themeSiteInfo := &entity.SiteInfo{
+ Type: "theme",
+ Content: themeConfig,
+ Status: 1,
+ }
+ exist, err = x.Get(&entity.SiteInfo{Type: themeSiteInfo.Type})
+ if err != nil {
+ return fmt.Errorf("get config failed: %w", err)
+ }
+ if !exist {
+ _, err = x.InsertOne(siteInfo)
+ }
return err
}