| | |
| | | const detailRow = ref(null); |
| | | const detailImages = ref([]); |
| | | |
| | | 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 || ''; |
| | | // Windows 路径转 URL |
| | | |
| | | if (fileUrl && fileUrl.indexOf('\\') > -1) { |
| | | const uploadsIndex = fileUrl.toLowerCase().indexOf('uploads'); |
| | | if (uploadsIndex > -1) { |
| | | const relativePath = fileUrl.substring(uploadsIndex).replace(/\\/g, '/'); |
| | | fileUrl = '/' + relativePath; |
| | | } else { |
| | | const parts = fileUrl.split('\\'); |
| | | const fileName = parts[parts.length - 1]; |
| | | fileUrl = '/uploads/' + fileName; |
| | | fileUrl = fileUrl.replace(/\\/g, '/'); |
| | | } |
| | | |
| | | const lowerPath = fileUrl.toLowerCase(); |
| | | |
| | | const uploadPathIndex = lowerPath.indexOf('/uploadpath/'); |
| | | if (uploadPathIndex > -1) { |
| | | fileUrl = '/profile' + fileUrl.substring(uploadPathIndex + '/uploadpath'.length); |
| | | } |
| | | |
| | | const fileRootIndex = fileUrl.toLowerCase().indexOf('/file/'); |
| | | if (!fileUrl.startsWith('/profile/') && fileRootIndex > -1) { |
| | | fileUrl = '/profile' + fileUrl.substring(fileRootIndex + '/file'.length); |
| | | } |
| | | |
| | | if (!fileUrl.startsWith('http') && fileUrl.toLowerCase().startsWith('profile/')) { |
| | | fileUrl = '/' + fileUrl; |
| | | } |
| | | |
| | | if (fileUrl && !fileUrl.startsWith('http')) { |
| | | if (!fileUrl.startsWith('/')) fileUrl = '/' + fileUrl; |
| | | fileUrl = javaApi + fileUrl; |
| | |
| | | // 如果有图片,将 commonFileList 转换为文件列表格式 |
| | | if (row.commonFileList && Array.isArray(row.commonFileList) && row.commonFileList.length > 0) { |
| | | deliveryFileList.value = row.commonFileList.map((file, index) => { |
| | | const fileUrl = normalizeFileUrl(file.url || ''); |
| | | const fileUrl = getFileAccessUrl(file); |
| | | |
| | | return { |
| | | uid: file.id || Date.now() + index, |
| | |
| | | detailRow.value = row || null; |
| | | const list = Array.isArray(row?.commonFileList) ? row.commonFileList : []; |
| | | detailImages.value = list |
| | | .map((f) => ({ url: normalizeFileUrl(f?.url || '') })) |
| | | .map((f) => ({ url: getFileAccessUrl(f) })) |
| | | .filter((i) => !!i.url); |
| | | detailDialogVisible.value = true; |
| | | }; |