Skip to content

Commit

Permalink
fix display issue for images in subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
rainu committed Nov 4, 2024
1 parent 7b34ae9 commit 5181b01
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/components/image/ImageItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,25 @@ export default defineComponent({
return
}
let parentDirectory = this.baseDir
let name = this.image.uri.name
const parents = this.image.uri.name.split('/')
if(parents.length > 1) {
name = parents.pop() || ''
for (let parent of parents) {
try {
parentDirectory = await parentDirectory.getDirectoryHandle(parent)
} catch (e: Error) {
if (e.name !== 'NotFoundError') {
console.error(e)
}
return
}
}
}
try {
const file = await this.baseDir.getFileHandle(this.image.uri.name)
const file = await parentDirectory.getFileHandle(name)
this.url = URL.createObjectURL(await file.getFile())
} catch (e: Error) {
if (e.name !== 'NotFoundError') {
Expand Down

0 comments on commit 5181b01

Please sign in to comment.