From 245eabe85fbc5cbf6345894fe70ea43f1fc1e1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Fri, 9 Aug 2024 15:30:04 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=B1=8F=E8=94=BD=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/apis/file.ts | 126 +++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/src/core/apis/file.ts b/src/core/apis/file.ts index d0dd7796..6b9a60a7 100644 --- a/src/core/apis/file.ts +++ b/src/core/apis/file.ts @@ -75,69 +75,69 @@ export class NTQQFileApi { async downloadMediaByUuid() { //napCatCore.session.getRichMediaService().downloadFileForFileUuid(); } - async downloadMedia(msgId: string, chatType: ChatType, peerUid: string, elementId: string, thumbPath: string, sourcePath: string, timeout = 1000 * 60 * 2, force: boolean = false) { - //logDebug('receive downloadMedia task', msgId, chatType, peerUid, elementId, thumbPath, sourcePath, timeout, force); - // 用于下载收到的消息中的图片等 - if (sourcePath && fs.existsSync(sourcePath)) { - if (force) { - try { - await fsPromises.unlink(sourcePath); - } catch (e) { - // - } - } else { - return sourcePath; - } - } - const data = await this.core.eventWrapper.CallNormalEvent< - ( - params: { - fileModelId: string, - downloadSourceType: number, - triggerType: number, - msgId: string, - chatType: ChatType, - peerUid: string, - elementId: string, - thumbSize: number, - downloadType: number, - filePath: string - }) => Promise, - (fileTransNotifyInfo: OnRichMediaDownloadCompleteParams) => void - >( - 'NodeIKernelMsgService/downloadRichMedia', - 'NodeIKernelMsgListener/onRichMediaDownloadComplete', - 1, - timeout, - (arg: OnRichMediaDownloadCompleteParams) => { - if (arg.msgId === msgId) { - return true; - } - return false; - }, - { - fileModelId: '0', - downloadSourceType: 0, - triggerType: 1, - msgId: msgId, - chatType: chatType, - peerUid: peerUid, - elementId: elementId, - thumbSize: 0, - downloadType: 1, - filePath: thumbPath - } - ); - let filePath = data[1].filePath; - if (filePath.startsWith('\\')) { - // log('filePath start with \\'); - const downloadPath = sessionConfig.defaultFileDownloadPath; - //logDebug('downloadPath', downloadPath); - filePath = path.join(downloadPath, filePath); - // 下载路径是下载文件夹的相对路径 - } - return filePath; - } + // async downloadMedia(msgId: string, chatType: ChatType, peerUid: string, elementId: string, thumbPath: string, sourcePath: string, timeout = 1000 * 60 * 2, force: boolean = false) { + // //logDebug('receive downloadMedia task', msgId, chatType, peerUid, elementId, thumbPath, sourcePath, timeout, force); + // // 用于下载收到的消息中的图片等 + // if (sourcePath && fs.existsSync(sourcePath)) { + // if (force) { + // try { + // await fsPromises.unlink(sourcePath); + // } catch (e) { + // // + // } + // } else { + // return sourcePath; + // } + // } + // const data = await this.core.eventWrapper.CallNormalEvent< + // ( + // params: { + // fileModelId: string, + // downloadSourceType: number, + // triggerType: number, + // msgId: string, + // chatType: ChatType, + // peerUid: string, + // elementId: string, + // thumbSize: number, + // downloadType: number, + // filePath: string + // }) => Promise, + // (fileTransNotifyInfo: OnRichMediaDownloadCompleteParams) => void + // >( + // 'NodeIKernelMsgService/downloadRichMedia', + // 'NodeIKernelMsgListener/onRichMediaDownloadComplete', + // 1, + // timeout, + // (arg: OnRichMediaDownloadCompleteParams) => { + // if (arg.msgId === msgId) { + // return true; + // } + // return false; + // }, + // { + // fileModelId: '0', + // downloadSourceType: 0, + // triggerType: 1, + // msgId: msgId, + // chatType: chatType, + // peerUid: peerUid, + // elementId: elementId, + // thumbSize: 0, + // downloadType: 1, + // filePath: thumbPath + // } + // ); + // let filePath = data[1].filePath; + // if (filePath.startsWith('\\')) { + // // log('filePath start with \\'); + // const downloadPath = sessionConfig.defaultFileDownloadPath; + // //logDebug('downloadPath', downloadPath); + // filePath = path.join(downloadPath, filePath); + // // 下载路径是下载文件夹的相对路径 + // } + // return filePath; + // } async getImageSize(filePath: string): Promise { return new Promise((resolve, reject) => {