35 lines
No EOL
698 B
Svelte
35 lines
No EOL
698 B
Svelte
<script lang="ts">
|
|
import { open } from '@tauri-apps/api/dialog';
|
|
|
|
export let path: string;
|
|
|
|
let buttonPrompt = "Select";
|
|
|
|
async function handleClick() {
|
|
const dirHandle = await open({
|
|
multiple: false,
|
|
directory: true,
|
|
defaultPath: path
|
|
});
|
|
if (Array.isArray(dirHandle)) {
|
|
path = dirHandle[0];
|
|
}
|
|
else if (dirHandle !== null) {
|
|
path = dirHandle;
|
|
}
|
|
}
|
|
|
|
</script>
|
|
|
|
<div>
|
|
<button on:click|preventDefault={handleClick}>{buttonPrompt}</button>
|
|
{#if path != ""}
|
|
<p>{path}</p>
|
|
{:else}
|
|
<p>Select Save Location...</p>
|
|
{/if}
|
|
</div>
|
|
|
|
<style>
|
|
|
|
</style> |