From 6c8d3db3a4e8dab59012daf3b11940974ee1b409 Mon Sep 17 00:00:00 2001 From: idranme Date: Fri, 9 Aug 2024 14:26:30 +0800 Subject: [PATCH] opt --- src/main/main.ts | 4 ++-- src/ntqqapi/api/file.ts | 4 ++-- src/ntqqapi/api/msg.ts | 4 ++-- src/ntqqapi/wrapper.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index dc74a4b..76ffee8 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -52,7 +52,7 @@ import { GroupDecreaseSubType, OB11GroupDecreaseEvent } from '../onebot11/event/ import '../ntqqapi/wrapper' import { sentMessages } from '@/ntqqapi/api' import { NTEventDispatch } from '../common/utils/EventTask' -import { wrapperApi, wrapperConstructor } from '../ntqqapi/wrapper' +import { wrapperConstructor, getSession } from '../ntqqapi/wrapper' let mainWindow: BrowserWindow | null = null @@ -441,7 +441,7 @@ function onLoad() { uidMaps[value] = key } }) - NTEventDispatch.init({ ListenerMap: wrapperConstructor, WrapperSession: wrapperApi.NodeIQQNTWrapperSession! }) + NTEventDispatch.init({ ListenerMap: wrapperConstructor, WrapperSession: getSession()! }) log('start activate group member info') NTQQGroupApi.activateMemberInfoChange().then().catch(log) NTQQGroupApi.activateMemberListChange().then().catch(log) diff --git a/src/ntqqapi/api/file.ts b/src/ntqqapi/api/file.ts index d38c86e..19bc1b0 100644 --- a/src/ntqqapi/api/file.ts +++ b/src/ntqqapi/api/file.ts @@ -16,12 +16,12 @@ import fs from 'node:fs' import { ReceiveCmdS } from '../hook' import { log } from '@/common/utils' import { rkeyManager } from '@/ntqqapi/api/rkey' -import { wrapperApi } from '@/ntqqapi/wrapper' +import { getSession } from '@/ntqqapi/wrapper' import { Peer } from '@/ntqqapi/types/msg' export class NTQQFileApi { static async getVideoUrl(peer: Peer, msgId: string, elementId: string): Promise { - const session = wrapperApi.NodeIQQNTWrapperSession + const session = getSession() return (await session?.getRichMediaService().getVideoPlayUrlV2(peer, msgId, elementId, diff --git a/src/ntqqapi/api/msg.ts b/src/ntqqapi/api/msg.ts index 9daf31e..159c158 100644 --- a/src/ntqqapi/api/msg.ts +++ b/src/ntqqapi/api/msg.ts @@ -6,7 +6,7 @@ import { ReceiveCmdS, registerReceiveHook } from '../hook' import { log } from '../../common/utils/log' import { sleep } from '../../common/utils/helper' import { isQQ998 } from '../../common/utils' -import { wrapperApi } from '@/ntqqapi/wrapper' +import { getSession } from '@/ntqqapi/wrapper' export let sendMessagePool: Record void) | null> = {} // peerUid: callbackFunc @@ -289,7 +289,7 @@ export class NTQQMsgApi { }) } static async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) { - const session = wrapperApi.NodeIQQNTWrapperSession + const session = getSession() return await session?.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z); } } diff --git a/src/ntqqapi/wrapper.ts b/src/ntqqapi/wrapper.ts index 31e7f1c..91567bf 100644 --- a/src/ntqqapi/wrapper.ts +++ b/src/ntqqapi/wrapper.ts @@ -36,7 +36,7 @@ export interface WrapperConstructor { NodeIKernelProfileListener?: any } -export const wrapperApi: WrapperApi = {} +const wrapperApi: WrapperApi = {} export const wrapperConstructor: WrapperConstructor = {} @@ -76,5 +76,5 @@ Process.dlopen = function (module, filename, flags = os.constants.dlopen.RTLD_LA } export function getSession() { - return wrapperApi.NodeIQQNTWrapperSession + return wrapperApi['NodeIQQNTWrapperSession'] } \ No newline at end of file