feat: 添加query功能

This commit is contained in:
2024-09-08 04:32:41 +08:00
parent 443a41110a
commit 360f6ba180
24 changed files with 6228 additions and 48 deletions

View File

@@ -1,2 +1,36 @@
# query
对应的 fetch 内容的一部分功能的封装。
主要目的:请求路径默认`/api/router`,使用`post`,`post`的数据分流使用`path``key`.
## query
```ts
const query = new Query();
const res = await query.post({
path: 'demo',
key: '1',
});
```
### 参数
```ts
type QueryOpts = {
url?: string;
adapter?: typeof adapter;
headers?: Record<string, string>;
timeout?: number;
};
type Data = {
path?: string;
key?: string;
[key: string]: any;
};
// 额外功能
type DataOpts = Partial<QueryOpts> & {
beforeRequest?: Fn;
};
```