Skip to content

Commit 9abed43

Browse files
committed
优化CodeDisplay组件样式,增加变量监视面板样式
1 parent bdfd927 commit 9abed43

File tree

1 file changed

+191
-26
lines changed

1 file changed

+191
-26
lines changed

src/components/tree/CodeDisplay.css

Lines changed: 191 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
66
font-size: 13px;
77
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
8+
display: flex;
9+
flex-direction: column;
10+
height: 100%;
811
}
912

1013
.code-header {
@@ -33,7 +36,7 @@
3336
.code-content {
3437
display: flex;
3538
overflow-x: auto;
36-
max-height: 600px;
39+
flex: 1;
3740
overflow-y: auto;
3841
}
3942

@@ -44,15 +47,35 @@
4447
background-color: #252526;
4548
border-right: 1px solid #3d3d3d;
4649
user-select: none;
47-
min-width: 40px;
50+
min-width: 50px;
4851
}
4952

5053
.line-number {
51-
padding: 0 12px;
54+
padding: 0 8px 0 12px;
5255
color: #858585;
5356
text-align: right;
5457
line-height: 1.6;
5558
font-size: 12px;
59+
display: flex;
60+
align-items: center;
61+
justify-content: flex-end;
62+
gap: 4px;
63+
}
64+
65+
.line-number.execution-line {
66+
background-color: rgba(255, 235, 59, 0.1);
67+
color: #ffeb3b;
68+
}
69+
70+
.execution-arrow {
71+
color: #ffeb3b;
72+
font-size: 10px;
73+
animation: pulse-arrow 1s ease-in-out infinite;
74+
}
75+
76+
@keyframes pulse-arrow {
77+
0%, 100% { opacity: 1; }
78+
50% { opacity: 0.5; }
5679
}
5780

5881
.code-lines {
@@ -69,38 +92,77 @@
6992
line-height: 1.6;
7093
white-space: pre;
7194
transition: background-color 0.3s ease;
95+
min-height: 21px;
7296
}
7397

7498
.code-line.highlighted {
75-
background-color: rgba(255, 235, 59, 0.15);
76-
border-left: 3px solid #ffeb3b;
77-
padding-left: 9px;
78-
animation: highlight-pulse 1.5s ease-in-out infinite;
99+
background-color: rgba(255, 235, 59, 0.1);
79100
}
80101

