feat(ai): 升级AI生图模型及多视角一致性支持

- 将默认AI生图模型升级为flux-dev及seedream-5.0版本
- SiliconFlow模型由FLUX.1-dev切换为Kolors,优化调用参数和返回值
- 火山引擎Seedream升级至5.0 lite版本,支持多视角参考图传入
- 设计图片字段由字符串改为Text扩展URL长度限制
- 设计图下载支持远程URL重定向和本地文件兼容
- 生成AI图片时多视角保持风格一致,SiliconFlow复用seed,Seedream传参考图
- 后台配置界面更改模型名称及价格显示,新增API Key状态检测
- 前端照片下载从链接改为按钮,远程文件新窗口打开
- 设计相关接口支持较长请求超时,下载走API路径无/api前缀
- 前端页面兼容驼峰与下划线格式URL参数识别
- 用户中心设计图下载支持本地文件Token授权下载
- 初始化数据库新增完整表结构与约束,适配新版设计业务逻辑
This commit is contained in:
2026-03-27 17:39:01 +08:00
parent 032c43525a
commit bb84747917
21 changed files with 645 additions and 414 deletions

View File

@@ -85,14 +85,14 @@
<!-- 操作按钮 -->
<div class="action-buttons">
<a
:href="downloadUrl"
:download="downloadFilename"
<button
class="action-btn download-btn"
@click="handleDownload"
:disabled="downloading"
>
<el-icon><Download /></el-icon>
<span>下载设计图</span>
</a>
<span>{{ downloading ? '下载中...' : '下载设计图' }}</span>
</button>
<button class="action-btn secondary-btn" @click="goToUserCenter">
<el-icon><User /></el-icon>
<span>查看我的设计</span>
@@ -108,6 +108,7 @@ import { Loading, PictureFilled, ZoomIn, ZoomOut, RefreshRight, Download, User }
import { ElMessage } from 'element-plus'
import type { Design } from '@/stores/design'
import { getDesignDownloadUrl } from '@/api/design'
import request from '@/api/request'
const props = defineProps<{
design: Design
@@ -134,11 +135,13 @@ const activeViewName = computed(() => {
return ''
})
// 获取图片URL添加API前缀
// 获取图片URL
const toImageUrl = (url: string | null): string => {
if (!url) return ''
if (url.startsWith('http')) return url
return `/api${url}`
// /uploads 路径已由 Vite 代理到后端,不需要加 /api 前缀
if (url.startsWith('/uploads')) return url
return url
}
// 当前显示的图片URL
@@ -159,8 +162,8 @@ const allImageUrls = computed(() => {
return [toImageUrl(props.design.image_url)]
})
// 下载URL
const downloadUrl = computed(() => getDesignDownloadUrl(props.design.id))
// 下载状态
const downloading = ref(false)
// 下载文件名
const downloadFilename = computed(() => {
@@ -170,6 +173,40 @@ const downloadFilename = computed(() => {
return `${category}${subType ? '-' + subType : ''}${viewSuffix}-${props.design.id}.png`
})
// 下载设计图
const handleDownload = () => {
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)
ElMessage.success('下载成功')
}).catch(() => {
ElMessage.error('下载失败,请重试')
}).finally(() => {
downloading.value = false
})
}
// 切换视角时重置缩放
watch(activeViewIndex, () => {
scale.value = 1