@setoelkahfi / svara / commits / 0da5dce

showing files in explorer (windows)

mellbacon committed Aug 11, 2022 at 17:22 UTC 0da5dce2bb7126dd85cce43a534ce278678f9d5c
2 files changed +12 -4
src/components/FileTree/LeafNodeMenu.svelte
+7 -2
@@ -6,7 +6,7 @@
6 import Paste from "carbon-icons-svelte/lib/Paste.svelte";
7 import Cut from "carbon-icons-svelte/lib/Cut.svelte";
8 import Script from "carbon-icons-svelte/lib/Script.svelte";
9 - import { fs, clipboard } from "@tauri-apps/api";
9 + import { fs, clipboard, shell, path } from "@tauri-apps/api";
10 export let target;
11 export let filename;
12 export let filepath;
@@ -39,7 +39,12 @@
39 <span slot="labelText" title={filepath}>Copy Absolute Path</span>
40 </ContextMenuOption>
41 </ContextMenuOption>
42 - <ContextMenuOption labelText="Show in Explorer"></ContextMenuOption>
42 + <ContextMenuOption labelText="Show in Explorer" on:click={() => {
43 + let dir = filepath.split(path.sep);
44 + dir.pop();
45 + dir = dir.join(path.sep);
46 + shell.open(dir);
47 + }}></ContextMenuOption>
48
49 <ContextMenuDivider></ContextMenuDivider>
50 <ContextMenuOption labelText="Delete..." on:click={ async() => {
src/components/FileTree/ParentNodeMenu.svelte
+5 -2
@@ -5,7 +5,8 @@
5 import Paste from "carbon-icons-svelte/lib/Paste.svelte";
6 import Cut from "carbon-icons-svelte/lib/Cut.svelte";
7 import RenameModel from "../Modal/RenameModel.svelte";
8 - import { fs, clipboard } from "@tauri-apps/api";
8 + import { fs, clipboard, shell, path } from "@tauri-apps/api";
9 +import { dirname } from "@tauri-apps/api/path";
10 export let target;
11 export let filename;
12 export let filepath;
@@ -40,7 +41,9 @@
41 <span slot="labelText" title={filepath}>Copy Absolute Path</span>
42 </ContextMenuOption>
43 </ContextMenuOption>
43 - <ContextMenuOption labelText="Show in Explorer"></ContextMenuOption>
44 + <ContextMenuOption labelText="Show in Explorer" on:click={() => {
45 + shell.open(filepath);
46 + }}></ContextMenuOption>
47 <ContextMenuDivider></ContextMenuDivider>
48 <ContextMenuOption labelText="Delete..." on:click={ async() => {
49 await fs.removeDir(filepath, {recursive: true});