81-
@keyframes highlight-pulse {
82-
0%, 100% {
83-
background-color: rgba(255, 235, 59, 0.15);
84-
}
85-
50% {
86-
background-color: rgba(255, 235, 59, 0.25);
87-
}
102+
.code-line.execution {
103+
background-color: rgba(255, 235, 59, 0.2);
104+
border-left: 3px solid #ffeb3b;
105+
padding-left: 9px;
88106
}
89107

90108
.code-text {
91109
color: #d4d4d4;
110+
flex-shrink: 0;
92111
}
93112

94-
.variable-value {
95-
margin-left: 20px;
113+
/* 变量标注样式 */
114+
.variable-annotations {
115+
display: inline-flex;
116+
gap: 8px;
117+
margin-left: 16px;
118+
flex-wrap: wrap;
119+
}
120+
121+
.variable-tag {
122+
display: inline-flex;
123+
align-items: center;
96124
padding: 2px 8px;
97-
background-color: rgba(76, 175, 80, 0.2);
98-
border: 1px solid #4caf50;
99125
border-radius: 4px;
100-
color: #4caf50;
101126
font-size: 11px;
102-
white-space: nowrap;
103127
animation: fade-in 0.3s ease;
128+
white-space: nowrap;
129+
}
130+
131+
.variable-tag.variable-node {
132+
background-color: rgba(33, 150, 243, 0.2);
133+
border: 1px solid #2196F3;
134+
color: #64B5F6;
135+
}
136+
137+
.variable-tag.variable-value {
138+
background-color: rgba(156, 39, 176, 0.2);
139+
border: 1px solid #9C27B0;
140+
color: #CE93D8;
141+
}
142+
143+
.variable-tag.variable-result {
144+
background-color: rgba(76, 175, 80, 0.2);
145+
border: 1px solid #4CAF50;
146+
color: #81C784;
147+
}
148+
149+
.variable-tag.variable-size {
150+
background-color: rgba(255, 152, 0, 0.2);
151+
border: 1px solid #FF9800;
152+
color: #FFB74D;
153+
}
154+
155+
.var-name {
156+
font-weight: 500;
157+
}
158+
159+
.var-equals {
160+
margin: 0 4px;
161+
opacity: 0.7;
162+
}
163+
164+
.var-value {
165+
font-weight: 600;
104166
}
105167

106168
@keyframes fade-in {
@@ -114,6 +176,92 @@
114176
}
115177
}
116178

179+
/* 旧的变量值样式(保留兼容) */
180+
.variable-value {
181+
margin-left: 20px;
182+
padding: 2px 8px;
183+
background-color: rgba(76, 175, 80, 0.2);
184+
border: 1px solid #4caf50;
185+
border-radius: 4px;
186+
color: #4caf50;
187+
font-size: 11px;
188+
white-space: nowrap;
189+
animation: fade-in 0.3s ease;
190+
}
191+
192+
/* 变量监视面板 */
193+
.variables-panel {
194+
background-color: #252526;
195+
border-top: 1px solid #3d3d3d;
196+
padding: 10px 12px;
197+
min-height: 60px;
198+
max-height: 120px;
199+
overflow-y: auto;
200+
flex-shrink: 0;
201+
}
202+
203+
.variables-header {
204+
display: flex;
205+
align-items: center;
206+
gap: 6px;
207+
color: #9cdcfe;
208+
font-size: 11px;
209+
font-weight: 600;
210+
margin-bottom: 8px;
211+
padding-bottom: 6px;
212+
border-bottom: 1px solid #3d3d3d;
213+
}
214+
215+
.variables-icon {
216+
font-size: 12px;
217+
}
218+
219+
.variables-list {
220+
display: flex;
221+
flex-wrap: wrap;
222+
gap: 8px 16px;
223+
}
224+
225+
.variable-item {
226+
display: flex;
227+
align-items: center;
228+
font-size: 11px;
229+
}
230+
231+
.variable-key {
232+
color: #9cdcfe;
233+
font-weight: 500;
234+
}
235+
236+
.variable-separator {
237+
color: #666;
238+
margin: 0 4px;
239+
}
240+
241+
.variable-val {
242+
font-weight: 600;
243+
}
244+
245+
.variable-val.val-null {
246+
color: #569cd6;
247+
}
248+
249+
.variable-val.val-true {
250+
color: #4ec9b0;
251+
}
252+
253+
.variable-val.val-false {
254+
color: #f48771;
255+
}
256+
257+
.variable-val.val-number {
258+
color: #b5cea8;
259+
}
260+
261+
.variable-val.val-string {
262+
color: #ce9178;
263+
}
264+
117265
/* 语法高亮颜色 */
118266
.code-text .keyword {
119267
color: #569cd6;
@@ -145,21 +293,25 @@
145293
}
146294

147295
/* 滚动条样式 */
148-
.code-content::-webkit-scrollbar {
296+
.code-content::-webkit-scrollbar,
297+
.variables-panel::-webkit-scrollbar {
149298
width: 8px;
150299
height: 8px;
151300
}
152301

153-
.code-content::-webkit-scrollbar-track {
302+
.code-content::-webkit-scrollbar-track,
303+
.variables-panel::-webkit-scrollbar-track {
154304
background: #1e1e1e;
155305
}
156306

157-
.code-content::-webkit-scrollbar-thumb {
307+
.code-content::-webkit-scrollbar-thumb,
308+
.variables-panel::-webkit-scrollbar-thumb {
158309
background: #424242;
159310
border-radius: 4px;
160311
}
161312

162-
.code-content::-webkit-scrollbar-thumb:hover {
313+
.code-content::-webkit-scrollbar-thumb:hover,
314+
.variables-panel::-webkit-scrollbar-thumb:hover {
163315
background: #555;
164316
}
165317

@@ -174,11 +326,24 @@
174326
}
175327

176328
.line-number {
177-
padding: 0 8px;
178-
min-width: 30px;
329+
padding: 0 6px 0 8px;
330+
min-width: 40px;
179331
}
180332

181333
.code-line {
182334
padding: 0 8px;
183335
}
336+
337+
.variable-annotations {
338+
margin-left: 8px;
339+
}
340+
341+
.variable-tag {
342+
padding: 1px 6px;
343+
font-size: 10px;
344+
}
345+
346+
.variables-panel {
347+
max-height: 80px;
348+
}
184349
}

0 commit comments

Comments
 (0)