mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-09 00:20: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/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||||
"github.com/iwind/TeaGo/actions"
|
"github.com/iwind/TeaGo/actions"
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
@@ -37,6 +38,8 @@ func (this *IndexAction) RunGet(params struct{}) {
|
|||||||
}
|
}
|
||||||
this.Data["timeZoneLocation"] = nodeconfigs.FindTimeZoneLocation(config.TimeZone)
|
this.Data["timeZoneLocation"] = nodeconfigs.FindTimeZoneLocation(config.TimeZone)
|
||||||
|
|
||||||
|
this.filterConfig(config)
|
||||||
|
|
||||||
this.Show()
|
this.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,6 +55,9 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
DefaultPageSize int
|
DefaultPageSize int
|
||||||
TimeZone string
|
TimeZone string
|
||||||
|
|
||||||
|
SupportModuleCDN bool
|
||||||
|
SupportModuleNS bool
|
||||||
|
|
||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
CSRF *actionutils.CSRF
|
CSRF *actionutils.CSRF
|
||||||
}) {
|
}) {
|
||||||
@@ -85,6 +91,14 @@ func (this *IndexAction) RunPost(params struct {
|
|||||||
config.DefaultPageSize = 10
|
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文件
|
// 上传Favicon文件
|
||||||
if params.FaviconFile != nil {
|
if params.FaviconFile != nil {
|
||||||
createResp, err := this.RPC().FileRPC().CreateFile(this.AdminContext(), &pb.CreateFileRequest{
|
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/EdgeAdmin/internal/setup"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"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/actions"
|
||||||
|
"github.com/iwind/TeaGo/lists"
|
||||||
"github.com/iwind/TeaGo/logs"
|
"github.com/iwind/TeaGo/logs"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"net"
|
"net"
|
||||||
@@ -192,7 +195,7 @@ func (this *userMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
config, err := configloaders.LoadAdminUIConfig()
|
uiConfig, err := configloaders.LoadAdminUIConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
action.WriteString(err.Error())
|
action.WriteString(err.Error())
|
||||||
return false
|
return false
|
||||||
@@ -203,11 +206,11 @@ func (this *userMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
|||||||
return action.Data["teaTitle"].(string)
|
return action.Data["teaTitle"].(string)
|
||||||
})
|
})
|
||||||
|
|
||||||
action.Data["teaShowVersion"] = config.ShowVersion
|
action.Data["teaShowVersion"] = uiConfig.ShowVersion
|
||||||
action.Data["teaTitle"] = config.AdminSystemName
|
action.Data["teaTitle"] = uiConfig.AdminSystemName
|
||||||
action.Data["teaName"] = config.ProductName
|
action.Data["teaName"] = uiConfig.ProductName
|
||||||
action.Data["teaFaviconFileId"] = config.FaviconFileId
|
action.Data["teaFaviconFileId"] = uiConfig.FaviconFileId
|
||||||
action.Data["teaLogoFileId"] = config.LogoFileId
|
action.Data["teaLogoFileId"] = uiConfig.LogoFileId
|
||||||
action.Data["teaUsername"] = configloaders.FindAdminFullname(adminId)
|
action.Data["teaUsername"] = configloaders.FindAdminFullname(adminId)
|
||||||
action.Data["teaTheme"] = configloaders.FindAdminTheme(adminId)
|
action.Data["teaTheme"] = configloaders.FindAdminTheme(adminId)
|
||||||
|
|
||||||
@@ -216,15 +219,15 @@ func (this *userMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
|
|||||||
if !action.Data.Has("teaMenu") {
|
if !action.Data.Has("teaMenu") {
|
||||||
action.Data["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["teaSubMenus"] = []map[string]interface{}{}
|
||||||
action.Data["teaTabbar"] = []map[string]interface{}{}
|
action.Data["teaTabbar"] = []map[string]interface{}{}
|
||||||
if len(config.Version) == 0 {
|
if len(uiConfig.Version) == 0 {
|
||||||
action.Data["teaVersion"] = teaconst.Version
|
action.Data["teaVersion"] = teaconst.Version
|
||||||
} else {
|
} 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["teaIsSuper"] = false
|
||||||
action.Data["teaIsPlus"] = teaconst.IsPlus
|
action.Data["teaIsPlus"] = teaconst.IsPlus
|
||||||
action.Data["teaDemoEnabled"] = teaconst.IsDemoMode
|
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()
|
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) {
|
for _, m := range FindAllMenuMaps(nodeLogsType, countUnreadNodeLogs, countUnreadIPItems) {
|
||||||
if m.GetString("code") == "finance" && !configloaders.ShowFinance() {
|
if m.GetString("code") == "finance" && !configloaders.ShowFinance() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
module := m.GetString("module")
|
var module = m.GetString("module")
|
||||||
if configloaders.AllowModule(adminId, 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)
|
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>
|
<p class="comment">定制自己的版本号,留空表示使用系统自带的版本号。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td>是否显示财务相关功能</td>
|
<td>是否显示财务相关功能</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -48,7 +56,7 @@
|
|||||||
<td>浏览器图标</td>
|
<td>浏览器图标</td>
|
||||||
<td>
|
<td>
|
||||||
<div v-if="config.faviconFileId > 0">
|
<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>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<span class="disabled">还没有上传。</span>
|
<span class="disabled">还没有上传。</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user