管理界面可以切换风格

This commit is contained in:
刘祥超
2021-07-12 10:21:17 +08:00
parent 9e36847397
commit 32683a2b59
12 changed files with 159 additions and 12 deletions

View File

@@ -0,0 +1,47 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package ui
import (
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type ThemeAction struct {
actionutils.ParentAction
}
func (this *ThemeAction) RunPost(params struct{}) {
theme := configloaders.FindAdminTheme(this.AdminId())
var themes = []string{"theme1", "theme2", "theme3"}
var nextTheme = "theme1"
if len(theme) == 0 {
nextTheme = "theme2"
} else {
for index, t := range themes {
if t == theme {
if index < len(themes)-1 {
nextTheme = themes[index+1]
break
}
}
}
}
_, err := this.RPC().AdminRPC().UpdateAdminTheme(this.AdminContext(), &pb.UpdateAdminThemeRequest{
AdminId: this.AdminId(),
Theme: nextTheme,
})
if err != nil {
this.ErrorPage(err)
return
}
configloaders.UpdateAdminTheme(this.AdminId(), nextTheme)
this.Data["theme"] = nextTheme
this.Success()
}