super-dev 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- super_dev/__init__.py +11 -0
- super_dev/analyzer/__init__.py +34 -0
- super_dev/analyzer/analyzer.py +440 -0
- super_dev/analyzer/detectors.py +511 -0
- super_dev/analyzer/models.py +285 -0
- super_dev/cli.py +3257 -0
- super_dev/config/__init__.py +11 -0
- super_dev/config/frontend.py +557 -0
- super_dev/config/manager.py +281 -0
- super_dev/creators/__init__.py +26 -0
- super_dev/creators/creator.py +134 -0
- super_dev/creators/document_generator.py +2473 -0
- super_dev/creators/frontend_builder.py +371 -0
- super_dev/creators/implementation_builder.py +789 -0
- super_dev/creators/prompt_generator.py +289 -0
- super_dev/creators/requirement_parser.py +354 -0
- super_dev/creators/spec_builder.py +195 -0
- super_dev/deployers/__init__.py +20 -0
- super_dev/deployers/cicd.py +1269 -0
- super_dev/deployers/delivery.py +229 -0
- super_dev/deployers/migration.py +1032 -0
- super_dev/design/__init__.py +74 -0
- super_dev/design/aesthetics.py +530 -0
- super_dev/design/charts.py +396 -0
- super_dev/design/codegen.py +379 -0
- super_dev/design/engine.py +528 -0
- super_dev/design/generator.py +395 -0
- super_dev/design/landing.py +422 -0
- super_dev/design/tech_stack.py +524 -0
- super_dev/design/tokens.py +269 -0
- super_dev/design/ux_guide.py +391 -0
- super_dev/exceptions.py +119 -0
- super_dev/experts/__init__.py +19 -0
- super_dev/experts/service.py +161 -0
- super_dev/integrations/__init__.py +7 -0
- super_dev/integrations/manager.py +264 -0
- super_dev/orchestrator/__init__.py +12 -0
- super_dev/orchestrator/engine.py +958 -0
- super_dev/orchestrator/experts.py +423 -0
- super_dev/orchestrator/knowledge.py +352 -0
- super_dev/orchestrator/quality.py +356 -0
- super_dev/reviewers/__init__.py +17 -0
- super_dev/reviewers/code_review.py +471 -0
- super_dev/reviewers/quality_gate.py +964 -0
- super_dev/reviewers/redteam.py +881 -0
- super_dev/skills/__init__.py +7 -0
- super_dev/skills/manager.py +307 -0
- super_dev/specs/__init__.py +44 -0
- super_dev/specs/generator.py +264 -0
- super_dev/specs/manager.py +428 -0
- super_dev/specs/models.py +348 -0
- super_dev/specs/validator.py +415 -0
- super_dev/utils/__init__.py +11 -0
- super_dev/utils/logger.py +133 -0
- super_dev/web/api.py +1402 -0
- super_dev-2.0.0.dist-info/METADATA +252 -0
- super_dev-2.0.0.dist-info/RECORD +61 -0
- super_dev-2.0.0.dist-info/WHEEL +5 -0
- super_dev-2.0.0.dist-info/entry_points.txt +2 -0
- super_dev-2.0.0.dist-info/licenses/LICENSE +21 -0
- super_dev-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,2473 @@
|
|
|
1
|
+
"""
|
|
2
|
+
文档生成器 - 高质量 PRD、架构、UI/UX 文档生成
|
|
3
|
+
|
|
4
|
+
开发:Excellent(11964948@qq.com)
|
|
5
|
+
功能:专家级文档生成
|
|
6
|
+
作用:生成专业、细致、完整的项目文档
|
|
7
|
+
创建时间:2025-12-30
|
|
8
|
+
最后修改:2025-01-04
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from datetime import datetime
|
|
12
|
+
|
|
13
|
+
from .requirement_parser import RequirementParser
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DocumentGenerator:
|
|
17
|
+
"""文档生成器 - 生成专家级项目文档"""
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
name: str,
|
|
22
|
+
description: str,
|
|
23
|
+
platform: str = "web",
|
|
24
|
+
frontend: str = "next",
|
|
25
|
+
backend: str = "node",
|
|
26
|
+
domain: str = "",
|
|
27
|
+
ui_library: str | None = None,
|
|
28
|
+
style_solution: str | None = None,
|
|
29
|
+
state_management: list[str] | None = None,
|
|
30
|
+
testing_frameworks: list[str] | None = None,
|
|
31
|
+
):
|
|
32
|
+
"""初始化文档生成器"""
|
|
33
|
+
self.name = name
|
|
34
|
+
self.description = description
|
|
35
|
+
self.platform = platform
|
|
36
|
+
self.frontend = frontend
|
|
37
|
+
self.backend = backend
|
|
38
|
+
self.domain = domain or "general"
|
|
39
|
+
self.ui_library = ui_library
|
|
40
|
+
self.style_solution = style_solution
|
|
41
|
+
self.state_management = state_management or []
|
|
42
|
+
self.testing_frameworks = testing_frameworks or []
|
|
43
|
+
self.requirement_parser = RequirementParser()
|
|
44
|
+
|
|
45
|
+
def _analyze_project_for_design(self) -> dict:
|
|
46
|
+
"""分析项目特征用于设计推荐"""
|
|
47
|
+
# 从描述中提取特征
|
|
48
|
+
description_lower = self.description.lower()
|
|
49
|
+
|
|
50
|
+
# 产品类型
|
|
51
|
+
product_type = "general"
|
|
52
|
+
if any(word in description_lower for word in ["saas", "软件服务", "platform", "平台"]):
|
|
53
|
+
product_type = "saas"
|
|
54
|
+
elif any(word in description_lower for word in ["电商", "商城", "shop", "store", "mall"]):
|
|
55
|
+
product_type = "ecommerce"
|
|
56
|
+
elif any(word in description_lower for word in ["landing", "落地页", "营销页"]):
|
|
57
|
+
product_type = "landing"
|
|
58
|
+
elif any(word in description_lower for word in ["admin", "管理", "dashboard", "仪表盘", "后台"]):
|
|
59
|
+
product_type = "dashboard"
|
|
60
|
+
elif any(word in description_lower for word in ["blog", "博客", "内容", "cms"]):
|
|
61
|
+
product_type = "content"
|
|
62
|
+
|
|
63
|
+
# 行业
|
|
64
|
+
industry = "general"
|
|
65
|
+
if any(word in description_lower for word in ["医疗", "健康", "health", "medical", "care"]):
|
|
66
|
+
industry = "healthcare"
|
|
67
|
+
elif any(word in description_lower for word in ["金融", "支付", "fintech", "金融科技", "banking"]):
|
|
68
|
+
industry = "fintech"
|
|
69
|
+
elif any(word in description_lower for word in ["教育", "培训", "education", "learning"]):
|
|
70
|
+
industry = "education"
|
|
71
|
+
|
|
72
|
+
# 风格倾向
|
|
73
|
+
style = "modern"
|
|
74
|
+
if any(word in description_lower for word in ["极简", "minimal", "简约"]):
|
|
75
|
+
style = "minimal"
|
|
76
|
+
elif any(word in description_lower for word in ["专业", "商务", "business", "professional"]):
|
|
77
|
+
style = "professional"
|
|
78
|
+
elif any(word in description_lower for word in ["活泼", "fun", "playful", "活力"]):
|
|
79
|
+
style = "playful"
|
|
80
|
+
elif any(word in description_lower for word in ["奢华", "luxury", "高端", "premium"]):
|
|
81
|
+
style = "luxury"
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
"product_type": product_type,
|
|
85
|
+
"industry": industry,
|
|
86
|
+
"style": style,
|
|
87
|
+
"domain": self.domain,
|
|
88
|
+
"platform": self.platform,
|
|
89
|
+
"frontend": self.frontend,
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
def _extract_tech_keywords(self) -> dict:
|
|
93
|
+
"""
|
|
94
|
+
从描述中提取技术栈关键词
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
dict: 包含提取的技术关键词分类
|
|
98
|
+
"""
|
|
99
|
+
description = self.description
|
|
100
|
+
keywords: dict[str, list[str]] = {
|
|
101
|
+
"ai_frameworks": [], # AI 框架:LangGraph, LangChain, Transformers 等
|
|
102
|
+
"agent_tools": [], # Agent 工具:AutoGPT, BabyAGI, CrewAI 等
|
|
103
|
+
"ml_libraries": [], # ML 库:PyTorch, TensorFlow, scikit-learn 等
|
|
104
|
+
"vector_stores": [], # 向量数据库:Pinecone, Chroma, Weaviate 等
|
|
105
|
+
"orchestration": [], # 编排工具:Airflow, Prefect, Dagster 等
|
|
106
|
+
"other_keywords": [], # 其他技术关键词
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# AI 框架
|
|
110
|
+
ai_frameworks = ["LangGraph", "LangChain", "LlamaIndex", "Haystack", "Semantic Kernel"]
|
|
111
|
+
for framework in ai_frameworks:
|
|
112
|
+
if framework in description:
|
|
113
|
+
keywords["ai_frameworks"].append(framework)
|
|
114
|
+
|
|
115
|
+
# Agent 工具
|
|
116
|
+
agent_tools = ["AutoGPT", "BabyAGI", "CrewAI", "AgentOps", "E2B"]
|
|
117
|
+
for tool in agent_tools:
|
|
118
|
+
if tool in description:
|
|
119
|
+
keywords["agent_tools"].append(tool)
|
|
120
|
+
|
|
121
|
+
# ML 库
|
|
122
|
+
ml_libraries = ["PyTorch", "TensorFlow", "Keras", "scikit-learn", "XGBoost", "LightGBM"]
|
|
123
|
+
for lib in ml_libraries:
|
|
124
|
+
if lib in description:
|
|
125
|
+
keywords["ml_libraries"].append(lib)
|
|
126
|
+
|
|
127
|
+
# 向量数据库
|
|
128
|
+
vector_stores = ["Pinecone", "Chroma", "Weaviate", "Qdrant", "Milvus", "FAISS"]
|
|
129
|
+
for store in vector_stores:
|
|
130
|
+
if store in description:
|
|
131
|
+
keywords["vector_stores"].append(store)
|
|
132
|
+
|
|
133
|
+
# 编排工具
|
|
134
|
+
orchestration = ["Airflow", "Prefect", "Dagster", "Argo Workflows", "Temporal"]
|
|
135
|
+
for tool in orchestration:
|
|
136
|
+
if tool in description:
|
|
137
|
+
keywords["orchestration"].append(tool)
|
|
138
|
+
|
|
139
|
+
# 提取 Agent 相关关键词
|
|
140
|
+
if "Agent" in description or "agent" in description or "智能体" in description:
|
|
141
|
+
keywords["other_keywords"].append("Multi-Agent System")
|
|
142
|
+
|
|
143
|
+
if "RAG" in description or "检索增强" in description:
|
|
144
|
+
keywords["other_keywords"].append("RAG (Retrieval-Augmented Generation)")
|
|
145
|
+
|
|
146
|
+
if "LLM" in description or "大语言模型" in description or "GPT" in description:
|
|
147
|
+
keywords["other_keywords"].append("LLM Integration")
|
|
148
|
+
|
|
149
|
+
return keywords
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def generate_prd(self) -> str:
|
|
153
|
+
"""生成高质量 PRD 文档"""
|
|
154
|
+
return f"""# {self.name} - 产品需求文档 (PRD)
|
|
155
|
+
|
|
156
|
+
> **生成时间**: {datetime.now().strftime('%Y-%m-%d %H:%M')}
|
|
157
|
+
> **版本**: v2.0.0
|
|
158
|
+
> **状态**: 草稿
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 文档信息
|
|
163
|
+
|
|
164
|
+
| 项目 | 内容 |
|
|
165
|
+
|:---|:---|
|
|
166
|
+
| **项目名称** | {self.name} |
|
|
167
|
+
| **项目描述** | {self.description} |
|
|
168
|
+
| **目标平台** | {self.platform.upper()} |
|
|
169
|
+
| **业务领域** | {self.domain.upper()} |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 1. 产品概述
|
|
174
|
+
|
|
175
|
+
### 1.1 产品愿景
|
|
176
|
+
|
|
177
|
+
{self._generate_vision()}
|
|
178
|
+
|
|
179
|
+
### 1.2 目标用户
|
|
180
|
+
|
|
181
|
+
{self._generate_target_users()}
|
|
182
|
+
|
|
183
|
+
### 1.3 核心价值
|
|
184
|
+
|
|
185
|
+
{self._generate_value_proposition()}
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## 2. 功能需求
|
|
190
|
+
|
|
191
|
+
### 2.1 核心功能 (MVP)
|
|
192
|
+
|
|
193
|
+
{self._generate_core_features()}
|
|
194
|
+
|
|
195
|
+
### 2.2 扩展功能 (Phase 2)
|
|
196
|
+
|
|
197
|
+
{self._generate_extended_features()}
|
|
198
|
+
|
|
199
|
+
### 2.3 用户故事
|
|
200
|
+
|
|
201
|
+
{self._generate_user_stories()}
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## 3. 非功能需求
|
|
206
|
+
|
|
207
|
+
### 3.1 性能要求
|
|
208
|
+
|
|
209
|
+
- **响应时间**: API 响应时间 < 200ms (P95)
|
|
210
|
+
- **并发用户**: 支持 1000+ 并发用户
|
|
211
|
+
- **页面加载**: 首屏加载时间 < 2s
|
|
212
|
+
|
|
213
|
+
### 3.2 安全要求
|
|
214
|
+
|
|
215
|
+
- **数据加密**: 传输层 TLS 1.3+
|
|
216
|
+
- **身份认证**: JWT Token 认证
|
|
217
|
+
- **权限控制**: RBAC 角色权限
|
|
218
|
+
- **数据保护**: 敏感数据加密存储
|
|
219
|
+
|
|
220
|
+
### 3.3 可用性要求
|
|
221
|
+
|
|
222
|
+
- **系统可用性**: 99.9% SLA
|
|
223
|
+
- **容错机制**: 自动故障转移
|
|
224
|
+
- **数据备份**: 每日自动备份
|
|
225
|
+
|
|
226
|
+
### 3.4 兼容性要求
|
|
227
|
+
|
|
228
|
+
- **浏览器**: Chrome 90+, Firefox 88+, Safari 14+, Edge 90+
|
|
229
|
+
- **移动端**: iOS 14+, Android 10+
|
|
230
|
+
- **分辨率**: 320px - 4K
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## 4. 用户流程
|
|
235
|
+
|
|
236
|
+
### 4.1 主要用户旅程
|
|
237
|
+
|
|
238
|
+
{self._generate_user_journeys()}
|
|
239
|
+
|
|
240
|
+
### 4.2 页面结构
|
|
241
|
+
|
|
242
|
+
{self._generate_page_structure()}
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## 5. 数据模型
|
|
247
|
+
|
|
248
|
+
### 5.1 核心实体
|
|
249
|
+
|
|
250
|
+
{self._generate_data_entities()}
|
|
251
|
+
|
|
252
|
+
### 5.2 关系图
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
[ER 图将在架构文档中详细说明]
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## 6. 业务规则
|
|
261
|
+
|
|
262
|
+
{self._generate_business_rules()}
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## 7. 验收标准
|
|
267
|
+
|
|
268
|
+
### 7.1 功能验收
|
|
269
|
+
|
|
270
|
+
{self._generate_acceptance_criteria()}
|
|
271
|
+
|
|
272
|
+
### 7.2 性能验收
|
|
273
|
+
|
|
274
|
+
- [ ] API 响应时间测试通过
|
|
275
|
+
- [ ] 并发压力测试通过
|
|
276
|
+
- [ ] 页面性能测试通过
|
|
277
|
+
|
|
278
|
+
### 7.3 安全验收
|
|
279
|
+
|
|
280
|
+
- [ ] 渗透测试通过
|
|
281
|
+
- [ ] 数据加密验证通过
|
|
282
|
+
- [ ] 权限控制验证通过
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## 8. 发布计划
|
|
287
|
+
|
|
288
|
+
### 8.1 MVP (v2.0)
|
|
289
|
+
|
|
290
|
+
**时间**: 4 周
|
|
291
|
+
**范围**: 核心功能 + 基础架构
|
|
292
|
+
|
|
293
|
+
### 8.2 Phase 2 (v1.5)
|
|
294
|
+
|
|
295
|
+
**时间**: MVP 后 2 周
|
|
296
|
+
**范围**: 扩展功能 + 性能优化
|
|
297
|
+
|
|
298
|
+
### 8.3 Phase 3 (v2.0)
|
|
299
|
+
|
|
300
|
+
**时间**: Phase 2 后 4 周
|
|
301
|
+
**范围**: 高级功能 + 生态集成
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 9. 成功指标
|
|
306
|
+
|
|
307
|
+
| 指标 | 目标 | 测量方式 |
|
|
308
|
+
|:---|:---|:---|
|
|
309
|
+
| **用户增长** | 月活用户 1000+ | Analytics |
|
|
310
|
+
| **留存率** | 7 日留存 40%+ | Analytics |
|
|
311
|
+
| **满意度** | NPS 50+ | 用户调研 |
|
|
312
|
+
| **性能** | API 响应 < 200ms | APM |
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## 10. 风险与限制
|
|
317
|
+
|
|
318
|
+
### 10.1 技术风险
|
|
319
|
+
|
|
320
|
+
{self._generate_technical_risks()}
|
|
321
|
+
|
|
322
|
+
### 10.2 业务风险
|
|
323
|
+
|
|
324
|
+
{self._generate_business_risks()}
|
|
325
|
+
|
|
326
|
+
### 10.3 依赖限制
|
|
327
|
+
|
|
328
|
+
{self._generate_dependencies()}
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## 附录
|
|
333
|
+
|
|
334
|
+
### A. 术语表
|
|
335
|
+
|
|
336
|
+
{self._generate_glossary()}
|
|
337
|
+
|
|
338
|
+
### B. 参考文档
|
|
339
|
+
|
|
340
|
+
{self._generate_references()}
|
|
341
|
+
|
|
342
|
+
### C. 变更历史
|
|
343
|
+
|
|
344
|
+
| 版本 | 日期 | 变更内容 | 作者 |
|
|
345
|
+
|:---|:---|:---|:---|
|
|
346
|
+
| v2.0.0 | {datetime.now().strftime('%Y-%m-%d')} | 初始版本 | Super Dev |
|
|
347
|
+
"""
|
|
348
|
+
|
|
349
|
+
def generate_architecture(self) -> str:
|
|
350
|
+
"""生成架构设计文档"""
|
|
351
|
+
return f"""# {self.name} - 架构设计文档
|
|
352
|
+
|
|
353
|
+
> **生成时间**: {datetime.now().strftime('%Y-%m-%d %H:%M')}
|
|
354
|
+
> **版本**: v2.0.0
|
|
355
|
+
> **架构师**: Super Dev ARCHITECT 专家
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## 1. 架构概述
|
|
360
|
+
|
|
361
|
+
### 1.1 系统目标
|
|
362
|
+
|
|
363
|
+
- **可扩展性**: 支持水平扩展,应对业务增长
|
|
364
|
+
- **可用性**: 99.9% 系统可用性
|
|
365
|
+
- **性能**: 低延迟、高吞吐
|
|
366
|
+
- **安全性**: 端到端安全防护
|
|
367
|
+
|
|
368
|
+
### 1.2 架构原则
|
|
369
|
+
|
|
370
|
+
1. **服务拆分**: 按业务领域拆分微服务
|
|
371
|
+
2. **数据库分离**: 读写分离、缓存层
|
|
372
|
+
3. **异步处理**: 消息队列解耦
|
|
373
|
+
4. **监控运维**: 全链路追踪、实时告警
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## 2. 技术栈
|
|
378
|
+
|
|
379
|
+
### 2.1 前端技术栈
|
|
380
|
+
|
|
381
|
+
| 层级 | 技术选型 | 说明 |
|
|
382
|
+
|:---|:---|:---|
|
|
383
|
+
| **框架** | {self.frontend.title()} | 组件化开发 |
|
|
384
|
+
| **状态管理** | {self._get_state_management()} | 全局状态管理 |
|
|
385
|
+
| **UI 框架** | {self._get_ui_library()} | 组件库 |
|
|
386
|
+
| **构建工具** | {self._get_build_tool()} | 打包构建 |
|
|
387
|
+
| **HTTP 客户端** | Axios | API 请求 |
|
|
388
|
+
| **路由** | React Router | 页面路由 |
|
|
389
|
+
|
|
390
|
+
### 2.2 后端技术栈
|
|
391
|
+
|
|
392
|
+
| 层级 | 技术选型 | 说明 |
|
|
393
|
+
|:---|:---|:---|
|
|
394
|
+
| **运行时** | {self.backend.title()} | 服务器运行时 |
|
|
395
|
+
| **框架** | {self._get_backend_framework()} | Web 框架 |
|
|
396
|
+
| **API 规范** | RESTful | 接口设计 |
|
|
397
|
+
| **认证** | JWT | Token 认证 |
|
|
398
|
+
| **ORM** | {self._get_orm()} | 数据库 ORM |
|
|
399
|
+
| **验证** | Joi/Zod | 数据验证 |
|
|
400
|
+
|
|
401
|
+
{self._generate_ai_ml_stack()}
|
|
402
|
+
|
|
403
|
+
### 2.3 数据存储
|
|
404
|
+
|
|
405
|
+
| 存储 | 技术选型 | 用途 |
|
|
406
|
+
|:---|:---|:---|
|
|
407
|
+
| **主数据库** | {self._get_database()} | 持久化存储 |
|
|
408
|
+
| **缓存** | Redis | 缓存层 |
|
|
409
|
+
| **文件存储** | {self._get_file_storage()} | 文件/图片 |
|
|
410
|
+
| **搜索** | Elasticsearch | 全文搜索 |
|
|
411
|
+
|
|
412
|
+
### 2.4 基础设施
|
|
413
|
+
|
|
414
|
+
| 组件 | 技术选型 | 说明 |
|
|
415
|
+
|:---|:---|:---|
|
|
416
|
+
| **容器化** | Docker | 应用容器 |
|
|
417
|
+
| **编排** | Kubernetes | 容器编排 |
|
|
418
|
+
| **CI/CD** | GitHub Actions | 持续集成 |
|
|
419
|
+
| **监控** | Prometheus + Grafana | 指标监控 |
|
|
420
|
+
| **日志** | ELK Stack | 日志分析 |
|
|
421
|
+
| **追踪** | Jaeger | 分布式追踪 |
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
425
|
+
## 3. 系统架构
|
|
426
|
+
|
|
427
|
+
### 3.1 整体架构图
|
|
428
|
+
|
|
429
|
+
```
|
|
430
|
+
┌─────────────────────────────────────────────────────────┐
|
|
431
|
+
│ 用户层 │
|
|
432
|
+
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
|
|
433
|
+
│ │ Web App │ │ iOS App │ │ Android │ │
|
|
434
|
+
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
|
|
435
|
+
└───────┼────────────┼────────────┼────────────────────────┘
|
|
436
|
+
│ │ │
|
|
437
|
+
┌───────┼────────────┼────────────┼────────────────────────┐
|
|
438
|
+
│ │ CDN │ │ │
|
|
439
|
+
│ ┌────▼────────────┴────────┐ │ │
|
|
440
|
+
│ │ 负载均衡器 │ │ │
|
|
441
|
+
│ └──────┬────────────────────┘ │ │
|
|
442
|
+
└─────────┼─────────────────────────┼──────────────────────┘
|
|
443
|
+
│ │
|
|
444
|
+
┌─────────┼─────────────────────────┼──────────────────────┐
|
|
445
|
+
│ │ API 网关层 │ │
|
|
446
|
+
│ ┌──────▼─────────────────────────▼──┐ │
|
|
447
|
+
│ │ API Gateway (Kong / Nginx) │ │
|
|
448
|
+
│ │ - 认证授权 │ │
|
|
449
|
+
│ │ - 限流熔断 │ │
|
|
450
|
+
│ │ - 路由转发 │ │
|
|
451
|
+
│ └──────┬────────────────────────────┘ │
|
|
452
|
+
└─────────┼──────────────────────────────────────────────┘
|
|
453
|
+
│
|
|
454
|
+
┌─────────┼──────────────────────────────────────────────┐
|
|
455
|
+
│ │ 服务层 │
|
|
456
|
+
│ ┌──────▼──────┐ ┌──────────┐ ┌──────────┐ │
|
|
457
|
+
│ │ API 服务 │ │ Auth 服务 │ │ User 服务 │ ... │
|
|
458
|
+
│ └─────────────┘ └──────────┘ └──────────┘ │
|
|
459
|
+
└─────────┼──────────────────────────────────────────────┘
|
|
460
|
+
│
|
|
461
|
+
┌─────────┼──────────────────────────────────────────────┐
|
|
462
|
+
│ │ 数据层 │
|
|
463
|
+
│ ┌──────▼──────┐ ┌──────────┐ ┌──────────┐ │
|
|
464
|
+
│ │ PostgreSQL │ │ Redis │ │ S3 │ │
|
|
465
|
+
│ └─────────────┘ └──────────┘ └──────────┘ │
|
|
466
|
+
└─────────────────────────────────────────────────────────┘
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### 3.2 分层架构
|
|
470
|
+
|
|
471
|
+
#### 3.2.1 表现层 (Presentation Layer)
|
|
472
|
+
|
|
473
|
+
- **职责**: 用户界面、交互逻辑
|
|
474
|
+
- **技术**: {self.frontend.title()} + {self._get_ui_library()}
|
|
475
|
+
- **组件**:
|
|
476
|
+
- 页面组件 (Pages)
|
|
477
|
+
- 业务组件 (Components)
|
|
478
|
+
- 布局组件 (Layouts)
|
|
479
|
+
- 服务层 (Services)
|
|
480
|
+
|
|
481
|
+
#### 3.2.2 API 层 (API Layer)
|
|
482
|
+
|
|
483
|
+
- **职责**: 请求处理、协议转换
|
|
484
|
+
- **技术**: {self._get_backend_framework()}
|
|
485
|
+
- **组件**:
|
|
486
|
+
- 路由定义
|
|
487
|
+
- 中间件
|
|
488
|
+
- 控制器
|
|
489
|
+
- 请求验证
|
|
490
|
+
|
|
491
|
+
#### 3.2.3 业务层 (Business Layer)
|
|
492
|
+
|
|
493
|
+
- **职责**: 业务逻辑、规则引擎
|
|
494
|
+
- **组件**:
|
|
495
|
+
- 服务
|
|
496
|
+
- 领域模型
|
|
497
|
+
- 业务规则
|
|
498
|
+
- 工作流引擎
|
|
499
|
+
|
|
500
|
+
#### 3.2.4 数据访问层 (Data Access Layer)
|
|
501
|
+
|
|
502
|
+
- **职责**: 数据持久化、缓存管理
|
|
503
|
+
- **技术**: {self._get_orm()} + Redis
|
|
504
|
+
- **组件**:
|
|
505
|
+
- Repository
|
|
506
|
+
- DAO
|
|
507
|
+
- Cache Manager
|
|
508
|
+
- Transaction Manager
|
|
509
|
+
|
|
510
|
+
---
|
|
511
|
+
|
|
512
|
+
## 4. 核心模块设计
|
|
513
|
+
|
|
514
|
+
### 4.1 认证授权模块
|
|
515
|
+
|
|
516
|
+
{self._generate_auth_module_design()}
|
|
517
|
+
|
|
518
|
+
### 4.2 用户管理模块
|
|
519
|
+
|
|
520
|
+
{self._generate_user_module_design()}
|
|
521
|
+
|
|
522
|
+
### 4.3 业务模块
|
|
523
|
+
|
|
524
|
+
{self._generate_business_module_design()}
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
## 5. 数据库设计
|
|
529
|
+
|
|
530
|
+
### 5.1 数据库选型
|
|
531
|
+
|
|
532
|
+
**主数据库**: PostgreSQL
|
|
533
|
+
- 理由: 成熟稳定、功能丰富、ACID 支持
|
|
534
|
+
- 版本: PostgreSQL 14+
|
|
535
|
+
|
|
536
|
+
**缓存**: Redis
|
|
537
|
+
- 理由: 高性能、数据结构丰富
|
|
538
|
+
- 用途: 会话存储、热点数据缓存
|
|
539
|
+
|
|
540
|
+
### 5.2 表结构设计
|
|
541
|
+
|
|
542
|
+
{self._generate_database_schema()}
|
|
543
|
+
|
|
544
|
+
### 5.3 索引策略
|
|
545
|
+
|
|
546
|
+
{self._generate_index_strategy()}
|
|
547
|
+
|
|
548
|
+
---
|
|
549
|
+
|
|
550
|
+
## 6. API 设计
|
|
551
|
+
|
|
552
|
+
### 6.1 RESTful 规范
|
|
553
|
+
|
|
554
|
+
```
|
|
555
|
+
GET /api/resources # 列表
|
|
556
|
+
GET /api/resources/:id # 详情
|
|
557
|
+
POST /api/resources # 创建
|
|
558
|
+
PUT /api/resources/:id # 更新
|
|
559
|
+
PATCH /api/resources/:id # 部分更新
|
|
560
|
+
DELETE /api/resources/:id # 删除
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### 6.2 核心 API 端点
|
|
564
|
+
|
|
565
|
+
{self._generate_api_endpoints()}
|
|
566
|
+
|
|
567
|
+
### 6.3 错误码规范
|
|
568
|
+
|
|
569
|
+
```
|
|
570
|
+
200 OK # 成功
|
|
571
|
+
201 Created # 创建成功
|
|
572
|
+
400 Bad Request # 请求错误
|
|
573
|
+
401 Unauthorized # 未认证
|
|
574
|
+
403 Forbidden # 无权限
|
|
575
|
+
404 Not Found # 不存在
|
|
576
|
+
422 Unprocessable # 验证失败
|
|
577
|
+
500 Server Error # 服务器错误
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
---
|
|
581
|
+
|
|
582
|
+
## 7. 安全设计
|
|
583
|
+
|
|
584
|
+
### 7.1 认证机制
|
|
585
|
+
|
|
586
|
+
- **方式**: JWT (JSON Web Token)
|
|
587
|
+
- **流程**:
|
|
588
|
+
1. 用户登录获取 Token
|
|
589
|
+
2. 请求携带 Token
|
|
590
|
+
3. 服务验证 Token
|
|
591
|
+
4. Token 过期重新获取
|
|
592
|
+
|
|
593
|
+
### 7.2 授权机制
|
|
594
|
+
|
|
595
|
+
- **模型**: RBAC (Role-Based Access Control)
|
|
596
|
+
- **角色**:
|
|
597
|
+
- 超级管理员
|
|
598
|
+
- 管理员
|
|
599
|
+
- 普通用户
|
|
600
|
+
- 访客
|
|
601
|
+
|
|
602
|
+
### 7.3 数据加密
|
|
603
|
+
|
|
604
|
+
- **传输加密**: TLS 1.3
|
|
605
|
+
- **存储加密**: AES-256
|
|
606
|
+
- **密码加密**: bcrypt
|
|
607
|
+
|
|
608
|
+
### 7.4 安全防护
|
|
609
|
+
|
|
610
|
+
- **SQL 注入**: 参数化查询
|
|
611
|
+
- **XSS**: 输出转义
|
|
612
|
+
- **CSRF**: Token 验证
|
|
613
|
+
- **限流**: 令牌桶算法
|
|
614
|
+
|
|
615
|
+
---
|
|
616
|
+
|
|
617
|
+
## 8. 性能设计
|
|
618
|
+
|
|
619
|
+
### 8.1 性能目标
|
|
620
|
+
|
|
621
|
+
| 指标 | 目标值 |
|
|
622
|
+
|:---|:---|
|
|
623
|
+
| **API 响应时间** | P50 < 100ms, P95 < 200ms, P99 < 500ms |
|
|
624
|
+
| **页面加载时间** | FCP < 1.5s, LCP < 2.5s |
|
|
625
|
+
| **并发用户** | 1000+ 并发 |
|
|
626
|
+
| **QPS** | 5000+ QPS |
|
|
627
|
+
|
|
628
|
+
### 8.2 性能优化策略
|
|
629
|
+
|
|
630
|
+
{self._generate_performance_optimization()}
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
634
|
+
## 9. 可观测性
|
|
635
|
+
|
|
636
|
+
### 9.1 监控指标
|
|
637
|
+
|
|
638
|
+
- **系统指标**: CPU、内存、磁盘、网络
|
|
639
|
+
- **应用指标**: QPS、响应时间、错误率
|
|
640
|
+
- **业务指标**: DAU、订单量、转化率
|
|
641
|
+
|
|
642
|
+
### 9.2 日志规范
|
|
643
|
+
|
|
644
|
+
- **格式**: JSON
|
|
645
|
+
- **级别**: DEBUG, INFO, WARN, ERROR
|
|
646
|
+
- **内容**: 时间戳、级别、消息、上下文
|
|
647
|
+
|
|
648
|
+
### 9.3 告警策略
|
|
649
|
+
|
|
650
|
+
- **告警渠道**: 邮件、钉钉、PagerDuty
|
|
651
|
+
- **告警级别**: P0-P4
|
|
652
|
+
- **响应时间**: P0 < 15min, P1 < 30min
|
|
653
|
+
|
|
654
|
+
---
|
|
655
|
+
|
|
656
|
+
## 10. 部署架构
|
|
657
|
+
|
|
658
|
+
### 10.1 容器化
|
|
659
|
+
|
|
660
|
+
```dockerfile
|
|
661
|
+
# 多阶段构建
|
|
662
|
+
FROM node:18-alpine AS builder
|
|
663
|
+
WORKDIR /app
|
|
664
|
+
COPY package*.json ./
|
|
665
|
+
RUN npm ci
|
|
666
|
+
COPY . .
|
|
667
|
+
RUN npm run build
|
|
668
|
+
|
|
669
|
+
FROM node:18-alpine
|
|
670
|
+
WORKDIR /app
|
|
671
|
+
COPY --from=builder /app/dist ./dist
|
|
672
|
+
COPY package*.json ./
|
|
673
|
+
RUN npm ci --production
|
|
674
|
+
EXPOSE 3000
|
|
675
|
+
CMD ["npm", "start"]
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
### 10.2 Kubernetes 部署
|
|
679
|
+
|
|
680
|
+
{self._generate_k8s_config()}
|
|
681
|
+
|
|
682
|
+
### 10.3 CI/CD 流程
|
|
683
|
+
|
|
684
|
+
```yaml
|
|
685
|
+
# GitHub Actions
|
|
686
|
+
name: CI/CD
|
|
687
|
+
on: [push]
|
|
688
|
+
jobs:
|
|
689
|
+
test:
|
|
690
|
+
runs-on: ubuntu-latest
|
|
691
|
+
steps:
|
|
692
|
+
- uses: actions/checkout@v3
|
|
693
|
+
- name: Run tests
|
|
694
|
+
run: npm test
|
|
695
|
+
deploy:
|
|
696
|
+
needs: test
|
|
697
|
+
runs-on: ubuntu-latest
|
|
698
|
+
if: github.ref == 'refs/heads/main'
|
|
699
|
+
steps:
|
|
700
|
+
- name: Deploy to production
|
|
701
|
+
run: kubectl apply -f k8s/
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
---
|
|
705
|
+
|
|
706
|
+
## 附录
|
|
707
|
+
|
|
708
|
+
### A. 技术选型对比
|
|
709
|
+
|
|
710
|
+
{self._generate_tech_comparison()}
|
|
711
|
+
|
|
712
|
+
### B. 架构决策记录 (ADR)
|
|
713
|
+
|
|
714
|
+
{self._generate_adr()}
|
|
715
|
+
|
|
716
|
+
### C. 参考文档
|
|
717
|
+
|
|
718
|
+
- [12-Factor App](https://12factor.net/)
|
|
719
|
+
- [Microservices Patterns](https://microservices.io/patterns/)
|
|
720
|
+
- [REST API Design](https://restfulapi.net/)
|
|
721
|
+
"""
|
|
722
|
+
|
|
723
|
+
def generate_uiux(self) -> str:
|
|
724
|
+
"""生成智能 UI/UX 设计文档(基于设计引擎推荐)"""
|
|
725
|
+
# 获取智能设计推荐
|
|
726
|
+
recommendations = self._get_design_recommendations()
|
|
727
|
+
analysis = self._analyze_project_for_design()
|
|
728
|
+
|
|
729
|
+
# 构建文档
|
|
730
|
+
doc_parts = []
|
|
731
|
+
|
|
732
|
+
# 文档头部
|
|
733
|
+
doc_parts.append(f"""# {self.name} - UI/UX 设计文档
|
|
734
|
+
|
|
735
|
+
> **生成时间**: {datetime.now().strftime('%Y-%m-%d %H:%M')}
|
|
736
|
+
> **版本**: v2.0.0
|
|
737
|
+
> **设计师**: Super Dev UI/UX 专家
|
|
738
|
+
|
|
739
|
+
---
|
|
740
|
+
|
|
741
|
+
## 0. 设计分析
|
|
742
|
+
|
|
743
|
+
### 0.1 项目特征
|
|
744
|
+
|
|
745
|
+
基于需求描述,AI 分析出以下项目特征:
|
|
746
|
+
|
|
747
|
+
| 特征 | 分析结果 | 说明 |
|
|
748
|
+
|:---|:---|:---|
|
|
749
|
+
| **产品类型** | {analysis['product_type'].title()} | {self._get_product_type_desc(analysis['product_type'])} |
|
|
750
|
+
| **行业领域** | {analysis['industry'].title()} | {self._get_industry_desc(analysis['industry'])} |
|
|
751
|
+
| **风格倾向** | {analysis['style'].title()} | {self._get_style_desc(analysis['style'])} |
|
|
752
|
+
| **技术栈** | {self.frontend.upper()} | 前端框架 |
|
|
753
|
+
|
|
754
|
+
### 0.2 设计推荐摘要
|
|
755
|
+
|
|
756
|
+
AI 基于项目特征,从设计数据库中为您推荐:
|
|
757
|
+
|
|
758
|
+
""")
|
|
759
|
+
|
|
760
|
+
# 添加推荐摘要
|
|
761
|
+
if recommendations.get('styles'):
|
|
762
|
+
doc_parts.append(f"""**推荐风格**: {', '.join([s.get('name', s.get('Style Category', 'Unknown')) for s in recommendations['styles'][:2]])}
|
|
763
|
+
""")
|
|
764
|
+
|
|
765
|
+
if recommendations.get('colors'):
|
|
766
|
+
color = recommendations['colors']
|
|
767
|
+
doc_parts.append(f"""**推荐配色**: {color.get('name', color.get('Palette Name', 'Standard'))}
|
|
768
|
+
""")
|
|
769
|
+
|
|
770
|
+
if recommendations.get('fonts'):
|
|
771
|
+
doc_parts.append(f"""**推荐字体**: {', '.join([f.get('Font Pairing Name', 'Professional') for f in recommendations['fonts'][:2]])}
|
|
772
|
+
""")
|
|
773
|
+
|
|
774
|
+
doc_parts.append("""
|
|
775
|
+
---
|
|
776
|
+
|
|
777
|
+
## 1. 设计概述
|
|
778
|
+
|
|
779
|
+
### 1.1 设计理念
|
|
780
|
+
|
|
781
|
+
- **简洁**: 去除不必要的元素
|
|
782
|
+
- **一致**: 统一的视觉语言
|
|
783
|
+
- **高效**: 快速完成任务
|
|
784
|
+
- **愉悦**: 细节打磨体验
|
|
785
|
+
|
|
786
|
+
### 1.2 设计原则
|
|
787
|
+
|
|
788
|
+
1. **用户中心**: 以用户需求为出发点
|
|
789
|
+
2. **数据驱动**: 基于数据迭代设计
|
|
790
|
+
3. **移动优先**: 响应式设计
|
|
791
|
+
4. **无障碍**: 符合 WCAG 2.1 AA
|
|
792
|
+
|
|
793
|
+
---
|
|
794
|
+
|
|
795
|
+
## 2. 设计系统
|
|
796
|
+
|
|
797
|
+
### 2.1 色彩规范
|
|
798
|
+
|
|
799
|
+
""")
|
|
800
|
+
|
|
801
|
+
# 智能配色推荐
|
|
802
|
+
if recommendations.get('colors'):
|
|
803
|
+
color = recommendations['colors']
|
|
804
|
+
doc_parts.append(f"""#### 推荐配色方案: {color.get('name', 'Professional Palette')}
|
|
805
|
+
|
|
806
|
+
**推荐理由**: 基于 {analysis['industry']} {analysis['product_type']} 产品的最佳实践
|
|
807
|
+
|
|
808
|
+
| 颜色 | 用途 | Hex | 备注 |
|
|
809
|
+
|:---|:---|:---|:---|
|
|
810
|
+
| **Primary** | 主要操作、强调 | {color.get('Primary (Hex)', '#2563EB')} | 主色调 |
|
|
811
|
+
| **Secondary** | 次要操作 | {color.get('Secondary (Hex)', '#64748B')} | 辅助色 |
|
|
812
|
+
| **CTA** | 行动号召 | {color.get('CTA (Hex)', '#2563EB')} | 转化按钮 |
|
|
813
|
+
| **Background** | 页面背景 | {color.get('Background (Hex)', '#F9FAFB')} | 背景色 |
|
|
814
|
+
| **Text** | 正文文本 | {color.get('Text (Hex)', '#111827')} | 文本色 |
|
|
815
|
+
| **Border** | 边框线条 | {color.get('Border (Hex)', '#E5E7EB')} | 分割线 |
|
|
816
|
+
|
|
817
|
+
**Tailwind 配置**:
|
|
818
|
+
```javascript
|
|
819
|
+
// tailwind.config.js
|
|
820
|
+
module.exports = {{
|
|
821
|
+
theme: {{
|
|
822
|
+
extend: {{
|
|
823
|
+
colors: {{
|
|
824
|
+
primary: '{color.get('Primary (Hex)', '#2563EB')}',
|
|
825
|
+
secondary: '{color.get('Secondary (Hex)', '#64748B')}',
|
|
826
|
+
cta: '{color.get('CTA (Hex)', '#2563EB')}',
|
|
827
|
+
}}
|
|
828
|
+
}}
|
|
829
|
+
}}
|
|
830
|
+
}}
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
---
|
|
834
|
+
|
|
835
|
+
""")
|
|
836
|
+
else:
|
|
837
|
+
# 默认配色
|
|
838
|
+
doc_parts.append("""#### 主色调
|
|
839
|
+
|
|
840
|
+
| 颜色 | 用途 | Hex | RGB |
|
|
841
|
+
|:---|:---|:---|:---|
|
|
842
|
+
| **Primary** | 主要操作、强调 | #2563EB | rgb(37, 99, 235) |
|
|
843
|
+
| **Secondary** | 次要操作 | #64748B | rgb(100, 116, 139) |
|
|
844
|
+
| **Success** | 成功状态 | #10B981 | rgb(16, 185, 129) |
|
|
845
|
+
| **Warning** | 警告状态 | #F59E0B | rgb(245, 158, 11) |
|
|
846
|
+
| **Error** | 错误状态 | #EF4444 | rgb(239, 68, 68) |
|
|
847
|
+
|
|
848
|
+
---
|
|
849
|
+
|
|
850
|
+
""")
|
|
851
|
+
|
|
852
|
+
# 智能字体推荐
|
|
853
|
+
doc_parts.append("""### 2.2 字体规范
|
|
854
|
+
""")
|
|
855
|
+
|
|
856
|
+
if recommendations.get('fonts'):
|
|
857
|
+
doc_parts.append("""#### 推荐字体组合
|
|
858
|
+
|
|
859
|
+
""")
|
|
860
|
+
for font in recommendations['fonts'][:2]:
|
|
861
|
+
doc_parts.append(f"""**{font.get('name', font.get('Font Pairing Name', 'Professional'))}**
|
|
862
|
+
- **Heading**: {font.get('heading_font', font.get('Heading Font', 'Inter'))}
|
|
863
|
+
- **Body**: {font.get('body_font', font.get('Body Font', 'Roboto'))}
|
|
864
|
+
- **风格**: {font.get('mood', font.get('Mood/Style Keywords', 'Professional'))}
|
|
865
|
+
- **适用**: {font.get('best_for', font.get('Best For', 'General purpose'))}
|
|
866
|
+
|
|
867
|
+
**Google Fonts 导入**:
|
|
868
|
+
```html
|
|
869
|
+
{font.get('css_import', font.get('CSS Import', '<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Roboto:wght@400;500&display=swap" rel="stylesheet">'))}
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
""")
|
|
873
|
+
else:
|
|
874
|
+
doc_parts.append("""#### 字体家族
|
|
875
|
+
|
|
876
|
+
```css
|
|
877
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
#### 字号层级
|
|
881
|
+
|
|
882
|
+
| 用途 | 大小 | 字重 | 行高 |
|
|
883
|
+
|:---|:---|:---|:---|
|
|
884
|
+
| **H1** | 32px | 700 | 1.2 |
|
|
885
|
+
| **H2** | 24px | 600 | 1.3 |
|
|
886
|
+
| **H3** | 20px | 600 | 1.4 |
|
|
887
|
+
| **Body** | 16px | 400 | 1.5 |
|
|
888
|
+
| **Caption** | 14px | 400 | 1.4 |
|
|
889
|
+
| **Button** | 16px | 600 | 1 |
|
|
890
|
+
|
|
891
|
+
---
|
|
892
|
+
|
|
893
|
+
""")
|
|
894
|
+
|
|
895
|
+
# 间距和圆角规范保持不变
|
|
896
|
+
doc_parts.append("""### 2.3 间距规范
|
|
897
|
+
|
|
898
|
+
使用 8px 基础单位:
|
|
899
|
+
- **xs**: 4px
|
|
900
|
+
- **sm**: 8px
|
|
901
|
+
- **md**: 16px
|
|
902
|
+
- **lg**: 24px
|
|
903
|
+
- **xl**: 32px
|
|
904
|
+
- **2xl**: 48px
|
|
905
|
+
|
|
906
|
+
### 2.4 圆角规范
|
|
907
|
+
|
|
908
|
+
| 元素 | 圆角 |
|
|
909
|
+
|:---|:---|
|
|
910
|
+
| **按钮** | 6px |
|
|
911
|
+
| **卡片** | 8px |
|
|
912
|
+
| **输入框** | 4px |
|
|
913
|
+
| **弹窗** | 12px |
|
|
914
|
+
|
|
915
|
+
---
|
|
916
|
+
|
|
917
|
+
## 3. 页面结构
|
|
918
|
+
|
|
919
|
+
### 3.1 整体布局
|
|
920
|
+
""")
|
|
921
|
+
|
|
922
|
+
# 如果有 Landing 页面推荐,添加它
|
|
923
|
+
if recommendations.get('landing'):
|
|
924
|
+
landing = recommendations['landing']
|
|
925
|
+
landing_sections = landing.get('sections', '')
|
|
926
|
+
if isinstance(landing_sections, list):
|
|
927
|
+
landing_sections_text = "\n".join(
|
|
928
|
+
f"- {s.get('name', s)}" if isinstance(s, dict) else f"- {s}"
|
|
929
|
+
for s in landing_sections[:8]
|
|
930
|
+
)
|
|
931
|
+
else:
|
|
932
|
+
landing_sections_text = str(landing_sections)
|
|
933
|
+
|
|
934
|
+
cta_strategy = landing.get('cta_strategy', {})
|
|
935
|
+
if isinstance(cta_strategy, dict):
|
|
936
|
+
cta_strategy_text = ", ".join(
|
|
937
|
+
f"{k}: {v}" for k, v in cta_strategy.items()
|
|
938
|
+
)
|
|
939
|
+
else:
|
|
940
|
+
cta_strategy_text = str(cta_strategy)
|
|
941
|
+
|
|
942
|
+
doc_parts.append(f"""
|
|
943
|
+
#### 推荐页面布局: {landing.get('name', 'Standard Layout')}
|
|
944
|
+
|
|
945
|
+
**布局类型**: {landing.get('category', 'classic').title()}
|
|
946
|
+
|
|
947
|
+
**页面结构**:
|
|
948
|
+
{landing_sections_text}
|
|
949
|
+
|
|
950
|
+
**CTA 策略**: {cta_strategy_text}
|
|
951
|
+
|
|
952
|
+
**转化优化**:
|
|
953
|
+
{chr(10).join(f"- {tip}" for tip in landing.get('conversion_tips', [])[:5])}
|
|
954
|
+
|
|
955
|
+
**适用场景**: {', '.join(landing.get('best_for', [])[:3])}
|
|
956
|
+
|
|
957
|
+
---
|
|
958
|
+
|
|
959
|
+
""")
|
|
960
|
+
else:
|
|
961
|
+
doc_parts.append("""
|
|
962
|
+
```
|
|
963
|
+
┌─────────────────────────────────────────────────┐
|
|
964
|
+
│ Header (Logo, Nav, User) │
|
|
965
|
+
├──────────┬──────────────────────────────────────┤
|
|
966
|
+
│ │ │
|
|
967
|
+
│ Sidebar │ Main Content │
|
|
968
|
+
│ (Nav) │ │
|
|
969
|
+
│ │ │
|
|
970
|
+
│ │ │
|
|
971
|
+
├──────────┴──────────────────────────────────────┤
|
|
972
|
+
│ Footer │
|
|
973
|
+
└─────────────────────────────────────────────────┘
|
|
974
|
+
```
|
|
975
|
+
|
|
976
|
+
---
|
|
977
|
+
|
|
978
|
+
""")
|
|
979
|
+
|
|
980
|
+
# 添加其他部分(保持原有的内容结构)
|
|
981
|
+
doc_parts.append(f"""### 3.2 导航结构
|
|
982
|
+
|
|
983
|
+
{self._generate_navigation_structure()}
|
|
984
|
+
|
|
985
|
+
---
|
|
986
|
+
|
|
987
|
+
## 4. 核心页面设计
|
|
988
|
+
|
|
989
|
+
### 4.1 登录页面
|
|
990
|
+
|
|
991
|
+
{self._generate_login_page_design()}
|
|
992
|
+
|
|
993
|
+
### 4.2 列表页面
|
|
994
|
+
|
|
995
|
+
{self._generate_list_page_design()}
|
|
996
|
+
|
|
997
|
+
### 4.3 详情页面
|
|
998
|
+
|
|
999
|
+
{self._generate_detail_page_design()}
|
|
1000
|
+
|
|
1001
|
+
### 4.4 表单页面
|
|
1002
|
+
|
|
1003
|
+
{self._generate_form_page_design()}
|
|
1004
|
+
|
|
1005
|
+
---
|
|
1006
|
+
|
|
1007
|
+
## 5. 组件设计
|
|
1008
|
+
|
|
1009
|
+
### 5.1 基础组件
|
|
1010
|
+
|
|
1011
|
+
{self._generate_base_components()}
|
|
1012
|
+
|
|
1013
|
+
### 5.2 业务组件
|
|
1014
|
+
|
|
1015
|
+
{self._generate_business_components()}
|
|
1016
|
+
|
|
1017
|
+
---
|
|
1018
|
+
|
|
1019
|
+
## 6. 交互设计
|
|
1020
|
+
|
|
1021
|
+
### 6.1 加载状态
|
|
1022
|
+
|
|
1023
|
+
- **页面加载**: 骨架屏
|
|
1024
|
+
- **按钮加载**: Spinner + 禁用
|
|
1025
|
+
- **数据加载**: Loading 动画
|
|
1026
|
+
|
|
1027
|
+
### 6.2 错误处理
|
|
1028
|
+
|
|
1029
|
+
- **网络错误**: 友好提示 + 重试按钮
|
|
1030
|
+
- **表单错误**: 字段级提示
|
|
1031
|
+
- **系统错误**: 错误页面 + 返回按钮
|
|
1032
|
+
|
|
1033
|
+
### 6.3 空状态
|
|
1034
|
+
|
|
1035
|
+
- **无数据**: 空状态插图 + 引导文案
|
|
1036
|
+
- **搜索无结果**: 提示 + 清空按钮
|
|
1037
|
+
|
|
1038
|
+
---
|
|
1039
|
+
|
|
1040
|
+
## 7. 响应式设计
|
|
1041
|
+
|
|
1042
|
+
### 7.1 断点定义
|
|
1043
|
+
|
|
1044
|
+
| 设备 | 宽度 | 说明 |
|
|
1045
|
+
|:---|:---|:---|
|
|
1046
|
+
| **Mobile** | < 640px | 手机竖屏 |
|
|
1047
|
+
| **Tablet** | 640px - 1024px | 平板/手机横屏 |
|
|
1048
|
+
| **Desktop** | 1024px - 1440px | 桌面 |
|
|
1049
|
+
| **Large** | > 1440px | 大屏 |
|
|
1050
|
+
|
|
1051
|
+
### 7.2 响应式策略
|
|
1052
|
+
|
|
1053
|
+
- **Mobile First**: 从小屏开始设计
|
|
1054
|
+
- **流式布局**: Flexbox + Grid
|
|
1055
|
+
- **响应式图片**: srcset + sizes
|
|
1056
|
+
- **响应式字体**: clamp() 函数
|
|
1057
|
+
|
|
1058
|
+
---
|
|
1059
|
+
|
|
1060
|
+
## 8. 用户流程
|
|
1061
|
+
|
|
1062
|
+
### 8.1 主要用户旅程
|
|
1063
|
+
|
|
1064
|
+
{self._generate_user_journeys_ui()}
|
|
1065
|
+
|
|
1066
|
+
### 8.2 交互流程图
|
|
1067
|
+
|
|
1068
|
+
```
|
|
1069
|
+
用户 → [页面] → [操作] → [反馈] → [下一步]
|
|
1070
|
+
```
|
|
1071
|
+
|
|
1072
|
+
---
|
|
1073
|
+
|
|
1074
|
+
## 9. 微交互
|
|
1075
|
+
|
|
1076
|
+
### 9.1 按钮交互
|
|
1077
|
+
|
|
1078
|
+
- **悬停**: 背景色变化
|
|
1079
|
+
- **点击**: 缩放动画
|
|
1080
|
+
- **禁用**: 透明度降低
|
|
1081
|
+
|
|
1082
|
+
### 9.2 表单交互
|
|
1083
|
+
|
|
1084
|
+
- **聚焦**: 边框高亮
|
|
1085
|
+
- **输入**: 实时验证
|
|
1086
|
+
- **提交**: Loading 状态
|
|
1087
|
+
|
|
1088
|
+
### 9.3 列表交互
|
|
1089
|
+
|
|
1090
|
+
- **悬停**: 操作按钮显示
|
|
1091
|
+
- **点击**: 选中状态
|
|
1092
|
+
- **拖拽**: 视觉反馈
|
|
1093
|
+
|
|
1094
|
+
---
|
|
1095
|
+
|
|
1096
|
+
## 10. 设计交付物
|
|
1097
|
+
|
|
1098
|
+
### A. 设计资产
|
|
1099
|
+
|
|
1100
|
+
- Figma 设计稿链接
|
|
1101
|
+
- 图标库 (Heroicons / Lucide)
|
|
1102
|
+
- 图片资源 (Unsplash / Pexels)
|
|
1103
|
+
|
|
1104
|
+
### B. 插件资源
|
|
1105
|
+
|
|
1106
|
+
- {self._get_ui_library()} 组件库
|
|
1107
|
+
- Figma 插件推荐
|
|
1108
|
+
|
|
1109
|
+
### C. 设计参考
|
|
1110
|
+
|
|
1111
|
+
- [Dribbble](https://dribbble.com/)
|
|
1112
|
+
- [Behance](https://www.behance.net/)
|
|
1113
|
+
- [Mobbin](https://mobbin.com/)
|
|
1114
|
+
""")
|
|
1115
|
+
|
|
1116
|
+
# 添加 UX 最佳实践部分
|
|
1117
|
+
if recommendations.get('ux_tips'):
|
|
1118
|
+
doc_parts.append("""
|
|
1119
|
+
|
|
1120
|
+
---
|
|
1121
|
+
|
|
1122
|
+
## 11. UX 最佳实践
|
|
1123
|
+
|
|
1124
|
+
基于项目特征,AI 为您推荐以下 UX 最佳实践:
|
|
1125
|
+
|
|
1126
|
+
""")
|
|
1127
|
+
for i, tip in enumerate(recommendations['ux_tips'][:5], 1):
|
|
1128
|
+
guideline = tip.get('guideline', tip)
|
|
1129
|
+
domain = guideline.get('domain', 'UX')
|
|
1130
|
+
domain_text = domain.value if hasattr(domain, 'value') else str(domain)
|
|
1131
|
+
complexity = guideline.get('complexity', 'medium')
|
|
1132
|
+
complexity_text = str(complexity).title()
|
|
1133
|
+
doc_parts.append(f"""### {i}. {guideline.get('topic', 'Best Practice')} ({domain_text})
|
|
1134
|
+
|
|
1135
|
+
**最佳实践**:
|
|
1136
|
+
{guideline.get('best_practice', 'Follow industry standards')}
|
|
1137
|
+
|
|
1138
|
+
**避免**:
|
|
1139
|
+
{guideline.get('anti_pattern', 'Common mistakes to avoid')}
|
|
1140
|
+
|
|
1141
|
+
**影响**: {guideline.get('impact', 'Improved user experience')}
|
|
1142
|
+
|
|
1143
|
+
**实施难度**: {complexity_text}
|
|
1144
|
+
|
|
1145
|
+
""")
|
|
1146
|
+
|
|
1147
|
+
return "\n".join(doc_parts)
|
|
1148
|
+
|
|
1149
|
+
def _get_product_type_desc(self, product_type: str) -> str:
|
|
1150
|
+
"""获取产品类型描述"""
|
|
1151
|
+
descs = {
|
|
1152
|
+
'saas': 'SaaS 软件服务,需要专业可信的设计',
|
|
1153
|
+
'ecommerce': '电商平台,注重转化和购买体验',
|
|
1154
|
+
'landing': '营销落地页,强调 CTA 和转化',
|
|
1155
|
+
'dashboard': '管理后台,注重数据展示和操作效率',
|
|
1156
|
+
'content': '内容平台,注重阅读体验',
|
|
1157
|
+
'general': '通用产品'
|
|
1158
|
+
}
|
|
1159
|
+
return descs.get(product_type, '常规产品')
|
|
1160
|
+
|
|
1161
|
+
def _get_industry_desc(self, industry: str) -> str:
|
|
1162
|
+
"""获取行业描述"""
|
|
1163
|
+
descs = {
|
|
1164
|
+
'healthcare': '医疗健康行业,需要传递安全、专业感',
|
|
1165
|
+
'fintech': '金融科技,需要信任、安全的设计语言',
|
|
1166
|
+
'education': '教育行业,需要亲和力、专业性',
|
|
1167
|
+
'general': '通用行业'
|
|
1168
|
+
}
|
|
1169
|
+
return descs.get(industry, '常规行业')
|
|
1170
|
+
|
|
1171
|
+
def _get_style_desc(self, style: str) -> str:
|
|
1172
|
+
"""获取风格描述"""
|
|
1173
|
+
descs = {
|
|
1174
|
+
'minimal': '极简风格,去除冗余,突出核心',
|
|
1175
|
+
'professional': '专业风格,商务、正式',
|
|
1176
|
+
'playful': '活泼风格,有趣、生动',
|
|
1177
|
+
'luxury': '奢华风格,高端、精致',
|
|
1178
|
+
'modern': '现代风格,时尚、前沿'
|
|
1179
|
+
}
|
|
1180
|
+
return descs.get(style, '现代风格')
|
|
1181
|
+
def _get_state_management(self) -> str:
|
|
1182
|
+
"""获取状态管理方案"""
|
|
1183
|
+
mapping = {
|
|
1184
|
+
"react": "Redux Toolkit / Zustand",
|
|
1185
|
+
"vue": "Pinia",
|
|
1186
|
+
"angular": "NgRx",
|
|
1187
|
+
"svelte": "Svelte Stores",
|
|
1188
|
+
}
|
|
1189
|
+
return mapping.get(self.frontend, "Context API")
|
|
1190
|
+
|
|
1191
|
+
def _get_ui_library(self) -> str:
|
|
1192
|
+
"""获取 UI 库"""
|
|
1193
|
+
mapping = {
|
|
1194
|
+
"react": "Ant Design / Chakra UI",
|
|
1195
|
+
"vue": "Element Plus / Naive UI",
|
|
1196
|
+
"angular": "Angular Material",
|
|
1197
|
+
"svelte": "Skeleton UI",
|
|
1198
|
+
}
|
|
1199
|
+
return mapping.get(self.frontend, "Custom")
|
|
1200
|
+
|
|
1201
|
+
def _get_build_tool(self) -> str:
|
|
1202
|
+
"""获取构建工具"""
|
|
1203
|
+
mapping = {
|
|
1204
|
+
"react": "Vite",
|
|
1205
|
+
"vue": "Vite",
|
|
1206
|
+
"angular": "Angular CLI",
|
|
1207
|
+
"svelte": "Vite",
|
|
1208
|
+
}
|
|
1209
|
+
return mapping.get(self.frontend, "Webpack")
|
|
1210
|
+
|
|
1211
|
+
def _get_backend_framework(self) -> str:
|
|
1212
|
+
"""获取后端框架"""
|
|
1213
|
+
mapping = {
|
|
1214
|
+
"node": "Express / Fastify / NestJS",
|
|
1215
|
+
"python": "FastAPI / Django",
|
|
1216
|
+
"go": "Gin / Echo",
|
|
1217
|
+
"java": "Spring Boot",
|
|
1218
|
+
}
|
|
1219
|
+
return mapping.get(self.backend, "Express")
|
|
1220
|
+
|
|
1221
|
+
def _get_database(self) -> str:
|
|
1222
|
+
"""获取数据库"""
|
|
1223
|
+
return "PostgreSQL 14+"
|
|
1224
|
+
|
|
1225
|
+
def _get_orm(self) -> str:
|
|
1226
|
+
"""获取 ORM"""
|
|
1227
|
+
mapping = {
|
|
1228
|
+
"node": "Prisma / TypeORM",
|
|
1229
|
+
"python": "SQLAlchemy / Django ORM",
|
|
1230
|
+
"go": "GORM",
|
|
1231
|
+
"java": "Hibernate / JPA",
|
|
1232
|
+
}
|
|
1233
|
+
return mapping.get(self.backend, "Prisma")
|
|
1234
|
+
|
|
1235
|
+
def _get_file_storage(self) -> str:
|
|
1236
|
+
"""获取文件存储"""
|
|
1237
|
+
return "AWS S3 / 阿里云 OSS"
|
|
1238
|
+
|
|
1239
|
+
def _generate_ai_ml_stack(self) -> str:
|
|
1240
|
+
"""生成 AI/ML 技术栈部分"""
|
|
1241
|
+
keywords = self._extract_tech_keywords()
|
|
1242
|
+
|
|
1243
|
+
# 检查是否有任何 AI/ML 相关技术
|
|
1244
|
+
has_ai_content = any([
|
|
1245
|
+
keywords["ai_frameworks"],
|
|
1246
|
+
keywords["agent_tools"],
|
|
1247
|
+
keywords["ml_libraries"],
|
|
1248
|
+
keywords["vector_stores"],
|
|
1249
|
+
keywords["orchestration"],
|
|
1250
|
+
keywords["other_keywords"],
|
|
1251
|
+
])
|
|
1252
|
+
|
|
1253
|
+
if not has_ai_content:
|
|
1254
|
+
return "" # 如果没有 AI/ML 内容,返回空字符串
|
|
1255
|
+
|
|
1256
|
+
# 构建 AI/ML 技术栈部分
|
|
1257
|
+
lines = ["### 2.2.1 AI/ML 技术栈", "", "| 层级 | 技术选型 | 说明 |", "|:---|:---|:---|"]
|
|
1258
|
+
|
|
1259
|
+
# AI 框架
|
|
1260
|
+
if keywords["ai_frameworks"]:
|
|
1261
|
+
for framework in keywords["ai_frameworks"]:
|
|
1262
|
+
lines.append(f"| **AI 框架** | {framework} | Agent 编排与开发 |")
|
|
1263
|
+
|
|
1264
|
+
# Agent 工具
|
|
1265
|
+
if keywords["agent_tools"]:
|
|
1266
|
+
for tool in keywords["agent_tools"]:
|
|
1267
|
+
lines.append(f"| **Agent 工具** | {tool} | Agent 构建与管理 |")
|
|
1268
|
+
|
|
1269
|
+
# ML 库
|
|
1270
|
+
if keywords["ml_libraries"]:
|
|
1271
|
+
for lib in keywords["ml_libraries"]:
|
|
1272
|
+
lines.append(f"| **ML 库** | {lib} | 机器学习模型 |")
|
|
1273
|
+
|
|
1274
|
+
# 向量数据库
|
|
1275
|
+
if keywords["vector_stores"]:
|
|
1276
|
+
for store in keywords["vector_stores"]:
|
|
1277
|
+
lines.append(f"| **向量数据库** | {store} | 向量存储与检索 |")
|
|
1278
|
+
|
|
1279
|
+
# 编排工具
|
|
1280
|
+
if keywords["orchestration"]:
|
|
1281
|
+
for tool in keywords["orchestration"]:
|
|
1282
|
+
lines.append(f"| **编排工具** | {tool} | 工作流编排 |")
|
|
1283
|
+
|
|
1284
|
+
# 其他关键词
|
|
1285
|
+
if keywords["other_keywords"]:
|
|
1286
|
+
for keyword in keywords["other_keywords"]:
|
|
1287
|
+
lines.append(f"| **核心能力** | {keyword} | 关键技术特性 |")
|
|
1288
|
+
|
|
1289
|
+
lines.append("")
|
|
1290
|
+
return "\n".join(lines)
|
|
1291
|
+
|
|
1292
|
+
def _generate_vision(self) -> str:
|
|
1293
|
+
"""生成产品愿景"""
|
|
1294
|
+
return f"""
|
|
1295
|
+
打造一个{self.description}的{self.platform.upper()}应用,
|
|
1296
|
+
为用户提供简单、高效、愉悦的使用体验。
|
|
1297
|
+
|
|
1298
|
+
我们相信:
|
|
1299
|
+
- **用户至上**: 一切以用户价值为导向
|
|
1300
|
+
- **简单至上**: 复杂的事情简单化
|
|
1301
|
+
- **体验至上**: 每个细节都精益求精
|
|
1302
|
+
"""
|
|
1303
|
+
|
|
1304
|
+
def _generate_target_users(self) -> str:
|
|
1305
|
+
"""生成目标用户"""
|
|
1306
|
+
return """
|
|
1307
|
+
**主要用户群体**:
|
|
1308
|
+
|
|
1309
|
+
1. **核心用户** (80%)
|
|
1310
|
+
- 年龄: 25-40 岁
|
|
1311
|
+
- 职业: 白领、自由职业者
|
|
1312
|
+
- 特征: 熟悉互联网、追求效率
|
|
1313
|
+
|
|
1314
|
+
2. **次要用户** (15%)
|
|
1315
|
+
- 年龄: 18-25 岁 / 40-50 岁
|
|
1316
|
+
- 特征: 学生/资深从业者
|
|
1317
|
+
|
|
1318
|
+
3. **潜在用户** (5%)
|
|
1319
|
+
- 特征: 对新功能感兴趣
|
|
1320
|
+
"""
|
|
1321
|
+
|
|
1322
|
+
def _generate_value_proposition(self) -> str:
|
|
1323
|
+
"""生成价值主张"""
|
|
1324
|
+
return f"""
|
|
1325
|
+
**核心价值**:
|
|
1326
|
+
|
|
1327
|
+
1. **省时**: 比 {self.description} 传统方式节省 50% 时间
|
|
1328
|
+
2. **省心**: 一站式解决方案,无需切换多个工具
|
|
1329
|
+
3. **省力**: 简洁直观,零学习成本
|
|
1330
|
+
"""
|
|
1331
|
+
|
|
1332
|
+
def _generate_core_features(self) -> str:
|
|
1333
|
+
"""生成核心功能"""
|
|
1334
|
+
# 从描述中提取业务领域关键词
|
|
1335
|
+
description_lower = self.description.lower()
|
|
1336
|
+
keywords = self._extract_tech_keywords()
|
|
1337
|
+
|
|
1338
|
+
# 基础功能(所有应用都有)
|
|
1339
|
+
base_features = """
|
|
1340
|
+
1. **用户认证与授权**
|
|
1341
|
+
- 注册/登录(邮箱/手机号)
|
|
1342
|
+
- 密码重置
|
|
1343
|
+
- JWT Token 认证
|
|
1344
|
+
- 第三方登录(可选)
|
|
1345
|
+
|
|
1346
|
+
2. **用户中心**
|
|
1347
|
+
- 个人资料管理
|
|
1348
|
+
- 账户安全设置
|
|
1349
|
+
- 偏好配置
|
|
1350
|
+
"""
|
|
1351
|
+
|
|
1352
|
+
# 根据业务领域生成核心功能
|
|
1353
|
+
business_features = ""
|
|
1354
|
+
|
|
1355
|
+
# 求职招聘领域
|
|
1356
|
+
if any(word in description_lower for word in ["求职", "招聘", "job", "resume", "career", "简历", "职位"]):
|
|
1357
|
+
business_features = """
|
|
1358
|
+
3. **简历管理**
|
|
1359
|
+
- 在线简历创建与编辑
|
|
1360
|
+
- 简历模板选择
|
|
1361
|
+
- 简历导入(上传 PDF/Word)
|
|
1362
|
+
- 简历预览与导出
|
|
1363
|
+
- 简历智能评分与优化建议
|
|
1364
|
+
|
|
1365
|
+
4. **职位搜索与推荐**
|
|
1366
|
+
- 职位搜索(关键词/地点/薪资)
|
|
1367
|
+
- 智能职位推荐
|
|
1368
|
+
- 职位收藏与对比
|
|
1369
|
+
- 职位订阅通知
|
|
1370
|
+
|
|
1371
|
+
5. **求职助手"""
|
|
1372
|
+
# 如果有 AI/Agent 相关技术,添加智能功能
|
|
1373
|
+
if keywords["ai_frameworks"] or keywords["agent_tools"] or "Multi-Agent System" in keywords["other_keywords"]:
|
|
1374
|
+
business_features += """
|
|
1375
|
+
- 多 Agent 智能求职助手:
|
|
1376
|
+
* **简历匹配 Agent**: JD 与简历匹配度分析,识别技能差距,提供优化建议
|
|
1377
|
+
* **简历优化 Agent**: 自动优化简历内容,提高匹配度
|
|
1378
|
+
* **职位推荐 Agent**: 基于用户画像智能推荐职位
|
|
1379
|
+
* **面试准备 Agent**: 模拟面试,提供问题预测和回答建议
|
|
1380
|
+
* **薪资谈判 Agent**: 分析市场薪资,提供谈判策略
|
|
1381
|
+
* **职业规划 Agent**: 基于行业趋势提供职业发展建议
|
|
1382
|
+
- 实时对话式求职咨询
|
|
1383
|
+
- 智能简历投递建议"""
|
|
1384
|
+
else:
|
|
1385
|
+
business_features += """
|
|
1386
|
+
- 求职进度跟踪
|
|
1387
|
+
- 面试提醒与日程管理
|
|
1388
|
+
- 求职数据分析"""
|
|
1389
|
+
|
|
1390
|
+
# 电商领域
|
|
1391
|
+
elif any(word in description_lower for word in ["电商", "商城", "shop", "store", "mall", "购物"]):
|
|
1392
|
+
business_features = """
|
|
1393
|
+
3. **商品管理**
|
|
1394
|
+
- 商品浏览与搜索
|
|
1395
|
+
- 商品分类与筛选
|
|
1396
|
+
- 商品详情与评价
|
|
1397
|
+
|
|
1398
|
+
4. **购物车与订单**
|
|
1399
|
+
- 购物车管理
|
|
1400
|
+
- 订单创建与支付
|
|
1401
|
+
- 物流跟踪
|
|
1402
|
+
|
|
1403
|
+
5. **用户中心**
|
|
1404
|
+
- 收藏夹
|
|
1405
|
+
- 浏览历史
|
|
1406
|
+
- 优惠券管理"""
|
|
1407
|
+
|
|
1408
|
+
# 内容/社区领域
|
|
1409
|
+
elif any(word in description_lower for word in ["内容", "社区", "content", "community", "blog", "forum", "社交"]):
|
|
1410
|
+
business_features = """
|
|
1411
|
+
3. **内容管理**
|
|
1412
|
+
- 内容发布与编辑
|
|
1413
|
+
- 富文本支持
|
|
1414
|
+
- 图片/视频上传
|
|
1415
|
+
|
|
1416
|
+
4. **社交互动**
|
|
1417
|
+
- 点赞/评论/分享
|
|
1418
|
+
- 关注作者
|
|
1419
|
+
- 消息通知"""
|
|
1420
|
+
|
|
1421
|
+
# 教育领域
|
|
1422
|
+
elif any(word in description_lower for word in ["教育", "培训", "education", "learning", "课程", "学习"]):
|
|
1423
|
+
business_features = """
|
|
1424
|
+
3. **课程管理**
|
|
1425
|
+
- 课程浏览与购买
|
|
1426
|
+
- 课程进度跟踪
|
|
1427
|
+
- 学习笔记
|
|
1428
|
+
|
|
1429
|
+
4. **学习互动**
|
|
1430
|
+
- 问答讨论
|
|
1431
|
+
- 作业提交
|
|
1432
|
+
- 在线测试"""
|
|
1433
|
+
|
|
1434
|
+
# 通用默认
|
|
1435
|
+
else:
|
|
1436
|
+
business_features = f"""
|
|
1437
|
+
3. **核心业务功能**
|
|
1438
|
+
- {self.description}
|
|
1439
|
+
- 数据管理与展示
|
|
1440
|
+
- 搜索与过滤
|
|
1441
|
+
- 数据导入/导出"""
|
|
1442
|
+
|
|
1443
|
+
return base_features + business_features
|
|
1444
|
+
|
|
1445
|
+
def _generate_extended_features(self) -> str:
|
|
1446
|
+
"""生成扩展功能"""
|
|
1447
|
+
return """
|
|
1448
|
+
1. **高级功能**
|
|
1449
|
+
- 数据导入/导出
|
|
1450
|
+
- 批量操作
|
|
1451
|
+
- 高级搜索
|
|
1452
|
+
|
|
1453
|
+
2. **协作功能**
|
|
1454
|
+
- 分享邀请
|
|
1455
|
+
- 权限管理
|
|
1456
|
+
- 活动日志
|
|
1457
|
+
|
|
1458
|
+
3. **分析功能**
|
|
1459
|
+
- 数据统计
|
|
1460
|
+
- 图表展示
|
|
1461
|
+
- 报告导出
|
|
1462
|
+
"""
|
|
1463
|
+
|
|
1464
|
+
def _generate_user_stories(self) -> str:
|
|
1465
|
+
"""生成用户故事"""
|
|
1466
|
+
return """
|
|
1467
|
+
| 作为 | 我想要 | 以便于 | 优先级 |
|
|
1468
|
+
|:---|:---|:---|:---:|
|
|
1469
|
+
| 用户 | 快速注册账户 | 开始使用 | P0 |
|
|
1470
|
+
| 用户 | 登录后查看数据 | 了解情况 | P0 |
|
|
1471
|
+
| 用户 | 搜索筛选数据 | 快速找到 | P1 |
|
|
1472
|
+
| 用户 | 导出数据 | 离线分析 | P2 |
|
|
1473
|
+
"""
|
|
1474
|
+
|
|
1475
|
+
def _generate_data_entities(self) -> str:
|
|
1476
|
+
"""生成数据实体"""
|
|
1477
|
+
return """
|
|
1478
|
+
### 用户实体
|
|
1479
|
+
|
|
1480
|
+
**属性**:
|
|
1481
|
+
- 用户 ID (UUID)
|
|
1482
|
+
- 用户名 (string)
|
|
1483
|
+
- 邮箱 (string, unique)
|
|
1484
|
+
- 密码哈希 (string)
|
|
1485
|
+
- 创建时间 (datetime)
|
|
1486
|
+
- 更新时间 (datetime)
|
|
1487
|
+
- 状态 (active/inactive)
|
|
1488
|
+
|
|
1489
|
+
### 会话实体
|
|
1490
|
+
|
|
1491
|
+
**属性**:
|
|
1492
|
+
- 会话 ID (UUID)
|
|
1493
|
+
- 用户 ID (FK)
|
|
1494
|
+
- Token (string)
|
|
1495
|
+
- 过期时间 (datetime)
|
|
1496
|
+
- 创建时间 (datetime)
|
|
1497
|
+
|
|
1498
|
+
### 审计日志实体
|
|
1499
|
+
|
|
1500
|
+
**属性**:
|
|
1501
|
+
- 日志 ID (UUID)
|
|
1502
|
+
- 用户 ID (FK)
|
|
1503
|
+
- 操作类型 (string)
|
|
1504
|
+
- 操作详情 (JSON)
|
|
1505
|
+
- IP 地址 (string)
|
|
1506
|
+
- 时间戳 (datetime)
|
|
1507
|
+
"""
|
|
1508
|
+
|
|
1509
|
+
def _generate_user_journeys(self) -> str:
|
|
1510
|
+
"""生成用户旅程"""
|
|
1511
|
+
return """
|
|
1512
|
+
**旅程 1: 新用户注册**
|
|
1513
|
+
|
|
1514
|
+
```
|
|
1515
|
+
发现产品 → 访问官网 → 点击注册 → 填写信息 → 验证邮箱 → 登录使用
|
|
1516
|
+
```
|
|
1517
|
+
|
|
1518
|
+
痛点: 注册流程太长
|
|
1519
|
+
优化: 社交登录一键注册
|
|
1520
|
+
|
|
1521
|
+
**旅程 2: 日常使用**
|
|
1522
|
+
|
|
1523
|
+
```
|
|
1524
|
+
登录 → 浏览内容 → 搜索筛选 → 查看详情 → 执行操作 → 退出
|
|
1525
|
+
```
|
|
1526
|
+
|
|
1527
|
+
关键点: 搜索响应速度、操作流畅度
|
|
1528
|
+
"""
|
|
1529
|
+
|
|
1530
|
+
def _generate_page_structure(self) -> str:
|
|
1531
|
+
"""生成页面结构"""
|
|
1532
|
+
return """
|
|
1533
|
+
**主要页面**:
|
|
1534
|
+
|
|
1535
|
+
1. **登录/注册页**
|
|
1536
|
+
- 登录表单
|
|
1537
|
+
- 注册表单
|
|
1538
|
+
- 忘记密码
|
|
1539
|
+
|
|
1540
|
+
2. **首页**
|
|
1541
|
+
- 欢迎信息
|
|
1542
|
+
- 快速入口
|
|
1543
|
+
- 数据概览
|
|
1544
|
+
|
|
1545
|
+
3. **列表页**
|
|
1546
|
+
- 搜索栏
|
|
1547
|
+
- 筛选器
|
|
1548
|
+
- 数据列表
|
|
1549
|
+
- 分页器
|
|
1550
|
+
|
|
1551
|
+
4. **详情页**
|
|
1552
|
+
- 详细信息
|
|
1553
|
+
- 相关操作
|
|
1554
|
+
- 返回按钮
|
|
1555
|
+
|
|
1556
|
+
5. **设置页**
|
|
1557
|
+
- 个人资料
|
|
1558
|
+
- 账户安全
|
|
1559
|
+
- 偏好设置
|
|
1560
|
+
"""
|
|
1561
|
+
|
|
1562
|
+
def _generate_business_rules(self) -> str:
|
|
1563
|
+
"""生成业务规则"""
|
|
1564
|
+
return """
|
|
1565
|
+
### 密码规则
|
|
1566
|
+
- 最小长度 8 位
|
|
1567
|
+
- 必须包含大小写字母、数字
|
|
1568
|
+
- 不能包含用户名
|
|
1569
|
+
- 90 天必须更换
|
|
1570
|
+
|
|
1571
|
+
### 访问规则
|
|
1572
|
+
- 连续失败 5 次锁定 30 分钟
|
|
1573
|
+
- Session 超时时间 2 小时
|
|
1574
|
+
- 同时在线设备限制 5 台
|
|
1575
|
+
|
|
1576
|
+
### 数据规则
|
|
1577
|
+
- 用户删除需保留 30 天
|
|
1578
|
+
- 敏感操作需要二次验证
|
|
1579
|
+
- 日志保留 180 天
|
|
1580
|
+
"""
|
|
1581
|
+
|
|
1582
|
+
def _generate_acceptance_criteria(self) -> str:
|
|
1583
|
+
"""生成验收标准"""
|
|
1584
|
+
return """
|
|
1585
|
+
### 功能验收
|
|
1586
|
+
- [ ] 用户可以使用邮箱注册
|
|
1587
|
+
- [ ] 用户可以使用密码登录
|
|
1588
|
+
- [ ] 用户可以重置密码
|
|
1589
|
+
- [ ] 登录状态保持 2 小时
|
|
1590
|
+
- [ ] 所有请求需要认证(除公开接口)
|
|
1591
|
+
|
|
1592
|
+
### 性能验收
|
|
1593
|
+
- [ ] 登录响应时间 < 500ms
|
|
1594
|
+
- [ ] API 响应时间 P95 < 200ms
|
|
1595
|
+
- [ ] 支持并发用户数 > 1000
|
|
1596
|
+
|
|
1597
|
+
### 安全验收
|
|
1598
|
+
- [ ] 密码使用 bcrypt 加密
|
|
1599
|
+
- [ ] Token 使用 JWT 签名
|
|
1600
|
+
- [ ] 所有输入验证防注入
|
|
1601
|
+
- [ ] 敏感操作有审计日志
|
|
1602
|
+
"""
|
|
1603
|
+
|
|
1604
|
+
def _generate_technical_risks(self) -> str:
|
|
1605
|
+
"""生成技术风险"""
|
|
1606
|
+
return """
|
|
1607
|
+
### 性能风险
|
|
1608
|
+
- 大量用户并发登录可能导致数据库压力
|
|
1609
|
+
- Token 验证可能成为瓶颈
|
|
1610
|
+
|
|
1611
|
+
**缓解方案**:
|
|
1612
|
+
- 使用 Redis 缓存活跃 Session
|
|
1613
|
+
- 实现无状态 JWT 验证
|
|
1614
|
+
|
|
1615
|
+
### 安全风险
|
|
1616
|
+
- 密码泄露风险
|
|
1617
|
+
- Session 劫持风险
|
|
1618
|
+
|
|
1619
|
+
**缓解方案**:
|
|
1620
|
+
- 使用 bcrypt 加密存储
|
|
1621
|
+
- 实现 CSRF 保护
|
|
1622
|
+
- 强制 HTTPS
|
|
1623
|
+
"""
|
|
1624
|
+
|
|
1625
|
+
def _generate_business_risks(self) -> str:
|
|
1626
|
+
"""生成业务风险"""
|
|
1627
|
+
return """
|
|
1628
|
+
### 用户体验风险
|
|
1629
|
+
- 密码复杂度要求可能导致用户流失
|
|
1630
|
+
- 多次验证可能影响注册转化
|
|
1631
|
+
|
|
1632
|
+
**缓解方案**:
|
|
1633
|
+
- 提供社交登录选项
|
|
1634
|
+
- 优化验证流程
|
|
1635
|
+
|
|
1636
|
+
### 合规风险
|
|
1637
|
+
- GDPR 数据保护要求
|
|
1638
|
+
- 密码存储安全标准
|
|
1639
|
+
|
|
1640
|
+
**缓解方案**:
|
|
1641
|
+
- 实现数据导出/删除功能
|
|
1642
|
+
- 定期安全审计
|
|
1643
|
+
"""
|
|
1644
|
+
|
|
1645
|
+
def _generate_dependencies(self) -> str:
|
|
1646
|
+
"""生成依赖关系"""
|
|
1647
|
+
return """
|
|
1648
|
+
### 外部依赖
|
|
1649
|
+
- 邮件服务 (SendGrid/阿里云)
|
|
1650
|
+
- 短信服务 (可选)
|
|
1651
|
+
- 社交登录 (OAuth2)
|
|
1652
|
+
|
|
1653
|
+
### 内部依赖
|
|
1654
|
+
- 用户服务 (提供用户信息)
|
|
1655
|
+
- 通知服务 (发送验证消息)
|
|
1656
|
+
- 审计服务 (记录操作日志)
|
|
1657
|
+
"""
|
|
1658
|
+
|
|
1659
|
+
def _generate_glossary(self) -> str:
|
|
1660
|
+
"""生成术语表"""
|
|
1661
|
+
return """
|
|
1662
|
+
| 术语 | 定义 |
|
|
1663
|
+
|:---|:---|
|
|
1664
|
+
| JWT | JSON Web Token,用于身份验证的令牌 |
|
|
1665
|
+
| Session | 用户会话,记录登录状态 |
|
|
1666
|
+
| 2FA | 双因素认证 |
|
|
1667
|
+
| RBAC | 基于角色的访问控制 |
|
|
1668
|
+
| CSRF | 跨站请求伪造 |
|
|
1669
|
+
"""
|
|
1670
|
+
|
|
1671
|
+
def _generate_references(self) -> str:
|
|
1672
|
+
"""生成参考资料"""
|
|
1673
|
+
return """
|
|
1674
|
+
### 技术标准
|
|
1675
|
+
- OWASP Top 10
|
|
1676
|
+
- RFC 6749 (OAuth 2.0)
|
|
1677
|
+
- RFC 7519 (JWT)
|
|
1678
|
+
|
|
1679
|
+
### 最佳实践
|
|
1680
|
+
- [OWASP Authentication Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html)
|
|
1681
|
+
- [JWT Best Practices](https://tools.ietf.org/html/rfc8725)
|
|
1682
|
+
"""
|
|
1683
|
+
|
|
1684
|
+
# ========== Architecture Document Methods ==========
|
|
1685
|
+
|
|
1686
|
+
def _generate_auth_module_design(self) -> str:
|
|
1687
|
+
"""生成认证模块设计"""
|
|
1688
|
+
return """
|
|
1689
|
+
### 认证模块 (Auth Module)
|
|
1690
|
+
|
|
1691
|
+
**职责**:
|
|
1692
|
+
- 用户注册/登录
|
|
1693
|
+
- Token 签发/验证
|
|
1694
|
+
- 密码管理
|
|
1695
|
+
|
|
1696
|
+
**接口**:
|
|
1697
|
+
```
|
|
1698
|
+
POST /api/v1/auth/register
|
|
1699
|
+
POST /api/v1/auth/login
|
|
1700
|
+
POST /api/v1/auth/logout
|
|
1701
|
+
POST /api/v1/auth/refresh
|
|
1702
|
+
POST /api/v1/auth/verify
|
|
1703
|
+
```
|
|
1704
|
+
|
|
1705
|
+
**实现要点**:
|
|
1706
|
+
- JWT Token 签发使用 RS256
|
|
1707
|
+
- Refresh Token 存储在 Redis
|
|
1708
|
+
- 密码使用 bcrypt (cost=10)
|
|
1709
|
+
"""
|
|
1710
|
+
|
|
1711
|
+
def _generate_user_module_design(self) -> str:
|
|
1712
|
+
"""生成用户模块设计"""
|
|
1713
|
+
return """
|
|
1714
|
+
### 用户模块 (User Module)
|
|
1715
|
+
|
|
1716
|
+
**职责**:
|
|
1717
|
+
- 用户信息管理
|
|
1718
|
+
- 权限验证
|
|
1719
|
+
- 用户状态管理
|
|
1720
|
+
|
|
1721
|
+
**接口**:
|
|
1722
|
+
```
|
|
1723
|
+
GET /api/v1/users/me
|
|
1724
|
+
PATCH /api/v1/users/me
|
|
1725
|
+
PUT /api/v1/users/me/password
|
|
1726
|
+
GET /api/v1/users/:id
|
|
1727
|
+
```
|
|
1728
|
+
|
|
1729
|
+
**实现要点**:
|
|
1730
|
+
- 实现乐观锁防止并发修改
|
|
1731
|
+
- 使用 RBAC 权限模型
|
|
1732
|
+
- 敏感操作需要二次验证
|
|
1733
|
+
"""
|
|
1734
|
+
|
|
1735
|
+
def _generate_business_module_design(self) -> str:
|
|
1736
|
+
"""生成业务模块设计"""
|
|
1737
|
+
return """
|
|
1738
|
+
### 业务模块 (Business Module)
|
|
1739
|
+
|
|
1740
|
+
**职责**:
|
|
1741
|
+
- 核心业务逻辑
|
|
1742
|
+
- 数据验证
|
|
1743
|
+
- 业务规则执行
|
|
1744
|
+
|
|
1745
|
+
**接口**:
|
|
1746
|
+
```
|
|
1747
|
+
GET /api/v1/resources
|
|
1748
|
+
POST /api/v1/resources
|
|
1749
|
+
GET /api/v1/resources/:id
|
|
1750
|
+
PATCH /api/v1/resources/:id
|
|
1751
|
+
DELETE /api/v1/resources/:id
|
|
1752
|
+
```
|
|
1753
|
+
|
|
1754
|
+
**实现要点**:
|
|
1755
|
+
- 实现幂等性
|
|
1756
|
+
- 数据验证使用 Pydantic/Zod
|
|
1757
|
+
- 审计日志记录所有变更
|
|
1758
|
+
"""
|
|
1759
|
+
|
|
1760
|
+
def _generate_database_schema(self) -> str:
|
|
1761
|
+
"""生成数据库设计"""
|
|
1762
|
+
return """
|
|
1763
|
+
### 表结构
|
|
1764
|
+
|
|
1765
|
+
**users 表**:
|
|
1766
|
+
```sql
|
|
1767
|
+
CREATE TABLE users (
|
|
1768
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
1769
|
+
username VARCHAR(50) UNIQUE NOT NULL,
|
|
1770
|
+
email VARCHAR(255) UNIQUE NOT NULL,
|
|
1771
|
+
password_hash VARCHAR(255) NOT NULL,
|
|
1772
|
+
status VARCHAR(20) DEFAULT 'active',
|
|
1773
|
+
created_at TIMESTAMP DEFAULT NOW(),
|
|
1774
|
+
updated_at TIMESTAMP DEFAULT NOW(),
|
|
1775
|
+
INDEX idx_email (email),
|
|
1776
|
+
INDEX idx_username (username)
|
|
1777
|
+
);
|
|
1778
|
+
```
|
|
1779
|
+
|
|
1780
|
+
**sessions 表**:
|
|
1781
|
+
```sql
|
|
1782
|
+
CREATE TABLE sessions (
|
|
1783
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
1784
|
+
user_id UUID NOT NULL REFERENCES users(id),
|
|
1785
|
+
token VARCHAR(500) UNIQUE NOT NULL,
|
|
1786
|
+
expires_at TIMESTAMP NOT NULL,
|
|
1787
|
+
created_at TIMESTAMP DEFAULT NOW(),
|
|
1788
|
+
INDEX idx_user_id (user_id),
|
|
1789
|
+
INDEX idx_token (token)
|
|
1790
|
+
);
|
|
1791
|
+
```
|
|
1792
|
+
|
|
1793
|
+
**audit_logs 表**:
|
|
1794
|
+
```sql
|
|
1795
|
+
CREATE TABLE audit_logs (
|
|
1796
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
1797
|
+
user_id UUID REFERENCES users(id),
|
|
1798
|
+
action VARCHAR(100) NOT NULL,
|
|
1799
|
+
details JSONB,
|
|
1800
|
+
ip_address INET,
|
|
1801
|
+
created_at TIMESTAMP DEFAULT NOW(),
|
|
1802
|
+
INDEX idx_user_id (user_id),
|
|
1803
|
+
INDEX idx_created_at (created_at)
|
|
1804
|
+
);
|
|
1805
|
+
```
|
|
1806
|
+
"""
|
|
1807
|
+
|
|
1808
|
+
def _generate_index_strategy(self) -> str:
|
|
1809
|
+
"""生成索引策略"""
|
|
1810
|
+
return """
|
|
1811
|
+
### 索引设计
|
|
1812
|
+
|
|
1813
|
+
| 表 | 索引 | 类型 | 用途 |
|
|
1814
|
+
|:---|:---|:---|:---|
|
|
1815
|
+
| users | idx_email | B-tree | 邮箱查询 |
|
|
1816
|
+
| users | idx_username | B-tree | 用户名查询 |
|
|
1817
|
+
| sessions | idx_user_id | B-tree | 用户会话查询 |
|
|
1818
|
+
| sessions | idx_token | B-tree | Token 验证 |
|
|
1819
|
+
| audit_logs | idx_user_id | B-tree | 用户审计日志 |
|
|
1820
|
+
| audit_logs | idx_created_at | B-tree | 时间范围查询 |
|
|
1821
|
+
|
|
1822
|
+
### 查询优化
|
|
1823
|
+
- 使用连接池 (pgbouncer)
|
|
1824
|
+
- 实现查询缓存层
|
|
1825
|
+
- 慢查询监控 (>100ms)
|
|
1826
|
+
"""
|
|
1827
|
+
|
|
1828
|
+
def _generate_api_endpoints(self) -> str:
|
|
1829
|
+
"""生成 API 端点"""
|
|
1830
|
+
return """
|
|
1831
|
+
### API 端点列表
|
|
1832
|
+
|
|
1833
|
+
#### 认证相关
|
|
1834
|
+
```
|
|
1835
|
+
POST /api/v1/auth/register # 用户注册
|
|
1836
|
+
POST /api/v1/auth/login # 用户登录
|
|
1837
|
+
POST /api/v1/auth/logout # 用户登出
|
|
1838
|
+
POST /api/v1/auth/refresh # 刷新 Token
|
|
1839
|
+
POST /api/v1/auth/verify # 验证 Token
|
|
1840
|
+
POST /api/v1/auth/forgot-password # 忘记密码
|
|
1841
|
+
POST /api/v1/auth/reset-password # 重置密码
|
|
1842
|
+
```
|
|
1843
|
+
|
|
1844
|
+
#### 用户相关
|
|
1845
|
+
```
|
|
1846
|
+
GET /api/v1/users/me # 当前用户信息
|
|
1847
|
+
PATCH /api/v1/users/me # 更新用户信息
|
|
1848
|
+
PUT /api/v1/users/me/password # 修改密码
|
|
1849
|
+
GET /api/v1/users/:id # 用户详情 (管理员)
|
|
1850
|
+
```
|
|
1851
|
+
|
|
1852
|
+
#### 业务资源
|
|
1853
|
+
```
|
|
1854
|
+
GET /api/v1/resources # 资源列表
|
|
1855
|
+
POST /api/v1/resources # 创建资源
|
|
1856
|
+
GET /api/v1/resources/:id # 资源详情
|
|
1857
|
+
PATCH /api/v1/resources/:id # 更新资源
|
|
1858
|
+
DELETE /api/v1/resources/:id # 删除资源
|
|
1859
|
+
```
|
|
1860
|
+
"""
|
|
1861
|
+
|
|
1862
|
+
def _generate_performance_optimization(self) -> str:
|
|
1863
|
+
"""生成性能优化"""
|
|
1864
|
+
return """
|
|
1865
|
+
### 后端优化
|
|
1866
|
+
|
|
1867
|
+
**数据库优化**:
|
|
1868
|
+
- 连接池配置 (max_connections=100)
|
|
1869
|
+
- 查询结果缓存 (Redis)
|
|
1870
|
+
- 慢查询日志优化
|
|
1871
|
+
|
|
1872
|
+
**应用层优化**:
|
|
1873
|
+
- 异步 I/O 处理
|
|
1874
|
+
- 请求限流 (100 req/s)
|
|
1875
|
+
- 响应压缩 (gzip)
|
|
1876
|
+
|
|
1877
|
+
**前端优化**:
|
|
1878
|
+
- 代码分割和懒加载
|
|
1879
|
+
- 资源 CDN 加速
|
|
1880
|
+
- 图片优化和缓存
|
|
1881
|
+
|
|
1882
|
+
### 监控指标
|
|
1883
|
+
- API 响应时间 P95 < 200ms
|
|
1884
|
+
- 数据库查询时间 < 50ms
|
|
1885
|
+
- 错误率 < 0.1%
|
|
1886
|
+
"""
|
|
1887
|
+
|
|
1888
|
+
def _generate_tech_comparison(self) -> str:
|
|
1889
|
+
"""生成技术对比"""
|
|
1890
|
+
return """
|
|
1891
|
+
### 技术选型对比
|
|
1892
|
+
|
|
1893
|
+
| 方面 | 选择 | 备选 | 理由 |
|
|
1894
|
+
|:---|:---|:---|:---|
|
|
1895
|
+
| 前端框架 | React | Vue, Angular | 生态成熟,组件丰富 |
|
|
1896
|
+
| 状态管理 | Redux Toolkit | Zustand, Jotai | 标准方案,文档完善 |
|
|
1897
|
+
| UI 库 | Ant Design | Material-UI | 设计规范完善 |
|
|
1898
|
+
| 后端框架 | Express | Fastify, Koa | 灵活,中间件丰富 |
|
|
1899
|
+
| ORM | Prisma | TypeORM, Sequelize | 类型安全,迁移友好 |
|
|
1900
|
+
| 数据库 | PostgreSQL | MySQL, MongoDB | 功能强大,JSON 支持 |
|
|
1901
|
+
| 缓存 | Redis | Memcached | 功能丰富,持久化 |
|
|
1902
|
+
"""
|
|
1903
|
+
|
|
1904
|
+
def _generate_adr(self) -> str:
|
|
1905
|
+
"""生成架构决策记录"""
|
|
1906
|
+
return """
|
|
1907
|
+
### 架构决策记录 (ADR)
|
|
1908
|
+
|
|
1909
|
+
#### ADR-001: 选择 JWT 作为认证方案
|
|
1910
|
+
|
|
1911
|
+
**状态**: 已接受
|
|
1912
|
+
|
|
1913
|
+
**背景**: 需要无状态的认证机制支持分布式部署
|
|
1914
|
+
|
|
1915
|
+
**决策**: 使用 JWT (JSON Web Token) 进行身份验证
|
|
1916
|
+
|
|
1917
|
+
**理由**:
|
|
1918
|
+
- 无状态,易于横向扩展
|
|
1919
|
+
- 标准化,跨语言支持
|
|
1920
|
+
- 包含声明,减少数据库查询
|
|
1921
|
+
|
|
1922
|
+
**后果**:
|
|
1923
|
+
- 优点: 无需 Session 存储,支持分布式
|
|
1924
|
+
- 缺点: Token 无法撤销,需要短过期时间
|
|
1925
|
+
|
|
1926
|
+
#### ADR-002: 选择 PostgreSQL 作为主数据库
|
|
1927
|
+
|
|
1928
|
+
**状态**: 已接受
|
|
1929
|
+
|
|
1930
|
+
**背景**: 需要关系型数据库支持复杂查询
|
|
1931
|
+
|
|
1932
|
+
**决策**: 使用 PostgreSQL 作为主数据库
|
|
1933
|
+
|
|
1934
|
+
**理由**:
|
|
1935
|
+
- 功能强大,支持 JSON、全文搜索
|
|
1936
|
+
- ACID 完整,数据一致性强
|
|
1937
|
+
- 开源免费,社区活跃
|
|
1938
|
+
|
|
1939
|
+
**后果**:
|
|
1940
|
+
- 优点: 数据完整性好,扩展性强
|
|
1941
|
+
- 缺点: 配置相对复杂
|
|
1942
|
+
"""
|
|
1943
|
+
|
|
1944
|
+
def _generate_k8s_config(self) -> str:
|
|
1945
|
+
"""生成 Kubernetes 配置"""
|
|
1946
|
+
return """
|
|
1947
|
+
### Deployment 配置
|
|
1948
|
+
|
|
1949
|
+
```yaml
|
|
1950
|
+
apiVersion: apps/v1
|
|
1951
|
+
kind: Deployment
|
|
1952
|
+
metadata:
|
|
1953
|
+
name: backend
|
|
1954
|
+
spec:
|
|
1955
|
+
replicas: 3
|
|
1956
|
+
selector:
|
|
1957
|
+
matchLabels:
|
|
1958
|
+
app: backend
|
|
1959
|
+
template:
|
|
1960
|
+
metadata:
|
|
1961
|
+
labels:
|
|
1962
|
+
app: backend
|
|
1963
|
+
spec:
|
|
1964
|
+
containers:
|
|
1965
|
+
- name: backend
|
|
1966
|
+
image: your-registry/backend:latest
|
|
1967
|
+
ports:
|
|
1968
|
+
- containerPort: 8080
|
|
1969
|
+
env:
|
|
1970
|
+
- name: DATABASE_URL
|
|
1971
|
+
valueFrom:
|
|
1972
|
+
secretKeyRef:
|
|
1973
|
+
name: db-secret
|
|
1974
|
+
key: url
|
|
1975
|
+
resources:
|
|
1976
|
+
requests:
|
|
1977
|
+
memory: "256Mi"
|
|
1978
|
+
cpu: "250m"
|
|
1979
|
+
limits:
|
|
1980
|
+
memory: "512Mi"
|
|
1981
|
+
cpu: "500m"
|
|
1982
|
+
livenessProbe:
|
|
1983
|
+
httpGet:
|
|
1984
|
+
path: /health
|
|
1985
|
+
port: 8080
|
|
1986
|
+
initialDelaySeconds: 30
|
|
1987
|
+
periodSeconds: 10
|
|
1988
|
+
readinessProbe:
|
|
1989
|
+
httpGet:
|
|
1990
|
+
path: /ready
|
|
1991
|
+
port: 8080
|
|
1992
|
+
initialDelaySeconds: 5
|
|
1993
|
+
periodSeconds: 5
|
|
1994
|
+
---
|
|
1995
|
+
apiVersion: v1
|
|
1996
|
+
kind: Service
|
|
1997
|
+
metadata:
|
|
1998
|
+
name: backend
|
|
1999
|
+
spec:
|
|
2000
|
+
selector:
|
|
2001
|
+
app: backend
|
|
2002
|
+
ports:
|
|
2003
|
+
- protocol: TCP
|
|
2004
|
+
port: 80
|
|
2005
|
+
targetPort: 8080
|
|
2006
|
+
type: LoadBalancer
|
|
2007
|
+
```
|
|
2008
|
+
|
|
2009
|
+
### ConfigMap 配置
|
|
2010
|
+
|
|
2011
|
+
```yaml
|
|
2012
|
+
apiVersion: v1
|
|
2013
|
+
kind: ConfigMap
|
|
2014
|
+
metadata:
|
|
2015
|
+
name: app-config
|
|
2016
|
+
data:
|
|
2017
|
+
LOG_LEVEL: "info"
|
|
2018
|
+
NODE_ENV: "production"
|
|
2019
|
+
```
|
|
2020
|
+
|
|
2021
|
+
### Secret 配置
|
|
2022
|
+
|
|
2023
|
+
```yaml
|
|
2024
|
+
apiVersion: v1
|
|
2025
|
+
kind: Secret
|
|
2026
|
+
metadata:
|
|
2027
|
+
name: db-secret
|
|
2028
|
+
type: Opaque
|
|
2029
|
+
stringData:
|
|
2030
|
+
url: "postgresql://user:pass@host:5432/db"
|
|
2031
|
+
```
|
|
2032
|
+
|
|
2033
|
+
### Ingress 配置
|
|
2034
|
+
|
|
2035
|
+
```yaml
|
|
2036
|
+
apiVersion: networking.k8s.io/v1
|
|
2037
|
+
kind: Ingress
|
|
2038
|
+
metadata:
|
|
2039
|
+
name: app-ingress
|
|
2040
|
+
annotations:
|
|
2041
|
+
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
|
2042
|
+
spec:
|
|
2043
|
+
tls:
|
|
2044
|
+
- hosts:
|
|
2045
|
+
- api.example.com
|
|
2046
|
+
secretName: app-tls
|
|
2047
|
+
rules:
|
|
2048
|
+
- host: api.example.com
|
|
2049
|
+
http:
|
|
2050
|
+
paths:
|
|
2051
|
+
- path: /
|
|
2052
|
+
pathType: Prefix
|
|
2053
|
+
backend:
|
|
2054
|
+
service:
|
|
2055
|
+
name: backend
|
|
2056
|
+
port:
|
|
2057
|
+
number: 80
|
|
2058
|
+
```
|
|
2059
|
+
"""
|
|
2060
|
+
|
|
2061
|
+
# ========== UI/UX Document Methods ==========
|
|
2062
|
+
|
|
2063
|
+
def _generate_navigation_structure(self) -> str:
|
|
2064
|
+
"""生成导航结构"""
|
|
2065
|
+
return """
|
|
2066
|
+
### 导航结构
|
|
2067
|
+
|
|
2068
|
+
**主导航**:
|
|
2069
|
+
- 首页
|
|
2070
|
+
- 功能模块
|
|
2071
|
+
- 设置
|
|
2072
|
+
- 帮助
|
|
2073
|
+
|
|
2074
|
+
**用户菜单**:
|
|
2075
|
+
- 个人资料
|
|
2076
|
+
- 账户安全
|
|
2077
|
+
- 通知设置
|
|
2078
|
+
- 退出登录
|
|
2079
|
+
|
|
2080
|
+
**面包屑**:
|
|
2081
|
+
- 显示当前页面路径
|
|
2082
|
+
- 支持快速返回上级
|
|
2083
|
+
"""
|
|
2084
|
+
|
|
2085
|
+
def _generate_login_page_design(self) -> str:
|
|
2086
|
+
"""生成登录页设计"""
|
|
2087
|
+
return """
|
|
2088
|
+
### 登录/注册页
|
|
2089
|
+
|
|
2090
|
+
**布局**:
|
|
2091
|
+
- 居中卡片式设计
|
|
2092
|
+
- 左侧品牌展示
|
|
2093
|
+
- 右侧表单区域
|
|
2094
|
+
|
|
2095
|
+
**表单元素**:
|
|
2096
|
+
- 邮箱输入框 (带验证)
|
|
2097
|
+
- 密码输入框 (带显示/隐藏)
|
|
2098
|
+
- 记住我复选框
|
|
2099
|
+
- 忘记密码链接
|
|
2100
|
+
- 登录按钮 (主操作)
|
|
2101
|
+
- 注册链接 (次要操作)
|
|
2102
|
+
|
|
2103
|
+
**交互**:
|
|
2104
|
+
- 输入框实时验证
|
|
2105
|
+
- 登录按钮 Loading 状态
|
|
2106
|
+
- 错误提示显示在表单顶部
|
|
2107
|
+
"""
|
|
2108
|
+
|
|
2109
|
+
def _generate_list_page_design(self) -> str:
|
|
2110
|
+
"""生成列表页设计"""
|
|
2111
|
+
return """
|
|
2112
|
+
### 列表页
|
|
2113
|
+
|
|
2114
|
+
**布局**:
|
|
2115
|
+
- 顶部搜索栏
|
|
2116
|
+
- 左侧筛选器
|
|
2117
|
+
- 右侧数据列表
|
|
2118
|
+
- 底部分页器
|
|
2119
|
+
|
|
2120
|
+
**列表项**:
|
|
2121
|
+
- 卡片式展示
|
|
2122
|
+
- 显示关键信息
|
|
2123
|
+
- 操作按钮组
|
|
2124
|
+
- 状态标签
|
|
2125
|
+
|
|
2126
|
+
**交互**:
|
|
2127
|
+
- 下拉加载更多
|
|
2128
|
+
- 搜索防抖 (300ms)
|
|
2129
|
+
- 筛选实时更新
|
|
2130
|
+
"""
|
|
2131
|
+
|
|
2132
|
+
def _generate_detail_page_design(self) -> str:
|
|
2133
|
+
"""生成详情页设计"""
|
|
2134
|
+
return """
|
|
2135
|
+
### 详情页
|
|
2136
|
+
|
|
2137
|
+
**布局**:
|
|
2138
|
+
- 顶部导航栏 (返回 + 操作)
|
|
2139
|
+
- 主要信息区
|
|
2140
|
+
- 相关信息区
|
|
2141
|
+
- 操作区
|
|
2142
|
+
|
|
2143
|
+
**信息层级**:
|
|
2144
|
+
- 标题 (H1)
|
|
2145
|
+
- 摘要
|
|
2146
|
+
- 详细内容
|
|
2147
|
+
- 元数据
|
|
2148
|
+
|
|
2149
|
+
**交互**:
|
|
2150
|
+
- 编辑/删除操作
|
|
2151
|
+
- 相关内容推荐
|
|
2152
|
+
- 快速导航
|
|
2153
|
+
"""
|
|
2154
|
+
|
|
2155
|
+
def _generate_form_page_design(self) -> str:
|
|
2156
|
+
"""生成表单页设计"""
|
|
2157
|
+
return """
|
|
2158
|
+
### 表单页
|
|
2159
|
+
|
|
2160
|
+
**布局**:
|
|
2161
|
+
- 左侧表单
|
|
2162
|
+
- 右侧预览 (可选)
|
|
2163
|
+
- 底部操作按钮
|
|
2164
|
+
|
|
2165
|
+
**表单元素**:
|
|
2166
|
+
- 必填项标记 (*)
|
|
2167
|
+
- 字段提示信息
|
|
2168
|
+
- 实时验证反馈
|
|
2169
|
+
- 保存/取消按钮
|
|
2170
|
+
|
|
2171
|
+
**交互**:
|
|
2172
|
+
- 表单验证
|
|
2173
|
+
- 草稿自动保存
|
|
2174
|
+
- 提交 Loading 状态
|
|
2175
|
+
"""
|
|
2176
|
+
|
|
2177
|
+
def _generate_base_components(self) -> str:
|
|
2178
|
+
"""生成基础组件"""
|
|
2179
|
+
return """
|
|
2180
|
+
### 基础组件库
|
|
2181
|
+
|
|
2182
|
+
**按钮 (Button)**:
|
|
2183
|
+
- 主要按钮
|
|
2184
|
+
- 次要按钮
|
|
2185
|
+
- 危险按钮
|
|
2186
|
+
- 文本按钮
|
|
2187
|
+
|
|
2188
|
+
**输入框 (Input)**:
|
|
2189
|
+
- 文本输入
|
|
2190
|
+
- 密码输入
|
|
2191
|
+
- 数字输入
|
|
2192
|
+
- 日期选择
|
|
2193
|
+
|
|
2194
|
+
**数据展示 (Data Display)**:
|
|
2195
|
+
- 表格
|
|
2196
|
+
- 卡片
|
|
2197
|
+
- 列表
|
|
2198
|
+
- 标签
|
|
2199
|
+
|
|
2200
|
+
**反馈 (Feedback)**:
|
|
2201
|
+
- 消息提示
|
|
2202
|
+
- 对话框
|
|
2203
|
+
- 加载状态
|
|
2204
|
+
- 空状态
|
|
2205
|
+
"""
|
|
2206
|
+
|
|
2207
|
+
def _generate_business_components(self) -> str:
|
|
2208
|
+
"""生成业务组件"""
|
|
2209
|
+
return """
|
|
2210
|
+
### 业务组件
|
|
2211
|
+
|
|
2212
|
+
**用户相关**:
|
|
2213
|
+
- 用户头像
|
|
2214
|
+
- 用户卡片
|
|
2215
|
+
- 用户选择器
|
|
2216
|
+
|
|
2217
|
+
**认证相关**:
|
|
2218
|
+
- 登录表单
|
|
2219
|
+
- 注册表单
|
|
2220
|
+
- 密码修改
|
|
2221
|
+
|
|
2222
|
+
**内容相关**:
|
|
2223
|
+
- 内容卡片
|
|
2224
|
+
- 内容列表
|
|
2225
|
+
- 内容编辑器
|
|
2226
|
+
"""
|
|
2227
|
+
|
|
2228
|
+
def _generate_user_journeys_ui(self) -> str:
|
|
2229
|
+
"""生成用户旅程 UI"""
|
|
2230
|
+
return """
|
|
2231
|
+
### 用户旅程 UI 设计
|
|
2232
|
+
|
|
2233
|
+
**旅程 1: 新用户注册**
|
|
2234
|
+
|
|
2235
|
+
关键页面:
|
|
2236
|
+
1. 访问首页 → CTA 按钮 "开始使用"
|
|
2237
|
+
2. 注册页 → 简洁表单
|
|
2238
|
+
3. 邮箱验证页 → 清晰提示
|
|
2239
|
+
4. 登录页 → 自动跳转
|
|
2240
|
+
5. 首次登录引导 → 功能介绍
|
|
2241
|
+
|
|
2242
|
+
**旅程 2: 日常使用**
|
|
2243
|
+
|
|
2244
|
+
关键页面:
|
|
2245
|
+
1. 登录页 → 快速登录
|
|
2246
|
+
2. 首页 → 功能概览
|
|
2247
|
+
3. 功能页 → 核心操作
|
|
2248
|
+
4. 设置页 → 个人配置
|
|
2249
|
+
|
|
2250
|
+
**交互要点**:
|
|
2251
|
+
- 操作反馈及时
|
|
2252
|
+
- 错误提示清晰
|
|
2253
|
+
- 加载状态明确
|
|
2254
|
+
"""
|
|
2255
|
+
|
|
2256
|
+
def _get_design_recommendations(self) -> dict:
|
|
2257
|
+
"""获取智能设计推荐"""
|
|
2258
|
+
try:
|
|
2259
|
+
# 导入设计引擎
|
|
2260
|
+
import sys
|
|
2261
|
+
from pathlib import Path
|
|
2262
|
+
|
|
2263
|
+
# 添加项目根目录到 Python 路径
|
|
2264
|
+
project_root = Path(__file__).parent.parent.parent
|
|
2265
|
+
if str(project_root) not in sys.path:
|
|
2266
|
+
sys.path.insert(0, str(project_root))
|
|
2267
|
+
|
|
2268
|
+
from super_dev.design import (
|
|
2269
|
+
DesignIntelligenceEngine,
|
|
2270
|
+
get_landing_generator,
|
|
2271
|
+
get_ux_guide,
|
|
2272
|
+
)
|
|
2273
|
+
|
|
2274
|
+
# 分析项目特征
|
|
2275
|
+
analysis = self._analyze_project_for_design()
|
|
2276
|
+
|
|
2277
|
+
# 初始化引擎
|
|
2278
|
+
design_engine = DesignIntelligenceEngine()
|
|
2279
|
+
landing_gen = get_landing_generator()
|
|
2280
|
+
ux_guide = get_ux_guide()
|
|
2281
|
+
|
|
2282
|
+
# 获取推荐
|
|
2283
|
+
recommendations = {}
|
|
2284
|
+
|
|
2285
|
+
# 1. 风格推荐
|
|
2286
|
+
style_query = f"{analysis['style']} {analysis['product_type']} {analysis['industry']}"
|
|
2287
|
+
style_results = design_engine.search(style_query, domain="style", max_results=3)
|
|
2288
|
+
recommendations['styles'] = style_results.get("results", [])[:3]
|
|
2289
|
+
|
|
2290
|
+
# 2. 配色推荐
|
|
2291
|
+
color_query = f"{analysis['industry']} {analysis['product_type']}" if analysis['industry'] != 'general' else analysis['product_type']
|
|
2292
|
+
color_results = design_engine.search(color_query, domain="color", max_results=1)
|
|
2293
|
+
recommendations['colors'] = (color_results.get("results", []) or [None])[0]
|
|
2294
|
+
|
|
2295
|
+
# 3. 字体推荐
|
|
2296
|
+
font_query = f"{analysis['style']} professional"
|
|
2297
|
+
font_results = design_engine.search(font_query, domain="typography", max_results=2)
|
|
2298
|
+
recommendations['fonts'] = font_results.get("results", [])[:2]
|
|
2299
|
+
|
|
2300
|
+
# 4. Landing 页面推荐(如果适用)
|
|
2301
|
+
if analysis['product_type'] in ['landing', 'saas', 'ecommerce']:
|
|
2302
|
+
landing_pattern = landing_gen.recommend(
|
|
2303
|
+
product_type=analysis['product_type'],
|
|
2304
|
+
goal='signup',
|
|
2305
|
+
audience='B2C' if analysis['industry'] == 'general' else 'B2B'
|
|
2306
|
+
)
|
|
2307
|
+
recommendations['landing'] = (
|
|
2308
|
+
landing_pattern.to_dict()
|
|
2309
|
+
if landing_pattern and hasattr(landing_pattern, "to_dict")
|
|
2310
|
+
else None
|
|
2311
|
+
)
|
|
2312
|
+
else:
|
|
2313
|
+
recommendations['landing'] = None
|
|
2314
|
+
|
|
2315
|
+
# 5. UX 最佳实践
|
|
2316
|
+
ux_quick_wins = ux_guide.get_quick_wins(max_results=5)
|
|
2317
|
+
ux_tips = []
|
|
2318
|
+
for rec in ux_quick_wins:
|
|
2319
|
+
guideline = rec.guideline
|
|
2320
|
+
ux_tips.append({
|
|
2321
|
+
"guideline": {
|
|
2322
|
+
"domain": guideline.domain.value if hasattr(guideline.domain, "value") else str(guideline.domain),
|
|
2323
|
+
"topic": guideline.topic,
|
|
2324
|
+
"best_practice": guideline.best_practice,
|
|
2325
|
+
"anti_pattern": guideline.anti_pattern,
|
|
2326
|
+
"impact": guideline.impact,
|
|
2327
|
+
"complexity": guideline.complexity,
|
|
2328
|
+
},
|
|
2329
|
+
"priority": rec.priority,
|
|
2330
|
+
"implementation_effort": rec.implementation_effort,
|
|
2331
|
+
"user_impact": rec.user_impact,
|
|
2332
|
+
})
|
|
2333
|
+
recommendations['ux_tips'] = ux_tips
|
|
2334
|
+
|
|
2335
|
+
return recommendations
|
|
2336
|
+
|
|
2337
|
+
except Exception as e:
|
|
2338
|
+
# 如果设计引擎失败,返回空推荐
|
|
2339
|
+
print(f"Warning: Design engine failed: {e}")
|
|
2340
|
+
return {
|
|
2341
|
+
'styles': [],
|
|
2342
|
+
'colors': None,
|
|
2343
|
+
'fonts': [],
|
|
2344
|
+
'landing': None,
|
|
2345
|
+
'ux_tips': []
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
def extract_requirements(self) -> list:
|
|
2349
|
+
"""从描述提取需求列表"""
|
|
2350
|
+
return self.requirement_parser.parse_requirements(self.description)
|
|
2351
|
+
|
|
2352
|
+
def generate_execution_plan(self, scenario: str = "0-1") -> str:
|
|
2353
|
+
"""生成分阶段执行路线图(支持 0-1 / 1-N+1)"""
|
|
2354
|
+
requirements = self.extract_requirements()
|
|
2355
|
+
phases = self.requirement_parser.build_execution_phases(scenario, requirements)
|
|
2356
|
+
|
|
2357
|
+
lines = [
|
|
2358
|
+
f"# {self.name} - 执行路线图",
|
|
2359
|
+
"",
|
|
2360
|
+
f"> **生成时间**: {datetime.now().strftime('%Y-%m-%d %H:%M')}",
|
|
2361
|
+
f"> **场景**: {scenario}",
|
|
2362
|
+
"> **策略**: 先前端可视化,再系统能力闭环",
|
|
2363
|
+
"",
|
|
2364
|
+
"---",
|
|
2365
|
+
"",
|
|
2366
|
+
"## 1. 需求范围",
|
|
2367
|
+
"",
|
|
2368
|
+
"| 模块 | 需求 | 说明 |",
|
|
2369
|
+
"|:---|:---|:---|",
|
|
2370
|
+
]
|
|
2371
|
+
|
|
2372
|
+
for req in requirements:
|
|
2373
|
+
lines.append(
|
|
2374
|
+
f"| {req.get('spec_name', 'core')} | {req.get('req_name', 'n/a')} | {req.get('description', '')} |"
|
|
2375
|
+
)
|
|
2376
|
+
|
|
2377
|
+
lines.extend(
|
|
2378
|
+
[
|
|
2379
|
+
"",
|
|
2380
|
+
"## 2. 分阶段计划",
|
|
2381
|
+
"",
|
|
2382
|
+
]
|
|
2383
|
+
)
|
|
2384
|
+
|
|
2385
|
+
for idx, phase in enumerate(phases, 1):
|
|
2386
|
+
lines.extend(
|
|
2387
|
+
[
|
|
2388
|
+
f"### Phase {idx}: {phase['title']}",
|
|
2389
|
+
"",
|
|
2390
|
+
f"**目标**: {phase['objective']}",
|
|
2391
|
+
"",
|
|
2392
|
+
"**交付物**:",
|
|
2393
|
+
]
|
|
2394
|
+
)
|
|
2395
|
+
for item in phase["deliverables"]:
|
|
2396
|
+
lines.append(f"- {item}")
|
|
2397
|
+
lines.append("")
|
|
2398
|
+
|
|
2399
|
+
lines.extend(
|
|
2400
|
+
[
|
|
2401
|
+
"## 3. 风险与控制",
|
|
2402
|
+
"",
|
|
2403
|
+
"- 需求漂移: 每个 Phase 完成后冻结版本并复核。",
|
|
2404
|
+
"- 前后端脱节: 在 Phase 2 开始前产出 API 契约草案。",
|
|
2405
|
+
"- 质量不足: 每个阶段结束前执行红队审查和质量门禁。",
|
|
2406
|
+
"",
|
|
2407
|
+
"## 4. 完成定义",
|
|
2408
|
+
"",
|
|
2409
|
+
"- 所有核心需求存在可验收场景并被实现。",
|
|
2410
|
+
"- 前端模块与文档一致,关键链路可演示。",
|
|
2411
|
+
"- 质量门禁通过,具备交付上线条件。",
|
|
2412
|
+
"",
|
|
2413
|
+
]
|
|
2414
|
+
)
|
|
2415
|
+
|
|
2416
|
+
return "\n".join(lines)
|
|
2417
|
+
|
|
2418
|
+
def generate_frontend_blueprint(self) -> str:
|
|
2419
|
+
"""生成前端先行的模块蓝图"""
|
|
2420
|
+
requirements = self.extract_requirements()
|
|
2421
|
+
modules = self.requirement_parser.build_frontend_modules(requirements)
|
|
2422
|
+
|
|
2423
|
+
lines = [
|
|
2424
|
+
f"# {self.name} - 前端蓝图",
|
|
2425
|
+
"",
|
|
2426
|
+
f"> **生成时间**: {datetime.now().strftime('%Y-%m-%d %H:%M')}",
|
|
2427
|
+
f"> **前端框架**: {self.frontend}",
|
|
2428
|
+
"> **设计重点**: 先可视化业务流程,再补齐系统深度能力",
|
|
2429
|
+
"",
|
|
2430
|
+
"---",
|
|
2431
|
+
"",
|
|
2432
|
+
"## 1. 体验目标",
|
|
2433
|
+
"",
|
|
2434
|
+
"- 一次进入即可理解产品价值和关键流程。",
|
|
2435
|
+
"- 文档和执行状态可追踪,避免信息散落。",
|
|
2436
|
+
"- 关键任务路径操作链路最短、反馈明确。",
|
|
2437
|
+
"",
|
|
2438
|
+
"## 2. 模块拆分",
|
|
2439
|
+
"",
|
|
2440
|
+
]
|
|
2441
|
+
|
|
2442
|
+
for index, module in enumerate(modules, 1):
|
|
2443
|
+
lines.extend(
|
|
2444
|
+
[
|
|
2445
|
+
f"### {index}. {module['name']}",
|
|
2446
|
+
"",
|
|
2447
|
+
f"**目标**: {module['goal']}",
|
|
2448
|
+
"",
|
|
2449
|
+
"**核心元素**:",
|
|
2450
|
+
]
|
|
2451
|
+
)
|
|
2452
|
+
for element in module["core_elements"]:
|
|
2453
|
+
lines.append(f"- {element}")
|
|
2454
|
+
lines.append("")
|
|
2455
|
+
|
|
2456
|
+
lines.extend(
|
|
2457
|
+
[
|
|
2458
|
+
"## 3. 开发顺序",
|
|
2459
|
+
"",
|
|
2460
|
+
"1. 先实现 `需求总览面板` + `文档工作台`,确保信息结构完整。",
|
|
2461
|
+
"2. 再实现业务模块页面,覆盖每条核心需求的主路径。",
|
|
2462
|
+
"3. 最后统一交互细节、动效和可访问性。",
|
|
2463
|
+
"",
|
|
2464
|
+
"## 4. 前后端契约建议",
|
|
2465
|
+
"",
|
|
2466
|
+
"- 页面只消费稳定 DTO,避免直接绑定数据库结构。",
|
|
2467
|
+
"- API 响应必须包含状态码、业务码和可读错误信息。",
|
|
2468
|
+
"- 对列表页统一分页/筛选参数结构,减少重复实现。",
|
|
2469
|
+
"",
|
|
2470
|
+
]
|
|
2471
|
+
)
|
|
2472
|
+
|
|
2473
|
+
return "\n".join(lines)
|