feat: 更新版本至 0.0.55,增强类型支持,优化登录缓存相关类

This commit is contained in:
2026-02-21 02:24:07 +08:00
parent 885abd8c46
commit 15fd2d3dc8
5 changed files with 16 additions and 22 deletions

View File

@@ -3,12 +3,12 @@ import type { Result, DataOpts } from '@kevisual/query/query';
import { LoginCacheStore, CacheStore } from './login-cache.ts';
import { Cache } from './login-cache.ts';
import { BaseLoad } from '@kevisual/load';
export type QueryLoginOpts = {
export type QueryLoginOpts<T extends Cache = Cache> = {
query?: Query;
isBrowser?: boolean;
onLoad?: () => void;
storage?: Storage;
cache: Cache;
cache: T;
};
export type QueryLoginData = {
username?: string;
@@ -20,21 +20,21 @@ export type QueryLoginResult = {
refreshToken: string;
};
export class QueryLogin extends BaseQuery {
export class QueryLogin<T extends Cache = Cache> extends BaseQuery {
/**
* query login cache 非实际操作, 一个cache的包裹模块
*/
cacheStore: CacheStore;
cacheStore: CacheStore<T>;
isBrowser: boolean;
load?: boolean;
storage: Storage;
onLoad?: () => void;
constructor(opts?: QueryLoginOpts) {
constructor(opts?: QueryLoginOpts<T>) {
super({
query: opts?.query || new Query(),
});
this.cacheStore = new LoginCacheStore({ name: 'login', cache: opts?.cache! });
this.cacheStore = new LoginCacheStore<T>({ name: 'login', cache: opts?.cache! });
this.isBrowser = opts?.isBrowser ?? true;
this.init();
this.onLoad = opts?.onLoad;