diff --git a/backend/app/schemas/design.py b/backend/app/schemas/design.py index 673c98b..14c7785 100644 --- a/backend/app/schemas/design.py +++ b/backend/app/schemas/design.py @@ -27,8 +27,9 @@ class DesignCreate(BaseModel): """创建设计请求""" category_id: int = Field(..., description="品类ID") sub_type_id: Optional[int] = Field(None, description="子类型ID") + sub_type_name: Optional[str] = Field(None, max_length=50, description="自定义子类型名称") color_id: Optional[int] = Field(None, description="颜色ID") - prompt: str = Field(..., min_length=1, max_length=2000, description="设计需求") + prompt: Optional[str] = Field(None, max_length=2000, description="设计需求") carving_technique: Optional[str] = Field(None, max_length=50, description="雕刻工艺") design_style: Optional[str] = Field(None, max_length=50, description="设计风格") motif: Optional[str] = Field(None, max_length=100, description="题材纹样") diff --git a/backend/app/services/design_service.py b/backend/app/services/design_service.py index 7f2a731..aff49f9 100644 --- a/backend/app/services/design_service.py +++ b/backend/app/services/design_service.py @@ -139,7 +139,7 @@ async def _generate_ai_images( prompt_text = build_prompt( category_name=category.name, view_name=view_name, - sub_type_name=sub_type.name if sub_type else None, + sub_type_name=sub_type.name if sub_type else design_data.sub_type_name, color_name=color.name if color else None, user_prompt=design_data.prompt, carving_technique=design_data.carving_technique, @@ -244,7 +244,7 @@ def _generate_mock_fallback( save_path = os.path.join(settings.UPLOAD_DIR, "designs", f"{design.id}.png") image_url = generate_mock_design( category_name=category.name, - sub_type_name=sub_type.name if sub_type else None, + sub_type_name=sub_type.name if sub_type else design_data.sub_type_name, color_name=color.name if color else None, prompt=design_data.prompt, save_path=save_path, diff --git a/backend/uploads/designs/28_0_8f1d51f1.png b/backend/uploads/designs/28_0_8f1d51f1.png new file mode 100644 index 0000000..ab22813 Binary files /dev/null and b/backend/uploads/designs/28_0_8f1d51f1.png differ diff --git a/backend/uploads/designs/28_1_652b3742.png b/backend/uploads/designs/28_1_652b3742.png new file mode 100644 index 0000000..4cc40ae Binary files /dev/null and b/backend/uploads/designs/28_1_652b3742.png differ diff --git a/backend/uploads/designs/28_2_afd0819c.png b/backend/uploads/designs/28_2_afd0819c.png new file mode 100644 index 0000000..9d4561a Binary files /dev/null and b/backend/uploads/designs/28_2_afd0819c.png differ diff --git a/backend/uploads/designs/28_3_597f23e1.png b/backend/uploads/designs/28_3_597f23e1.png new file mode 100644 index 0000000..eaa88e9 Binary files /dev/null and b/backend/uploads/designs/28_3_597f23e1.png differ diff --git a/backend/uvicorn.log b/backend/uvicorn.log index 73c73e1..2de49c1 100644 --- a/backend/uvicorn.log +++ b/backend/uvicorn.log @@ -317,3 +317,125 @@ INFO: 127.0.0.1:58331 - "GET /api/categories/12/sub-types HTTP/1.1" 200 OK INFO: 127.0.0.1:58335 - "GET /api/categories/13/colors HTTP/1.1" 200 OK INFO: 127.0.0.1:58341 - "GET /api/categories/1/colors HTTP/1.1" 200 OK INFO: 127.0.0.1:58340 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58408 - "GET /api/auth/me HTTP/1.1" 200 OK +INFO: 127.0.0.1:58417 - "GET /api/auth/me HTTP/1.1" 200 OK +INFO: 127.0.0.1:58419 - "GET /api/categories HTTP/1.1" 200 OK +INFO: 127.0.0.1:58504 - "GET /api/categories/1/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58503 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58509 - "GET /api/categories/2/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58511 - "GET /api/categories/2/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58517 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58519 - "GET /api/categories/1/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58527 - "GET /api/categories/2/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58529 - "GET /api/categories/2/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58535 - "GET /api/categories/3/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58534 - "GET /api/categories/3/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58550 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58551 - "GET /api/categories/1/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58638 - "GET /api/categories/13/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58644 - "GET /api/categories/12/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58643 - "GET /api/categories/12/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58649 - "GET /api/categories/11/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58651 - "GET /api/categories/11/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58658 - "GET /api/categories/10/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58659 - "GET /api/categories/10/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58665 - "GET /api/categories/9/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58664 - "GET /api/categories/9/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58670 - "GET /api/categories/8/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58671 - "GET /api/categories/8/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58677 - "GET /api/categories/7/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58678 - "GET /api/categories/7/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58684 - "GET /api/categories/6/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58686 - "GET /api/categories/6/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58692 - "GET /api/categories/1/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58691 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK +WARNING: StatReload detected changes in 'app/schemas/design.py'. Reloading... +INFO: Shutting down +INFO: Waiting for application shutdown. +INFO: Application shutdown complete. +INFO: Finished server process [903] +👋 应用已关闭 +INFO: Started server process [3994] +INFO: Waiting for application startup. +INFO: Application startup complete. +✅ 上传目录已准备: uploads +INFO: 127.0.0.1:58700 - "GET /api/categories/2/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58699 - "GET /api/categories/2/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58708 - "GET /api/categories/3/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58709 - "GET /api/categories/3/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58715 - "GET /api/categories/4/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58716 - "GET /api/categories/4/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58721 - "GET /api/categories/5/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58722 - "GET /api/categories/5/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58727 - "GET /api/categories/6/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58728 - "GET /api/categories/6/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58734 - "GET /api/categories/7/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58733 - "GET /api/categories/7/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58739 - "GET /api/categories/8/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58740 - "GET /api/categories/8/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58746 - "GET /api/categories/9/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58747 - "GET /api/categories/9/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58751 - "GET /api/categories/10/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58753 - "GET /api/categories/10/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58758 - "GET /api/categories/9/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58759 - "GET /api/categories/9/colors HTTP/1.1" 200 OK +WARNING: StatReload detected changes in 'app/services/design_service.py'. Reloading... +INFO: Shutting down +INFO: Waiting for application shutdown. +INFO: Application shutdown complete. +INFO: Finished server process [3994] +👋 应用已关闭 +INFO: Started server process [4005] +INFO: Waiting for application startup. +INFO: Application startup complete. +WARNING: StatReload detected changes in 'app/services/design_service.py'. Reloading... +INFO: Shutting down +INFO: Waiting for application shutdown. +INFO: Application shutdown complete. +INFO: Finished server process [4005] +✅ 上传目录已准备: uploads +👋 应用已关闭 +INFO: Started server process [4016] +INFO: Waiting for application startup. +INFO: Application startup complete. +✅ 上传目录已准备: uploads +INFO: 127.0.0.1:58910 - "GET /api/categories HTTP/1.1" 200 OK +INFO: 127.0.0.1:58916 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58918 - "GET /api/categories/1/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58925 - "GET /api/categories HTTP/1.1" 200 OK +INFO: 127.0.0.1:58930 - "GET /api/categories/2/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:58931 - "GET /api/categories/2/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58937 - "GET /api/categories/3/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:58936 - "GET /api/categories/3/sub-types HTTP/1.1" 200 OK +WARNING: StatReload detected changes in 'app/schemas/design.py'. Reloading... +INFO: Shutting down +INFO: Waiting for application shutdown. +INFO: Application shutdown complete. +INFO: Finished server process [4016] +👋 应用已关闭 +INFO: Started server process [4272] +INFO: Waiting for application startup. +INFO: Application startup complete. +✅ 上传目录已准备: uploads +INFO: 127.0.0.1:59022 - "GET /api/auth/me HTTP/1.1" 200 OK +INFO: 127.0.0.1:59025 - "GET /api/categories HTTP/1.1" 200 OK +INFO: 127.0.0.1:59072 - "POST /api/auth/login HTTP/1.1" 200 OK +INFO: 127.0.0.1:59076 - "GET /api/auth/me HTTP/1.1" 200 OK +INFO: 127.0.0.1:59082 - "GET /api/categories HTTP/1.1" 200 OK +INFO: 127.0.0.1:59089 - "GET /api/categories/1/sub-types HTTP/1.1" 200 OK +INFO: 127.0.0.1:59090 - "GET /api/categories/1/colors HTTP/1.1" 200 OK +INFO: 127.0.0.1:59224 - "POST /api/designs/generate HTTP/1.1" 200 OK +INFO: 127.0.0.1:59331 - "GET /uploads/designs/28_0_8f1d51f1.png HTTP/1.1" 200 OK +INFO: 127.0.0.1:59345 - "GET /uploads/designs/28_2_afd0819c.png HTTP/1.1" 200 OK +INFO: 127.0.0.1:59348 - "GET /uploads/designs/28_3_597f23e1.png HTTP/1.1" 200 OK +INFO: 127.0.0.1:59352 - "GET /uploads/designs/28_1_652b3742.png HTTP/1.1" 200 OK +INFO: 127.0.0.1:50695 - "GET /projects.php HTTP/1.1" 404 Not Found +INFO: ('127.0.0.1', 55036) - "WebSocket /CLodopfuncs.js" 403 +INFO: connection rejected (403 Forbidden) +INFO: connection closed +INFO: Shutting down +INFO: Waiting for application shutdown. +INFO: Application shutdown complete. +INFO: Finished server process [4272] +👋 应用已关闭 +INFO: Stopping reloader process [63566] diff --git a/frontend/src/api/design.ts b/frontend/src/api/design.ts index 6d1b583..4f17678 100644 --- a/frontend/src/api/design.ts +++ b/frontend/src/api/design.ts @@ -52,6 +52,7 @@ export interface DesignListResponse { export interface GenerateDesignParams { category_id: number sub_type_id?: number + sub_type_name?: string color_id?: number prompt: string carving_technique?: string diff --git a/frontend/src/components/SubTypePanel.vue b/frontend/src/components/SubTypePanel.vue index f434f92..511fb33 100644 --- a/frontend/src/components/SubTypePanel.vue +++ b/frontend/src/components/SubTypePanel.vue @@ -27,7 +27,7 @@ v-for="subType in subTypes" :key="subType.id" class="subtype-card" - :class="{ active: currentSubType?.id === subType.id }" + :class="{ active: !useCustomSubType && currentSubType?.id === subType.id }" @click="handleSelectSubType(subType)" >