| | |
| | | previewUrl: "", |
| | | }); |
| | | |
| | | const getFileAccessUrl = (file = {}) => { |
| | | if (file?.link) { |
| | | if (String(file.link).startsWith('http')) return file.link; |
| | | return normalizeFileUrl(file.link); |
| | | } |
| | | return normalizeFileUrl(file?.url || ''); |
| | | }; |
| | | |
| | | const normalizeFileUrl = (rawUrl = '') => { |
| | | let fileUrl = rawUrl || ''; |
| | | |
| | |
| | | attachment.fileList = attachment.files.map((item) => ({ |
| | | id: item.id, |
| | | name: item.name, |
| | | url: normalizeFileUrl(item.url), |
| | | url: getFileAccessUrl(item), |
| | | })); |
| | | } finally { |
| | | attachment.loading = false; |
| | |
| | | }; |
| | | |
| | | const handleAttachmentPreview = (file) => { |
| | | const rawUrl = file?.url || file?.response?.data?.url || ""; |
| | | const rawUrl = file?.url || file?.response?.data?.link || file?.response?.data?.url || ""; |
| | | if (!rawUrl) { |
| | | ElMessage.warning("图片地址无效,无法预览"); |
| | | return; |