| | |
| | | class="attachment-item" |
| | | @click="previewAttachment(file)"> |
| | | <view class="attachment-preview-container"> |
| | | {{formatFileUrl(file.url || file.downloadUrl)}} |
| | | <!-- {{formatFileUrl(file.url || file.downloadUrl)}} --> |
| | | <image v-if="file.type === 'image' || isImageFile(file)" |
| | | :src="formatFileUrl(file.url || file.downloadUrl)" |
| | | class="attachment-preview" |
| | |
| | | }; |
| | | |
| | | // 文件访问基础域(后端要求前缀) |
| | | const filePreviewBase = config.baseUrl; |
| | | const filePreviewBase = config.fileUrl; |
| | | |
| | | // 将后端返回的文件地址规范成可访问URL |
| | | // 兼容场景: |
| | |
| | | if (url.startsWith("http://") || url.startsWith("https://")) { |
| | | return url; |
| | | } |
| | | const uploadsIndex = url.indexOf("uploads"); |
| | | if (uploadsIndex !== -1) { |
| | | const relativePath = url.substring(uploadsIndex); |
| | | return `${config.baseUrl}/profile/${relativePath}`; |
| | | } |
| | | return `${config.baseUrl}/profile/${url}`; |
| | | // const uploadsIndex = url.indexOf("uploads"); |
| | | // if (uploadsIndex !== -1) { |
| | | // const relativePath = url.substring(uploadsIndex); |
| | | // return `${config.fileUrl}/${relativePath}`; |
| | | // } |
| | | return `${config.fileUrl}/${url}`; |
| | | }; |
| | | // 格式化文件大小 |
| | | const formatFileSize = size => { |