tauri-apps / tauri

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

[docs] How to load image resource in v2 #9667

Closed Arman19941113 closed 1 week ago

Arman19941113 commented 1 week ago

we can use convertFileSrc to load local resources in v1

function App() {
  const filepath = '/Users/arman/Downloads/test/sony.JPG'
  const url = convertFileSrc(filepath)

  return (
    <img src={url} alt="" />
  )
}

but allowlist.protocol.asset is not supported in v2

So this approach caused the issue

Failed to load resource: unsupported URL

And I didn't find any approach to fix it

7112

Arman19941113 commented 1 week ago

The doc still recommends this unsupported configuration.

image
FabianLars commented 1 week ago

It's app.security.assetProtocol now. I hope we can move that into the capabilities to the other scopes but for now it's there.

Arman19941113 commented 1 week ago

It's app.security.assetProtocol now. I hope we can move that into the capabilities to the other scopes but for now it's there.

Thanks! It's helpful~