feat: 更新版本至 0.0.61,重构登录缓存逻辑,添加浏览器缓存支持
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 设置当前用户
|
||||
|
||||
Reference in New Issue
Block a user