feat(watermark): 水印前后端代码修改
This commit is contained in:
@@ -33,3 +33,35 @@ export type CreateMediaUploadIntentRequest = z.infer<
|
||||
export type CompleteMediaUploadIntentRequest = z.infer<
|
||||
typeof completeMediaUploadIntentRequestSchema
|
||||
>;
|
||||
|
||||
// ── 只读响应类型(由前端 AI 按 docs/api/watermarks-and-assets.md §1 补充,后端请复核) ──
|
||||
|
||||
/** 预签名直传端点:前端必须按返回的 method/url/headers 原样上传 */
|
||||
export type MediaUploadEndpoint = {
|
||||
method: string;
|
||||
url: string;
|
||||
headers: Record<string, string>;
|
||||
};
|
||||
|
||||
/** POST /api/media/upload-intents 响应 */
|
||||
export type MediaUploadIntent = {
|
||||
upload_id: string;
|
||||
expires_at: string;
|
||||
upload: MediaUploadEndpoint;
|
||||
};
|
||||
|
||||
/** 校验通过后创建/复用的素材 */
|
||||
export type MediaAsset = {
|
||||
id: string;
|
||||
content_type: string;
|
||||
byte_size: number;
|
||||
width_px: number | null;
|
||||
height_px: number | null;
|
||||
created_at: string;
|
||||
};
|
||||
|
||||
/** POST /api/media-assets/{asset_id}/access-urls 响应(短时预览 URL) */
|
||||
export type MediaAccessUrl = {
|
||||
url: string;
|
||||
expires_at: string;
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@ const opacity = z
|
||||
const scaleRatio = z
|
||||
.string()
|
||||
.regex(/^(0\.([1-9]|[1-9]\d{1,3})|1(\.\d{1,4})?|2(\.0{1,4})?)$/, '缩放比例必须在 0.1 到 2 之间');
|
||||
export type WatermarkPosition = z.infer<typeof watermarkPositionSchema>;
|
||||
export const watermarkPositionSchema = z.enum([
|
||||
'top_left', 'top_center', 'top_right', 'middle_left', 'center',
|
||||
'middle_right', 'bottom_left', 'bottom_center', 'bottom_right',
|
||||
@@ -68,3 +69,42 @@ export const bindStoreWatermarkRequestSchema = z.object({
|
||||
export type CreateWatermarkTemplateRequest = z.infer<typeof createWatermarkTemplateRequestSchema>;
|
||||
export type UpdateWatermarkTemplateRequest = z.infer<typeof updateWatermarkTemplateRequestSchema>;
|
||||
export type ListWatermarkTemplatesQuery = z.infer<typeof listWatermarkTemplatesQuerySchema>;
|
||||
|
||||
// ── 只读响应类型(由前端 AI 按 docs/api/watermarks-and-assets.md §2/§3 补充,后端请复核) ──
|
||||
|
||||
/** GET /api/watermark-fonts 返回的渲染服务可用字体 */
|
||||
export type WatermarkFont = {
|
||||
code: string;
|
||||
display_name: string;
|
||||
};
|
||||
|
||||
/** 图片水印模板引用的素材摘要(含短时预览 URL,过期后重新读取列表/详情) */
|
||||
export type WatermarkTemplateImageAsset = {
|
||||
id: string;
|
||||
preview_url: string;
|
||||
preview_url_expires_at: string;
|
||||
};
|
||||
|
||||
/** 模板当前版本的渲染配置;kind=text 时为文字字段,kind=image 时为图片字段 */
|
||||
export type WatermarkTemplateConfig = {
|
||||
text_content?: string;
|
||||
font_code?: string;
|
||||
font_size_px?: number;
|
||||
image_asset_id?: string;
|
||||
image_asset?: WatermarkTemplateImageAsset;
|
||||
opacity?: string;
|
||||
scale_ratio?: string;
|
||||
position: WatermarkPosition;
|
||||
};
|
||||
|
||||
/** 水印模板读取形状(revision 用于 If-Match 乐观锁;current_version 随渲染参数变更递增) */
|
||||
export type WatermarkTemplate = {
|
||||
id: string;
|
||||
name: string;
|
||||
kind: 'text' | 'image';
|
||||
current_version: number;
|
||||
config: WatermarkTemplateConfig;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
revision: number;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user