From c09c8b5e9cbaacd6781acf287e0b8debc72f2189 Mon Sep 17 00:00:00 2001 From: Frankie Huang Date: Fri, 4 Apr 2025 19:13:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=AF=BB=E5=86=99?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++ src-tauri/capabilities/default.json | 18 ++++++- src/App.vue | 53 ++++++++++++++------ src/components/SelectFolder.vue | 76 +++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 17 deletions(-) create mode 100644 src/components/SelectFolder.vue diff --git a/README.md b/README.md index 03be44e..0e88e6a 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,9 @@ This template should help get you started developing with Tauri + Vue 3 in Vite. 1. `npm run tauri add fs` 2. `npm run tauri add dialog` + +## 支持读本地目录,读写本地文件 + +1. 新建 SelectFolder.vue 用于打开本地目录 +2. 在 App.vue 使用组件 SelectFolder 和 MarkdownEditor.vue +3. 使用 plugin-fs 插件读写本地文件内容 diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 724be5d..bfb4265 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -9,6 +9,22 @@ "core:default", "opener:default", "fs:default", - "dialog:default" + "dialog:default", + { + "identifier": "fs:scope", + "allow": [ + { + "path": "$HOME/**" + } + ] + }, + { + "identifier": "fs:allow-app-write", + "allow": [ + { + "path": "$HOME/**" + } + ] + } ] } \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index b8801dc..de9895f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,12 @@ diff --git a/src/components/SelectFolder.vue b/src/components/SelectFolder.vue new file mode 100644 index 0000000..588046e --- /dev/null +++ b/src/components/SelectFolder.vue @@ -0,0 +1,76 @@ + + + \ No newline at end of file