From a6d38ed9cb311fcc4ba8f72086faaa0ac95e3f96 Mon Sep 17 00:00:00 2001 From: Metona Dev Date: Sat, 18 Apr 2026 10:42:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A5=E5=85=B7=E9=9D=A2=E6=9D=BF/?= =?UTF-8?q?=E5=B8=AE=E5=8A=A9=E9=9D=A2=E6=9D=BF=E5=90=8C=E6=AD=A5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=20+=20=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 工具面板: 20→29个工具,补齐 web_search/memory_*/session_*/spawn_task/browser_* - 帮助面板: 工具数量21→29,新增人格模式/MCP/Cron/Heartbeat说明,补充/retry等命令 - 图片上传: preload透传完整options,ipc尊重multiple参数,图片选择器限制单文件 --- src/main/ipc.ts | 15 +++++- src/main/preload.ts | 2 +- src/renderer/components/input-area.ts | 4 +- src/renderer/index.html | 70 +++++++++++++++++++++++++-- 4 files changed, 82 insertions(+), 9 deletions(-) diff --git a/src/main/ipc.ts b/src/main/ipc.ts index 0d98427..fdc448b 100644 --- a/src/main/ipc.ts +++ b/src/main/ipc.ts @@ -80,9 +80,20 @@ function summarizeResult(toolName: string, result: Record): str } export async function setupIPC(): Promise { - ipcMain.handle('dialog:openFile', async (_, options?: { filters?: Array<{ name: string; extensions: string[] }> }) => { + ipcMain.handle('dialog:openFile', async (_, options?: { filters?: Array<{ name: string; extensions: string[] }>; properties?: string[]; multiple?: boolean }) => { + const dialogProperties: Array<'openFile' | 'multiSelections' | 'openDirectory'> = ['openFile']; + if (options?.multiple !== false && !options?.properties?.includes('openFile')) { + dialogProperties.push('multiSelections'); + } + if (options?.properties) { + for (const p of options.properties) { + if (p === 'multiSelections' && !dialogProperties.includes('multiSelections')) { + dialogProperties.push('multiSelections'); + } + } + } const result = await dialog.showOpenDialog(mainWindow!, { - properties: ['openFile', 'multiSelections'], + properties: dialogProperties, filters: options?.filters || [{ name: '所有文件', extensions: ['*'] }] }); if (result.canceled) return null; diff --git a/src/main/preload.ts b/src/main/preload.ts index 1bf739b..1ad5f5b 100644 --- a/src/main/preload.ts +++ b/src/main/preload.ts @@ -8,7 +8,7 @@ contextBridge.exposeInMainWorld('metonaDesktop', { isDesktop: true, info: () => ipcRenderer.invoke('app:info'), dialog: { - openFile: (filters?: unknown) => ipcRenderer.invoke('dialog:openFile', { filters }), + openFile: (options?: unknown) => ipcRenderer.invoke('dialog:openFile', options), saveFile: (options?: unknown) => ipcRenderer.invoke('dialog:saveFile', options) }, fs: { diff --git a/src/renderer/components/input-area.ts b/src/renderer/components/input-area.ts index 7bb557e..8142ca2 100644 --- a/src/renderer/components/input-area.ts +++ b/src/renderer/components/input-area.ts @@ -90,7 +90,9 @@ export function initInputArea(): void { const bridge = getBridge(); if (!bridge) return; const paths = await bridge.dialog.openFile({ - filters: [{ name: '图片', extensions: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'] }] + filters: [{ name: '图片', extensions: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg'] }], + properties: ['openFile'], + multiple: false }); if (!paths || paths.length === 0) return; await handleImagePaths(paths); diff --git a/src/renderer/index.html b/src/renderer/index.html index a6dca93..2f0d2a1 100644 --- a/src/renderer/index.html +++ b/src/renderer/index.html @@ -413,11 +413,15 @@ @@ -426,7 +430,7 @@