add 开发文档
This commit is contained in:
14
web-react/public/doc-code/api/setting.js
Normal file
14
web-react/public/doc-code/api/setting.js
Normal file
@@ -0,0 +1,14 @@
|
||||
export default {
|
||||
/* 自定义的接口名称 */
|
||||
apiName: [
|
||||
/* 接口地址 */
|
||||
url,
|
||||
/* 请求类型 [get | post] */
|
||||
'get',
|
||||
/* axios所需的设置参数 */
|
||||
options,
|
||||
],
|
||||
|
||||
/* 默认为get接口 */
|
||||
apiPostName: getUrl
|
||||
}
|
||||
25
web-react/public/doc-code/api/usage.js
Normal file
25
web-react/public/doc-code/api/usage.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { api } from 'common/api'
|
||||
|
||||
api.apiName(params)
|
||||
.then(res => {
|
||||
/* ... */
|
||||
})
|
||||
.catch(error => {
|
||||
/* catch */
|
||||
})
|
||||
.finally(() => {
|
||||
/* finally */
|
||||
})
|
||||
|
||||
|
||||
// 或者采用异步
|
||||
async function foo() {
|
||||
try {
|
||||
const res = await api.apiName(params)
|
||||
/* ... */
|
||||
} catch (error) {
|
||||
/* catch */
|
||||
} finally {
|
||||
/* finally */
|
||||
}
|
||||
}
|
||||
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