mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 13:01:14 +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';
|
import type { NapCatCore } from '@/core';
|
||||||
|
|
||||||
export abstract class ConfigBase<T> {
|
export abstract class ConfigBase<T> {
|
||||||
abstract name: string;
|
name: string;
|
||||||
coreContext: NapCatCore;
|
coreContext: NapCatCore;
|
||||||
configPath: string;
|
configPath: string;
|
||||||
configData: T = {} as T;
|
configData: T = {} as T;
|
||||||
|
|
||||||
constructor(coreContext: NapCatCore, configPath: string) {
|
protected constructor(name: string, coreContext: NapCatCore, configPath: string) {
|
||||||
|
this.name = name;
|
||||||
this.coreContext = coreContext;
|
this.coreContext = coreContext;
|
||||||
this.configPath = configPath;
|
this.configPath = configPath;
|
||||||
fs.mkdirSync(this.configPath, { recursive: true });
|
fs.mkdirSync(this.configPath, { recursive: true });
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
import { ConfigBase } from "@/common/utils/ConfigBase";
|
import { ConfigBase } from "@/common/utils/ConfigBase";
|
||||||
import { LogLevel } from "@/common/utils/log";
|
|
||||||
import napCatDefaultConfig from '@/core/external/napcat.json';
|
import napCatDefaultConfig from '@/core/external/napcat.json';
|
||||||
|
import { NapCatCore } from '@/core';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||||
export type NapCatConfig = typeof napCatDefaultConfig;
|
export type NapCatConfig = typeof napCatDefaultConfig;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||||
export class NapCatConfigLoader extends ConfigBase<NapCatConfig> {
|
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 { ConfigBase } from '@/common/utils/ConfigBase';
|
||||||
import ob11DefaultConfig from '@/onebot/external/onebot11.json';
|
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;
|
export type OB11Config = typeof ob11DefaultConfig;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
||||||
export class OB11ConfigLoader extends ConfigBase<OB11Config> {
|
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