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(stylePath(projectId), { signal }), save: (projectId: string, input: SaveVisualStyleInput) => request(stylePath(projectId), { method: 'PUT', body: input }), generate: (projectId: string, force: boolean) => request(`${stylePath(projectId)}/generate`, { method: 'POST', body: { force }, timeoutMs: 0 }), addImage: (projectId: string, input: AddStyleImageInput) => request(`${stylePath(projectId)}/images`, { method: 'POST', body: input }), setImageEnabled: (projectId: string, imageId: string, enabled: boolean) => request(`${stylePath(projectId)}/images/${encodeURIComponent(imageId)}/enabled`, { method: 'PUT', body: { enabled } }), removeImage: (projectId: string, imageId: string) => request(`${stylePath(projectId)}/images/${encodeURIComponent(imageId)}`, { method: 'DELETE' }) }