From ff189378283b9cebadef3688d4b642f25f49c4bb Mon Sep 17 00:00:00 2001
From: idranme <idranme@outlook.com>
Date: Mon, 19 Aug 2024 17:29:58 +0800
Subject: [PATCH] fix

---
 package.json          |  2 +-
 src/common/config.ts  |  4 +---
 src/ntqqapi/hook.ts   | 16 ++++++++--------
 src/ntqqapi/ntcall.ts | 27 +++------------------------
 4 files changed, 13 insertions(+), 36 deletions(-)

diff --git a/package.json b/package.json
index c269e75..2898750 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,7 @@
     "@types/fluent-ffmpeg": "^2.1.25",
     "@types/node": "^20.14.15",
     "@types/ws": "^8.5.12",
-    "electron": "^29.1.4",
+    "electron": "^31.4.0",
     "electron-vite": "^2.3.0",
     "typescript": "^5.5.4",
     "vite": "^5.4.1",
diff --git a/src/common/config.ts b/src/common/config.ts
index ce2250f..df571ff 100644
--- a/src/common/config.ts
+++ b/src/common/config.ts
@@ -5,9 +5,7 @@ import path from 'node:path'
 import { getSelfUin } from './data'
 import { DATA_DIR } from './utils'
 
-export const HOOK_LOG = false
-
-export const ALLOW_SEND_TEMP_MSG = false
+//export const HOOK_LOG = false
 
 export class ConfigUtil {
   private readonly configPath: string
diff --git a/src/ntqqapi/hook.ts b/src/ntqqapi/hook.ts
index aa107cc..deccbb6 100644
--- a/src/ntqqapi/hook.ts
+++ b/src/ntqqapi/hook.ts
@@ -16,7 +16,7 @@ import {
   setSelfInfo
 } from '@/common/data'
 import { postOb11Event } from '../onebot11/server/post-ob11-event'
-import { getConfigUtil, HOOK_LOG } from '@/common/config'
+import { getConfigUtil } from '@/common/config'
 import fs from 'node:fs'
 import { log } from '@/common/utils'
 import { randomUUID } from 'node:crypto'
@@ -81,7 +81,7 @@ export function hookNTQQApiReceive(window: BrowserWindow) {
   const originalSend = window.webContents.send
   const patchSend = (channel: string, ...args: NTQQApiReturnData) => {
     // console.log("hookNTQQApiReceive", channel, args)
-    let isLogger = false
+    /*let isLogger = false
     try {
       isLogger = args[0]?.eventName?.startsWith('ns-LoggerApi')
     } catch (e) { }
@@ -91,7 +91,7 @@ export function hookNTQQApiReceive(window: BrowserWindow) {
       } catch (e) {
         log('hook log error', e, args)
       }
-    }
+    }*/
     try {
       if (args?.[1] instanceof Array) {
         for (let receiveData of args?.[1]) {
@@ -145,9 +145,9 @@ export function hookNTQQApiCall(window: BrowserWindow) {
         isLogger = args[3][0].eventName.startsWith('ns-LoggerApi')
       } catch (e) { }
       if (!isLogger) {
-        try {
+        /*try {
           HOOK_LOG && log('call NTQQ api', thisArg, args)
-        } catch (e) { }
+        } catch (e) { }*/
         try {
           const _args: unknown[] = args[3][1]
           const cmdName: NTQQApiMethod = _args[0] as NTQQApiMethod
@@ -181,16 +181,16 @@ export function hookNTQQApiCall(window: BrowserWindow) {
   const proxyIpcInvoke = new Proxy(ipc_invoke_proxy, {
     apply(target, thisArg, args) {
       // console.log(args);
-      HOOK_LOG && log('call NTQQ invoke api', thisArg, args)
+      //HOOK_LOG && log('call NTQQ invoke api', thisArg, args)
       args[0]['_replyChannel']['sendReply'] = new Proxy(args[0]['_replyChannel']['sendReply'], {
         apply(sendtarget, sendthisArg, sendargs) {
           sendtarget.apply(sendthisArg, sendargs)
         },
       })
       let ret = target.apply(thisArg, args)
-      try {
+      /*try {
         HOOK_LOG && log('call NTQQ invoke api return', ret)
-      } catch (e) { }
+      } catch (e) { }*/
       return ret
     },
   })
diff --git a/src/ntqqapi/ntcall.ts b/src/ntqqapi/ntcall.ts
index aed5651..9fec4d2 100644
--- a/src/ntqqapi/ntcall.ts
+++ b/src/ntqqapi/ntcall.ts
@@ -1,7 +1,6 @@
 import { ipcMain } from 'electron'
 import { hookApiCallbacks, ReceiveCmd, ReceiveCmdS, registerReceiveHook, removeReceiveHook } from './hook'
 import { log } from '../common/utils/log'
-import { HOOK_LOG } from '../common/config'
 import { randomUUID } from 'node:crypto'
 
 export enum NTQQApiClass {
@@ -15,6 +14,7 @@ export enum NTQQApiClass {
   SKEY_API = 'ns-SkeyApi',
   GROUP_HOME_WORK = 'ns-GroupHomeWork',
   GROUP_ESSENCE = 'ns-GroupEssence',
+  NODE_STORE_API = 'ns-NodeStoreApi'
 }
 
 export enum NTQQApiMethod {
@@ -129,7 +129,7 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
   timeout = timeout ?? 5
   afterFirstCmd = afterFirstCmd ?? true
   const uuid = randomUUID()
-  HOOK_LOG && log('callNTQQApi', channel, className, methodName, args, uuid)
+  //HOOK_LOG && log('callNTQQApi', channel, className, methodName, args, uuid)
   return new Promise((resolve: (data: ReturnType) => void, reject) => {
     // log("callNTQQApiPromise", channel, className, methodName, args, uuid)
     const _timeout = timeout * 1000
@@ -202,25 +202,4 @@ export function callNTQQApi<ReturnType>(params: NTQQApiParams) {
 export interface GeneralCallResult {
   result: number // 0: success
   errMsg: string
-}
-
-export class NTQQApi {
-  static async call(className: NTQQApiClass, cmdName: string, args: any[]) {
-    return await callNTQQApi<GeneralCallResult>({
-      className,
-      methodName: cmdName,
-      args: [...args],
-    })
-  }
-
-  static async fetchUnitedCommendConfig() {
-    return await callNTQQApi<GeneralCallResult>({
-      methodName: NTQQApiMethod.FETCH_UNITED_COMMEND_CONFIG,
-      args: [
-        {
-          groups: ['100243'],
-        },
-      ],
-    })
-  }
-}
+}
\ No newline at end of file