feat: 更新版本至 0.0.61,重构登录缓存逻辑,添加浏览器缓存支持

This commit is contained in:
2026-03-05 21:53:42 +08:00
parent b32e622707
commit 27503bf4a7
8 changed files with 217 additions and 23 deletions

View File

@@ -146,19 +146,21 @@ export class LoginCacheStore<T extends Cache = Cache> implements CacheStore<T> {
/**
* 初始化,设置默认值
*/
async init() {
async init(): Promise<CacheLogin> {
const defaultData: CacheLogin = { ...this.cacheData };
if (this.cache.init) {
try {
const cacheData = await this.cache.init();
this.cacheData = cacheData || defaultData;
} catch (error) {
console.log('cacheInit error', error);
return new Promise(async (resolve) => {
if (this.cache.init) {
try {
const cacheData = await this.cache.init();
this.cacheData = cacheData || defaultData;
} catch (error) {
console.log('cacheInit error', error);
}
} else {
this.cacheData = (await this.getValue()) || defaultData;
}
} else {
this.cacheData = (await this.getValue()) || defaultData;
}
return this.cacheData;
resolve(this.cacheData);
});
}
/**
* 设置当前用户