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 @@ - Welcome to Tauri + Vue + + + - - - - - - - - - + + 读取指定文件 + 更新指定文件 - Click on the Tauri, Vite, and Vue logos to learn more. - - - Greet - - {{ greetMsg }} + 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
Click on the Tauri, Vite, and Vue logos to learn more.
{{ greetMsg }}