tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
83.64k stars 2.51k forks source link

[bug] Local files cannot be loaded correctly using `convertFileSrc` on windows #8244

Closed raycaster08 closed 10 months ago

raycaster08 commented 11 months ago

Describe the bug

if (path === "") return;
    const assetsPath = convertFileSrc(path);
    Potree.loadPointCloud(`${assetsPath}/potree/metadata.json`, name).then(
      (e: any) => {
        const { pointcloud } = e;
        pointcloud.material.activeAttributeName = "elevation";
        pointcloud.material.gradient = Potree.Gradients.RAINBOW;
        pointcloud.material.intensityRange = [0, 255];

        pointCloudRef.current = pointcloud;
        pointCloudMaterialRef.current = pointcloud.material;
        viewerRef.current.scene.addPointCloud(pointcloud);
      }
    );

console log: path and assetsPath image

The loading of /potree/metadata.json has been successful so far.. but other files inside the method cannot be loaded proper image

I don't understand whyhierarchy.bin and metadata.json cannot be loaded in the same directory

I didn't experience this problem with macos

Reproduction

No response

Expected behavior

Hopefully he will be able to load the files in the local file system correctly under windows

Platform and versions

[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 119.0.2151.58
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.74.0 (79e9716c9 2023-11-13)
    ✔ cargo: 1.74.0 (ecb9851af 2023-10-18)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.18.2
    - pnpm: 8.9.2
    - npm: 9.8.1

[-] Packages
    - tauri [RUST]: 1.5.2
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.4
    - tao [RUST]: 0.16.5
    - @tauri-apps/api [NPM]: 1.5.1
    - @tauri-apps/cli [NPM]: 1.5.6

[-] App
    - build-type: bundle
    - CSP: default-src blob: data: filesystem: wss: https: tauri: 'unsafe-inline' asset: https://asset.localhost 'self'; script-src 'self'
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: React
    - bundler: Vite

Stack trace

`tauri.config.json`

    "allowlist": {
    ...
      "protocol": {
        "all": true,
        "asset": true,
        "assetScope": ["**", "**/*"]
      },
    ...
    },
    "security": {
      "csp": "default-src blob: data: filesystem: wss: https: tauri: 'unsafe-inline' asset: https://asset.localhost 'self'; script-src 'self'"
    },

Additional context

No response

amrbashir commented 10 months ago

convertFileSrc works just fine on Windows for me, Please provide a minimal reproduction