docs: update request and access docs (#5468)
* fix: Update server.md * docs: update request and access docs
This commit is contained in:
parent
67d1f299b3
commit
a832edce0d
@ -231,19 +231,17 @@ function createRequestClient(baseURL: string) {
|
||||
},
|
||||
});
|
||||
|
||||
// response数据解构
|
||||
client.addResponseInterceptor<HttpResponse>({
|
||||
fulfilled: (response) => {
|
||||
const { data: responseData, status } = response;
|
||||
|
||||
const { code, data } = responseData;
|
||||
|
||||
if (status >= 200 && status < 400 && code === 0) {
|
||||
return data;
|
||||
}
|
||||
throw Object.assign({}, response, { response });
|
||||
},
|
||||
});
|
||||
// 处理返回的响应数据格式。会根据responseReturn指定的类型返回对应的数据
|
||||
client.addResponseInterceptor(
|
||||
defaultResponseInterceptor({
|
||||
// 指定接口返回的数据中的 code 字段名
|
||||
codeField: 'code',
|
||||
// 指定接口返回的数据中装载了主要数据的字段名
|
||||
dataField: 'data',
|
||||
// 请求成功的 code 值,如果接口返回的 code 等于 successCode 则会认为是成功的请求
|
||||
successCode: 0,
|
||||
}),
|
||||
);
|
||||
|
||||
// token过期的处理
|
||||
client.addResponseInterceptor(
|
||||
|
@ -296,7 +296,7 @@ const { hasAccessByRoles } = useAccess();
|
||||
|
||||
#### 指令方式
|
||||
|
||||
> 指令支持绑定单个或多个权限码。单个时可以直接传入字符串或数组中包含一个权限码,多个权限码则传入数组。
|
||||
> 指令支持绑定单个或多个角色。单个时可以直接传入字符串或数组中包含一个角色,多个角色均可访问则传入数组。
|
||||
|
||||
```vue
|
||||
<template>
|
||||
|
Loading…
Reference in New Issue
Block a user