mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
feat: open default when pickDirectory
This commit is contained in:
parent
2bb6831bae
commit
3d38d37635
7 changed files with 7 additions and 7 deletions
|
|
@ -30,7 +30,7 @@ export function CloneWikiForm({ form, isCreateMainWorkspace }: IWikiWorkspaceFor
|
|||
/>
|
||||
<LocationPickerButton
|
||||
onClick={async () => {
|
||||
const filePaths = await window.service.native.pickDirectory();
|
||||
const filePaths = await window.service.native.pickDirectory(form.parentFolderLocation);
|
||||
if (filePaths?.length > 0) {
|
||||
form.parentFolderLocationSetter(filePaths[0]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export function ExistedWikiForm({
|
|||
/>
|
||||
<LocationPickerButton
|
||||
onClick={async () => {
|
||||
const filePaths = await window.service.native.pickDirectory();
|
||||
const filePaths = await window.service.native.pickDirectory(form.parentFolderLocation);
|
||||
if (filePaths?.length > 0) {
|
||||
form.existedWikiFolderPathSetter(filePaths[0]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export function NewWikiForm({
|
|||
/>
|
||||
<LocationPickerButton
|
||||
onClick={async () => {
|
||||
const filePaths = await window.service.native.pickDirectory();
|
||||
const filePaths = await window.service.native.pickDirectory(form.parentFolderLocation);
|
||||
if (filePaths?.length > 0) {
|
||||
form.parentFolderLocationSetter(filePaths[0]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ export class NativeService implements INativeService {
|
|||
}
|
||||
}
|
||||
|
||||
public async pickDirectory(): Promise<string[]> {
|
||||
public async pickDirectory(defaultPath?: string): Promise<string[]> {
|
||||
const dialogResult = await dialog.showOpenDialog({
|
||||
properties: ['openDirectory'],
|
||||
defaultPath,
|
||||
});
|
||||
if (!dialogResult.canceled && dialogResult.filePaths.length > 0) {
|
||||
return dialogResult.filePaths;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { WindowNames } from '@services/windows/WindowProperties';
|
|||
*/
|
||||
export interface INativeService {
|
||||
showElectronMessageBox(message: string, type: MessageBoxOptions['type'], WindowName?: WindowNames): Promise<void>;
|
||||
pickDirectory(): Promise<string[]>;
|
||||
pickDirectory(defaultPath?: string): Promise<string[]>;
|
||||
pickFile(filters?: Electron.OpenDialogOptions['filters']): Promise<string[]>;
|
||||
open(uri: string, isDirectory?: boolean): Promise<void>;
|
||||
quit(): void;
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue