()
| 180 | * 设置附件相关的 IPC 处理器 |
| 181 | */ |
| 182 | export function setupAttachmentHandlers(): void { |
| 183 | // 保存附件 |
| 184 | ipcMain.handle( |
| 185 | 'attachment:save', |
| 186 | async ( |
| 187 | _event, |
| 188 | options: { |
| 189 | fileId: string |
| 190 | fileName: string |
| 191 | base64Content: string |
| 192 | pageId?: string |
| 193 | messageId?: string |
| 194 | } |
| 195 | ) => { |
| 196 | return await attachmentHandler.saveAttachment( |
| 197 | options.fileId, |
| 198 | options.fileName, |
| 199 | options.base64Content, |
| 200 | options.pageId, |
| 201 | options.messageId |
| 202 | ) |
| 203 | } |
| 204 | ) |
| 205 | |
| 206 | // 读取附件 |
| 207 | ipcMain.handle('attachment:read', async (_event, localPath: string) => { |
| 208 | return await attachmentHandler.readAttachment(localPath) |
| 209 | }) |
| 210 | |
| 211 | // 删除附件 |
| 212 | ipcMain.handle('attachment:delete', async (_event, localPath: string) => { |
| 213 | return await attachmentHandler.deleteAttachment(localPath) |
| 214 | }) |
| 215 | |
| 216 | // 移动附件 |
| 217 | ipcMain.handle( |
| 218 | 'attachment:move', |
| 219 | async ( |
| 220 | _event, |
| 221 | options: { |
| 222 | fileId: string |
| 223 | fileName: string |
| 224 | fromPath: string |
| 225 | pageId: string |
| 226 | messageId: string |
| 227 | } |
| 228 | ) => { |
| 229 | return await attachmentHandler.moveAttachment( |
| 230 | options.fileId, |
| 231 | options.fileName, |
| 232 | options.fromPath, |
| 233 | options.pageId, |
| 234 | options.messageId |
| 235 | ) |
| 236 | } |
| 237 | ) |
| 238 | |
| 239 | // 清理消息附件 |
no test coverage detected