chore: bump version to 0.0.40, update rollup and zustand dependencies, and refine adapter logic

This commit is contained in:
2026-02-09 00:17:16 +08:00
parent 3920183a21
commit 7adedc0552
5 changed files with 150 additions and 135 deletions

View File

@@ -92,11 +92,13 @@ export const adapter = async (opts: AdapterOpts = {}, overloadOpts?: RequestInit
} else if (isPostFile) {
body = opts.body as FormData; // 如果是文件上传,直接使用 FormData
} else {
headers = {
'Content-Type': 'application/json',
...headers,
};
body = JSON.stringify(opts.body); // 否则将对象转换为 JSON 字符串
if (opts.body && typeof opts.body === 'object' && !(opts.body instanceof FormData)) {
headers = {
'Content-Type': 'application/json',
...headers,
};
body = JSON.stringify(opts.body); // 否则将对象转换为 JSON 字符串
}
}
return fetch(url, {
method: method.toUpperCase(),

View File

@@ -105,6 +105,9 @@ export class Query {
stop?: boolean;
// 默认不使用ws
qws: QueryWs;
/**
* 默认是 /client/router或者 默认是 /api/router
*/
isClient = false;
constructor(opts?: QueryOptions) {
this.adapter = opts?.adapter || adapter;
@@ -114,7 +117,7 @@ export class Query {
'Content-Type': 'application/json',
};
this.timeout = opts?.timeout || 60000 * 3; // 默认超时时间为 60s * 3
if (opts.beforeRequest) {
if (opts?.beforeRequest) {
this.beforeRequest = opts.beforeRequest;
} else {
this.beforeRequest = async (opts) => {