This commit is contained in:
手瓜一十雪
2024-08-10 21:53:08 +08:00
parent ef7d2f4a82
commit 4cbaf0dc70

View File

@@ -1,4 +1,4 @@
import { NTApiContext, WrapperNodeApi } from '@/core/wrapper'; import { NodeQQNTWrapperUtil, NTApiContext, WrapperNodeApi } from '@/core/wrapper';
import path from 'node:path'; import path from 'node:path';
import fs from 'node:fs'; import fs from 'node:fs';
import { InstanceContext } from './wrapper'; import { InstanceContext } from './wrapper';
@@ -35,11 +35,13 @@ export class NapCatCore {
NapCatTempPath: string; NapCatTempPath: string;
// runtime info, not readonly // runtime info, not readonly
selfInfo: SelfInfo; selfInfo: SelfInfo;
util: NodeQQNTWrapperUtil;
// 通过构造器递过去的 runtime info 应该尽量少 // 通过构造器递过去的 runtime info 应该尽量少
constructor(context: InstanceContext, selfInfo: SelfInfo) { constructor(context: InstanceContext, selfInfo: SelfInfo) {
this.selfInfo = selfInfo; this.selfInfo = selfInfo;
this.context = context; this.context = context;
this.util = new this.context.wrapper.NodeQQNTWrapperUtil();
this.eventWrapper = new LegacyNTEventWrapper(context.wrapper, context.session); this.eventWrapper = new LegacyNTEventWrapper(context.wrapper, context.session);
this.initNapCatCoreListeners().then().catch(console.error); this.initNapCatCoreListeners().then().catch(console.error);
this.ApiContext = { this.ApiContext = {
@@ -66,7 +68,7 @@ export class NapCatCore {
} }
get dataPath(): string { get dataPath(): string {
let result = this.context.wrapper.util.getNTUserDataInfoConfig(); let result = this.util.getNTUserDataInfoConfig();
if (!result) { if (!result) {
result = path.resolve(os.homedir(), './.config/QQ'); result = path.resolve(os.homedir(), './.config/QQ');
fs.mkdirSync(result, { recursive: true }); fs.mkdirSync(result, { recursive: true });