| | |
| | | import { computed } from 'vue'; |
| | | |
| | | import { IconifyIcon } from '@vben/icons'; |
| | | import { getFileIcon, getFileNameFromUrl, getFileTypeClass } from '@vben/utils'; |
| | | import { getFileIcon, getFileNameFromUrl, getFileTypeClass, isImage } from '@vben/utils'; |
| | | |
| | | import { FilePreviewModal, useFilePreview } from '#/components/file-preview'; |
| | | |
| | | const props = defineProps<{ |
| | | attachmentUrls?: string[]; |
| | | }>(); |
| | | |
| | | const { openPreview, previewState } = useFilePreview(); |
| | | |
| | | /** 过滤掉空值的附件列表 */ |
| | | const validAttachmentUrls = computed(() => { |
| | |
| | | |
| | | /** 点击文件 */ |
| | | function handleFileClick(url: string) { |
| | | window.open(url, '_blank'); |
| | | if (isImage(url)) { |
| | | window.open(url, '_blank'); |
| | | } else { |
| | | openPreview(url); |
| | | } |
| | | } |
| | | </script> |
| | | |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <FilePreviewModal |
| | | v-model:visible="previewState.visible.value" |
| | | :file-url="previewState.fileUrl.value" |
| | | :file-name="previewState.fileName.value" |
| | | /> |
| | | </template> |