feat(canvas): 画布工作区 - 整合侧栏与风格预设并修复提示词回填
选择性整合 #547,保留主分支节点与工具条设计。新增默认折叠的节点、资产、任务和历史面板,风格与预设保留在节点内,移除重复入口。 补齐工具权限、提示词解析、资源引用保护及数据库迁移,修复提示词清空和连续编辑后的生成配置同步。 验证:前端全量 1925 项测试、构建、类型检查及 lint 通过;后端 go test ./... 通过。真实模型、PostgreSQL 实库与登录态页面验收仍待进行。 Refs #547 Co-authored-by: bensharp <bensharp@qq.com>
This commit is contained in:
84
web/src/services/api/tools.ts
Normal file
84
web/src/services/api/tools.ts
Normal file
@@ -0,0 +1,84 @@
|
||||
import { http, compactApiParams, serializeApiParams, type ApiParams, type HttpRequestConfig } from "@/services/api/request";
|
||||
|
||||
export type ToolType = "style" | "motion" | "nine_grid" | "effect";
|
||||
export type ToolScope = "public" | "favorites" | "custom";
|
||||
export type ToolSource = "builtin" | "user";
|
||||
export type ToolVisibility = "public" | "private";
|
||||
|
||||
// 列表摘要项:不含 prompt、extraInfo 等大字段
|
||||
export type ToolSummary = {
|
||||
id: number;
|
||||
type: ToolType | string;
|
||||
labelEn: string;
|
||||
label: string;
|
||||
desc: string;
|
||||
tag: string;
|
||||
cover: string;
|
||||
ratio: string;
|
||||
mediaUrl: string;
|
||||
ownerId: string;
|
||||
source: ToolSource | string;
|
||||
enabled: boolean;
|
||||
visibility: ToolVisibility | string;
|
||||
sortWeight: number;
|
||||
favorited: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
// 详情/写操作返回的完整工具
|
||||
export type ToolItem = ToolSummary & {
|
||||
extraInfo: string[];
|
||||
prompt: string;
|
||||
};
|
||||
|
||||
export type ToolList = {
|
||||
tools: ToolSummary[];
|
||||
totalCount: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
hasMore: boolean;
|
||||
};
|
||||
|
||||
export type ListToolsInput = {
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
scope?: ToolScope;
|
||||
type?: ToolType | string;
|
||||
tag?: string;
|
||||
search?: string;
|
||||
};
|
||||
|
||||
export type ToolMutationInput = {
|
||||
type: ToolType | string;
|
||||
label: string;
|
||||
desc?: string;
|
||||
tag?: string;
|
||||
cover?: string;
|
||||
extraInfo?: string[];
|
||||
prompt: string;
|
||||
ratio?: string;
|
||||
mediaUrl?: string;
|
||||
visibility?: ToolVisibility;
|
||||
};
|
||||
|
||||
export function listTools(input: ListToolsInput = {}, config?: HttpRequestConfig) {
|
||||
const params = serializeApiParams(compactApiParams(input as ApiParams));
|
||||
return http.get<ToolList>(`/tools?${params.toString()}`, config);
|
||||
}
|
||||
|
||||
export function getTool(id: number, config?: HttpRequestConfig) {
|
||||
return http.get<ToolItem>(`/tools/${encodeURIComponent(String(id))}`, config);
|
||||
}
|
||||
|
||||
export function setToolFavorite(id: number, favorite: boolean) {
|
||||
return favorite ? http.post<ToolItem>(`/tools/${encodeURIComponent(String(id))}/favorite`) : http.delete<ToolItem>(`/tools/${encodeURIComponent(String(id))}/favorite`);
|
||||
}
|
||||
|
||||
export function createTool(input: ToolMutationInput) {
|
||||
return http.post<ToolItem>("/tools", input);
|
||||
}
|
||||
|
||||
export function deleteTool(id: number) {
|
||||
return http.delete<{ deleted: boolean }>(`/tools/${encodeURIComponent(String(id))}`);
|
||||
}
|
||||
Reference in New Issue
Block a user