52 lines
859 B
Plaintext
52 lines
859 B
Plaintext
import { Auth } from 'components'
|
|
import auth from 'components/authorized/handler'
|
|
|
|
/**
|
|
* 简单的权限标识
|
|
*/
|
|
function foo1() {
|
|
return (
|
|
<Auth auth="permissions:name">
|
|
<a>连接</a>
|
|
</Auth>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 多个并且关系的权限标识
|
|
*/
|
|
function foo2() {
|
|
return (
|
|
<Auth auth={['permissions:name1', 'permissions:name2']}>
|
|
<a>连接</a>
|
|
</Auth>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 多个或者关系的权限标识
|
|
*/
|
|
function foo3() {
|
|
return (
|
|
<Auth auth={[['permissions:name1'], ['permissions:name2']]}>
|
|
<a>连接</a>
|
|
</Auth>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 前缀简化
|
|
*/
|
|
function foo4() {
|
|
return (
|
|
<Auth auth={{ permissions: ['name1', 'name2'] }}>
|
|
<a>连接</a>
|
|
</Auth>
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 纯js
|
|
*/
|
|
const flag = auth('permissions:name') // => Boolean
|