diff --git a/.gitignore b/.gitignore index c839b08..2a2843e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ __pycache__/ .mypy_cache/ .venv/ venv/ +pytest-cache-files-*/ # Node / frontend node_modules/ @@ -32,6 +33,7 @@ data/exports/* !data/exports/.gitkeep # Local machine/editor noise +.tmp/ .env .env.* !.env.example diff --git a/backend/route_registry.py b/backend/route_registry.py index 694e4d4..5a9f406 100644 --- a/backend/route_registry.py +++ b/backend/route_registry.py @@ -69,6 +69,7 @@ ROUTES: tuple[RouteSpec, ...] = ( RouteSpec("POST", "workflows/{workflow_id}/branches", "backend.routes.branch_routes.create_workflow_branch", "write"), RouteSpec("POST", "workflows/{workflow_id}/switch-branch", "backend.routes.branch_routes.switch_workflow_branch", "write"), RouteSpec("GET", "workflows/{workflow_id}/history", "backend.routes.history_routes.list_workflow_history", "read"), + RouteSpec("POST", "workflows/{workflow_id}/history", "backend.routes.history_routes.save_workflow_history", "write"), RouteSpec("GET", "nodes/{node_id}", "backend.routes.node_routes.get_node", "read"), RouteSpec("GET", "nodes/{node_id}/dependency-context", "backend.routes.node_routes.get_node_dependency_context", "read"), RouteSpec("PUT", "nodes/{node_id}", "backend.routes.node_routes.update_node", "write"), diff --git a/backend/routes/history_routes.py b/backend/routes/history_routes.py index d423262..c0a2bf1 100644 --- a/backend/routes/history_routes.py +++ b/backend/routes/history_routes.py @@ -49,6 +49,21 @@ def list_workflow_history( return handle_request(ctx, action) +def save_workflow_history( + ctx: RequestContext, + workflow_id: str, + payload: dict[str, Any], + service: HistoryService | None = None, +) -> dict: + history_service = service or _create_history_service() + + def action() -> dict[str, Any]: + require_write(ctx) + return history_service.save_workflow_snapshot(workflow_id, payload, ctx).to_dict() + + return handle_request(ctx, action) + + def _create_history_service() -> HistoryService: database = Database(load_database_settings()) audit_service = AuditService(database) diff --git a/backend/routes/node_routes.py b/backend/routes/node_routes.py index e58a11f..4abded5 100644 --- a/backend/routes/node_routes.py +++ b/backend/routes/node_routes.py @@ -24,6 +24,7 @@ from database.repositories.job_repository import JobRepository from database.repositories.model_provider_repository import ModelProviderRepository from database.repositories.profile_repository import ProfileRepository from database.repositories.workflow_repository import WorkflowRepository +from engines.single_flow import SingleFlowEngine def list_workflow_nodes( diff --git a/backend/routes/profile_routes.py b/backend/routes/profile_routes.py index f2a5206..e554e5a 100644 --- a/backend/routes/profile_routes.py +++ b/backend/routes/profile_routes.py @@ -5,13 +5,16 @@ from __future__ import annotations from typing import Any from backend.routes.common import handle_request +from backend.services.event_stream_service import get_default_event_bus from backend.services.profile_service import ProfileService from backend.services.quick_profile_service import QuickProfileService +from backend.services.workflow_service import WorkflowService from core.audit_service import AuditService from core.identity import RequestContext from core.security import require_authenticated, require_write from database.db_helper import Database, load_database_settings from database.repositories.profile_repository import ProfileRepository +from database.repositories.workflow_repository import WorkflowRepository def list_profiles( @@ -120,25 +123,39 @@ def save_quick_profile_draft( payload: dict[str, Any], service: QuickProfileService | None = None, profile_service: ProfileService | None = None, + workflow_service: WorkflowService | None = None, ) -> dict: quick_service = service or QuickProfileService() resolved_profile_service = profile_service or _create_profile_service() + resolved_workflow_service = workflow_service or _create_workflow_service( + resolved_profile_service.repository.database + ) def action() -> dict: require_write(ctx) - return quick_service.save_draft(payload, resolved_profile_service, ctx) + return quick_service.save_draft(payload, resolved_profile_service, ctx, resolved_workflow_service) return handle_request(ctx, action) -def _create_profile_service() -> ProfileService: - database = Database(load_database_settings()) +def _create_profile_service(database: Database | None = None) -> ProfileService: + database = database or Database(load_database_settings()) return ProfileService( repository=ProfileRepository(database), audit_service=AuditService(database), ) +def _create_workflow_service(database: Database | None = None) -> WorkflowService: + database = database or Database(load_database_settings()) + return WorkflowService( + workflow_repository=WorkflowRepository(database), + profile_repository=ProfileRepository(database), + audit_service=AuditService(database), + event_bus=get_default_event_bus(), + ) + + def _optional_str(value: Any) -> str | None: if value is None: return None diff --git a/backend/services/character_workflow_service.py b/backend/services/character_workflow_service.py index 0f0ce5b..b8e1784 100644 --- a/backend/services/character_workflow_service.py +++ b/backend/services/character_workflow_service.py @@ -11,7 +11,7 @@ from backend.services.workflow_service import WorkflowService from core.identity import RequestContext -CHARACTER_WORKFLOW_TYPES = {"character_fast", "character_gradual"} +CHARACTER_WORKFLOW_TYPES = {"character_fast", "character_gradual", "quick_profile"} class CharacterWorkflowService: @@ -38,7 +38,7 @@ class CharacterWorkflowService: if not active_nodes: raise ApiError(ErrorCode.VALIDATION_FAILED, "workflow has no executable nodes", {"workflow_id": workflow_id}) running_workflow = workflow - if workflow.status != "running": + if workflow.status not in {"running", "completed"}: running_workflow = self.workflow_service.update_workflow(workflow_id, {"status": "running"}, ctx) completed_nodes: list[WorkflowNode] = [] prompt_context: list[str] = [] @@ -111,6 +111,10 @@ def _negative_prompt(profile: CharacterProfile, node: WorkflowNode) -> str: def _step_instruction(workflow_type: str, node_key: str) -> str: + quick_profile = { + "questionnaire": "normalized questionnaire and quick profile archive input", + "preview": "saved quick profile prompts ready for structured setting split", + } fast = { "fast_profile": "condensed character design brief", "fast_candidates": "candidate batch, varied composition, keep identity consistent", @@ -126,7 +130,12 @@ def _step_instruction(workflow_type: str, node_key: str) -> str: "style_lock": "style consistency lock and final rendering rules", "final_pack": "final character pack, accepted images and reusable metadata", } - table = fast if workflow_type == "character_fast" else gradual + tables = { + "character_fast": fast, + "character_gradual": gradual, + "quick_profile": quick_profile, + } + table = tables.get(workflow_type, {}) return table.get(node_key, node_key.replace("_", " ")) diff --git a/backend/services/generation_service.py b/backend/services/generation_service.py index 96ab207..e648b39 100644 --- a/backend/services/generation_service.py +++ b/backend/services/generation_service.py @@ -11,7 +11,11 @@ from backend.services.image_service import ImageService from backend.services.model_provider_service import ModelProviderService from backend.services.prompt_expansion_service import PromptExpansionService from backend.services.queue_service import QueueService -from backend.services.workflow_service import WorkflowService +from backend.services.workflow_service import ( + LOCKED_NODE_STATUSES, + WorkflowService, + locked_node_edit_error, +) from core.event_bus import EventBus from core.identity import RequestContext from engines.single_flow import SingleFlowEngine @@ -40,6 +44,23 @@ class GenerationService: def generate_node(self, node_id: str, payload: dict[str, Any], ctx: RequestContext) -> dict[str, Any]: node = self.workflow_service.get_node(node_id) + idempotency_key = _optional_text(payload.get("idempotency_key")) + if idempotency_key: + existing_task = self.queue_service.get_job_by_idempotency_key(idempotency_key) + if existing_task is not None: + if existing_task.node_id != node_id: + raise ApiError( + ErrorCode.VALIDATION_FAILED, + "idempotency_key belongs to another node", + { + "idempotency_key": idempotency_key, + "node_id": node_id, + "existing_node_id": existing_task.node_id, + }, + ) + return self._existing_generation_response(existing_task, node_id) + if node.status in LOCKED_NODE_STATUSES: + raise locked_node_edit_error(node) workflow = self.workflow_service.get_workflow(node.workflow_id).workflow model_route = str(payload.get("model_route") or node.model_route or "image_low") route_resolution = self._resolve_model_route(model_route) @@ -60,21 +81,6 @@ class GenerationService: else {} ), } - idempotency_key = _optional_text(payload.get("idempotency_key")) - if idempotency_key: - existing_task = self.queue_service.get_job_by_idempotency_key(idempotency_key) - if existing_task is not None: - if existing_task.node_id != node_id: - raise ApiError( - ErrorCode.VALIDATION_FAILED, - "idempotency_key belongs to another node", - { - "idempotency_key": idempotency_key, - "node_id": node_id, - "existing_node_id": existing_task.node_id, - }, - ) - return self._existing_generation_response(existing_task, node_id) task = self.queue_service.create_task( { "profile_id": workflow.profile_id, diff --git a/backend/services/history_service.py b/backend/services/history_service.py index 77abd6e..8c22b9f 100644 --- a/backend/services/history_service.py +++ b/backend/services/history_service.py @@ -97,6 +97,59 @@ class HistoryService: ) return self.workflow_repository.list_history(workflow_id, node_id=node_id) + def save_workflow_snapshot( + self, + workflow_id: str, + payload: dict[str, Any], + ctx: RequestContext, + ) -> WorkflowHistoryEntry: + detail = self.workflow_service.get_workflow(workflow_id) + workflow = detail.workflow + node_id = _optional_text(payload.get("node_id")) + node = None + if node_id: + node = self.workflow_service.get_node(node_id) + if node.workflow_id != workflow_id: + raise ApiError( + ErrorCode.VALIDATION_FAILED, + "node does not belong to this workflow", + {"workflow_id": workflow_id, "node_id": node_id}, + ) + history = self.workflow_repository.create_history( + { + "history_id": payload.get("history_id") or new_history_id(), + "profile_id": workflow.profile_id, + "workflow_id": workflow.workflow_id, + "node_id": node_id, + "image_id": payload.get("image_id"), + "branch_name": payload.get("branch_name") or workflow.current_branch or "main", + "action": payload.get("action") or "save_version", + "title": payload.get("title") or workflow.display_name, + "prompt": payload.get("prompt") or (node.prompt if node else None), + "metadata": { + "source": "workflow_snapshot", + "workflow": workflow.to_dict(), + "nodes": [item.to_dict() for item in detail.nodes] if payload.get("include_nodes", True) else [], + **(payload.get("metadata") if isinstance(payload.get("metadata"), dict) else {}), + }, + } + ) + self.audit_service.record( + ctx=ctx, + action="save_workflow_snapshot", + target_type="workflow_history", + target_id=history.history_id, + after_snapshot=history.to_dict(), + ) + return history + def new_history_id() -> str: return f"hist_{uuid4().hex}" + + +def _optional_text(value: Any) -> str | None: + if value is None: + return None + text = str(value).strip() + return text or None diff --git a/backend/services/image_service.py b/backend/services/image_service.py index 8bc54d4..ecdf8e5 100644 --- a/backend/services/image_service.py +++ b/backend/services/image_service.py @@ -7,6 +7,7 @@ from uuid import uuid4 from backend.dto.common import ApiError, ErrorCode from backend.dto.image_dto import GenerationImage +from backend.services.workflow_service import LOCKED_NODE_STATUSES, locked_node_edit_error from core.audit_service import AuditService from core.identity import RequestContext from database.repositories.image_repository import ImageRepository @@ -87,6 +88,7 @@ class ImageService: def select_image(self, image_id: str, ctx: RequestContext) -> GenerationImage: before = self.get_image(image_id) + self._ensure_image_node_is_editable(before) if before.is_archived: raise ApiError(ErrorCode.VALIDATION_FAILED, "不能选择已归档图片", {"image_id": image_id}) after = self.image_repository.select_exclusive(before) @@ -106,6 +108,7 @@ class ImageService: def unselect_image(self, image_id: str, ctx: RequestContext) -> GenerationImage: before = self.get_image(image_id) + self._ensure_image_node_is_editable(before) after = self.image_repository.update(image_id, {"is_selected": False}) if after is None: raise ApiError(ErrorCode.RESOURCE_NOT_FOUND, "图片不存在", {"image_id": image_id}) @@ -125,6 +128,7 @@ class ImageService: def archive_image(self, image_id: str, ctx: RequestContext) -> GenerationImage: before = self.get_image(image_id) + self._ensure_image_node_is_editable(before) after = self.image_repository.update( image_id, { @@ -149,6 +153,8 @@ class ImageService: return after def delete_image_metadata(self, image_id: str, ctx: RequestContext) -> GenerationImage: + existing = self.get_image(image_id) + self._ensure_image_node_is_editable(existing) before = self.image_repository.delete_metadata(image_id) if before is None: raise ApiError(ErrorCode.RESOURCE_NOT_FOUND, "图片不存在", {"image_id": image_id}) @@ -166,6 +172,13 @@ class ImageService: ) return before + def _ensure_image_node_is_editable(self, image: GenerationImage) -> None: + if not image.node_id: + return + node = self.workflow_repository.get_node(image.node_id) + if node and node.status in LOCKED_NODE_STATUSES: + raise locked_node_edit_error(node) + def new_image_id() -> str: return f"img_{uuid4().hex}" diff --git a/backend/services/quick_profile_service.py b/backend/services/quick_profile_service.py index a2d4b3b..64d87aa 100644 --- a/backend/services/quick_profile_service.py +++ b/backend/services/quick_profile_service.py @@ -6,13 +6,16 @@ the prompt expansion internals without changing the API contract. from __future__ import annotations -from typing import Any +from typing import TYPE_CHECKING, Any from uuid import uuid4 from backend.dto.common import ApiError, ErrorCode from backend.services.profile_service import ProfileService from core.identity import RequestContext +if TYPE_CHECKING: + from backend.services.workflow_service import WorkflowService + class QuickProfileService: def create_draft(self, payload: dict[str, Any]) -> dict[str, Any]: @@ -71,6 +74,7 @@ class QuickProfileService: payload: dict[str, Any], profile_service: ProfileService, ctx: RequestContext, + workflow_service: "WorkflowService | None" = None, ) -> dict[str, Any]: draft = payload.get("draft") if isinstance(payload.get("draft"), dict) else {} preview = payload.get("profile_preview") if isinstance(payload.get("profile_preview"), dict) else None @@ -103,10 +107,42 @@ class QuickProfileService: }, ctx, ) - return { + result = { "draft_id": draft_id or None, "profile": profile.to_dict(), } + should_create_workflow = bool(payload.get("create_workflow", workflow_service is not None)) + if should_create_workflow: + if workflow_service is None: + raise ApiError( + ErrorCode.VALIDATION_FAILED, + "\u7f3a\u5c11\u5feb\u901f\u89d2\u8272\u5de5\u4f5c\u6d41\u670d\u52a1", + {"field": "workflow_service"}, + ) + workflow_detail = workflow_service.create_workflow( + profile.profile_id, + { + "workflow_type": "quick_profile", + "display_name": _text(payload.get("workflow_display_name")) + or f"{name} \u5feb\u901f\u89d2\u8272\u5de5\u4f5c\u6d41", + "status": _text(payload.get("workflow_status")) or "draft", + "metadata": { + "source": "quick_profile", + "profile_id": profile.profile_id, + **({"draft_id": draft_id} if draft_id else {}), + "profile_preview": preview, + **( + {"questionnaire": payload["questionnaire"]} + if isinstance(payload.get("questionnaire"), dict) + else {} + ), + }, + }, + ctx, + ) + result["workflow"] = workflow_detail.workflow.to_dict() + result["nodes"] = [node.to_dict() for node in workflow_detail.nodes] + return result def _text(value: Any) -> str: diff --git a/backend/services/workflow_service.py b/backend/services/workflow_service.py index 11efce4..6ed0cec 100644 --- a/backend/services/workflow_service.py +++ b/backend/services/workflow_service.py @@ -31,6 +31,7 @@ NODE_STATUSES = { "skipped", "discarded", } +LOCKED_NODE_STATUSES = {"completed", "selected"} class WorkflowService: @@ -180,8 +181,11 @@ class WorkflowService: "branch already exists", {"workflow_id": workflow_id, "branch_name": branch_name}, ) - base_branch_name = str(payload.get("base_branch_name") or workflow.current_branch or "main") + base_branch_name = str(payload.get("base_branch_name") or workflow.current_branch or "main").strip() base_node_id = payload.get("base_node_id") or workflow.current_node_id + copy_nodes = payload.get("copy_nodes", True) + if copy_nodes or base_node_id: + self._resolve_branch_copy_base(workflow_id, base_branch_name, base_node_id) branch = self.workflow_repository.create_branch( { "branch_id": payload.get("branch_id") or new_branch_id(), @@ -194,8 +198,8 @@ class WorkflowService: } ) copied_nodes = [] - if payload.get("copy_nodes", True): - copied_nodes = self._copy_branch_nodes(workflow_id, base_branch_name, branch_name, ctx) + if copy_nodes: + copied_nodes = self._copy_branch_nodes(workflow_id, base_branch_name, branch_name, ctx, base_node_id) self.audit_service.record( ctx=ctx, action="create_branch", @@ -326,6 +330,8 @@ class WorkflowService: def update_node(self, node_id: str, payload: dict[str, Any], ctx: RequestContext) -> WorkflowNode: before = self.get_node(node_id) + if before.status in LOCKED_NODE_STATUSES and _node_payload_changes(before, payload): + raise locked_node_edit_error(before) if "status" in payload: self._validate_node_status_transition(before.status, str(payload["status"])) if "title" in payload and not str(payload["title"]).strip(): @@ -381,10 +387,9 @@ class WorkflowService: from_branch: str, to_branch: str, ctx: RequestContext, + base_node_id: str | None = None, ) -> list[WorkflowNode]: - source_nodes = self.workflow_repository.list_nodes(workflow_id, branch_name=from_branch) - if not source_nodes and from_branch != "main": - source_nodes = self.workflow_repository.list_nodes(workflow_id, branch_name="main") + source_nodes, base_sort_order = self._resolve_branch_copy_base(workflow_id, from_branch, base_node_id) return [ self.create_node( workflow_id, @@ -394,13 +399,14 @@ class WorkflowService: "description": node.description, "step_name": node.step_name, "node_type": node.node_type, - "status": "draft", + "status": _branch_copy_status(node, base_sort_order), "branch_name": to_branch, "prompt": node.prompt, "negative_prompt": node.negative_prompt, "model_route": node.model_route, + "selected_image_id": _branch_copy_selected_image_id(node, base_sort_order), "sort_order": node.sort_order, - "metadata": {**node.metadata, "copied_from_node_id": node.node_id}, + "metadata": _branch_copy_metadata(node, base_sort_order), }, ctx, audit=False, @@ -408,6 +414,26 @@ class WorkflowService: for node in source_nodes ] + def _resolve_branch_copy_base( + self, + workflow_id: str, + from_branch: str, + base_node_id: str | None = None, + ) -> tuple[list[WorkflowNode], int | None]: + source_nodes = self.workflow_repository.list_nodes(workflow_id, branch_name=from_branch) + if not source_nodes and from_branch != "main": + source_nodes = self.workflow_repository.list_nodes(workflow_id, branch_name="main") + base_node = None + if base_node_id: + base_node = next((node for node in source_nodes if node.node_id == base_node_id), None) + if base_node is None: + raise ApiError( + ErrorCode.VALIDATION_FAILED, + "base_node_id does not belong to the source branch", + {"workflow_id": workflow_id, "branch_name": from_branch, "base_node_id": base_node_id}, + ) + return source_nodes, base_node.sort_order if base_node else None + def _ensure_profile_exists(self, profile_id: str) -> None: profile = self.profile_repository.get(profile_id) if profile is None or profile.status == "deleted": @@ -474,6 +500,85 @@ def new_branch_id() -> str: return f"branch_{uuid4().hex}" +def locked_node_edit_error(node: WorkflowNode) -> ApiError: + return ApiError( + ErrorCode.VALIDATION_FAILED, + "completed node is locked; create a workflow branch before editing", + { + "node_id": node.node_id, + "workflow_id": node.workflow_id, + "branch_name": node.branch_name, + "status": node.status, + "suggested_action": "create_branch", + "base_node_id": node.node_id, + }, + ) + + +def _node_payload_changes(node: WorkflowNode, payload: dict[str, Any]) -> bool: + comparable = { + "title": node.title, + "description": node.description, + "step_name": node.step_name, + "node_type": node.node_type, + "status": node.status, + "branch_name": node.branch_name, + "prompt": node.prompt, + "negative_prompt": node.negative_prompt, + "model_route": node.model_route, + "selected_image_id": node.selected_image_id, + "sort_order": node.sort_order, + "metadata": node.metadata, + } + for key, value in payload.items(): + if key not in comparable: + continue + current = comparable[key] + if key == "sort_order": + try: + value = int(value) + except (TypeError, ValueError): + return True + if key == "title" and value is not None: + value = str(value).strip() + if value != current: + return True + return False + + +def _branch_copy_status(node: WorkflowNode, base_sort_order: int | None) -> str: + if base_sort_order is None: + return "draft" + if node.sort_order < base_sort_order: + return node.status + return "draft" + + +def _branch_copy_selected_image_id(node: WorkflowNode, base_sort_order: int | None) -> str | None: + if base_sort_order is not None and node.sort_order < base_sort_order: + return node.selected_image_id + return None + + +def _branch_copy_metadata(node: WorkflowNode, base_sort_order: int | None) -> dict[str, Any]: + metadata = { + **node.metadata, + "copied_from_node_id": node.node_id, + } + if base_sort_order is None: + return metadata + locked_ancestor = node.sort_order < base_sort_order and node.status in LOCKED_NODE_STATUSES + metadata.update( + { + "branch_cut_base_sort_order": base_sort_order, + "branch_reset_from_status": node.status, + "branch_locked_ancestor": locked_ancestor, + "branch_editable_from_cut": node.sort_order >= base_sort_order, + } + ) + return metadata + + def _initial_node_templates(workflow_type: str) -> list[dict[str, Any]]: if workflow_type == "single_image": return [ diff --git a/docs/ui-function-entry-index.md b/docs/ui-function-entry-index.md new file mode 100644 index 0000000..40a2f48 --- /dev/null +++ b/docs/ui-function-entry-index.md @@ -0,0 +1,293 @@ +# ImageStudio UI 功能入口与接口索引 + +日期:2026-07-07 +维护规则:每新增一个可点击的功能入口、浮层、工作台入口、页面入口或后端 API 占位,都必须更新本文档。 + +## 2026-07-08 已完成闭环总结 + +- 快速角色:创建角色档案问卷已扩展为简单/复杂模式,复杂字段支持世界观、背景、身高/身材、身体特征、喜好、关系、故事钩子、画风和镜头偏好;字段可留空,不阻断生成档案。 +- 快速角色落库:生成档案会调用 `profiles/quick-draft/save`,保存角色档案并创建对应 `quick_profile`/角色工作流关联,前端不会在预览模式伪造落库成功。 +- 外部角色卡导入:工作流导入入口已提供粘贴导入弹窗,可识别外部人设文本并回填角色档案问卷。 +- 角色工作流:前期人设准备节点已接入后端角色工作流执行入口 `workflows/:workflowId/execute-character`,成功后进入 LLM 设定拆解节点。 +- LLM 设定拆解:中间大卡片固定为拆解工作台,身份性格、外观锚点、服装素材、约束负面项按组顺序排列,超出内容滚动展示;右侧详情显示 LLM 拆解摘要。 +- 节点对话注入:底部对话框会打包当前节点、角色档案、素材、拆解字段和用户原文,标记 `source_language:auto`、`target_prompt_language:en`、`translation_mode:backend_llm` 后提交 `nodes/:nodeId/generate`。 +- 工作流锁定与分支:后端将 `completed`/`selected` 节点作为锁定节点,禁止原链路继续修改、重跑、选图、归档或删除绑定图片;如需修改,前端提供“从此节点创建分支”,调用 `workflows/:workflowId/branches` 和 `workflows/:workflowId/switch-branch`,从选中节点切分支并保证旧链路干净。 +- 分支复制规则:从 `base_node_id` 创建分支时,切点之前的节点保留完成状态和选中图;切点及之后重置为 `draft` 并清空选中图,metadata 写入 `copied_from_node_id` 和分支切点信息。 +- 验证结果:后端锁定/分支/生成/图像/历史相关测试 39 条通过;前端 `vue-tsc --noEmit` 和 `build:web` 通过;浏览器预览工作流三栏布局无控制台错误。 + +## 维护方式 + +- `入口名称` 写用户在界面上能理解的名称。 +- `位置` 写清楚入口在哪个页面、哪个卡片或哪个浮层。 +- `当前动作` 写现在点击会发生什么。 +- `关联接口` 写已规划或已接入的 endpoint;纯前端占位写 `local/*`。 +- `状态` 使用:`已接 UI`、`模拟数据`、`占位入口`、`待后端接入`、`已接后端`。 + +## 前端入口总览 + +### 左侧导航 + +| 入口名称 | 位置 | 当前动作 | 关联模块 | 状态 | +| --- | --- | --- | --- | --- | +| 概览 | 左侧星图导航 | 切换到概览页 | `overview` | 已接 UI | +| 生成 | 左侧星图导航 | 切换到生成页 | `generate` | 已接 UI | +| 队列 | 左侧星图导航 | 切换到队列模块 | `queue` | 已接 UI | +| 性能 | 左侧星图导航 | 切换到性能详情页 | `performance` | 占位入口 | +| 图库 | 左侧星图导航 | 切换到图库模块 | `images` | 占位入口 | +| 角色 | 左侧星图导航 | 切换到角色模块 | `suggestions` | 占位入口 | +| 素材 | 左侧星图导航 | 切换到素材模块 | `images` | 占位入口 | +| 设置 | 左侧星图导航 | 切换到设置模块 | `settings` | 已接 UI | +| 日志 | 左侧星图导航 | 切换到日志模块 | `logs` | 已接 UI | + +### 顶部工具区 + +| 入口名称 | 位置 | 当前动作 | 关联接口 | 状态 | +| --- | --- | --- | --- | --- | +| 主题切换 | 顶部工具区 | 日间/夜间模式切换 | `local/preferences` | 已接 UI | +| 消息中心 | 顶部工具区铃铛 | 打开消息浮层,外部点击关闭 | `local/notifications` | 模拟数据 | +| 日志浮层 | 顶部工具区文件图标 | 悬停或点击打开日志浮层 | `logs/generation`, `logs/errors` | 已接 UI | +| 后端连接诊断 | 顶部工具区刷新按钮旁 | 显示插件桥/同源 API 连接状态,预览或异常时展开诊断横幅 | `ui/bootstrap` | 已接 UI | +| 调色盘 | 顶部工具区调色盘 | 打开主题色选择浮层 | `local/preferences` | 已接 UI | +| 搜索 | 顶部搜索框 | 搜索功能入口和模块 | `local/search-index` | 已接 UI | + +## 生成页入口 + +### 生成页模式切换 + +| 入口名称 | 位置 | 当前动作 | 关联接口 | 状态 | +| --- | --- | --- | --- | --- | +| 图片生成 | 生成页顶部模式按钮 | 切换到图片生成工作台 | `nodes/:nodeId/generate` | 已接 UI / 后端落库 | +| 快速角色 | 生成页顶部模式按钮 | 切换到快速角色工作台 | `profiles/quick-draft`, `profiles/quick-draft/save` | 已接 UI / 后端落库 | +| 角色工作流 | 生成页顶部模式按钮 | 切换到角色工作流工作台 | `profiles/:profileId/workflows`, `workflows/:workflowId/nodes` | 已接 UI / 后端数据 | + +### 图片生成工作台 + +| 入口名称 | 位置 | 当前动作 | 关联接口 | 状态 | +| --- | --- | --- | --- | --- | +| 生图模型选择 | 图片生成底部输入框 | 选择当前生图模型 | `api-discovery/capabilities` | 模拟数据 | +| 自然语言输入框 | 图片生成底部 | 输入自然语言生图需求 | `local/prompt-composer` | 占位入口 | +| 提交生成 | 图片生成输入框按钮 | 自动准备单图工作流并提交后端生成,返回图片写入预览 | `profiles`, `profiles/:profileId/workflows`, `nodes/:nodeId/generate` | 已接 UI / 后端落库 | +| 最近请求 | 图片生成输入框内 | 点击填入历史请求 | `local/recent-prompts` | 模拟数据 | +| 图片队列 | 图片生成左侧队列 | 优先展示后端返回图片和最近图库结果,选择后在主图区放大显示 | `images/:imageId` | 已接 UI / 后端数据 | +| 图片主预览 | 图片生成中间主图 | 点击打开图片详情卡 | `images/:imageId` | 已接 UI | +| 图片详情卡 | 图片预览浮层 | 滚轮缩放、双击缩放、拖拽查看 | `images/:imageId` | 已接 UI | + +## 快速角色入口 + +| 入口名称 | 位置 | 当前动作 | 关联接口 | 状态 | +| --- | --- | --- | --- | --- | +| 全部角色档案列表 | 快速角色左侧 | 选择当前角色卡 | `profiles` | 模拟数据 | +| 添加档案 | 全部角色档案列表顶部 | 打开创建角色档案问卷,可在生成档案旁切换简单/复杂问卷 | `profiles/quick-draft` | 已接 UI | +| 角色预览折角 | 角色预览卡右上角 | 打开角色设定详情大卡片 | `profiles/:profileId` | 已接 UI | +| 角色设定详情大卡片 | 角色预览折角打开 | 查看当前角色基础、外观、风格、负面词 | `profiles/:profileId` | 模拟数据 | +| 半身像/头像图片 | 角色预览图 | 打开图片详情卡,可缩放拖拽 | `images/:imageId` | 已接 UI | +| 角色图片类型卡 | 角色图片区域右侧 | 切换头像、半身、立绘、设定图 | `images/:imageId` | 模拟数据 | +| 参考素材卡 | 快速角色参考素材区 | 打开素材选择浮层 | `materials` | 已接 UI | +| 不使用参考 | 素材选择浮层顶部 | 清空对应分类素材 | `local/material-selection` | 已接 UI | +| 添加素材占位卡 | 素材选择浮层底部 | 记录添加意图,后续跳转素材库新增 | `materials/upload` | 占位入口 | +| 配饰细分类 | 配饰素材浮层 | 切换配饰子类并单列展示 | `material-categories` | 模拟数据 | +| 生成人设 | 快速角色功能按钮 | 打开问卷大卡片 | `profiles/quick-draft` | 已接 UI | +| 保存角色 | 快速角色功能按钮 | 调用后端保存快速角色档案,并创建 `quick_profile` 工作流 | `profiles/quick-draft/save` | 已接 UI / 后端落库 | +| 整理素材集 | 快速角色功能按钮 | 后续整理角色专属素材包 | `materials` | 占位入口 | +| 衣橱匹配 | 快速角色功能按钮 | 后续按当前人设匹配服装与配饰 | `profiles/:profileId/wardrobe/match` | 占位入口 | +| 每日穿搭 | 快速角色功能按钮 | 后续生成长期穿搭方案 | `integrations/private-companion/daily-outfit` | 占位入口 | +| 进入工作流 | 快速角色功能按钮 | 切到角色工作流并使用当前人设继续细化 | `profiles/:profileId/workflows` | 已接 UI | + +## 角色工作流入口 + +### 节点流程 + +| 入口名称 | 位置 | 当前动作 | 关联接口 | 状态 | +| --- | --- | --- | --- | --- | +| 大节点卡 | 角色工作流左侧节点流程 | 优先读取已选角色的后端角色工作流节点,缺数据时回退演示节点 | `workflows/:workflowId/nodes` | 已接 UI / 后端数据 | +| 小节点卡 | 大节点内部 | 选择具体节点并联动中间工作幕布 | `nodes/:nodeId` | 已接 UI / 后端数据 | +| 前期人设准备 | 大节点 | 展示人设导入、拆解、提示词和素材绑定节点 | `workflows/:workflowId/nodes` | 模拟数据 | +| 头像草稿 | 大节点 | 展示头像草稿多轮节点 | `nodes/:nodeId/images` | 模拟数据 | +| 全身与设定图 | 大节点 | 展示全身、手部、配饰和设定图拆分节点 | `nodes/:nodeId/images` | 模拟数据 | +| 审核修复并入库 | 大节点 | 展示审核、高清修复和归档节点 | `workflows/:workflowId/review` | 模拟数据 | + +### 工作幕布联动 + +| 入口名称 | 位置 | 当前动作 | 关联接口 | 状态 | +| --- | --- | --- | --- | --- | +| 导入粗略人设工作台 | 选中 `导入粗略人设` 节点时的中间幕布 | 显示新建人设和选择已有角色卡 | `profiles/quick-draft`, `profiles` | 已接 UI | +| 新建粗略人设 | 导入粗略人设工作台左侧右下角 `+` 按钮 | 打开创建角色档案问卷,可选简单/复杂字段 | `profiles/quick-draft` | 已接 UI | +| 选择已有角色卡 | 导入粗略人设工作台右侧 | 选择当前角色卡作为工作流输入 | `profiles/:profileId` | 模拟数据 | +| 当前导入摘要 | 导入粗略人设工作台底部 | 展示当前导入角色卡、风格、素材和状态 | `profiles/:profileId` | 模拟数据 | +| 节点草稿池 | 图片类节点下方 | 按当前后端节点图片显示候选图,缺数据时回退演示图 | `nodes/:nodeId/images` | 已接 UI / 后端数据 | +| 多选草稿 | 节点草稿池 | 多选后同步到主预览,并把当前采用图写回后端节点 | `nodes/:nodeId/select-image` | 已接 UI / 后端落库 | +| 平铺对比 | 主预览右上角 | 打开多图对比浮层 | `local/workflow-compare` | 已接 UI | +| 工作流图片详情 | 主预览图片点击 | 打开图片详情卡,可缩放拖拽 | `images/:imageId` | 已接 UI | +| 节点详情 | 右侧节点详情卡 | 展示后端节点阶段、状态、队列任务和产物摘要,缺字段时使用 UI 摘要 | `nodes/:nodeId` | 已接 UI / 后端数据 | + +### 工作流操作按钮 + +| 入口名称 | 位置 | 当前动作 | 关联接口 | 状态 | +| --- | --- | --- | --- | --- | +| 创建角色档案 | 前期人设准备 / 导入粗略人设 | 打开创建角色档案问卷,简单字段可直接生成,复杂字段作为可选结构传后端并自动选中角色卡 | `profiles/quick-draft/save` | 已接 UI / 后端落库 | +| 导入外部角色卡 | 前期人设准备 / 导入粗略人设 | 打开外部角色卡导入浮层,识别文本后填入创建角色档案问卷 | `local/profile-import-parser`, `profiles/quick-draft` | 已接 UI | +| 导入当前角色卡 | 前期人设准备 / 导入粗略人设 | 选中已落库角色卡作为工作流输入,自动加载或创建角色工作流 | `profiles/:profileId`, `profiles/:profileId/workflows` | 已接 UI / 后端落库 | +| 进入设定拆解 | 前期人设准备 / 导入粗略人设 | 使用当前已落库角色卡调用后端工作流执行,成功后切到 LLM 拆解节点 | `workflows/:workflowId/nodes`, `workflows/:workflowId/execute-character` | 已接 UI / 后端已接 | +| LLM 拆解设定工作台 | 前期人设准备 / LLM 拆解设定 | 展示身份性格、外观锚点、服装素材、约束负面项四组结构化字段,并显示字段完成度 | `workflows/:workflowId/nodes` | 已接 UI / 后端数据 | +| 重新拆解设定 | 前期人设准备 / LLM 拆解设定 | 用当前角色档案重新生成结构化字段,后端连通时写回当前节点 | `nodes/:nodeId/generate` | 已接 UI / 后端预留 | +| 确认字段 | 前期人设准备 / LLM 拆解设定 | 确认身份、外观、服装、配饰和禁用项,成功后进入提示词规划 | `nodes/:nodeId/complete` | 已接 UI / 后端已接 | +| 节点对话注入 | 角色工作流 / 底部对话框 | 自动识别当前节点、角色档案、素材和拆解字段,打包用户原文并标记后端 LLM 翻译为英文提示词后注入节点 | `nodes/:nodeId/generate` | 已接 UI / 后端注入预留 | +| 生成提示词矩阵 | 前期人设准备 / 提示词规划 | 后续生成头像、半身、全身和设定图提示词 | `nodes/:nodeId/generate` | 待后端接入 | +| 校验负面词 | 前期人设准备 / 提示词规划 | 后续检查负面词、权重和冲突项 | `review/policy/validate` | 待后端接入 | +| 绑定参考素材 | 前期人设准备 / 参考素材绑定 | 后续把素材写入节点参数 | `materials`, `nodes/:nodeId` | 待后端接入 | +| 打开素材库 | 前期人设准备 / 参考素材绑定 | 跳转素材模块补充素材 | `materials` | 已接 UI | +| 生成头像草稿 | 头像草稿阶段 | 按当前后端节点生成头像和半身候选,结果写入节点图片 | `nodes/:nodeId/generate`, `nodes/:nodeId/images` | 已接 UI / 后端落库 | +| 对比候选 | 头像草稿阶段 | 打开已选草稿平铺对比 | `local/workflow-compare` | 已接 UI | +| 再跑一轮 | 头像草稿阶段 | 将当前后端节点标记重试并再次生成候选 | `nodes/:nodeId/retry`, `nodes/:nodeId/generate` | 已接 UI / 后端落库 | +| 生成设定图 | 全身与设定图阶段 | 生成全身、手部、配饰或拆分设定图并写入节点图片 | `nodes/:nodeId/generate`, `nodes/:nodeId/images` | 已接 UI / 后端落库 | +| 细节补图 | 全身与设定图阶段 | 后续针对手部、鞋袜、配饰等局部补图 | `nodes/:nodeId/generate` | 待后端接入 | +| 重跑当前设定 | 全身与设定图阶段 | 后续保留人设锁定项重跑当前节点 | `nodes/:nodeId/retry` | 待后端接入 | +| 审核选图 | 审核修复并入库阶段 | 后续标记采用、备选或废弃版本 | `nodes/:nodeId/review` | 待后端接入 | +| 高清修复 | 审核修复并入库阶段 | 对当前后端节点发起高清修复生成,结果写入节点图片 | `nodes/:nodeId/generate`, `nodes/:nodeId/images` | 已接 UI / 后端落库 | +| 保存快照 | 各工作流阶段 | 保存当前流程快照、节点参数和选中角色卡摘要到 `workflow_history` | `POST workflows/:workflowId/history` | 已接 UI / 后端已接 | +| 从此节点创建分支 | 选中已完成/已采用节点时的右侧操作区 | 已完成节点锁定后,点击会以当前节点为切点复制工作流分支并切换到新分支;切点之前保持锁定,切点及之后重置为草稿 | `POST workflows/:workflowId/branches`, `POST workflows/:workflowId/switch-branch` | 已接 UI / 后端已接 | +| 归档图库 | 审核修复并入库阶段 | 后续把最终图放入角色图库 | `images/:imageId/archive` | 待后端接入 | + +## 当前已定义 API endpoint + +源码位置:`frontend/shared/api/endpoints.ts` + +### UI 与概览 + +- `ui/bootstrap` +- `ui/actions` +- `dashboard/summary` + +### 角色与快速角色 + +- `profiles` +- `profiles/:profileId` +- `profiles/:profileId/archive` +- `profiles/quick-draft` +- `profiles/quick-draft/save` +- `profiles/:profileId/workflows` + +### 工作流 + +- `workflows/:workflowId` +- `workflows/:workflowId/start` +- `workflows/:workflowId/cancel` +- `workflows/:workflowId/archive` +- `workflows/:workflowId/execute-character` +- `workflows/:workflowId/nodes` +- `workflows/:workflowId/branches` +- `workflows/:workflowId/switch-branch` +- `workflows/:workflowId/history` +- `workflows/:workflowId/review` + +### 节点 + +- `nodes/:nodeId` +- `nodes/:nodeId/generate` +- `nodes/:nodeId/retry` +- `nodes/:nodeId/complete` +- `nodes/:nodeId/mark-completed` +- `nodes/:nodeId/select-image` +- `nodes/:nodeId/adopt-image` +- `nodes/:nodeId/review` +- `nodes/:nodeId/images` + +### 图片 + +- `images/:imageId` +- `images/:imageId/select` +- `images/:imageId/unselect` +- `images/:imageId/archive` + +### 队列 + +- `jobs` +- `jobs/:taskId` +- `jobs/:taskId/cancel` +- `jobs/:taskId/retry` +- `jobs/dead-letter/retry` +- `jobs/dead-letter/move-failed` + +### 设置与存储 + +- `settings/schema` +- `settings/current` +- `settings/validate` +- `settings/diff` +- `settings/save` +- `settings/reload` +- `settings/export` +- `settings/import` +- `settings/snapshots` +- `settings/snapshots/:snapshotId` +- `settings/rollback` +- `storage/status` +- `storage/migrate` + +### 素材库 + +- `material-categories` +- `material-categories/:categoryId` +- `materials` +- `materials/upload` +- `materials/:materialId` +- `materials/:materialId/recognize` +- `materials/:materialId/re-recognize` +- `materials/:materialId/confirm` +- `assets/import-pack` + +### 衣橱与穿搭 + +- `profiles/:profileId/wardrobe` +- `profiles/:profileId/wardrobe/import-material` +- `profiles/:profileId/wardrobe/items` +- `profiles/:profileId/wardrobe/items/:wardrobeItemId` +- `profiles/:profileId/wardrobe/:wardrobeItemId` +- `profiles/:profileId/wardrobe/match` +- `integrations/private-companion/daily-outfit` + +### 模型发现与能力探测 + +- `api-discovery/dialects` +- `api-discovery/probe-provider` +- `api-discovery/probe-model` +- `api-discovery/capabilities` +- `api-discovery/manual-override` +- `api-discovery/validate-render-plan` + +### 日志、事件与安全 + +- `logs/generation` +- `logs/workflows` +- `logs/errors` +- `logs/integrations` +- `integrations/logs` +- `security/audit-logs` +- `events/stream` +- `web/manifest` + +## 浮层与弹出卡片 + +| 浮层名称 | 触发入口 | 当前内容 | 关闭方式 | 状态 | +| --- | --- | --- | --- | --- | +| 消息中心 | 顶部铃铛 | 通知列表 | 外部点击 / 再点按钮 / ESC | 已接 UI | +| 日志浮层 | 顶部日志图标 | 生成日志、错误日志 | 外部点击 / ESC | 已接 UI | +| 调色盘 | 顶部调色盘 | 主题色选择 | 外部点击 / ESC | 已接 UI | +| 图片详情卡 | 图片生成/工作流/快速角色图片 | 大图缩放、双击、拖拽 | 外部点击 / 关闭按钮 / ESC | 已接 UI | +| 角色设定详情卡 | 快速角色折角 | 当前角色设定详情 | 外部点击 / 关闭按钮 / ESC | 已接 UI | +| 创建角色档案问卷 | 快速角色生成人设/添加档案/工作流新建人设 | 简单/复杂问卷切换;复杂问卷包含世界观、背景、身高身材、喜好、关系和生成偏好,字段可留空;保存时调用后端生成角色档案与 `quick_profile` 工作流 | 外部点击 / 关闭按钮 / ESC | 已接 UI / 后端落库 | +| 外部角色卡导入 | 工作流导入粗略人设 / 粘贴导入 | 粘贴外部角色卡、人设文本或设定片段,并识别填入创建角色档案问卷 | 外部点击 / 取消 / 关闭按钮 / ESC | 已接 UI | +| 素材选择卡 | 快速角色参考素材 | 不使用、素材候选、添加素材 | 外部点击 / ESC | 已接 UI | +| 工作流多图对比 | 角色工作流平铺对比 | 多草稿大图对比 | 关闭按钮 / ESC | 已接 UI | + +## 待补入口记录 + +新增功能时先写这里,再实现 UI 或接口。 + +| 待补入口 | 预期位置 | 预期接口 | 备注 | +| --- | --- | --- | --- | +| 素材库添加对应分类素材 | 素材选择浮层底部添加卡 | `materials/upload` | 需要带分类参数,如构图、服装、配饰子类 | +| 工作流草稿轮次自动创建 | 角色工作流节点流程 | `workflows/:workflowId/nodes` | 不满意重跑时自动创建草稿 02/03 等小节点 | +| 节点锁定元素写入 | 工作流多选草稿/节点详情 | `nodes/:nodeId/select-image` | 选中五官、发色、服装等锁定项 | +| 角色编辑界面 | 角色设定详情卡或角色模块 | `profiles/:profileId` | 当前只有详情卡和问卷占位 | +| 性能详情页 | 左侧性能入口 | 待定 | 当前只有入口和概览精简卡 | diff --git a/frontend/shared/api/client.ts b/frontend/shared/api/client.ts index b0f1a40..e86c15d 100644 --- a/frontend/shared/api/client.ts +++ b/frontend/shared/api/client.ts @@ -1,6 +1,8 @@ import { API_BASE } from "./endpoints" import type { ApiResponse } from "../types/api" +export type ApiTransport = "plugin-bridge" | "direct-fetch" + export class ApiClientError extends Error { readonly code: string readonly details: Record @@ -21,6 +23,13 @@ export async function postJson(endpoint: string, body?: unknown) { return request(endpoint, { method: "POST", body }) } +export function getApiTransport(): ApiTransport { + const bridge = typeof window === "undefined" ? undefined : window.AstrBotPluginPage + return bridge && (typeof bridge.apiGet === "function" || typeof bridge.apiPost === "function") + ? "plugin-bridge" + : "direct-fetch" +} + export async function request( endpoint: string, options: { @@ -34,12 +43,33 @@ export async function request( return unwrapApiResponse(bridgePayload) } - const response = await fetch(buildUrl(endpoint, options.query), { - method: options.method ?? "GET", - headers: options.body === undefined ? undefined : { "Content-Type": "application/json" }, - body: options.body === undefined ? undefined : JSON.stringify(options.body), - }) - const payload = (await response.json()) as ApiResponse + const url = buildUrl(endpoint, options.query) + let response: Response + try { + response = await fetch(url, { + method: options.method ?? "GET", + headers: options.body === undefined ? undefined : { "Content-Type": "application/json" }, + body: options.body === undefined ? undefined : JSON.stringify(options.body), + }) + } catch (err) { + throw new ApiClientError("network_unreachable", "无法连接 ImageStudio 后端接口", { + endpoint, + transport: "direct-fetch", + url, + reason: err instanceof Error ? err.message : String(err), + }) + } + + const payload = await parseResponsePayload(response, endpoint, url) + if (!response.ok && !isApiResponse(payload)) { + throw new ApiClientError("http_error", `接口请求失败(HTTP ${response.status})`, { + endpoint, + transport: "direct-fetch", + url, + status: response.status, + status_text: response.statusText, + }) + } return unwrapApiResponse(payload) } @@ -78,6 +108,36 @@ function unwrapApiResponse(payload: T | ApiResponse): T { return payload.data } +async function parseResponsePayload(response: Response, endpoint: string, url: string): Promise> { + const contentType = response.headers.get("content-type") ?? "" + const isJson = contentType.includes("application/json") || contentType.includes("+json") + if (!isJson) { + const preview = (await response.text()).slice(0, 240) + throw new ApiClientError("invalid_api_response", "接口返回了非 JSON 响应", { + endpoint, + transport: "direct-fetch", + url, + status: response.status, + status_text: response.statusText, + content_type: contentType, + preview, + }) + } + try { + return (await response.json()) as T | ApiResponse + } catch (err) { + throw new ApiClientError("invalid_api_response", "接口返回格式不正确", { + endpoint, + transport: "direct-fetch", + url, + status: response.status, + status_text: response.statusText, + content_type: contentType, + reason: err instanceof Error ? err.message : String(err), + }) + } +} + function isApiResponse(payload: T | ApiResponse): payload is ApiResponse { return Boolean(payload && typeof payload === "object" && "ok" in payload) } diff --git a/frontend/shared/api/endpoints.ts b/frontend/shared/api/endpoints.ts index 474a96e..9cfaefa 100644 --- a/frontend/shared/api/endpoints.ts +++ b/frontend/shared/api/endpoints.ts @@ -14,6 +14,7 @@ export const endpoints = { workflowStart: (workflowId: string) => `workflows/${workflowId}/start`, workflowCancel: (workflowId: string) => `workflows/${workflowId}/cancel`, workflowArchive: (workflowId: string) => `workflows/${workflowId}/archive`, + workflowExecuteCharacter: (workflowId: string) => `workflows/${workflowId}/execute-character`, workflowNodes: (workflowId: string) => `workflows/${workflowId}/nodes`, workflowBranches: (workflowId: string) => `workflows/${workflowId}/branches`, workflowSwitchBranch: (workflowId: string) => `workflows/${workflowId}/switch-branch`, diff --git a/frontend/shared/types/profile.ts b/frontend/shared/types/profile.ts index 4c36aa8..1df1f5e 100644 --- a/frontend/shared/types/profile.ts +++ b/frontend/shared/types/profile.ts @@ -1,3 +1,5 @@ +import type { ProfileWorkflow, WorkflowNode } from "./workflow" + export interface CharacterProfile { profile_id: string name: string @@ -9,6 +11,7 @@ export interface CharacterProfile { style_prompt?: string | null negative_prompt?: string | null default_model_route?: string | null + metadata?: Record created_at: string updated_at: string } @@ -30,3 +33,10 @@ export interface QuickProfileDraftResult { negative_prompt: string } } + +export interface QuickProfileDraftSaveResult { + draft_id?: string | null + profile: CharacterProfile + workflow?: ProfileWorkflow + nodes?: WorkflowNode[] +} diff --git a/frontend/standalone-web/src/App.vue b/frontend/standalone-web/src/App.vue index 3868ed1..c2935ee 100644 --- a/frontend/standalone-web/src/App.vue +++ b/frontend/standalone-web/src/App.vue @@ -1,12 +1,21 @@ @@ -3621,12 +5737,33 @@ function errorMessage(err: unknown) { +
+
+ +
+
+ {{ backendConnection.title }} + {{ backendConnection.detail }} +
+ +
+
@@ -3839,6 +5976,8 @@ function errorMessage(err: unknown) { 同步中 + 生成中 + {{ imageGenerationError }} 使用本地模型
@@ -3849,9 +5988,9 @@ function errorMessage(err: unknown) { type="submit" class="composer-send-button" title="交给 LLM 翻译并生成" - :disabled="!imageGenerationPrompt.trim()" + :disabled="!imageGenerationPrompt.trim() || imageGenerationSubmitting" > - ↑ + {{ imageGenerationSubmitting ? "..." : "↑" }}
@@ -3953,10 +6092,23 @@ function errorMessage(err: unknown) {
+
@@ -4270,52 +6422,37 @@ function errorMessage(err: unknown) { + + + +