Skip to content

Commit 140616e

Browse files
committed
feat: 添加随机数组按钮,算法思路改为弹窗形式
1 parent 157ef24 commit 140616e

File tree

5 files changed

+260
-108
lines changed

5 files changed

+260
-108
lines changed

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ function App() {
211211
<InputPanel onSubmit={handleSubmit} disabled={isPlaying} />
212212
</div>
213213
<div className="header-right">
214+
<AlgorithmIntro inputNumbers={inputNumbers} />
214215
{steps.length > 0 && !tutorialState.isActive && (
215216
<button className="tutorial-button" onClick={startTutorial}>
216217
🎓 教程
@@ -293,7 +294,6 @@ function App() {
293294

294295
{/* 右侧:辅助信息 */}
295296
<aside className="right-panel">
296-
<AlgorithmIntro inputNumbers={inputNumbers} />
297297
<EnhancedStepExplanation
298298
stepType={currentStepType}
299299
currentPath={currentPath}

src/components/AlgorithmIntro.css

Lines changed: 145 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,121 @@
1-
.algorithm-intro {
1+
/* 算法思路按钮 */
2+
.algorithm-intro-btn {
3+
padding: 6px 12px;
4+
background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
5+
border: 1px solid #90caf9;
6+
border-radius: 6px;
7+
color: #1976d2;
8+
font-size: 13px;
9+
font-weight: 600;
10+
cursor: pointer;
11+
transition: all 0.2s;
12+
display: flex;
13+
align-items: center;
14+
gap: 6px;
15+
}
16+
17+
.algorithm-intro-btn:hover {
18+
background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
19+
transform: translateY(-1px);
20+
box-shadow: 0 2px 8px rgba(25, 118, 210, 0.2);
21+
}
22+
23+
/* 弹窗遮罩 */
24+
.modal-overlay {
25+
position: fixed;
26+
top: 0;
27+
left: 0;
28+
right: 0;
29+
bottom: 0;
30+
background: rgba(0, 0, 0, 0.5);
31+
display: flex;
32+
align-items: center;
33+
justify-content: center;
34+
z-index: 1000;
35+
animation: fadeIn 0.2s ease;
36+
}
37+
38+
@keyframes fadeIn {
39+
from {
40+
opacity: 0;
41+
}
42+
to {
43+
opacity: 1;
44+
}
45+
}
46+
47+
/* 弹窗内容 */
48+
.modal-content {
249
background: #fff;
3-
border-radius: 8px;
4-
border: 1px solid #e0e0e0;
5-
margin-bottom: 12px;
50+
border-radius: 12px;
51+
width: 90%;
52+
max-width: 500px;
53+
max-height: 80vh;
654
overflow: hidden;
55+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
56+
animation: slideUp 0.3s ease;
57+
}
58+
59+
@keyframes slideUp {
60+
from {
61+
opacity: 0;
62+
transform: translateY(20px);
63+
}
64+
to {
65+
opacity: 1;
66+
transform: translateY(0);
67+
}
768
}
869

9-
.intro-header {
70+
.modal-header {
1071
display: flex;
1172
align-items: center;
12-
gap: 8px;
13-
padding: 10px 12px;
73+
gap: 10px;
74+
padding: 16px 20px;
1475
background: linear-gradient(135deg, #e3f2fd 0%, #fff 100%);
15-
cursor: pointer;
16-
user-select: none;
17-
}
18-
19-
.intro-header:hover {
20-
background: linear-gradient(135deg, #bbdefb 0%, #e3f2fd 100%);
76+
border-bottom: 1px solid #e0e0e0;
2177
}
2278

23-
.intro-icon {
24-
font-size: 16px;
79+
.modal-icon {
80+
font-size: 24px;
2581
}
2682

27-
.intro-title {
83+
.modal-title {
2884
flex: 1;
85+
font-size: 18px;
2986
font-weight: 600;
3087
color: #1976d2;
31-
font-size: 13px;
3288
}
3389

34-
.toggle-icon {
35-
font-size: 10px;
90+
.modal-close {
91+
width: 32px;
92+
height: 32px;
93+
border: none;
94+
background: transparent;
3695
color: #666;
96+
font-size: 18px;
97+
cursor: pointer;
98+
border-radius: 50%;
99+
display: flex;
100+
align-items: center;
101+
justify-content: center;
102+
transition: all 0.2s;
37103
}
38104

39-
.intro-content {
40-
padding: 12px;
41-
font-size: 12px;
42-
line-height: 1.6;
43-
max-height: 280px;
44-
overflow-y: auto;
45-
}
46-
47-
.intro-content::-webkit-scrollbar {
48-
width: 4px;
49-
}
50-
51-
.intro-content::-webkit-scrollbar-track {
105+
.modal-close:hover {
52106
background: #f0f0f0;
107+
color: #333;
53108
}
54109

55-
.intro-content::-webkit-scrollbar-thumb {
56-
background: #ccc;
57-
border-radius: 2px;
110+
.modal-body {
111+
padding: 20px;
112+
overflow-y: auto;
113+
max-height: calc(80vh - 70px);
58114
}
59115

116+
/* 内容区域样式 */
60117
.intro-section {
61-
margin-bottom: 12px;
118+
margin-bottom: 20px;
62119
}
63120

64121
.intro-section:last-child {
@@ -68,32 +125,36 @@
68125
.section-title {
69126
font-weight: 600;
70127
color: #333;
71-
margin-bottom: 6px;
72-
font-size: 12px;
128+
margin-bottom: 8px;
129+
font-size: 14px;
73130
}
74131

75-
.intro-content p {
76-
margin: 0 0 6px 0;
132+
.modal-body p {
133+
margin: 0 0 8px 0;
77134
color: #555;
135+
font-size: 14px;
136+
line-height: 1.6;
78137
}
79138

80-
.intro-content code {
139+
.modal-body code {
81140
background: #f5f5f5;
82-
padding: 2px 6px;
83-
border-radius: 3px;
141+
padding: 2px 8px;
142+
border-radius: 4px;
84143
font-family: 'Monaco', 'Menlo', monospace;
85-
font-size: 11px;
144+
font-size: 13px;
86145
color: #d32f2f;
87146
}
88147

89148
.thought-steps {
90-
margin: 6px 0 0 0;
91-
padding-left: 20px;
149+
margin: 8px 0 0 0;
150+
padding-left: 24px;
92151
color: #555;
152+
font-size: 14px;
153+
line-height: 1.8;
93154
}
94155

95156
.thought-steps li {
96-
margin-bottom: 4px;
157+
margin-bottom: 6px;
97158
}
98159

99160
.thought-steps strong {
@@ -102,33 +163,35 @@
102163

103164
.key-insight {
104165
background: #fff8e1;
105-
padding: 8px 10px;
106-
border-radius: 6px;
107-
border-left: 3px solid #ffc107;
166+
padding: 12px 16px;
167+
border-radius: 8px;
168+
border-left: 4px solid #ffc107;
108169
margin: 0;
170+
font-size: 14px;
109171
}
110172

111173
.key-insight strong {
112174
color: #f57c00;
113175
}
114176

115177
.watch-points {
116-
margin: 6px 0 0 0;
178+
margin: 8px 0 0 0;
117179
padding: 0;
118180
list-style: none;
119181
}
120182

121183
.watch-points li {
122184
display: flex;
123185
align-items: center;
124-
gap: 6px;
125-
margin-bottom: 4px;
186+
gap: 8px;
187+
margin-bottom: 8px;
126188
color: #555;
189+
font-size: 14px;
127190
}
128191

129192
.color-dot {
130-
width: 10px;
131-
height: 10px;
193+
width: 12px;
194+
height: 12px;
132195
border-radius: 50%;
133196
flex-shrink: 0;
134197
}
@@ -147,12 +210,33 @@
147210

148211
.visual-example {
149212
background: #fafafa;
150-
padding: 10px;
151-
border-radius: 6px;
152-
margin-top: 8px;
213+
padding: 16px;
214+
border-radius: 8px;
215+
}
216+
217+
.shortcut-list {
218+
margin: 8px 0 0 0;
219+
padding: 0;
220+
list-style: none;
221+
display: flex;
222+
flex-wrap: wrap;
223+
gap: 12px;
224+
}
225+
226+
.shortcut-list li {
227+
display: flex;
228+
align-items: center;
229+
gap: 6px;
230+
font-size: 13px;
231+
color: #555;
153232
}
154233

155-
/* 折叠状态 */
156-
.algorithm-intro.collapsed .intro-content {
157-
display: none;
234+
.shortcut-list kbd {
235+
background: #f5f5f5;
236+
border: 1px solid #ddd;
237+
border-radius: 4px;
238+
padding: 2px 8px;
239+
font-family: inherit;
240+
font-size: 12px;
241+
color: #333;
158242
}

0 commit comments

Comments
 (0)