feat: 结果页添加帧预览、GIF动画和导出选项
- 后端: GetAssets 返回素材级别 metadata,区分 frame/preview/spritesheet 类型 - 后端: 上传时区分素材类型标签,GIF URL 独立追踪 - 前端: 结果详情页默认展示拆分后的单帧网格 - 前端: 添加动作帧 GIF 预览弹窗 - 前端: 添加导出下拉菜单(整张精灵表/自动切分帧) - 前端: 失败任务展示错误信息和重试次数
This commit is contained in:
@@ -19,18 +19,31 @@ export async function getTask(taskId: string): Promise<Task> {
|
||||
|
||||
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}`,
|
||||
key: a.key,
|
||||
url: `/api/v1/assets/download?key=${encodeURIComponent(a.key)}`,
|
||||
format: a.format,
|
||||
width: resp.metadata.frameWidth,
|
||||
height: resp.metadata.frameHeight,
|
||||
metadata: {
|
||||
frameWidth: resp.metadata.frameWidth,
|
||||
frameHeight: resp.metadata.frameHeight,
|
||||
frameCount: resp.metadata.frameCount,
|
||||
directions: resp.metadata.directions,
|
||||
},
|
||||
}))
|
||||
return resp.assets.map((a, i) => {
|
||||
let assetType: Asset['assetType'] = 'frame'
|
||||
let index = i
|
||||
try {
|
||||
const meta = JSON.parse(a.metadata)
|
||||
if (meta.type) assetType = meta.type
|
||||
if (typeof meta.index === 'number') index = meta.index
|
||||
} catch { /* use defaults */ }
|
||||
|
||||
return {
|
||||
id: `asset-${i}`,
|
||||
key: a.key,
|
||||
url: `/api/v1/assets/download?key=${encodeURIComponent(a.key)}`,
|
||||
format: a.format,
|
||||
width: resp.metadata.frameWidth,
|
||||
height: resp.metadata.frameHeight,
|
||||
assetType,
|
||||
index,
|
||||
metadata: {
|
||||
frameWidth: resp.metadata.frameWidth,
|
||||
frameHeight: resp.metadata.frameHeight,
|
||||
frameCount: resp.metadata.frameCount,
|
||||
directions: resp.metadata.directions,
|
||||
gifUrl: resp.metadata.gifUrl,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -115,6 +115,8 @@ const MOCK_ASSETS: Asset[] = [
|
||||
format: 'png',
|
||||
width: 256,
|
||||
height: 256,
|
||||
assetType: 'frame',
|
||||
index: 0,
|
||||
metadata: {
|
||||
frameWidth: 64,
|
||||
frameHeight: 64,
|
||||
|
||||
@@ -87,12 +87,15 @@ export interface Asset {
|
||||
format: string
|
||||
width: number
|
||||
height: number
|
||||
assetType: 'frame' | 'preview' | 'spritesheet'
|
||||
metadata: {
|
||||
frameWidth?: number
|
||||
frameHeight?: number
|
||||
frameCount?: number
|
||||
directions?: number
|
||||
gifUrl?: string
|
||||
}
|
||||
index: number
|
||||
}
|
||||
|
||||
// 生成请求 — 对应 POST /api/v1/generate
|
||||
@@ -121,6 +124,7 @@ export interface AssetsResponse {
|
||||
key: string
|
||||
url: string
|
||||
format: string
|
||||
metadata: string // JSON: {"index":0,"type":"frame"|"preview"|"spritesheet"}
|
||||
}[]
|
||||
metadata: {
|
||||
frameWidth: number
|
||||
|
||||
Reference in New Issue
Block a user