add 开发文档
This commit is contained in:
43
web-react/public/doc-code/auth/index.js
Normal file
43
web-react/public/doc-code/auth/index.js
Normal file
@@ -0,0 +1,43 @@
|
||||
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
|
||||
Reference in New Issue
Block a user