fix: change base query
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "@kevisual/query", |   "name": "@kevisual/query", | ||||||
|   "version": "0.0.19", |   "version": "0.0.20", | ||||||
|   "main": "dist/index.js", |   "main": "dist/index.js", | ||||||
|   "module": "dist/index.js", |   "module": "dist/index.js", | ||||||
|   "types": "dist/index.d.ts", |   "types": "dist/index.d.ts", | ||||||
|   | |||||||
| @@ -21,8 +21,6 @@ export class QueryClient extends Query { | |||||||
|   tokenName: string; |   tokenName: string; | ||||||
|   storage: Storage; |   storage: Storage; | ||||||
|   token: string; |   token: string; | ||||||
|   // 默认不使用ws |  | ||||||
|   qws: QueryWs; |  | ||||||
|   constructor(opts?: QueryOpts & { tokenName?: string; storage?: Storage; io?: boolean }) { |   constructor(opts?: QueryOpts & { tokenName?: string; storage?: Storage; io?: boolean }) { | ||||||
|     super(opts); |     super(opts); | ||||||
|     this.tokenName = opts?.tokenName || 'token'; |     this.tokenName = opts?.tokenName || 'token'; | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								src/query.ts
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/query.ts
									
									
									
									
									
								
							| @@ -1,4 +1,5 @@ | |||||||
| import { adapter, Method } from './adapter.ts'; | import { adapter, Method } from './adapter.ts'; | ||||||
|  | import type { QueryWs } from './ws.ts'; | ||||||
| /** | /** | ||||||
|  * 请求前处理函数 |  * 请求前处理函数 | ||||||
|  * @param opts 请求配置 |  * @param opts 请求配置 | ||||||
| @@ -98,6 +99,8 @@ export class Query { | |||||||
|    * 需要突然停止请求,比如401的时候 |    * 需要突然停止请求,比如401的时候 | ||||||
|    */ |    */ | ||||||
|   stop?: boolean; |   stop?: boolean; | ||||||
|  |   // 默认不使用ws | ||||||
|  |   qws: QueryWs; | ||||||
|  |  | ||||||
|   constructor(opts?: QueryOpts) { |   constructor(opts?: QueryOpts) { | ||||||
|     this.adapter = opts?.adapter || adapter; |     this.adapter = opts?.adapter || adapter; | ||||||
| @@ -107,6 +110,9 @@ export class Query { | |||||||
|     }; |     }; | ||||||
|     this.timeout = opts?.timeout || 60000 * 3; // 默认超时时间为 60s * 3 |     this.timeout = opts?.timeout || 60000 * 3; // 默认超时时间为 60s * 3 | ||||||
|   } |   } | ||||||
|  |   setQueryWs(qws: QueryWs) { | ||||||
|  |     this.qws = qws; | ||||||
|  |   } | ||||||
|   /** |   /** | ||||||
|    * 突然停止请求 |    * 突然停止请求 | ||||||
|    */ |    */ | ||||||
| @@ -228,7 +234,7 @@ export { adapter }; | |||||||
| export class BaseQuery<T extends Query = Query, R extends { queryChain?: any; query?: any } = { queryChain: any; query?: T }> { | export class BaseQuery<T extends Query = Query, R extends { queryChain?: any; query?: any } = { queryChain: any; query?: T }> { | ||||||
|   query: T; |   query: T; | ||||||
|   queryDefine: R; |   queryDefine: R; | ||||||
|   constructor(opts?: { query: T; queryDefine?: R; clientQuery?: T }) { |   constructor(opts?: { query?: T; queryDefine?: R; clientQuery?: T }) { | ||||||
|     if (opts?.clientQuery) { |     if (opts?.clientQuery) { | ||||||
|       this.query = opts.clientQuery; |       this.query = opts.clientQuery; | ||||||
|     } else { |     } else { | ||||||
| @@ -239,7 +245,7 @@ export class BaseQuery<T extends Query = Query, R extends { queryChain?: any; qu | |||||||
|       this.queryDefine.query = this.query; |       this.queryDefine.query = this.query; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   get chain(){ |   get chain(): R['queryChain'] { | ||||||
|     return this.queryDefine.queryChain; |     return this.queryDefine.queryChain; | ||||||
|   } |   } | ||||||
|   post<R = any, P = any>(data: P, options?: DataOpts): Promise<Result<R>> { |   post<R = any, P = any>(data: P, options?: DataOpts): Promise<Result<R>> { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user