简体   繁体   English

Tauri 不允许加载本地资源

[英]Tauri Not allowed to load local resource

I've been using electron for GUI interface development, recently I came across Tauri as electron alternative and coming to realize that the same code works on electron but not Tauri where:我一直在使用 electron 进行 GUI 界面开发,最近我遇到了 Tauri 作为 electron 替代品,并意识到相同的代码适用于 electron 但不适用于 Tauri:

<video controls preload src="file:\\C:\Users\User\Desktop\HelloTest\testVideo.mp4" ></video>

I've already tried:我已经尝试过:

<video controls preload src="C:\Users\User\Desktop\HelloTest\testVideo.mp4" ></video>

and the error is still Not allowed to load local resource: file:///.....并且错误仍然是 Not allowed to load local resource: file:///.....

it works in electron by disabling the webSecurity:false in webPreference , is there any ways I can disable web security in Tauri, so that I can use local resources (videos from C:// or D://) in Tauri, my Tauri are using Angular as frontend它通过在 webPreference 中禁用webSecurity:falsewebPreference中工作,有什么方法可以在 Tauri 中禁用 web 安全性,以便我可以使用本地资源(来自 Z0D61F8370CAD1D412F80B84D1 中的 Z0D61F8370CAD1D412F80B84D1 的视频)正在使用 Angular 作为前端

You can configure the security.您可以配置安全性。 Take a look at the documentation here: https://tauri.app/v1/api/js/modules/fs#security看看这里的文档: https://tauri.app/v1/api/js/modules/fs#security

  {
   "tauri": {
     "allowlist": {
       "fs": {
        "scope": ["$APP/databases/*"]
    }
  }

.Paths accessed with this API must be relative to one of the base directories so if you need access to arbitrary filesystem paths, you must write such logic on the core layer instead. . 使用此 API 访问的路径必须相对于基本目录之一,因此如果您需要访问任意文件系统路径,则必须在核心层上编写此类逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM