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
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.handle('pick-paths', async () => {
|
ipcMain.handle('pick-paths', async (event, options = {}) => {
|
||||||
const result = await dialog.showOpenDialog(mainWindow, {
|
const dialogOptions = {
|
||||||
properties: ['openFile', 'multiSelections'],
|
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
|
return result.canceled ? [] : result.filePaths
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
|||||||
getChangelogPage: (page) => ipcRenderer.invoke('get-changelog-page', page),
|
getChangelogPage: (page) => ipcRenderer.invoke('get-changelog-page', page),
|
||||||
setSetting: (key, value) => ipcRenderer.invoke('set-setting', key, value),
|
setSetting: (key, value) => ipcRenderer.invoke('set-setting', key, value),
|
||||||
updateSettings: (settings) => ipcRenderer.invoke('update-settings', settings),
|
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),
|
openPath: (filePath) => ipcRenderer.invoke('open-path', filePath),
|
||||||
openExternalLink: (event) => {
|
openExternalLink: (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user