diff --git a/src/common/utils/EventTask.ts b/src/common/utils/EventTask.ts index 3263f06c..89a326f2 100644 --- a/src/common/utils/EventTask.ts +++ b/src/common/utils/EventTask.ts @@ -146,6 +146,7 @@ export class NTEventWrapper { this.EventTask.get(ListenerMainName)?.set(ListenerSubName, new Map()); } this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.set(id, eventCallbak); + this.CreatListenerFunction(ListenerMainName); }); } async CallNormalEvent Promise, ListenerType extends (...args: any[]) => void> diff --git a/src/core/src/apis/file.ts b/src/core/src/apis/file.ts index 676b6dde..54b83316 100644 --- a/src/core/src/apis/file.ts +++ b/src/core/src/apis/file.ts @@ -19,6 +19,7 @@ import { rkeyManager } from '../utils/rkey'; import { NTEventDispatch } from '@/common/utils/EventTask'; import { NodeIKernelSearchService } from '../services/NodeIKernelSearchService'; + export class NTQQFileApi { static async getFileType(filePath: string) { return fileType.fileTypeFromFile(filePath); @@ -147,7 +148,6 @@ export class NTQQFileApi { }); } static async searchfile(keys: string[]) { - type EventType = NodeIKernelSearchService['searchFileWithKeywords']; interface OnListener { searchId: string, @@ -187,22 +187,17 @@ export class NTQQFileApi { }[] }[] }; - // (params: OnListener) => void 'NodeIKernelSearchListener/onSearchFileKeywordsResult', - // 1, - // 10000, - // (arg): boolean => { return id == data.searchId }, - // keys, - // 12 const Event = await NTEventDispatch.CreatEventFunction('NodeIKernelSearchService/searchFileWithKeywords'); let id = ''; - const [Listener] = await NTEventDispatch.RegisterListen<(params: OnListener) => void>('NodeIKernelSearchListener/onSearchFileKeywordsResult', 1, 5000, (params) => { + const Listener = NTEventDispatch.RegisterListen<(params: OnListener) => void>('NodeIKernelSearchListener/onSearchFileKeywordsResult', 1, 20000, (params) => { if (id !== '' && params.searchId == id) { return true } return false; }); id = await Event!(keys, 12); - return Listener.resultItems[0]; + let [ret] = (await Listener); + return ret; } static async getImageUrl(element: PicElement) { if (!element) { diff --git a/src/core/src/apis/system.ts b/src/core/src/apis/system.ts index 0a3ba816..ece8e197 100644 --- a/src/core/src/apis/system.ts +++ b/src/core/src/apis/system.ts @@ -1,11 +1,11 @@ import { NTEventDispatch } from '@/common/utils/EventTask'; -import { GeneralCallResult, NTQQUserApi, napCatCore } from '@/core'; -// setTimeout(async () => { -// let ret = await NTQQSystemApi.getArkJsonCollection('1-2-162b9b42-65b9-4405-a8ed-2e256ec8aa50'); -// console.log(ret); -// }, 20000) +import { GeneralCallResult, NTQQFileApi, NTQQUserApi, napCatCore } from '@/core'; +setTimeout(async () => { + let ret = await NTQQFileApi.searchfile(['doc']); + console.log(ret); +}, 20000) export class NTQQSystemApi { static async hasOtherRunningQQProcess() { return napCatCore.util.hasOtherRunningQQProcess();