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

@@ -51,7 +51,6 @@ export class StorageNode implements Storage {
cacheData: any;
filePath: string = '';
hostname: string = '';
isLoaded: boolean = false;
constructor(opts?: { baseURL?: string, load?: boolean }) {
this.cacheData = {};
const hostname = getHostName(opts?.baseURL);
@@ -70,13 +69,11 @@ export class StorageNode implements Storage {
this.loadCache();
}
}
loadCache(force?: boolean) {
if (this.isLoaded && !force) return;
loadCache() {
const filePath = this.filePath;
try {
const data = readConfigFile(filePath);
this.cacheData = data;
this.isLoaded = true;
} catch (error) {
this.cacheData = {};
writeFileSync(filePath, JSON.stringify(this.cacheData, null, 2));
@@ -106,7 +103,6 @@ export class StorageNode implements Storage {
}
export class LoginNodeCache implements Cache {
filepath: string;
isLoaded: boolean = false;
constructor(opts?: { baseURL?: string, load?: boolean }) {
this.filepath = join(homedir(), '.config', 'envision', 'config', `${getHostName(opts?.baseURL)}-login.json`);
fileExists(this.filepath, { isFile: true });
@@ -136,12 +132,10 @@ export class LoginNodeCache implements Cache {
async del() {
unlinkSync(this.filepath);
}
loadCache(filePath: string, force?: boolean) {
if (this.isLoaded && !force) return;
loadCache(filePath: string) {
try {
const data = readFileSync(filePath, 'utf-8');
const jsonData = JSON.parse(data);
this.isLoaded = true;
return jsonData;
} catch (error) {
// console.log('loadCache error', error);