mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-03 02:10:25 +08:00
管理界面可以切换风格
This commit is contained in:
47
internal/web/actions/default/ui/theme.go
Normal file
47
internal/web/actions/default/ui/theme.go
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user