🐛 (images) fix images not showing when reloading the page
This commit is contained in:
@@ -36,13 +36,15 @@ const { displayNoteOverlay } = useNoteOverlay(className.value, props.index)
|
|||||||
const displayedTitle = computed(() => filenameToNoteTitle(props.title))
|
const displayedTitle = computed(() => filenameToNoteTitle(props.title))
|
||||||
|
|
||||||
watch(content, () => {
|
watch(content, () => {
|
||||||
if (content.value) {
|
if (!content.value) {
|
||||||
nextTick(() => {
|
return
|
||||||
listenToClick()
|
|
||||||
useImages(props.sha)
|
|
||||||
generateTweets()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
listenToClick()
|
||||||
|
useImages(props.sha)
|
||||||
|
generateTweets()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const focus = () => scrollToFocusedNote(props.sha)
|
const focus = () => scrollToFocusedNote(props.sha)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useFile } from '@/hooks/useFile.hook'
|
import { useFile } from '@/hooks/useFile.hook'
|
||||||
import { resolvePath } from '@/modules/repo/services/resolvePath'
|
import { resolvePath } from '@/modules/repo/services/resolvePath'
|
||||||
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
import { useUserRepoStore } from '@/modules/repo/store/userRepo.store'
|
||||||
import { computed } from 'vue'
|
import { computed, watch } from 'vue'
|
||||||
|
|
||||||
const SRC_PREFIX = 'data:image/jpeg;charset=utf-8;base64,'
|
const SRC_PREFIX = 'data:image/jpeg;charset=utf-8;base64,'
|
||||||
|
|
||||||
@@ -12,17 +12,21 @@ export const useImages = (sha: string) => {
|
|||||||
() => store.files.find((file) => file.sha === sha)?.path
|
() => store.files.find((file) => file.sha === sha)?.path
|
||||||
)
|
)
|
||||||
|
|
||||||
const images = document.querySelectorAll(`.note-${sha} img`)
|
watch(currentFilePath, (filePath) => {
|
||||||
|
if (!filePath) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
images.forEach(async (image) => {
|
const images = document.querySelectorAll(`.note-${sha} img`)
|
||||||
if (currentFilePath.value) {
|
|
||||||
|
images.forEach(async (image) => {
|
||||||
const src = image.getAttribute('src')
|
const src = image.getAttribute('src')
|
||||||
if (!src || src.startsWith(SRC_PREFIX)) {
|
if (!src || src.startsWith(SRC_PREFIX)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const imageFilePath = resolvePath(
|
const imageFilePath = resolvePath(
|
||||||
currentFilePath.value,
|
filePath,
|
||||||
image.getAttribute('src') ?? ''
|
image.getAttribute('src') ?? ''
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,6 +39,6 @@ export const useImages = (sha: string) => {
|
|||||||
|
|
||||||
const fileContent = await getCachedFileContent()
|
const fileContent = await getCachedFileContent()
|
||||||
image.setAttribute('src', `${SRC_PREFIX} ${fileContent}`)
|
image.setAttribute('src', `${SRC_PREFIX} ${fileContent}`)
|
||||||
}
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user