mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
fix: use constructor to pass config name
This commit is contained in:
parent
6d863ac29c
commit
436249597d
@ -3,12 +3,13 @@ import fs from 'node:fs';
|
||||
import type { NapCatCore } from '@/core';
|
||||
|
||||
export abstract class ConfigBase<T> {
|
||||
abstract name: string;
|
||||
name: string;
|
||||
coreContext: NapCatCore;
|
||||
configPath: string;
|
||||
configData: T = {} as T;
|
||||
|
||||
constructor(coreContext: NapCatCore, configPath: string) {
|
||||
protected constructor(name: string, coreContext: NapCatCore, configPath: string) {
|
||||
this.name = name;
|
||||
this.coreContext = coreContext;
|
||||
this.configPath = configPath;
|
||||
fs.mkdirSync(this.configPath, { recursive: true });
|
||||
|
@ -1,11 +1,13 @@
|
||||
import { ConfigBase } from "@/common/utils/ConfigBase";
|
||||
import { LogLevel } from "@/common/utils/log";
|
||||
import napCatDefaultConfig from '@/core/external/napcat.json';
|
||||
import { NapCatCore } from '@/core';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
export type NapCatConfig = typeof napCatDefaultConfig;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
export class NapCatConfigLoader extends ConfigBase<NapCatConfig> {
|
||||
name = 'napcat';
|
||||
constructor(coreContext: NapCatCore, configPath: string) {
|
||||
super('napcat', coreContext, configPath);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { ConfigBase } from '@/common/utils/ConfigBase';
|
||||
import ob11DefaultConfig from '@/onebot/external/onebot11.json';
|
||||
import { NapCatCore } from '@/core';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
export type OB11Config = typeof ob11DefaultConfig;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
export class OB11ConfigLoader extends ConfigBase<OB11Config> {
|
||||
name = 'onebot11';
|
||||
constructor(coreContext: NapCatCore, configPath: string) {
|
||||
super('onebot11', coreContext, configPath);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user