diff --git a/src/pages/AddWorkspace/CloneWikiForm.tsx b/src/pages/AddWorkspace/CloneWikiForm.tsx index 967eacd4..ada6e4ce 100644 --- a/src/pages/AddWorkspace/CloneWikiForm.tsx +++ b/src/pages/AddWorkspace/CloneWikiForm.tsx @@ -30,7 +30,7 @@ export function CloneWikiForm({ form, isCreateMainWorkspace }: IWikiWorkspaceFor /> { - const filePaths = await window.service.native.pickDirectory(); + const filePaths = await window.service.native.pickDirectory(form.parentFolderLocation); if (filePaths?.length > 0) { form.parentFolderLocationSetter(filePaths[0]); } diff --git a/src/pages/AddWorkspace/ExistedWikiForm.tsx b/src/pages/AddWorkspace/ExistedWikiForm.tsx index cc674fb5..3c08ab17 100644 --- a/src/pages/AddWorkspace/ExistedWikiForm.tsx +++ b/src/pages/AddWorkspace/ExistedWikiForm.tsx @@ -37,7 +37,7 @@ export function ExistedWikiForm({ /> { - const filePaths = await window.service.native.pickDirectory(); + const filePaths = await window.service.native.pickDirectory(form.parentFolderLocation); if (filePaths?.length > 0) { form.existedWikiFolderPathSetter(filePaths[0]); } diff --git a/src/pages/AddWorkspace/NewWikiForm.tsx b/src/pages/AddWorkspace/NewWikiForm.tsx index 42a7b2cc..81715160 100644 --- a/src/pages/AddWorkspace/NewWikiForm.tsx +++ b/src/pages/AddWorkspace/NewWikiForm.tsx @@ -34,7 +34,7 @@ export function NewWikiForm({ /> { - const filePaths = await window.service.native.pickDirectory(); + const filePaths = await window.service.native.pickDirectory(form.parentFolderLocation); if (filePaths?.length > 0) { form.parentFolderLocationSetter(filePaths[0]); } diff --git a/src/pages/Preferences/index.tsx b/src/pages/Preferences/index.tsx index bb80d2f3..ec37b682 100644 --- a/src/pages/Preferences/index.tsx +++ b/src/pages/Preferences/index.tsx @@ -607,7 +607,7 @@ export default function Preferences(): JSX.Element { button onClick={() => { window.service.native - .pickDirectory() + .pickDirectory(downloadPath) .then(async (filePaths) => { if (filePaths.length > 0) { await window.service.preference.set('downloadPath', filePaths[0]); diff --git a/src/services/native/index.ts b/src/services/native/index.ts index 5938da92..2cb2bbff 100644 --- a/src/services/native/index.ts +++ b/src/services/native/index.ts @@ -18,9 +18,10 @@ export class NativeService implements INativeService { } } - public async pickDirectory(): Promise { + public async pickDirectory(defaultPath?: string): Promise { const dialogResult = await dialog.showOpenDialog({ properties: ['openDirectory'], + defaultPath, }); if (!dialogResult.canceled && dialogResult.filePaths.length > 0) { return dialogResult.filePaths; diff --git a/src/services/native/interface.ts b/src/services/native/interface.ts index e3fbb643..a7faed8e 100644 --- a/src/services/native/interface.ts +++ b/src/services/native/interface.ts @@ -9,7 +9,7 @@ import { WindowNames } from '@services/windows/WindowProperties'; */ export interface INativeService { showElectronMessageBox(message: string, type: MessageBoxOptions['type'], WindowName?: WindowNames): Promise; - pickDirectory(): Promise; + pickDirectory(defaultPath?: string): Promise; pickFile(filters?: Electron.OpenDialogOptions['filters']): Promise; open(uri: string, isDirectory?: boolean): Promise; quit(): void; diff --git a/src/services/preferences/defaultPreferences.ts b/src/services/preferences/defaultPreferences.ts index cb4756d6..d1b95346 100644 --- a/src/services/preferences/defaultPreferences.ts +++ b/src/services/preferences/defaultPreferences.ts @@ -32,7 +32,6 @@ export const defaultPreferences: IPreferences = { useHardwareAcceleration: true, }; -/** get path, note that if use this from the preload script, app will be undefined, so have to use remote.app here */ function getDefaultDownloadsPath(): string { return path.join(app.getPath('home'), 'Downloads'); }