mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	可以根据管理界面设置/用户界面设置隐藏财务相关功能菜单
This commit is contained in:
		@@ -52,6 +52,15 @@ func UpdateAdminUIConfig(uiConfig *systemconfigs.AdminUIConfig) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 是否显示财务信息
 | 
			
		||||
func ShowFinance() bool {
 | 
			
		||||
	config, _ := LoadAdminUIConfig()
 | 
			
		||||
	if config != nil && !config.ShowFinance {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func loadAdminUIConfig() (*systemconfigs.AdminUIConfig, error) {
 | 
			
		||||
	if sharedAdminUIConfig != nil {
 | 
			
		||||
		return sharedAdminUIConfig, nil
 | 
			
		||||
@@ -88,5 +97,6 @@ func defaultAdminUIConfig() *systemconfigs.AdminUIConfig {
 | 
			
		||||
		AdminSystemName:    "GoEdge管理员系统",
 | 
			
		||||
		ShowOpenSourceInfo: true,
 | 
			
		||||
		ShowVersion:        true,
 | 
			
		||||
		ShowFinance:        true,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -88,5 +88,6 @@ func defaultUserUIConfig() *systemconfigs.UserUIConfig {
 | 
			
		||||
		UserSystemName:     "GoEdge用户系统",
 | 
			
		||||
		ShowOpenSourceInfo: true,
 | 
			
		||||
		ShowVersion:        true,
 | 
			
		||||
		ShowFinance:        true,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,7 @@ func (this *IndexAction) RunPost(params struct {
 | 
			
		||||
	ProductName        string
 | 
			
		||||
	AdminSystemName    string
 | 
			
		||||
	ShowOpenSourceInfo bool
 | 
			
		||||
	ShowFinance        bool
 | 
			
		||||
	ShowVersion        bool
 | 
			
		||||
	Version            string
 | 
			
		||||
 | 
			
		||||
@@ -49,6 +50,7 @@ func (this *IndexAction) RunPost(params struct {
 | 
			
		||||
	config.ProductName = params.ProductName
 | 
			
		||||
	config.AdminSystemName = params.AdminSystemName
 | 
			
		||||
	config.ShowOpenSourceInfo = params.ShowOpenSourceInfo
 | 
			
		||||
	config.ShowFinance = params.ShowFinance
 | 
			
		||||
	config.ShowVersion = params.ShowVersion
 | 
			
		||||
	config.Version = params.Version
 | 
			
		||||
	err = configloaders.UpdateAdminUIConfig(config)
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,7 @@ func (this *IndexAction) RunPost(params struct {
 | 
			
		||||
	ShowOpenSourceInfo bool
 | 
			
		||||
	ShowVersion        bool
 | 
			
		||||
	Version            string
 | 
			
		||||
	ShowFinance        bool
 | 
			
		||||
 | 
			
		||||
	Must *actions.Must
 | 
			
		||||
	CSRF *actionutils.CSRF
 | 
			
		||||
@@ -51,6 +52,7 @@ func (this *IndexAction) RunPost(params struct {
 | 
			
		||||
	config.ShowOpenSourceInfo = params.ShowOpenSourceInfo
 | 
			
		||||
	config.ShowVersion = params.ShowVersion
 | 
			
		||||
	config.Version = params.Version
 | 
			
		||||
	config.ShowFinance = params.ShowFinance
 | 
			
		||||
	err = configloaders.UpdateUserUIConfig(config)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		this.ErrorPage(err)
 | 
			
		||||
 
 | 
			
		||||
@@ -106,6 +106,7 @@ func (this *userMustAuth) BeforeAction(actionPtr actions.ActionWrapper, paramNam
 | 
			
		||||
	action.Data["teaShowOpenSourceInfo"] = config.ShowOpenSourceInfo
 | 
			
		||||
	action.Data["teaIsSuper"] = false
 | 
			
		||||
	action.Data["teaDemoEnabled"] = teaconst.IsDemo
 | 
			
		||||
	action.Data["teaShowFinance"] = configloaders.ShowFinance()
 | 
			
		||||
	if !action.Data.Has("teaSubMenu") {
 | 
			
		||||
		action.Data["teaSubMenu"] = ""
 | 
			
		||||
	}
 | 
			
		||||
@@ -238,6 +239,10 @@ func (this *userMustAuth) modules(adminId int64) []maps.Map {
 | 
			
		||||
 | 
			
		||||
	result := []maps.Map{}
 | 
			
		||||
	for _, m := range allMaps {
 | 
			
		||||
		if m.GetString("code") == "finance" && !configloaders.ShowFinance() {
 | 
			
		||||
			continue
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		module := m.GetString("module")
 | 
			
		||||
		if configloaders.AllowModule(adminId, module) {
 | 
			
		||||
			result = append(result, m)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
<first-menu>
 | 
			
		||||
    <menu-item href="/clusters/regions" code="region">区域</menu-item>
 | 
			
		||||
    <menu-item href="/clusters/regions/prices" code="price">价格</menu-item>
 | 
			
		||||
    <span class="item">|</span>
 | 
			
		||||
    <menu-item><tip-icon content="可以设置节点所属区域,从而利用区域设置进行不同的价格设定。"></tip-icon></menu-item>
 | 
			
		||||
    <menu-item href="/clusters/regions/prices" code="price" v-if="teaShowFinance">价格</menu-item>
 | 
			
		||||
    <span class="item" v-if="teaShowFinance">|</span>
 | 
			
		||||
    <menu-item v-if="teaShowFinance"><tip-icon content="可以设置节点所属区域,从而利用区域设置进行不同的价格设定。"></tip-icon></menu-item>
 | 
			
		||||
</first-menu>
 | 
			
		||||
@@ -35,6 +35,12 @@
 | 
			
		||||
				<p class="comment">定制自己的版本号,留空表示使用系统自带的版本号。</p>
 | 
			
		||||
			</td>
 | 
			
		||||
		</tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
            <td>是否显示财务相关功能</td>
 | 
			
		||||
            <td>
 | 
			
		||||
                <checkbox name="showFinance" v-model="config.showFinance"></checkbox>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
	</table>
 | 
			
		||||
 | 
			
		||||
	<submit-btn></submit-btn>
 | 
			
		||||
 
 | 
			
		||||
@@ -35,7 +35,14 @@
 | 
			
		||||
                <p class="comment">定制自己的版本号,留空表示使用系统自带的版本号。</p>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
        <tr>
 | 
			
		||||
            <td>是否显示财务相关功能</td>
 | 
			
		||||
            <td>
 | 
			
		||||
                <checkbox name="showFinance" v-model="config.showFinance"></checkbox>
 | 
			
		||||
            </td>
 | 
			
		||||
        </tr>
 | 
			
		||||
    </table>
 | 
			
		||||
    <p class="comment">修改后,可能需要等待数分钟才会生效。</p>
 | 
			
		||||
 | 
			
		||||
    <submit-btn></submit-btn>
 | 
			
		||||
</form>
 | 
			
		||||
		Reference in New Issue
	
	Block a user