mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 08:40:26 +08:00
可以隐藏CDN功能菜单
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"io"
|
||||
)
|
||||
@@ -37,6 +38,8 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
}
|
||||
this.Data["timeZoneLocation"] = nodeconfigs.FindTimeZoneLocation(config.TimeZone)
|
||||
|
||||
this.filterConfig(config)
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
@@ -52,6 +55,9 @@ func (this *IndexAction) RunPost(params struct {
|
||||
DefaultPageSize int
|
||||
TimeZone string
|
||||
|
||||
SupportModuleCDN bool
|
||||
SupportModuleNS bool
|
||||
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
@@ -85,6 +91,14 @@ func (this *IndexAction) RunPost(params struct {
|
||||
config.DefaultPageSize = 10
|
||||
}
|
||||
|
||||
config.Modules = []userconfigs.UserModule{}
|
||||
if params.SupportModuleCDN {
|
||||
config.Modules = append(config.Modules, userconfigs.UserModuleCDN)
|
||||
}
|
||||
if params.SupportModuleNS {
|
||||
config.Modules = append(config.Modules, userconfigs.UserModuleNS)
|
||||
}
|
||||
|
||||
// 上传Favicon文件
|
||||
if params.FaviconFile != nil {
|
||||
createResp, err := this.RPC().FileRPC().CreateFile(this.AdminContext(), &pb.CreateFileRequest{
|
||||
|
||||
12
internal/web/actions/default/settings/ui/index_ext.go
Normal file
12
internal/web/actions/default/settings/ui/index_ext.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
//go:build !plus
|
||||
|
||||
package ui
|
||||
|
||||
import "github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
|
||||
func (this *IndexAction) filterConfig(config *systemconfigs.AdminUIConfig) {
|
||||
this.Data["supportModuleCDN"] = true
|
||||
this.Data["supportModuleNS"] = true
|
||||
this.Data["nsIsVisible"] = false
|
||||
}
|
||||
@@ -9,7 +9,10 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/setup"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
"github.com/iwind/TeaGo/logs"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"net"
|
||||
@@ -192,7 +195,7 @@ func (this *userMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
||||
return true
|
||||
}
|
||||
|
||||
config, err := configloaders.LoadAdminUIConfig()
|
||||
uiConfig, err := configloaders.LoadAdminUIConfig()
|
||||
if err != nil {
|
||||
action.WriteString(err.Error())
|
||||
return false
|
||||
@@ -203,11 +206,11 @@ func (this *userMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
||||
return action.Data["teaTitle"].(string)
|
||||
})
|
||||
|
||||
action.Data["teaShowVersion"] = config.ShowVersion
|
||||
action.Data["teaTitle"] = config.AdminSystemName
|
||||
action.Data["teaName"] = config.ProductName
|
||||
action.Data["teaFaviconFileId"] = config.FaviconFileId
|
||||
action.Data["teaLogoFileId"] = config.LogoFileId
|
||||
action.Data["teaShowVersion"] = uiConfig.ShowVersion
|
||||
action.Data["teaTitle"] = uiConfig.AdminSystemName
|
||||
action.Data["teaName"] = uiConfig.ProductName
|
||||
action.Data["teaFaviconFileId"] = uiConfig.FaviconFileId
|
||||
action.Data["teaLogoFileId"] = uiConfig.LogoFileId
|
||||
action.Data["teaUsername"] = configloaders.FindAdminFullname(adminId)
|
||||
action.Data["teaTheme"] = configloaders.FindAdminTheme(adminId)
|
||||
|
||||
@@ -216,15 +219,15 @@ func (this *userMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
||||
if !action.Data.Has("teaMenu") {
|
||||
action.Data["teaMenu"] = ""
|
||||
}
|
||||
action.Data["teaModules"] = this.modules(actionPtr, adminId)
|
||||
action.Data["teaModules"] = this.modules(actionPtr, adminId, uiConfig)
|
||||
action.Data["teaSubMenus"] = []map[string]interface{}{}
|
||||
action.Data["teaTabbar"] = []map[string]interface{}{}
|
||||
if len(config.Version) == 0 {
|
||||
if len(uiConfig.Version) == 0 {
|
||||
action.Data["teaVersion"] = teaconst.Version
|
||||
} else {
|
||||
action.Data["teaVersion"] = config.Version
|
||||
action.Data["teaVersion"] = uiConfig.Version
|
||||
}
|
||||
action.Data["teaShowOpenSourceInfo"] = config.ShowOpenSourceInfo
|
||||
action.Data["teaShowOpenSourceInfo"] = uiConfig.ShowOpenSourceInfo
|
||||
action.Data["teaIsSuper"] = false
|
||||
action.Data["teaIsPlus"] = teaconst.IsPlus
|
||||
action.Data["teaDemoEnabled"] = teaconst.IsDemoMode
|
||||
@@ -251,7 +254,7 @@ func (this *userMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
||||
}
|
||||
|
||||
// 菜单配置
|
||||
func (this *userMustAuth) modules(actionPtr actions.ActionWrapper, adminId int64) []maps.Map {
|
||||
func (this *userMustAuth) modules(actionPtr actions.ActionWrapper, adminId int64, adminUIConfig *systemconfigs.AdminUIConfig) []maps.Map {
|
||||
// 父级动作
|
||||
var action = actionPtr.Object()
|
||||
|
||||
@@ -269,14 +272,27 @@ func (this *userMustAuth) modules(actionPtr actions.ActionWrapper, adminId int64
|
||||
}
|
||||
}
|
||||
|
||||
result := []maps.Map{}
|
||||
var result = []maps.Map{}
|
||||
for _, m := range FindAllMenuMaps(nodeLogsType, countUnreadNodeLogs, countUnreadIPItems) {
|
||||
if m.GetString("code") == "finance" && !configloaders.ShowFinance() {
|
||||
continue
|
||||
}
|
||||
|
||||
module := m.GetString("module")
|
||||
var module = m.GetString("module")
|
||||
if configloaders.AllowModule(adminId, module) {
|
||||
if module == "ns" && !adminUIConfig.ContainsModule(userconfigs.UserModuleNS) {
|
||||
continue
|
||||
}
|
||||
if lists.ContainsString([]string{
|
||||
configloaders.AdminModuleCodeNode,
|
||||
configloaders.AdminModuleCodeDNS,
|
||||
configloaders.AdminModuleCodePlan,
|
||||
configloaders.AdminModuleCodeServer,
|
||||
configloaders.AdminModuleCodeDashboard,
|
||||
}, module) && !adminUIConfig.ContainsModule(userconfigs.UserModuleCDN) {
|
||||
continue
|
||||
}
|
||||
|
||||
result = append(result, m)
|
||||
}
|
||||
}
|
||||
|
||||
1
web/views/@default/@blank.html
Normal file
1
web/views/@default/@blank.html
Normal file
@@ -0,0 +1 @@
|
||||
{$layout}
|
||||
@@ -38,6 +38,14 @@
|
||||
<p class="comment">定制自己的版本号,留空表示使用系统自带的版本号。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="teaIsPlus">
|
||||
<td>显示模块</td>
|
||||
<td>
|
||||
<checkbox name="supportModuleCDN" v-model="supportModuleCDN">CDN</checkbox>
|
||||
<checkbox name="supportModuleNS" v-model="supportModuleNS" v-show="nsIsVisible">智能DNS</checkbox>
|
||||
<p class="comment">当前管理系统中可以显示的模块,不能为空。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>是否显示财务相关功能</td>
|
||||
<td>
|
||||
@@ -48,7 +56,7 @@
|
||||
<td>浏览器图标</td>
|
||||
<td>
|
||||
<div v-if="config.faviconFileId > 0">
|
||||
<a :href="'/ui/image/' + config.faviconFileId" target="_blank"><img :src="'/ui/image/' + config.faviconFileId" style="width:32px;border:1px #ccc solid;"/></a>
|
||||
<a :href="'/ui/image/' + config.faviconFileId" target="_blank"><img alt="" :src="'/ui/image/' + config.faviconFileId" style="width:32px;border:1px #ccc solid;"/></a>
|
||||
</div>
|
||||
<div v-else>
|
||||
<span class="disabled">还没有上传。</span>
|
||||
|
||||
Reference in New Issue
Block a user