mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-04-10 09:45:19 +08:00
[系统设置]增加界面设置,可以定制系统名称等
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/oplogs"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/uimanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
@@ -48,6 +49,13 @@ func (this *IndexAction) RunGet(params struct {
|
||||
this.Data["token"] = stringutil.Md5(TokenSalt+timestamp) + timestamp
|
||||
this.Data["from"] = params.From
|
||||
|
||||
config, err := uimanager.LoadUIConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["systemName"] = config.AdminSystemName
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
|
||||
@@ -13,5 +13,5 @@ func (this *IndexAction) Init() {
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.RedirectURL("/settings/ui")
|
||||
this.RedirectURL("/settings/server")
|
||||
}
|
||||
|
||||
27
internal/web/actions/default/settings/server/index.go
Normal file
27
internal/web/actions/default/settings/server/index.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *IndexAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.Data["serverIsChanged"] = serverConfigIsChanged
|
||||
|
||||
serverConfig, err := loadServerConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["serverConfig"] = serverConfig
|
||||
|
||||
this.Show()
|
||||
}
|
||||
20
internal/web/actions/default/settings/server/init.go
Normal file
20
internal/web/actions/default/settings/server/init.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
|
||||
"github.com/iwind/TeaGo"
|
||||
)
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(settingutils.NewHelper("server")).
|
||||
Prefix("/settings/server").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("/updateHTTPPopup", new(UpdateHTTPPopupAction)).
|
||||
GetPost("/updateHTTPSPopup", new(UpdateHTTPSPopupAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package ui
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
@@ -1,4 +1,4 @@
|
||||
package ui
|
||||
package server
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@@ -1,4 +1,4 @@
|
||||
package ui
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo"
|
||||
@@ -25,7 +25,8 @@ func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) (goNext bool)
|
||||
|
||||
// 标签栏
|
||||
tabbar := actionutils.NewTabbar()
|
||||
tabbar.Add("管理界面", "", "/settings", "", this.tab == "ui")
|
||||
tabbar.Add("Web服务", "", "/settings/server", "", this.tab == "server")
|
||||
tabbar.Add("界面设置", "", "/settings/ui", "", this.tab == "ui")
|
||||
tabbar.Add("安全设置", "", "/settings/security", "", this.tab == "security")
|
||||
tabbar.Add("数据库", "", "/settings/database", "", this.tab == "database")
|
||||
tabbar.Add("API节点", "", "/api", "", this.tab == "apiNodes")
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package ui
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/uimanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
@@ -13,15 +15,47 @@ func (this *IndexAction) Init() {
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunGet(params struct{}) {
|
||||
this.Data["serverIsChanged"] = serverConfigIsChanged
|
||||
config, err := uimanager.LoadUIConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["config"] = config
|
||||
|
||||
serverConfig, err := loadServerConfig()
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *IndexAction) RunPost(params struct {
|
||||
ProductName string
|
||||
AdminSystemName string
|
||||
ShowOpenSourceInfo bool
|
||||
ShowVersion bool
|
||||
Version string
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
params.Must.
|
||||
Field("productName", params.ProductName).
|
||||
Require("请输入产品名称").
|
||||
Field("adminSystemName", params.AdminSystemName).
|
||||
Require("请输入管理员系统名称")
|
||||
|
||||
config, err := uimanager.LoadUIConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
config.ProductName = params.ProductName
|
||||
config.AdminSystemName = params.AdminSystemName
|
||||
config.ShowOpenSourceInfo = params.ShowOpenSourceInfo
|
||||
config.ShowVersion = params.ShowVersion
|
||||
config.Version = params.Version
|
||||
err = uimanager.UpdateUIConfig(config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["serverConfig"] = serverConfig
|
||||
|
||||
this.Show()
|
||||
this.Success()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ui
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/settingutils"
|
||||
@@ -12,9 +12,7 @@ func init() {
|
||||
Helper(helpers.NewUserMustAuth()).
|
||||
Helper(settingutils.NewHelper("ui")).
|
||||
Prefix("/settings/ui").
|
||||
Get("", new(IndexAction)).
|
||||
GetPost("/updateHTTPPopup", new(UpdateHTTPPopupAction)).
|
||||
GetPost("/updateHTTPSPopup", new(UpdateHTTPSPopupAction)).
|
||||
GetPost("", new(IndexAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
nodes "github.com/TeaOSLab/EdgeAdmin/internal/rpc"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/securitymanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/uimanager"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
@@ -83,13 +84,20 @@ func (this *UserMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
||||
return true
|
||||
}
|
||||
|
||||
config, err := uimanager.LoadUIConfig()
|
||||
if err != nil {
|
||||
action.WriteString(err.Error())
|
||||
return false
|
||||
}
|
||||
|
||||
// 初始化内置方法
|
||||
action.ViewFunc("teaTitle", func() string {
|
||||
return action.Data["teaTitle"].(string)
|
||||
})
|
||||
|
||||
action.Data["teaTitle"] = teaconst.ProductNameZH
|
||||
action.Data["teaName"] = teaconst.ProductNameZH
|
||||
action.Data["teaShowVersion"] = config.ShowVersion
|
||||
action.Data["teaTitle"] = config.AdminSystemName
|
||||
action.Data["teaName"] = config.ProductName
|
||||
|
||||
resp, err := rpc.AdminRPC().FindAdminFullname(rpc.Context(0), &pb.FindAdminFullnameRequest{AdminId: int64(this.AdminId)})
|
||||
if err != nil {
|
||||
@@ -105,7 +113,12 @@ func (this *UserMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
||||
action.Data["teaModules"] = this.modules()
|
||||
action.Data["teaSubMenus"] = []map[string]interface{}{}
|
||||
action.Data["teaTabbar"] = []map[string]interface{}{}
|
||||
action.Data["teaVersion"] = teaconst.Version
|
||||
if len(config.Version) == 0 {
|
||||
action.Data["teaVersion"] = teaconst.Version
|
||||
} else {
|
||||
action.Data["teaVersion"] = config.Version
|
||||
}
|
||||
action.Data["teaShowOpenSourceInfo"] = config.ShowOpenSourceInfo
|
||||
action.Data["teaIsSuper"] = false
|
||||
action.Data["teaDemoEnabled"] = teaconst.IsDemo
|
||||
if !action.Data.Has("teaSubMenu") {
|
||||
|
||||
@@ -77,6 +77,7 @@ import (
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/login"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/profile"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/security"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/server"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/ui"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/upgrade"
|
||||
_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/setup"
|
||||
|
||||
Reference in New Issue
Block a user