feat(wordcloud): 前端 R4 类型/api/词云页真实接口 + stickerEdit 线稿真实地址

This commit is contained in:
2026-08-12 19:10:41 +08:00
parent 85356e7a39
commit 73fac0cb9c
4 changed files with 252 additions and 54 deletions
+77 -8
View File
@@ -56,6 +56,10 @@ export interface StickerItem {
width: number
height: number
isOverlapping: boolean
/** 旋转角(度);本期 DIY 持久化,WCD 打包会携带(见 design-data-contract-v1.md 决策#2 */
rotation?: number
/** 图层顺序,WCD 按 zIndex 排列元素 */
zIndex?: number
/** 编辑状态持久化 */
edits?: {
brightness?: number // -100 ~ 100
@@ -66,6 +70,78 @@ export interface StickerItem {
}
}
/**
* 设计数据 v1:支撑 R4 下单后 WCD 生产任务打包。
* 契约见 docs/design-data-contract-v1.md;贴纸 src 持久化由 R4 负责。
*/
export interface DesignDataV1 {
/** 结构版本;旧数据缺省视为 v1 */
version?: 1
/** 商品品类:mask 是画布尺寸来源,说明见 docs/mask-config-guide.md */
category?: ProductCategory
/** 底图(持久 URL),WCD 打包的画布底 */
background?: {
src: string
color?: string
pos?: { x: number; y: number; scale: number }
}
/** 词云信息(R4 词云生成后写入,R2 保存/更新清单时原样保留) */
wordcloud?: {
jobId?: string
imageUrl: string
names: string[]
}
/** 贴纸(src 需为 COS 持久 URL,见 design-data-contract-v1.md 约束#1 */
stickers?: StickerItem[]
/** 兼容旧版字段 */
imageSrc?: string
imagePos?: { x: number; y: number; scale: number }
}
/** 词云任务状态(与 wordcloud 契约、后端透传一致) */
export type WordCloudStatus = 'queued' | 'running' | 'success' | 'failed'
/** 词云任务(前端轮询模型:route-r4 §2 / api-contract §8 */
export interface WordCloudJob {
id: string
status: WordCloudStatus
progress: number
imageUrl?: string
error?: string
}
/** COS 直传凭证(STS 临时凭证或预签名 URL;小程序不得持有永久密钥) */
export interface CosCredentials {
key: string
bucket?: string
region?: string
/** STS 临时密钥(服务端下发,非主账户密钥) */
credentials?: { secretId?: string; secretKey?: string; token?: string } | null
/** 预签名直传 URL(与 credentials 二选一) */
presignedUrl?: string
}
/** 线稿处理结果(POST /api/sketch */
export interface SketchResult {
imageUrl: string
}
/** 下单后 WCD 派单状态:not_configured = WORDCLOUD_API_URL 未配置(见 api-contract §8 */
export type WordCloudDispatchStatus =
| 'queued'
| 'running'
| 'success'
| 'failed'
| 'not_configured'
/** 下单后 WCD 派单结果(POST /api/orders/:id/dispatch */
export interface WordCloudDispatchResult {
orderId: string
status: WordCloudDispatchStatus
wordcloudJobId?: string
message?: string
}
/** 设计清单条目 */
export interface DesignItem {
id: string
@@ -75,14 +151,7 @@ export interface DesignItem {
unitPrice: number
count: number
status: 'undesigned' | 'designing' | 'ordered'
designData?: {
/** 兼容旧版字段 */
imageSrc?: string
imagePos?: { x: number; y: number; scale: number }
/** 新版贴纸列表 */
stickers?: StickerItem[]
category?: ProductCategory
}
designData?: DesignDataV1
orderId?: string
createdAt: string
}