Enhance pick-paths functionality with options for filters and title

This commit is contained in:
2026-04-17 12:59:32 +02:00
parent d5a4ab8417
commit b627c51f7d
2 changed files with 13 additions and 3 deletions

View File

@@ -708,9 +708,19 @@ ipcMain.handle('update-settings', (event, settings) => {
return true
})
ipcMain.handle('pick-paths', async () => {
const result = await dialog.showOpenDialog(mainWindow, {
ipcMain.handle('pick-paths', async (event, options = {}) => {
const dialogOptions = {
properties: ['openFile', 'multiSelections'],
}
if (Array.isArray(options?.filters) && options.filters.length > 0) {
dialogOptions.filters = options.filters
}
if (typeof options?.title === 'string' && options.title.trim()) {
dialogOptions.title = options.title.trim()
}
const result = await dialog.showOpenDialog(mainWindow, {
...dialogOptions,
})
return result.canceled ? [] : result.filePaths
})

View File

@@ -9,7 +9,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
getChangelogPage: (page) => ipcRenderer.invoke('get-changelog-page', page),
setSetting: (key, value) => ipcRenderer.invoke('set-setting', key, value),
updateSettings: (settings) => ipcRenderer.invoke('update-settings', settings),
pickPaths: () => ipcRenderer.invoke('pick-paths'),
pickPaths: (options) => ipcRenderer.invoke('pick-paths', options),
openPath: (filePath) => ipcRenderer.invoke('open-path', filePath),
openExternalLink: (event) => {
event.preventDefault();