mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-19 04:37:28 +08:00
feat(desktop): render sent images/videos/files
This commit is contained in:
@@ -219,6 +219,15 @@ function setupIPC() {
|
||||
return result.canceled ? null : result.filePaths[0]
|
||||
})
|
||||
|
||||
// Open a local file with the OS default app; falls back to revealing it in
|
||||
// the file manager when no handler exists. Returns '' on success.
|
||||
ipcMain.handle('open-path', async (_event, targetPath: string) => {
|
||||
if (!targetPath) return 'empty path'
|
||||
const err = await shell.openPath(targetPath)
|
||||
if (err) shell.showItemInFolder(targetPath)
|
||||
return err
|
||||
})
|
||||
|
||||
// Custom window controls (used by Windows frameless titlebar)
|
||||
ipcMain.handle('window-minimize', () => mainWindow?.minimize())
|
||||
ipcMain.handle('window-maximize', () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
restartBackend: () => ipcRenderer.invoke('restart-backend'),
|
||||
selectDirectory: () => ipcRenderer.invoke('select-directory'),
|
||||
selectFile: (filters?: Electron.FileFilter[]) => ipcRenderer.invoke('select-file', filters),
|
||||
openPath: (targetPath: string) => ipcRenderer.invoke('open-path', targetPath) as Promise<string>,
|
||||
|
||||
// Each listener registrar returns an unsubscribe fn so renderers can clean
|
||||
// up on unmount / effect re-run and avoid accumulating duplicate handlers.
|
||||
|
||||
Reference in New Issue
Block a user