feat: 强化多视角图片一致性 + 修复下载逻辑 + 技术文档
- 新增品类专属背面/侧面描述(BACK_VIEW_HINTS/SIDE_VIEW_HINTS) - 强化一致性前缀策略,按视角定制相机位置描述 - 更新视角映射提示词为纯摄影术语 - 修复前端下载逻辑:改用fetch直接下载当前视角图片 - HTTPS改HTTP修复外网URL访问 - 新增多视角一致性与3D视频生成技术文档
This commit is contained in:
@@ -195,8 +195,7 @@ import { useRouter } from 'vue-router'
|
||||
import { Loading, PictureFilled, ZoomIn, ZoomOut, RefreshRight, Download, User, Platform, VideoCameraFilled } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { Design } from '@/stores/design'
|
||||
import { getDesignDownloadUrl, generate3DModelApi, generateVideoApi } from '@/api/design'
|
||||
import request from '@/api/request'
|
||||
import { generate3DModelApi, generateVideoApi } from '@/api/design'
|
||||
|
||||
const props = defineProps<{
|
||||
design: Design
|
||||
@@ -384,38 +383,31 @@ const downloadFilename = computed(() => {
|
||||
return `${category}${subType ? '-' + subType : ''}${viewSuffix}-${props.design.id}.png`
|
||||
})
|
||||
|
||||
// 下载设计图
|
||||
const handleDownload = () => {
|
||||
// 下载设计图(直接下载当前视角的图片,而非固定第一张)
|
||||
const handleDownload = async () => {
|
||||
const imgUrl = currentImageUrl.value
|
||||
if (!imgUrl) {
|
||||
ElMessage.error('图片不存在')
|
||||
return
|
||||
}
|
||||
// 远程 URL 直接新窗口打开(用户右键可保存)
|
||||
if (imgUrl.startsWith('http')) {
|
||||
window.open(imgUrl, '_blank')
|
||||
return
|
||||
}
|
||||
// 本地文件通过 axios 携带 Token 下载
|
||||
downloading.value = true
|
||||
request.get(getDesignDownloadUrl(props.design.id), {
|
||||
responseType: 'blob'
|
||||
}).then((response: any) => {
|
||||
const blob = new Blob([response], { type: 'image/png' })
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = downloadFilename.value
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
window.URL.revokeObjectURL(url)
|
||||
try {
|
||||
// 远程 URL 或本地路径都通过 fetch 下载当前视角的图片
|
||||
const res = await fetch(imgUrl)
|
||||
if (!res.ok) throw new Error('下载失败')
|
||||
const blob = await res.blob()
|
||||
_downloadBlob(blob, downloadFilename.value)
|
||||
ElMessage.success('下载成功')
|
||||
}).catch(() => {
|
||||
ElMessage.error('下载失败,请重试')
|
||||
}).finally(() => {
|
||||
} catch {
|
||||
// 远程 URL fetch 失败时新窗口打开
|
||||
if (imgUrl.startsWith('http')) {
|
||||
window.open(imgUrl, '_blank')
|
||||
} else {
|
||||
ElMessage.error('下载失败,请重试')
|
||||
}
|
||||
} finally {
|
||||
downloading.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 切换视角时重置缩放
|
||||
|
||||
Reference in New Issue
Block a user