| | |
| | | const cancel = () => { |
| | | dialogVisitable.value = false; |
| | | }; |
| | | // 基础预览URL |
| | | const BASE_PREVIEW_URL = 'https://nj477vg8876.vicp.fun'; |
| | | |
| | | // 处理每一类数据:分离图片和视频 |
| | | function processItems(items) { |
| | | const images = []; |
| | | const videos = []; |
| | | if (!items || !Array.isArray(items)) { |
| | | return { images, videos }; |
| | | } |
| | | items.forEach(item => { |
| | | // 使用 fileUrl 字段,如果不存在则使用 url 字段作为兼容 |
| | | const fileUrl = item.fileUrl || item.url; |
| | | if (!fileUrl) return; |
| | | |
| | | // 构建完整的预览URL |
| | | let fullUrl = fileUrl; |
| | | // 如果 fileUrl 不是完整URL,则拼接基础URL |
| | | if (!fileUrl.startsWith('http://') && !fileUrl.startsWith('https://')) { |
| | | // 确保路径以 / 开头 |
| | | const path = fileUrl.startsWith('/') ? fileUrl : `/${fileUrl}`; |
| | | fullUrl = `${BASE_PREVIEW_URL}${path}`; |
| | | } |
| | | |
| | | // 输出最终路径,方便调试 |
| | | console.log('原始 fileUrl:', fileUrl); |
| | | console.log('最终预览路径:', fullUrl); |
| | | console.log('文件类型:', item.contentType); |
| | | |
| | | if (item.contentType?.startsWith('image/')) { |
| | | images.push(item.url); |
| | | images.push(fullUrl); |
| | | } else if (item.contentType?.startsWith('video/')) { |
| | | videos.push(item.url); |
| | | videos.push(fullUrl); |
| | | } |
| | | }); |
| | | return { images, videos }; |