feat(web-water): 水印设置页面开发

This commit is contained in:
R524809
2026-09-04 15:57:16 +08:00
parent 009082d0f4
commit e277754588
15 changed files with 1514 additions and 80 deletions
+58
View File
@@ -0,0 +1,58 @@
import type {
CreateWatermarkTemplateRequest,
UpdateWatermarkTemplateRequest,
WatermarkFont,
WatermarkTemplate,
} from '@atlas/contracts';
import { api } from '@/services/api';
import type { CursorPaginationMeta } from '@atlas/contracts';
export interface WatermarkListResult {
data: WatermarkTemplate[];
meta: CursorPaginationMeta;
}
export interface UpdateWatermarkOptions {
/** 提交时的乐观锁版本,取自模板 revision */
revision: number;
}
/**
* 水印模板接口,契约见 docs/api/watermarks-and-assets.md §2/§3。
* 列表/详情的图片模板携带短时 preview_url,过期后重新读取即可。
*/
export const watermarksApi = {
/** 渲染服务已部署的可用字体;字体 code 是模板的稳定保存值 */
fonts: () => api.get<WatermarkFont[]>('/watermark-fonts'),
list: (cursor?: string) =>
api.getList<WatermarkTemplate, CursorPaginationMeta>('/watermark-templates', {
params: { limit: 100, ...(cursor ? { cursor } : {}) },
}),
get: (templateId: string) => api.get<WatermarkTemplate>(`/watermark-templates/${templateId}`),
create: (payload: CreateWatermarkTemplateRequest) =>
api.post<WatermarkTemplate>('/watermark-templates', payload, {
headers: { 'Idempotency-Key': crypto.randomUUID() },
}),
/** 渲染参数变更由服务端创建不可变版本并递增 current_version;仅改名不创建版本 */
update: (
templateId: string,
payload: UpdateWatermarkTemplateRequest,
options: UpdateWatermarkOptions
) =>
api.patch<WatermarkTemplate>(`/watermark-templates/${templateId}`, payload, {
headers: {
'If-Match': `"${options.revision}"`,
'Idempotency-Key': crypto.randomUUID(),
},
}),
/** 软删除并解除所有店铺绑定,返回 204 */
remove: (templateId: string) =>
api.delete<void>(`/watermark-templates/${templateId}`, {
headers: { 'Idempotency-Key': crypto.randomUUID() },
}),
};