fix: search file

This commit is contained in:
手瓜一十雪
2024-07-26 17:37:04 +08:00
parent b236cdd060
commit a625e30dd4
3 changed files with 10 additions and 14 deletions

View File

@@ -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<EventType extends (...args: any[]) => Promise<any>, ListenerType extends (...args: any[]) => void>

View File

@@ -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<EventType>('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) {

View File

@@ -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();