Enhance pick-paths functionality with options for filters and title
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user