Файли
openidea/src/platform/choosePath.ts
T
Mr0Bread 41951e2895 refactor(platform): move choosePath out of settings (#3594)
choosePath, a thin wrapper over the platform file/folder dialog, lived in features/settings/languages/api.ts, so vcs/RevisionBrowser imported the settings feature to open a folder picker. It moves to platform/choosePath.ts unchanged (the dialog module still loads lazily). No behaviour change.

Co-authored-by: Mr0Bread <[email protected]>
2026-11-16 04:15:46 +08:00

20 рядки
662 B
TypeScript

import { isTauri } from "@/platform/ipc";
/** File / folder chooser (Tauri dialog); null when cancelled or outside Tauri. */
export async function choosePath(opts: {
directory: boolean;
title: string;
defaultPath?: string;
}): Promise<string | null> {
if (!isTauri()) return null;
// Lazy on purpose: loading platform/dialog starts its GTK capability probe at module load.
const { open } = await import("@/platform/dialog");
const picked = await open({
directory: opts.directory,
multiple: false,
title: opts.title,
defaultPath: opts.defaultPath || undefined,
});
return (Array.isArray(picked) ? picked[0] : picked) ?? null;
}