refactor: make ConfigBase abstract

This commit is contained in:
Wesley F. Young
2024-08-12 00:26:44 +08:00
parent 23ee480c4f
commit ef4dee8886
4 changed files with 6 additions and 15 deletions

View File

@@ -2,17 +2,13 @@ import path from 'node:path';
import fs from 'node:fs';
import type { NapCatCore } from '@/core';
export class ConfigBase<T> {
name: string = this.getConfigName();
export abstract class ConfigBase<T> {
abstract name: string;
pathName: string | null = null; // 本次读取的文件路径
coreContext: NapCatCore;
configPath: string;
configData: T = {} as T;
getConfigName() {
return this.constructor.name
}
constructor(coreContext: NapCatCore, configPath: string) {
this.coreContext = coreContext;
this.configPath = configPath;
@@ -25,7 +21,6 @@ export class ConfigBase<T> {
return null;
}
getConfigPath(pathName: string | undefined): string {
const suffix = pathName ? `_${pathName}` : '';
const filename = `${this.name}${suffix}.json`;