oa_app仓库初始化
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 权限只认 /auth/my-perms。
|
||||
* 和 Web permissions.js 一致:格子有 allowed 就用格子;超管看服务端下发的格子。
|
||||
* 工作台入口可见性禁止写死人名/岗位。
|
||||
*/
|
||||
|
||||
export function cellAllowed(cell) {
|
||||
if (cell === true || cell === 1 || cell === '1') return true
|
||||
if (cell === false || cell === 0 || cell === '0') return false
|
||||
if (cell && typeof cell === 'object' && 'allowed' in cell) {
|
||||
return cell.allowed === true || cell.allowed === 1
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export function canMenu(menus, menuId, action = 'view', isSuper = false) {
|
||||
if (!menuId) return false
|
||||
const block = menus && typeof menus === 'object' ? menus[menuId] : null
|
||||
const cell = block && typeof block === 'object' ? block[action] : undefined
|
||||
if (cell !== undefined && cell !== null) return cellAllowed(cell)
|
||||
return !!isSuper
|
||||
}
|
||||
|
||||
export function visibleOf(catalog, menus, isSuper) {
|
||||
return (catalog || []).filter((item) => canMenu(menus, item.menu, item.action || 'view', isSuper))
|
||||
}
|
||||
Reference in New Issue
Block a user