初始化fateverse
This commit is contained in:
24
src/components/Authenticationbtn.tsx
Normal file
24
src/components/Authenticationbtn.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import React, { useState } from "react";
|
||||
|
||||
/**
|
||||
* @author {温华}
|
||||
* @description 用于包裹需要鉴权的行为按钮
|
||||
* @example <Authenticationbtn permission="["system:list"]"><Button>新增</Button></Authenticationbtn>
|
||||
* @param {permission: string[]}
|
||||
*/
|
||||
|
||||
export default function Authenticationbtn({ permission }: any) {
|
||||
// 还需从缓存中获取用户权限数组
|
||||
const [visible, setVisible] = useState(true)
|
||||
const allPermission: string = "*:*:*"
|
||||
const authPermissions: Array<string> = []
|
||||
if(permission && permission instanceof Array && permission.length > 0) {
|
||||
const permissiosFlag = permission
|
||||
const hasPermission = authPermissions.some((perm: string)=>{
|
||||
return allPermission === perm || permissiosFlag.includes(perm)
|
||||
})
|
||||
setVisible(hasPermission)
|
||||
}
|
||||
|
||||
return <div style={{display: visible ? 'block' : 'none'}}></div>
|
||||
}
|
||||
Reference in New Issue
Block a user