fix: search file

This commit is contained in:
手瓜一十雪 2024-07-26 12:27:02 +08:00
parent 620d61c8dc
commit 18892379de
2 changed files with 57 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import { ISizeCalculationResult } from 'image-size/dist/types/interface';
import { sessionConfig } from '@/core/sessionConfig';
import { rkeyManager } from '../utils/rkey';
import { NTEventDispatch } from '@/common/utils/EventTask';
import { NodeIKernelSearchService } from '../services/NodeIKernelSearchService';
export class NTQQFileApi {
static async getFileType(filePath: string) {
@ -145,6 +146,58 @@ export class NTQQFileApi {
});
});
}
static async searchfile(keys: string[]) {
type EventType = NodeIKernelSearchService['searchFileWithKeywords'];
interface OnListener {
searchId: string,
hasMore: boolean,
resultItems: {
chatType: ChatType,
buddyChatInfo: any[],
discussChatInfo: any[],
groupChatInfo:
{
groupCode: string,
isConf: boolean,
hasModifyConfGroupFace: boolean,
hasModifyConfGroupName: boolean,
groupName: string,
remark: string
}[]
,
dataLineChatInfo: any[],
tmpChatInfo: any[],
msgId: string,
msgSeq: string,
msgTime: string,
senderUid: string,
senderNick: string,
senderRemark: string,
senderCard: string,
elemId: string,
elemType: number,
fileSize: string,
filePath: string,
fileName: string,
hits:
{
start: number,
end: number
}[]
}[]
};
const [id, data] = await NTEventDispatch.CallNormalEvent<EventType, (params: OnListener) => void>(
'NodeIKernelSearchService/searchFileWithKeywords',
'NodeIKernelSearchListener/onSearchFileKeywordsResult',
1,
10000,
(arg): boolean => { return id == data.searchId },
keys,
12
);
return data.resultItems[0];
}
static async getImageUrl(element: { originImageUrl: any; md5HexStr?: any; fileUuid: any; }) {
if (!element) {
return '';

View File

@ -1,4 +1,4 @@
export interface NodeIKernelSearchService{
export interface NodeIKernelSearchService {
addKernelSearchListenerr(...args: any[]): unknown;// needs 1 arguments
removeKernelSearchListenerr(...args: any[]): unknown;// needs 1 arguments
@ -48,10 +48,10 @@ export interface NodeIKernelSearchService{
searchMsgWithKeywordsr(...args: any[]): unknown;// needs 2 arguments
searchMoreMsgWithKeywordsr(...args: any[]): unknown;// needs 1 arguments
cancelSearchMsgWithKeywordsr(...args: any[]): unknown;// needs 3 arguments
searchFileWithKeywordsr(...args: any[]): unknown;// needs 2 arguments
cancelSearchMsgWithKeywords(...args: any[]): unknown;// needs 3 arguments
searchFileWithKeywords(keywords: string[], source: number): Promise<unknown>;// needs 2 arguments
searchMoreFileWithKeywordsr(...args: any[]): unknown;// needs 1 arguments