Browse Source

feat(nc-gui): useAttachment

pull/5046/head
Wing-Kam Wong 2 years ago
parent
commit
174394ef35
  1. 24
      packages/nc-gui/composables/useAttachment.ts

24
packages/nc-gui/composables/useAttachment.ts

@ -0,0 +1,24 @@
const useAttachment = () => {
const { appInfo } = useGlobal()
const getAttachmentSrc = (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
}
return {
getAttachmentSrc,
showFallback,
}
}
export default useAttachment
Loading…
Cancel
Save