我对Tauri很陌生,我正在尝试读取/ ls一个目录。
window.__TAURI__.fs.readDir("com.tauri.dev/", { dir: window.__TAURI__.fs.Dir.Data }).then(...
Unhandled Promise Rejection: path not allowed on the configured scope: /home/user/.local/share/com.tauri.dev/好像是我搞砸了瞄准镜?我启用了所有我能想到的“允许列表”项,并且范围似乎被正确地定义了:
"allowlist": {
"path": { "all": true },
"all": true,
"fs": {
"all": true,
"readFile": true,
"writeFile": true,
"readDir": true,
"copyFile": true,
"createDir": true,
"removeDir": true,
"removeFile": true,
"renameFile": true,
"scope": ["$DATA/com.tauri.dev/*"]
}怎么回事?
Tauri信息:
$ npm run tauri info
> tauri-app@0.0.0 tauri
> tauri "info"
Environment
› OS: Pop!_OS 21.10 X64
› Node.js: 17.7.0
› npm: 8.5.2
› pnpm: Not installed!
› yarn: 1.22.17
› rustup: 1.24.3
› rustc: 1.59.0
› cargo: 1.59.0
› Rust toolchain: stable-x86_64-unknown-linux-gnu
Packages
› @tauri-apps/cli [NPM]: 1.0.0-rc.7(outdated, latest: 1.0.0-rc.8)
› @tauri-apps/api [NPM]: 1.0.0-rc.3(outdated, latest: 1.0.0-rc.3)
› tauri [RUST]: 1.0.0-rc.6,
› tauri-build [RUST]: 1.0.0-rc.5,
› tao [RUST]: 0.7.0,
› wry [RUST]: 0.14.0,
App
› build-type: bundle
› CSP: unset
› distDir: ../dist
› devPath: http://localhost:3000/
› framework: Svelte
App directory structure
├─ .vscode
├─ js
├─ node_modules
├─ public
├─ css
├─ src
├─ img
├─ src-tauri
├─ old_nm
├─ doc
└─ data发布于 2022-05-14 16:55:32
它似乎需要基本路径和附加*的路径,才能在所引用的目录中工作。
"scope": ["$APP/*","$APP"]发布于 2022-04-23 17:59:49
我在http中的tauri版本1.0.0-rc.3中也有类似的问题。
在tauri上看到了一些修复,并升级到一个未发布的git支持版本(在Cargo.toml中):
tauri = { git = "https://github.com/tauri-apps/tauri/", rev="834ccc51539401d36a7dfa1c0982623c9c446a4c", features = ["fs-read-file", "fs-write-file", "http-all",...修复了HTTP问题,fs也为我工作(在tauri.conf.json中)
"allowlist": {
"fs": {
"readFile": true,
"writeFile": true,
"scope": ["$DATA/XXX/**"]
},https://stackoverflow.com/questions/71663083
复制相似问题