diff --git a/src/adapter.ts b/src/adapter.ts index 6ded4e4..4968e96 100644 --- a/src/adapter.ts +++ b/src/adapter.ts @@ -7,7 +7,7 @@ type AdapterOpts = { export const adapter = async (opts: AdapterOpts) => { const controller = new AbortController(); const signal = controller.signal; - const timeout = opts.timeout || 60000; // 默认超时时间为 60s + const timeout = opts.timeout || 60000 * 3; // 默认超时时间为 60s * 3 const timer = setTimeout(() => { controller.abort(); }, timeout); diff --git a/src/index.ts b/src/index.ts index 16fd673..8de0d7d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,7 +54,7 @@ export class Query { this.headers = opts?.headers || { 'Content-Type': 'application/json', }; - this.timeout = opts?.timeout || 60000; // 默认超时时间为 60s + this.timeout = opts?.timeout || 60000 * 3; // 默认超时时间为 60s * 3 } async get(params: Record & Data & U & T, options?: DataOpts): Promise> { return this.post(params, options); @@ -117,7 +117,7 @@ export class QueryClient extends Query { } } createWs(opts?: QueryWsOpts) { - this.qws = new QueryWs({ url: this.url }); + this.qws = new QueryWs({ url: this.url, ...opts }); } getToken() { return this.storage.getItem(this.tokenName); @@ -129,5 +129,6 @@ export class QueryClient extends Query { this.storage.removeItem(this.tokenName); } } +export const client = new QueryClient(); export { adapter };