add 开发文档

This commit is contained in:
2021-07-09 17:41:27 +08:00
parent 6c01b43550
commit b40f86b310
19 changed files with 1038 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
export default {
/* 自定义的接口名称 */
apiName: [
/* 接口地址 */
url,
/* 请求类型 [get | post] */
'get',
/* axios所需的设置参数 */
options,
],
/* 默认为get接口 */
apiPostName: getUrl
}

View 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 */
}
}

View 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