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,74 @@
|
|
|
1
|
+
"""
|
|
2
|
+
开发:Excellent(11964948@qq.com)
|
|
3
|
+
功能:设计系统模块 - 企业级设计智能能力
|
|
4
|
+
作用:生成完整的设计系统、美学方向、design tokens、Landing 模式、图表推荐、UX 指南、技术栈最佳实践、代码生成
|
|
5
|
+
创建时间:2025-12-30
|
|
6
|
+
最后修改:2025-01-04
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .aesthetics import AestheticDirection, AestheticDirectionType, AestheticEngine
|
|
10
|
+
from .charts import ChartRecommendation, ChartRecommender, ChartType, get_chart_recommender
|
|
11
|
+
from .codegen import (
|
|
12
|
+
CodeGenerator,
|
|
13
|
+
ComponentCategory,
|
|
14
|
+
ComponentSnippet,
|
|
15
|
+
Framework,
|
|
16
|
+
GeneratedComponent,
|
|
17
|
+
generate_component_snippet,
|
|
18
|
+
get_code_generator,
|
|
19
|
+
)
|
|
20
|
+
from .engine import DesignIntelligenceEngine, EnhancedBM25
|
|
21
|
+
from .generator import DesignSystem, DesignSystemGenerator
|
|
22
|
+
from .landing import CTAStrategy, LandingPattern, LandingPatternGenerator, get_landing_generator
|
|
23
|
+
from .tech_stack import (
|
|
24
|
+
PerformanceTip,
|
|
25
|
+
PracticeCategory,
|
|
26
|
+
StackRecommendation,
|
|
27
|
+
TechBestPractice,
|
|
28
|
+
TechPattern,
|
|
29
|
+
TechStack,
|
|
30
|
+
TechStackEngine,
|
|
31
|
+
get_tech_stack_engine,
|
|
32
|
+
)
|
|
33
|
+
from .tokens import TokenGenerator
|
|
34
|
+
from .ux_guide import UXGuideEngine, UXGuideline, UXRecommendation, get_ux_guide
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
"DesignIntelligenceEngine",
|
|
38
|
+
"EnhancedBM25",
|
|
39
|
+
"DesignSystemGenerator",
|
|
40
|
+
"DesignSystem",
|
|
41
|
+
"AestheticEngine",
|
|
42
|
+
"AestheticDirection",
|
|
43
|
+
"AestheticDirectionType",
|
|
44
|
+
"TokenGenerator",
|
|
45
|
+
"LandingPatternGenerator",
|
|
46
|
+
"LandingPattern",
|
|
47
|
+
"CTAStrategy",
|
|
48
|
+
"get_landing_generator",
|
|
49
|
+
"ChartRecommender",
|
|
50
|
+
"ChartType",
|
|
51
|
+
"ChartRecommendation",
|
|
52
|
+
"get_chart_recommender",
|
|
53
|
+
"UXGuideEngine",
|
|
54
|
+
"UXGuideline",
|
|
55
|
+
"UXRecommendation",
|
|
56
|
+
"get_ux_guide",
|
|
57
|
+
# Tech Stack
|
|
58
|
+
"TechStackEngine",
|
|
59
|
+
"TechStack",
|
|
60
|
+
"PracticeCategory",
|
|
61
|
+
"TechBestPractice",
|
|
62
|
+
"TechPattern",
|
|
63
|
+
"PerformanceTip",
|
|
64
|
+
"StackRecommendation",
|
|
65
|
+
"get_tech_stack_engine",
|
|
66
|
+
# Code Generator
|
|
67
|
+
"CodeGenerator",
|
|
68
|
+
"Framework",
|
|
69
|
+
"ComponentCategory",
|
|
70
|
+
"ComponentSnippet",
|
|
71
|
+
"GeneratedComponent",
|
|
72
|
+
"get_code_generator",
|
|
73
|
+
"generate_component_snippet",
|
|
74
|
+
]
|
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
"""
|
|
2
|
+
开发:Excellent(11964948@qq.com)
|
|
3
|
+
功能:美学引擎 - 生成独特的设计美学方向
|
|
4
|
+
作用:避免通用 AI 美学,生成独特、令人难忘的设计方向
|
|
5
|
+
创建时间:2025-12-30
|
|
6
|
+
最后修改:2025-12-30
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import random
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
from enum import Enum
|
|
12
|
+
from typing import cast
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AestheticDirectionType(str, Enum):
|
|
16
|
+
"""美学方向类型"""
|
|
17
|
+
|
|
18
|
+
# 极简方向
|
|
19
|
+
BRUTALIST_MINIMAL = "brutalist_minimal"
|
|
20
|
+
JAPANESE_ZEN = "japanese_zen"
|
|
21
|
+
SCANDINAVIAN = "scandinavian"
|
|
22
|
+
SWISS_INTERNATIONAL = "swiss_international"
|
|
23
|
+
|
|
24
|
+
# 极繁方向
|
|
25
|
+
MAXIMALIST_CHAOS = "maximalist_chaos"
|
|
26
|
+
MEMPHIS_GROUP = "memphis_group"
|
|
27
|
+
POP_ART = "pop_art"
|
|
28
|
+
VAPORWAVE = "vaporwave"
|
|
29
|
+
|
|
30
|
+
# 复古未来
|
|
31
|
+
RETRO_FUTURISM = "retro_futurism"
|
|
32
|
+
CYBERPUNK = "cyberpunk"
|
|
33
|
+
ART_DECO = "art_deco"
|
|
34
|
+
STEAMPUNK = "steampunk"
|
|
35
|
+
|
|
36
|
+
# 自然有机
|
|
37
|
+
ORGANIC_NATURAL = "organic_natural"
|
|
38
|
+
BIOPHILIC = "biophilic"
|
|
39
|
+
EARTHY = "earthy"
|
|
40
|
+
BOTANICAL = "botanical"
|
|
41
|
+
|
|
42
|
+
# 奢华精致
|
|
43
|
+
LUXURY_REFINED = "luxury_refined"
|
|
44
|
+
FRENCH_ELEGANCE = "french_elegance"
|
|
45
|
+
ITALIAN_SOPHISTICATION = "italian_sophistication"
|
|
46
|
+
ARTISANAL = "artisanal"
|
|
47
|
+
|
|
48
|
+
# 俏皮趣味
|
|
49
|
+
PLAYFUL_TOY = "playful_toy"
|
|
50
|
+
KAWAII = "kawaii"
|
|
51
|
+
WHIMSICAL = "whimsical"
|
|
52
|
+
NEON_POP = "neon_pop"
|
|
53
|
+
|
|
54
|
+
# 编辑杂志
|
|
55
|
+
EDITORIAL_MAGAZINE = "editorial_magazine"
|
|
56
|
+
TYPOGRAPHY_CENTRIC = "typography_centric"
|
|
57
|
+
GRID_BREAKING = "grid_breaking"
|
|
58
|
+
|
|
59
|
+
# 原始工业
|
|
60
|
+
RAW_INDUSTRIAL = "raw_industrial"
|
|
61
|
+
UTILITARIAN = "utilitarian"
|
|
62
|
+
GRUNGE = "grunge"
|
|
63
|
+
POST_APOCALYPTIC = "post_apocalyptic"
|
|
64
|
+
|
|
65
|
+
# 柔和梦幻
|
|
66
|
+
SOFT_PASTEL = "soft_pastel"
|
|
67
|
+
DREAMY = "dreamy"
|
|
68
|
+
ETHEREAL = "ethereal"
|
|
69
|
+
GLASS_MORPHISM = "glass_morphism"
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@dataclass
|
|
73
|
+
class Typography:
|
|
74
|
+
"""字体配置"""
|
|
75
|
+
display: str # 标题字体
|
|
76
|
+
body: str # 正文字体
|
|
77
|
+
accent: str | None = None # 强调字体
|
|
78
|
+
mono: str | None = None # 等宽字体
|
|
79
|
+
|
|
80
|
+
def get_css_imports(self) -> list[str]:
|
|
81
|
+
"""获取 Google Fonts 导入"""
|
|
82
|
+
fonts = [self.display, self.body]
|
|
83
|
+
if self.accent:
|
|
84
|
+
fonts.append(self.accent)
|
|
85
|
+
if self.mono:
|
|
86
|
+
fonts.append(self.mono)
|
|
87
|
+
return list(set(fonts))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@dataclass
|
|
91
|
+
class ColorPalette:
|
|
92
|
+
"""色彩配置"""
|
|
93
|
+
primary: str # 主色
|
|
94
|
+
secondary: str # 次要色
|
|
95
|
+
accent: str # 强调色
|
|
96
|
+
background: str # 背景色
|
|
97
|
+
surface: str # 表面色
|
|
98
|
+
text: str # 文本色
|
|
99
|
+
text_secondary: str # 次要文本色
|
|
100
|
+
|
|
101
|
+
# 可选的高级色彩
|
|
102
|
+
gradient_start: str | None = None
|
|
103
|
+
gradient_end: str | None = None
|
|
104
|
+
noise_texture: str | None = None
|
|
105
|
+
|
|
106
|
+
def get_css_variables(self) -> dict[str, str]:
|
|
107
|
+
"""获取 CSS 变量"""
|
|
108
|
+
vars = {
|
|
109
|
+
"--color-primary": self.primary,
|
|
110
|
+
"--color-secondary": self.secondary,
|
|
111
|
+
"--color-accent": self.accent,
|
|
112
|
+
"--color-background": self.background,
|
|
113
|
+
"--color-surface": self.surface,
|
|
114
|
+
"--color-text": self.text,
|
|
115
|
+
"--color-text-secondary": self.text_secondary,
|
|
116
|
+
}
|
|
117
|
+
if self.gradient_start:
|
|
118
|
+
vars["--color-gradient-start"] = self.gradient_start
|
|
119
|
+
if self.gradient_end:
|
|
120
|
+
vars["--color-gradient-end"] = self.gradient_end
|
|
121
|
+
return vars
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@dataclass
|
|
125
|
+
class AnimationStyle:
|
|
126
|
+
"""动画风格"""
|
|
127
|
+
easing: str # 缓动函数
|
|
128
|
+
duration: str # 默认时长
|
|
129
|
+
stagger: bool = True # 是否使用交错
|
|
130
|
+
micro_interactions: bool = True # 是否有微交互
|
|
131
|
+
scroll_trigger: bool = False # 是否有滚动触发
|
|
132
|
+
|
|
133
|
+
# 特殊效果
|
|
134
|
+
parallax: bool = False
|
|
135
|
+
morphing: bool = False
|
|
136
|
+
particle_effects: bool = False
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@dataclass
|
|
140
|
+
class LayoutPrinciples:
|
|
141
|
+
"""布局原则"""
|
|
142
|
+
grid_system: str # 栅格系统
|
|
143
|
+
asymmetry: bool = False # 不对称
|
|
144
|
+
overlap: bool = False # 重叠元素
|
|
145
|
+
diagonal_flow: bool = False # 对角线流动
|
|
146
|
+
generous_spacing: bool = True # 宽松间距
|
|
147
|
+
density: str = "balanced" # 密度:sparse, balanced, dense
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
@dataclass
|
|
151
|
+
class VisualDetails:
|
|
152
|
+
"""视觉细节"""
|
|
153
|
+
shadows: str # 阴影风格
|
|
154
|
+
borders: str # 边框风格
|
|
155
|
+
corner_radius: str # 圆角
|
|
156
|
+
textures: list[str] # 纹理列表
|
|
157
|
+
|
|
158
|
+
# 特效
|
|
159
|
+
grain_overlay: bool = False
|
|
160
|
+
gradient_mesh: bool = False
|
|
161
|
+
decorative_borders: bool = False
|
|
162
|
+
custom_cursor: bool = False
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
@dataclass
|
|
166
|
+
class AestheticDirection:
|
|
167
|
+
"""完整的美学方向"""
|
|
168
|
+
name: str
|
|
169
|
+
description: str
|
|
170
|
+
typography: Typography
|
|
171
|
+
colors: ColorPalette
|
|
172
|
+
animation: AnimationStyle
|
|
173
|
+
layout: LayoutPrinciples
|
|
174
|
+
details: VisualDetails
|
|
175
|
+
differentiation: str # 令人难忘的独特元素
|
|
176
|
+
|
|
177
|
+
def to_css(self) -> str:
|
|
178
|
+
"""生成 CSS 变量"""
|
|
179
|
+
css = [":root {"]
|
|
180
|
+
css.extend([f" {k}: {v};" for k, v in self.colors.get_css_variables().items()])
|
|
181
|
+
css.append("}")
|
|
182
|
+
return "\n".join(css)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class AestheticEngine:
|
|
186
|
+
"""美学引擎 - 生成独特的设计方向"""
|
|
187
|
+
|
|
188
|
+
# 独特的字体库(避免 Inter, Roboto, Arial)
|
|
189
|
+
DISPLAY_FONTS = [
|
|
190
|
+
"Space Grotesk", "Syne", "Clash Display", "General Sans",
|
|
191
|
+
"Fraunces", "Bebas Neue", "Right Grotesk", "PP Neue Montreal",
|
|
192
|
+
"DM Sans", "Outfit", "Sora", "Chillax",
|
|
193
|
+
"Monument Extended", "Bodon", "Playfair Display", "Cormorant",
|
|
194
|
+
"IBM Plex Sans", "Syncopate", "Russo One", "Lexend",
|
|
195
|
+
]
|
|
196
|
+
|
|
197
|
+
BODY_FONTS = [
|
|
198
|
+
"Plus Jakarta Sans", "Inter", "Satoshi", "Geist",
|
|
199
|
+
"Neue Haas Grotesk", "SF Pro Display", "Source Sans Pro",
|
|
200
|
+
"Work Sans", "Space Grotesk", "DM Sans", "Outfit",
|
|
201
|
+
"EB Garamond", "Crimson Pro", "Lora", "Merriweather",
|
|
202
|
+
]
|
|
203
|
+
|
|
204
|
+
ACCENT_FONTS = [
|
|
205
|
+
"Playfair Display", "Cormorant", "Fraunces", "Bebas Neue",
|
|
206
|
+
"Syncopate", "Russo One", "Monument Extended",
|
|
207
|
+
]
|
|
208
|
+
|
|
209
|
+
MONO_FONTS = [
|
|
210
|
+
"JetBrains Mono", "Fira Code", "IBM Plex Mono", "Source Code Pro",
|
|
211
|
+
"Space Mono", "Roboto Mono", "DM Mono",
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
# 预设美学方向
|
|
215
|
+
AESTHETIC_PRESETS: dict[AestheticDirectionType, dict] = {
|
|
216
|
+
AestheticDirectionType.BRUTALIST_MINIMAL: {
|
|
217
|
+
"description": "原始极简主义 - 粗糙、直接、无装饰",
|
|
218
|
+
"typography": {
|
|
219
|
+
"display": "Space Grotesk",
|
|
220
|
+
"body": "Plus Jakarta Sans",
|
|
221
|
+
},
|
|
222
|
+
"colors": {
|
|
223
|
+
"primary": "#000000",
|
|
224
|
+
"secondary": "#FFFFFF",
|
|
225
|
+
"accent": "#FF0000",
|
|
226
|
+
"background": "#F5F5F5",
|
|
227
|
+
"surface": "#FFFFFF",
|
|
228
|
+
"text": "#000000",
|
|
229
|
+
"text_secondary": "#666666",
|
|
230
|
+
},
|
|
231
|
+
"animation": {
|
|
232
|
+
"easing": "steps(4)",
|
|
233
|
+
"duration": "0.2s",
|
|
234
|
+
"stagger": False,
|
|
235
|
+
"micro_interactions": False,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
AestheticDirectionType.MAXIMALIST_CHAOS: {
|
|
240
|
+
"description": "极繁混乱 - 最大化视觉冲击力",
|
|
241
|
+
"typography": {
|
|
242
|
+
"display": "Clash Display",
|
|
243
|
+
"body": "Satoshi",
|
|
244
|
+
"accent": "Bebas Neue",
|
|
245
|
+
},
|
|
246
|
+
"colors": {
|
|
247
|
+
"primary": "#FF6B6B",
|
|
248
|
+
"secondary": "#4ECDC4",
|
|
249
|
+
"accent": "#FFE66D",
|
|
250
|
+
"background": "#1A1A2E",
|
|
251
|
+
"surface": "#16213E",
|
|
252
|
+
"text": "#FFFFFF",
|
|
253
|
+
"text_secondary": "#B0B0B0",
|
|
254
|
+
"gradient_start": "#FF6B6B",
|
|
255
|
+
"gradient_end": "#4ECDC4",
|
|
256
|
+
},
|
|
257
|
+
"animation": {
|
|
258
|
+
"easing": "cubic-bezier(0.68, -0.55, 0.265, 1.55)",
|
|
259
|
+
"duration": "0.6s",
|
|
260
|
+
"stagger": True,
|
|
261
|
+
"micro_interactions": True,
|
|
262
|
+
"scroll_trigger": True,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
AestheticDirectionType.CYBERPUNK: {
|
|
267
|
+
"description": "赛博朋克 - 高科技低生活",
|
|
268
|
+
"typography": {
|
|
269
|
+
"display": "Syncopate",
|
|
270
|
+
"body": "Rajdhani",
|
|
271
|
+
"mono": "Orbitron",
|
|
272
|
+
},
|
|
273
|
+
"colors": {
|
|
274
|
+
"primary": "#00FF41",
|
|
275
|
+
"secondary": "#FF00FF",
|
|
276
|
+
"accent": "#00FFFF",
|
|
277
|
+
"background": "#0D0D0D",
|
|
278
|
+
"surface": "#1A1A1A",
|
|
279
|
+
"text": "#00FF41",
|
|
280
|
+
"text_secondary": "#B0B0B0",
|
|
281
|
+
"gradient_start": "#00FF41",
|
|
282
|
+
"gradient_end": "#FF00FF",
|
|
283
|
+
"noise_texture": "url(#noise)",
|
|
284
|
+
},
|
|
285
|
+
"animation": {
|
|
286
|
+
"easing": "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
287
|
+
"duration": "0.3s",
|
|
288
|
+
"stagger": True,
|
|
289
|
+
"micro_interactions": True,
|
|
290
|
+
"scroll_trigger": True,
|
|
291
|
+
"parallax": True,
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
AestheticDirectionType.SOFT_PASTEL: {
|
|
296
|
+
"description": "柔和梦幻 - 粉彩与柔和",
|
|
297
|
+
"typography": {
|
|
298
|
+
"display": "Fraunces",
|
|
299
|
+
"body": "Sora",
|
|
300
|
+
},
|
|
301
|
+
"colors": {
|
|
302
|
+
"primary": "#FFB3BA",
|
|
303
|
+
"secondary": "#BAFFC9",
|
|
304
|
+
"accent": "#BAE1FF",
|
|
305
|
+
"background": "#FFFDF5",
|
|
306
|
+
"surface": "#FFFFFF",
|
|
307
|
+
"text": "#4A4A4A",
|
|
308
|
+
"text_secondary": "#8A8A8A",
|
|
309
|
+
},
|
|
310
|
+
"animation": {
|
|
311
|
+
"easing": "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
312
|
+
"duration": "0.5s",
|
|
313
|
+
"stagger": True,
|
|
314
|
+
"micro_interactions": True,
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
|
|
318
|
+
AestheticDirectionType.LUXURY_REFINED: {
|
|
319
|
+
"description": "奢华精致 - 优雅与品质",
|
|
320
|
+
"typography": {
|
|
321
|
+
"display": "Playfair Display",
|
|
322
|
+
"body": "Cormorant",
|
|
323
|
+
"accent": "Bodoni",
|
|
324
|
+
},
|
|
325
|
+
"colors": {
|
|
326
|
+
"primary": "#1C1C1C",
|
|
327
|
+
"secondary": "#C9A962",
|
|
328
|
+
"accent": "#8B7355",
|
|
329
|
+
"background": "#FAFAFA",
|
|
330
|
+
"surface": "#FFFFFF",
|
|
331
|
+
"text": "#1C1C1C",
|
|
332
|
+
"text_secondary": "#666666",
|
|
333
|
+
},
|
|
334
|
+
"animation": {
|
|
335
|
+
"easing": "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
336
|
+
"duration": "0.6s",
|
|
337
|
+
"stagger": True,
|
|
338
|
+
"micro_interactions": True,
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
|
|
342
|
+
AestheticDirectionType.VAPORWAVE: {
|
|
343
|
+
"description": "蒸汽波 - 复古数字美学",
|
|
344
|
+
"typography": {
|
|
345
|
+
"display": "Right Grotesk",
|
|
346
|
+
"body": "Space Grotesk",
|
|
347
|
+
},
|
|
348
|
+
"colors": {
|
|
349
|
+
"primary": "#FF71CE",
|
|
350
|
+
"secondary": "#01CDFE",
|
|
351
|
+
"accent": "#B967FF",
|
|
352
|
+
"background": "#2D1B4E",
|
|
353
|
+
"surface": "#1A0B2E",
|
|
354
|
+
"text": "#FFFFFF",
|
|
355
|
+
"text_secondary": "#B0B0B0",
|
|
356
|
+
"gradient_start": "#FF71CE",
|
|
357
|
+
"gradient_end": "#01CDFE",
|
|
358
|
+
},
|
|
359
|
+
"animation": {
|
|
360
|
+
"easing": "cubic-bezier(0.68, -0.55, 0.265, 1.55)",
|
|
361
|
+
"duration": "0.4s",
|
|
362
|
+
"stagger": True,
|
|
363
|
+
"micro_interactions": True,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
def __init__(self, seed: int | None = None):
|
|
369
|
+
"""
|
|
370
|
+
初始化美学引擎
|
|
371
|
+
|
|
372
|
+
Args:
|
|
373
|
+
seed: 随机种子,用于可重现的结果
|
|
374
|
+
"""
|
|
375
|
+
self._rng: random.Random | random.SystemRandom
|
|
376
|
+
if seed is not None:
|
|
377
|
+
self._rng = random.Random(seed) # nosec B311
|
|
378
|
+
else:
|
|
379
|
+
self._rng = random.SystemRandom()
|
|
380
|
+
|
|
381
|
+
def generate_direction(
|
|
382
|
+
self,
|
|
383
|
+
direction: AestheticDirectionType | None = None,
|
|
384
|
+
custom_context: str | None = None,
|
|
385
|
+
) -> AestheticDirection:
|
|
386
|
+
"""
|
|
387
|
+
生成美学方向
|
|
388
|
+
|
|
389
|
+
Args:
|
|
390
|
+
direction: 指定的美学方向,None 则随机
|
|
391
|
+
custom_context: 自定义上下文,用于 AI 生成定制方向
|
|
392
|
+
|
|
393
|
+
Returns:
|
|
394
|
+
完整的美学方向配置
|
|
395
|
+
"""
|
|
396
|
+
if direction is None:
|
|
397
|
+
direction = self._rng.choice(list(AestheticDirectionType))
|
|
398
|
+
|
|
399
|
+
preset = self.AESTHETIC_PRESETS.get(direction)
|
|
400
|
+
if not preset:
|
|
401
|
+
# 如果没有预设,生成基础配置
|
|
402
|
+
return self._generate_custom_direction(direction)
|
|
403
|
+
|
|
404
|
+
return self._build_from_preset(direction, preset)
|
|
405
|
+
|
|
406
|
+
def _generate_custom_direction(
|
|
407
|
+
self, direction: AestheticDirectionType
|
|
408
|
+
) -> AestheticDirection:
|
|
409
|
+
"""生成自定义美学方向"""
|
|
410
|
+
return AestheticDirection(
|
|
411
|
+
name=direction.value,
|
|
412
|
+
description=f"Custom {direction.value} aesthetic",
|
|
413
|
+
typography=Typography(
|
|
414
|
+
display=self._rng.choice(self.DISPLAY_FONTS),
|
|
415
|
+
body=self._rng.choice(self.BODY_FONTS),
|
|
416
|
+
accent=self._rng.choice(self.ACCENT_FONTS) if self._rng.random() > 0.5 else None,
|
|
417
|
+
mono=self._rng.choice(self.MONO_FONTS),
|
|
418
|
+
),
|
|
419
|
+
colors=ColorPalette(
|
|
420
|
+
primary=self._random_color(),
|
|
421
|
+
secondary=self._random_color(),
|
|
422
|
+
accent=self._random_color(),
|
|
423
|
+
background=self._random_color(light=True),
|
|
424
|
+
surface=self._random_color(light=True),
|
|
425
|
+
text="#000000" if self._rng.random() > 0.5 else "#FFFFFF",
|
|
426
|
+
text_secondary="#666666",
|
|
427
|
+
),
|
|
428
|
+
animation=AnimationStyle(
|
|
429
|
+
easing=self._rng.choice([
|
|
430
|
+
"ease", "ease-in", "ease-out", "ease-in-out",
|
|
431
|
+
"cubic-bezier(0.4, 0, 0.2, 1)",
|
|
432
|
+
"cubic-bezier(0.68, -0.55, 0.265, 1.55)",
|
|
433
|
+
]),
|
|
434
|
+
duration=f"{self._rng.uniform(0.2, 0.8):.1f}s",
|
|
435
|
+
stagger=self._rng.random() > 0.3,
|
|
436
|
+
micro_interactions=self._rng.random() > 0.2,
|
|
437
|
+
scroll_trigger=self._rng.random() > 0.5,
|
|
438
|
+
),
|
|
439
|
+
layout=LayoutPrinciples(
|
|
440
|
+
grid_system=self._rng.choice(["8pt", "12pt", "baseline"]),
|
|
441
|
+
asymmetry=self._rng.random() > 0.5,
|
|
442
|
+
overlap=self._rng.random() > 0.7,
|
|
443
|
+
diagonal_flow=self._rng.random() > 0.8,
|
|
444
|
+
),
|
|
445
|
+
details=VisualDetails(
|
|
446
|
+
shadows=self._rng.choice(["none", "subtle", "medium", "dramatic"]),
|
|
447
|
+
borders=self._rng.choice(["none", "thin", "medium", "thick"]),
|
|
448
|
+
corner_radius=self._rng.choice(["0", "4px", "8px", "16px", "pill"]),
|
|
449
|
+
textures=[],
|
|
450
|
+
),
|
|
451
|
+
differentiation="Unique custom aesthetic",
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
def _build_from_preset(
|
|
455
|
+
self, direction: AestheticDirectionType, preset: dict
|
|
456
|
+
) -> AestheticDirection:
|
|
457
|
+
"""从预设构建美学方向"""
|
|
458
|
+
typo_cfg = preset["typography"]
|
|
459
|
+
color_cfg = preset["colors"]
|
|
460
|
+
anim_cfg = preset["animation"]
|
|
461
|
+
|
|
462
|
+
return AestheticDirection(
|
|
463
|
+
name=direction.value,
|
|
464
|
+
description=preset["description"],
|
|
465
|
+
typography=Typography(
|
|
466
|
+
display=typo_cfg.get("display", self._rng.choice(self.DISPLAY_FONTS)),
|
|
467
|
+
body=typo_cfg.get("body", self._rng.choice(self.BODY_FONTS)),
|
|
468
|
+
accent=typo_cfg.get("accent"),
|
|
469
|
+
mono=typo_cfg.get("mono", self._rng.choice(self.MONO_FONTS)),
|
|
470
|
+
),
|
|
471
|
+
colors=ColorPalette(**color_cfg),
|
|
472
|
+
animation=AnimationStyle(**anim_cfg),
|
|
473
|
+
layout=LayoutPrinciples(
|
|
474
|
+
grid_system="8pt",
|
|
475
|
+
asymmetry=direction in [
|
|
476
|
+
AestheticDirectionType.MAXIMALIST_CHAOS,
|
|
477
|
+
AestheticDirectionType.GRID_BREAKING,
|
|
478
|
+
],
|
|
479
|
+
overlap=direction in [
|
|
480
|
+
AestheticDirectionType.MAXIMALIST_CHAOS,
|
|
481
|
+
AestheticDirectionType.MEMPHIS_GROUP,
|
|
482
|
+
],
|
|
483
|
+
),
|
|
484
|
+
details=VisualDetails(
|
|
485
|
+
shadows="dramatic" if direction in [
|
|
486
|
+
AestheticDirectionType.CYBERPUNK,
|
|
487
|
+
AestheticDirectionType.VAPORWAVE,
|
|
488
|
+
] else "subtle",
|
|
489
|
+
borders="thin",
|
|
490
|
+
corner_radius="0" if direction in [
|
|
491
|
+
AestheticDirectionType.BRUTALIST_MINIMAL,
|
|
492
|
+
AestheticDirectionType.RAW_INDUSTRIAL,
|
|
493
|
+
] else "8px",
|
|
494
|
+
textures=["noise"] if direction == AestheticDirectionType.CYBERPUNK else [],
|
|
495
|
+
),
|
|
496
|
+
differentiation=self._get_differentiation(direction),
|
|
497
|
+
)
|
|
498
|
+
|
|
499
|
+
def _get_differentiation(self, direction: AestheticDirectionType) -> str:
|
|
500
|
+
"""获取令人难忘的独特元素"""
|
|
501
|
+
differentiations = {
|
|
502
|
+
AestheticDirectionType.BRUTALIST_MINIMAL: "粗体排版、单色对比、极简装饰",
|
|
503
|
+
AestheticDirectionType.MAXIMALIST_CHAOS: "饱和色彩、大胆碰撞、最大视觉密度",
|
|
504
|
+
AestheticDirectionType.CYBERPUNK: "霓虹发光、故障效果、数字纹理",
|
|
505
|
+
AestheticDirectionType.SOFT_PASTEL: "柔和粉彩、圆润形状、梦幻氛围",
|
|
506
|
+
AestheticDirectionType.LUXURY_REFINED: "金色点缀、精致衬线、充足留白",
|
|
507
|
+
AestheticDirectionType.VAPORWAVE: "紫粉渐变、复古网格、雕塑效果",
|
|
508
|
+
AestheticDirectionType.RETRO_FUTURISM: "原子图案、流线型形状、复古科技",
|
|
509
|
+
AestheticDirectionType.ORGANIC_NATURAL: "有机曲线、大地色调、自然纹理",
|
|
510
|
+
AestheticDirectionType.PLAYFUL_TOY: "明亮色彩、圆润形状、趣味图标",
|
|
511
|
+
AestheticDirectionType.EDITORIAL_MAGAZINE: "大胆排版、不对称布局、编辑感",
|
|
512
|
+
}
|
|
513
|
+
return differentiations.get(
|
|
514
|
+
direction, "独特的视觉识别,令人难忘的设计语言"
|
|
515
|
+
)
|
|
516
|
+
|
|
517
|
+
def _random_color(self, light: bool = False) -> str:
|
|
518
|
+
"""生成随机颜色"""
|
|
519
|
+
if light:
|
|
520
|
+
return f"#{self._rng.randint(200, 255):02x}{self._rng.randint(200, 255):02x}{self._rng.randint(200, 255):02x}"
|
|
521
|
+
return f"#{self._rng.randint(0, 255):02x}{self._rng.randint(0, 255):02x}{self._rng.randint(0, 255):02x}"
|
|
522
|
+
|
|
523
|
+
def list_directions(self) -> list[str]:
|
|
524
|
+
"""列出所有可用的美学方向"""
|
|
525
|
+
return [d.value for d in AestheticDirectionType]
|
|
526
|
+
|
|
527
|
+
def get_direction_description(self, direction: AestheticDirectionType) -> str:
|
|
528
|
+
"""获取美学方向的描述"""
|
|
529
|
+
preset = self.AESTHETIC_PRESETS.get(direction, {})
|
|
530
|
+
return cast(str, preset.get("description", direction.value))
|