Files
short-drama-agent-front/src/features/visual-style/api.ts
T
GouJ 669f4d9df0 feat: 同步视觉风格与主体身份母版工作区
对齐后端 dev 059e597,新增项目风格编辑锁定、身份文本生成、身份参考图与母版切换。
整理六个工作区入口,接通人物及场景母版继承说明、形态图片来源追溯。
补充草稿保护、正式 ID 校验、费用确认及部分失败回执,67 项测试和静态检查、构建通过。
未修改后端,未调用真实模型;本环境未完成浏览器视觉验收。
2026-08-28 19:28:27 +08:00

26 lines
1.4 KiB
TypeScript

import { request } from '../../lib/http'
import type { AddStyleImageInput, SaveVisualStyleInput, VisualStyle, VisualStyleImage } from './types'
/** 固定项目范围并编码正式 ID。 */
function stylePath(projectId: string) {
return `/projects/${encodeURIComponent(projectId)}/visual-style`
}
/** 风格查询、编辑与图片登记;只有 generate 会调用文本模型。 */
export const visualStyleApi = {
get: (projectId: string, signal?: AbortSignal) => request<VisualStyle | null>(stylePath(projectId), { signal }),
save: (projectId: string, input: SaveVisualStyleInput) =>
request<VisualStyle>(stylePath(projectId), { method: 'PUT', body: input }),
generate: (projectId: string, force: boolean) =>
request<VisualStyle>(`${stylePath(projectId)}/generate`, { method: 'POST', body: { force }, timeoutMs: 0 }),
addImage: (projectId: string, input: AddStyleImageInput) =>
request<VisualStyleImage>(`${stylePath(projectId)}/images`, { method: 'POST', body: input }),
setImageEnabled: (projectId: string, imageId: string, enabled: boolean) =>
request<VisualStyleImage>(`${stylePath(projectId)}/images/${encodeURIComponent(imageId)}/enabled`, {
method: 'PUT',
body: { enabled }
}),
removeImage: (projectId: string, imageId: string) =>
request<VisualStyleImage>(`${stylePath(projectId)}/images/${encodeURIComponent(imageId)}`, { method: 'DELETE' })
}