gpt4 book ai didi

javascript - 在视口(viewport)中有条件加载项目

转载 作者:行者123 更新时间:2023-12-02 18:07:48 25 4
gpt4 key购买 nike

你好,为了管理用户访问,我需要禁用加载一些项目,现在在视口(viewport)中我用“隐藏”属性隐藏它们,但我无法阻止这些项目的后台处理,例如服务器请求

如何禁用特定项目的加载。

这是我的视口(viewport)代码

var notAllowAdmin=true; //init access rule gere for admin panel

Ext.define('eFinances.view.Viewport', {
extend: 'Ext.container.Viewport',
requires: [
'Ext.layout.container.Border'
],

layout: 'border',

items: [
{
xtype: 'eFinancesToolbar',
region: 'north'
},
{

title: 'Navigation',
region: 'west',
collapsible: true,
split: true,
width: 200,
minWidth: 175,
maxWidth: 400,
animCollapse: true,
margins: '0 0 0 5',
layout: 'accordion',
items: [{
xtype:'menuTresorerie',
title: 'Trésoreries',
iconCls: 'balance' // see the HEAD section for style used


},{

xtype:'menuAchat',
title: 'Achat et fournisseurs',
iconCls: 'depense' // see the HEAD section for style used

}, {
xtype:'menuVente',
title: 'Ventes et clients',
iconCls: 'recette'
}, {
xtype:'menuAdmin',
hidden :notAllowAdmin, // hide items if not allowed
title: 'Administration',
iconCls: 'administration'

}]

},
{
region: 'center',
title: 'work area'
}
]

});

目前我隐藏管理面板,其中 notAllowAdmin 变量使用规则访问初始化,但整个后台进程都被执行,有些人可以告诉我如何继续完全禁用面板加载或给我最好的主意来做到这一点(管理用户访问)

问候

最佳答案

您可以停止向项目数组添加隐藏组件。示例:

items: [
{
xtype:'menuTresorerie',
title: 'Trésoreries',
iconCls: 'balance' // see the HEAD section for style used
},
{
xtype:'menuAchat',
title: 'Achat et fournisseurs',
iconCls: 'depense' // see the HEAD section for style used
},
{
xtype:'menuVente',
title: 'Ventes et clients',
iconCls: 'recette'
}
].concat(notAllowAdmin ? [] : [
{
xtype:'menuAdmin',
title: 'Administration',
iconCls: 'administration'
}
]);

但是您应该注意到,这应该仅被视为优化,真正的访问控制应该在服务器端实现。

关于javascript - 在视口(viewport)中有条件加载项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19951312/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com