Closed vincent-lu closed 9 months ago
The issue here is that if you use resolveResource and convertFileSrc like this you'll end up with a url encoded path that mixed forward and backward slashes. I'm not sure if we consider this a bug or simply expected behavior, but you can workaround it really easily. This is how we intended the resolveResource api to be used (this would fix the issue here):
resolveResource("resources/image.jpg")
Alternative you can use path.resolve like
const path = await resolveResource('resources');
state.image = convertFileSrc(await resolve(`${path}/image.jpg`));
Ah ok, that worked. Thanks @FabianLars. I always thought forward slashes (sort of) already work on Windows.
Describe the bug
The files in resources folders can be accessed on MacOS but not on Windows.
This is the main part of the code:
When I run
pnpm i && pnpm tauri dev
on MacOS, the app opens with a sample image shown. But on Windows the exact same code will show a broken image (the url actually points to the right path, but seems the app lacks permission to access it)This seems to be very similar to https://github.com/tauri-apps/tauri/issues/6962 but I tried to set assetScope to
"**/*"
(instead of"**"
), it still doesn't work on Windows.Reproduction
Expected behavior
The jpeg image stored at
./src-tauri/resources/image.jpg
should be shown as a web image on the frontend on both MacOS and Windows.Full
tauri info
outputStack trace
No response
Additional context
No response