mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
refactor: make ConfigBase abstract
This commit is contained in:
parent
23ee480c4f
commit
ef4dee8886
@ -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`;
|
||||
|
@ -11,7 +11,5 @@ export interface NapCatConfig {
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
export class NapCatConfig extends ConfigBase<NapCatConfig> {
|
||||
getConfigName() {
|
||||
return 'napcat';
|
||||
}
|
||||
name = 'napcat';
|
||||
}
|
||||
|
@ -36,7 +36,5 @@ export interface OB11Config {
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
export class OB11Config extends ConfigBase<OB11Config> {
|
||||
getConfigName() {
|
||||
return 'onebot11';
|
||||
}
|
||||
name = 'onebot11';
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { OB11Config } from "@/onebot/helper/config";
|
||||
|
||||
import { OB11Config } from '@/onebot/helper/config';
|
||||
|
||||
interface LoginRuntimeType {
|
||||
LoginCurrentTime: number;
|
||||
@ -30,6 +29,7 @@ const LoginRuntime: LoginRuntimeType = {
|
||||
QQLoginList: [],
|
||||
},
|
||||
};
|
||||
|
||||
export const WebUiDataRuntime = {
|
||||
checkLoginRate: async function(RateLimit: number): Promise<boolean> {
|
||||
LoginRuntime.LoginCurrentRate++;
|
||||
|
Loading…
Reference in New Issue
Block a user