fix: 修复前端无法加载七牛云图片的问题

1. 修复 buildURL 中 url.PathEscape 对路径分隔符 / 的错误编码(/→%2F),
   改为逐段编码后拼接
2. AssetResponse 新增 key 字段,返回七牛云对象存储 Key
3. 前端改用 /api/v1/assets/download 接口加载图片,通过后端 302 重定向
   访问 CDN,避免浏览器直接访问 CDN 可能出现的跨域或编码问题
4. 更新 api.md 文档,补充 key 字段说明和 download 接口公开属性
This commit is contained in:
2026-05-25 15:25:40 +08:00
parent 50caad8e6c
commit 2f8e7ead17
5 changed files with 20 additions and 5 deletions
+2 -1
View File
@@ -21,7 +21,8 @@ export async function getAssets(taskId: string): Promise<Asset[]> {
const resp = await get<AssetsResponse>(`/api/v1/tasks/${taskId}/assets`)
return resp.assets.map((a, i) => ({
id: `asset-${i}`,
url: a.url,
key: a.key,
url: `/api/v1/assets/download?key=${encodeURIComponent(a.key)}`,
format: a.format,
width: resp.metadata.frameWidth,
height: resp.metadata.frameHeight,
+2
View File
@@ -79,6 +79,7 @@ export interface Task {
// 素材
export interface Asset {
id: string
key: string
url: string
format: string
width: number
@@ -114,6 +115,7 @@ export interface GenerateResponse {
// 素材列表响应 — 对应 GET /api/v1/tasks/:taskId/assets
export interface AssetsResponse {
assets: {
key: string
url: string
format: string
}[]