Browse Source

fix(nc-gui): apply getImgSrc and showFallback on Gallery and kanban

pull/5046/head
Wing-Kam Wong 2 years ago
parent
commit
1fecbe0df8
  1. 19
      packages/nc-gui/components/smartsheet/Gallery.vue
  2. 17
      packages/nc-gui/components/smartsheet/Kanban.vue

19
packages/nc-gui/components/smartsheet/Gallery.vue

@ -168,6 +168,22 @@ watch(view, async (nextView) => {
await loadGalleryData() await loadGalleryData()
} }
}) })
const { appInfo } = useGlobal()
const getImgSrc = (item: Record<string, any>) => {
if (item.data) {
return item.data
} else if (item.path) {
return `${appInfo.value.ncSiteUrl}/${item.path}`
}
return item.url
}
const showFallback = (evt: any, item: Record<string, any>) => {
evt.onerror = null
evt.target.src = item.url
}
</script> </script>
<template> <template>
@ -205,7 +221,8 @@ watch(view, async (nextView) => {
quality="90" quality="90"
placeholder placeholder
class="h-52 object-contain" class="h-52 object-contain"
:src="attachment.url" :src="getImgSrc(attachment)"
:onerror="(e) => showFallback(e, attachment)"
/> />
</a-carousel> </a-carousel>

17
packages/nc-gui/components/smartsheet/Kanban.vue

@ -312,6 +312,20 @@ watch(view, async (nextView) => {
} }
} }
}) })
const getImgSrc = (item: Record<string, any>) => {
if (item.data) {
return item.data
} else if (item.path) {
return `${appInfo.ncSiteUrl}/${item.path}`
}
return item.url
}
const showFallback = (evt: any, item: Record<string, any>) => {
evt.onerror = null
evt.target.src = item.url
}
</script> </script>
<template> <template>
@ -462,7 +476,8 @@ watch(view, async (nextView) => {
quality="90" quality="90"
placeholder placeholder
class="h-52 object-cover" class="h-52 object-cover"
:src="attachment.url" :src="getImgSrc(attachment)"
:onerror="(e) => showFallback(e, attachment)"
/> />
</a-carousel> </a-carousel>

Loading…
Cancel
Save