theme.go 604 B

1234567891011121314151617181920212223242526272829303132
  1. package system_setting
  2. import (
  3. "github.com/QuantumNous/new-api/common"
  4. "github.com/QuantumNous/new-api/setting/config"
  5. )
  6. type ThemeSettings struct {
  7. Frontend string `json:"frontend"`
  8. }
  9. var themeSettings = ThemeSettings{
  10. Frontend: "classic",
  11. }
  12. func init() {
  13. config.GlobalConfig.Register("theme", &themeSettings)
  14. syncThemeToCommon()
  15. }
  16. func syncThemeToCommon() {
  17. common.SetTheme(themeSettings.Frontend)
  18. }
  19. func GetThemeSettings() *ThemeSettings {
  20. return &themeSettings
  21. }
  22. // UpdateAndSyncTheme syncs the theme config to common after DB load.
  23. func UpdateAndSyncTheme() {
  24. syncThemeToCommon()
  25. }