fix: change base query

This commit is contained in:
熊潇 2025-05-25 00:06:10 +08:00
parent 8385ab05f6
commit 366840bb1d
3 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@kevisual/query",
"version": "0.0.19",
"version": "0.0.20",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -21,8 +21,6 @@ export class QueryClient extends Query {
tokenName: string;
storage: Storage;
token: string;
// 默认不使用ws
qws: QueryWs;
constructor(opts?: QueryOpts & { tokenName?: string; storage?: Storage; io?: boolean }) {
super(opts);
this.tokenName = opts?.tokenName || 'token';

View File

@ -1,4 +1,5 @@
import { adapter, Method } from './adapter.ts';
import type { QueryWs } from './ws.ts';
/**
*
* @param opts
@ -98,6 +99,8 @@ export class Query {
* 401
*/
stop?: boolean;
// 默认不使用ws
qws: QueryWs;
constructor(opts?: QueryOpts) {
this.adapter = opts?.adapter || adapter;
@ -107,6 +110,9 @@ export class Query {
};
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 }> {
query: T;
queryDefine: R;
constructor(opts?: { query: T; queryDefine?: R; clientQuery?: T }) {
constructor(opts?: { query?: T; queryDefine?: R; clientQuery?: T }) {
if (opts?.clientQuery) {
this.query = opts.clientQuery;
} else {
@ -239,7 +245,7 @@ export class BaseQuery<T extends Query = Query, R extends { queryChain?: any; qu
this.queryDefine.query = this.query;
}
}
get chain(){
get chain(): R['queryChain'] {
return this.queryDefine.queryChain;
}
post<R = any, P = any>(data: P, options?: DataOpts): Promise<Result<R>> {