koishi-plugin-monetary-bourse 2.0.3-Alpha.12 → 2.1.1
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.
- package/lib/index.js +36 -27
- package/lib/templates/holding-card.html +556 -379
- package/lib/templates/stock-chart.html +478 -468
- package/lib/templates/trade-result.html +624 -559
- package/package.json +1 -1
- package/readme.md +13 -2
|
@@ -1,469 +1,479 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<style>
|
|
4
|
-
:root {
|
|
5
|
-
--main-color: {{MAIN_COLOR}};
|
|
6
|
-
--glow-color: {{GLOW_COLOR}};
|
|
7
|
-
--icon-gradient-start: {{ICON_GRADIENT_START}};
|
|
8
|
-
--icon-gradient-end: {{ICON_GRADIENT_END}};
|
|
9
|
-
--icon-shadow: {{ICON_SHADOW}};
|
|
10
|
-
--change-badge-bg: {{CHANGE_BADGE_BG}};
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
--bg-color: #0c0f15;
|
|
14
|
-
--card-bg: #
|
|
15
|
-
--
|
|
16
|
-
--text-
|
|
17
|
-
--
|
|
18
|
-
--
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
display: flex;
|
|
74
|
-
|
|
75
|
-
gap:
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.stock-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
display: flex;
|
|
84
|
-
align-items: center;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
font-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.meta-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
border-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
font-
|
|
184
|
-
color: var(--text-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
font-
|
|
194
|
-
color: var(--text-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
//
|
|
269
|
-
const
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
ctx.
|
|
302
|
-
ctx.
|
|
303
|
-
|
|
304
|
-
ctx.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
ctx.
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
ctx.stroke();
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
//
|
|
376
|
-
ctx.
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
//
|
|
386
|
-
ctx.
|
|
387
|
-
ctx.
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
ctx.
|
|
403
|
-
ctx.
|
|
404
|
-
ctx.
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
ctx.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
ctx.
|
|
413
|
-
ctx.
|
|
414
|
-
ctx.
|
|
415
|
-
|
|
416
|
-
ctx.
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
if (
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<style>
|
|
4
|
+
:root {
|
|
5
|
+
--main-color: {{MAIN_COLOR}};
|
|
6
|
+
--glow-color: {{GLOW_COLOR}};
|
|
7
|
+
--icon-gradient-start: {{ICON_GRADIENT_START}};
|
|
8
|
+
--icon-gradient-end: {{ICON_GRADIENT_END}};
|
|
9
|
+
--icon-shadow: {{ICON_SHADOW}};
|
|
10
|
+
--change-badge-bg: {{CHANGE_BADGE_BG}};
|
|
11
|
+
|
|
12
|
+
/* 统一配色板 */
|
|
13
|
+
--bg-color: #0c0f15;
|
|
14
|
+
--card-bg: #161b22;
|
|
15
|
+
--item-bg: #1f242e;
|
|
16
|
+
--text-primary: #f0f3f5;
|
|
17
|
+
--text-secondary: #8b949e;
|
|
18
|
+
--border-color: #30363d;
|
|
19
|
+
|
|
20
|
+
--grid-line-color: #30363d;
|
|
21
|
+
|
|
22
|
+
/* 语义色 */
|
|
23
|
+
--buy-color: #f87171;
|
|
24
|
+
--sell-color: #4ade80;
|
|
25
|
+
--buy-bg: rgba(248, 113, 113, 0.15);
|
|
26
|
+
--sell-bg: rgba(74, 222, 128, 0.15);
|
|
27
|
+
--pending-color: #eab308;
|
|
28
|
+
--pending-bg: rgba(234, 179, 8, 0.15);
|
|
29
|
+
--accent-color: #58a6ff;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
33
|
+
|
|
34
|
+
body {
|
|
35
|
+
padding: 64px;
|
|
36
|
+
/* 字体栈优化:优先使用现代系统字体 */
|
|
37
|
+
font-family: 'Roboto Mono', 'Trebuchet MS', 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
|
|
38
|
+
background-color: var(--bg-color);
|
|
39
|
+
|
|
40
|
+
/* 强制 4:3 比例 (1024x768) */
|
|
41
|
+
width: 1024px;
|
|
42
|
+
height: 768px;
|
|
43
|
+
|
|
44
|
+
color: var(--text-primary);
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
align-items: center;
|
|
48
|
+
overflow: hidden; /* 防止溢出 */
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.card {
|
|
52
|
+
background-color: var(--card-bg);
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: 100%;
|
|
55
|
+
padding: 32px 40px;
|
|
56
|
+
border-radius: 16px;
|
|
57
|
+
box-shadow: 0 32px 64px rgba(0,0,0,0.6), 0 0 0 1px var(--border-color);
|
|
58
|
+
position: relative; /* ensure absolute children like .update-time are positioned inside the card */
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: column;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* 头部区域优化 */
|
|
64
|
+
.header {
|
|
65
|
+
display: flex;
|
|
66
|
+
justify-content: space-between;
|
|
67
|
+
align-items: flex-start;
|
|
68
|
+
margin-bottom: 24px;
|
|
69
|
+
flex-shrink: 0; /* 防止头部被压缩 */
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.title-group {
|
|
73
|
+
display: flex;
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
gap: 8px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.stock-name {
|
|
79
|
+
font-size: 42px;
|
|
80
|
+
font-weight: 700;
|
|
81
|
+
color: #ffffff;
|
|
82
|
+
letter-spacing: -0.5px;
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
gap: 16px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.stock-icon {
|
|
89
|
+
width: 44px;
|
|
90
|
+
height: 44px;
|
|
91
|
+
border-radius: 12px;
|
|
92
|
+
background: linear-gradient(135deg, var(--icon-gradient-start), var(--icon-gradient-end));
|
|
93
|
+
display: flex;
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
font-size: 24px;
|
|
97
|
+
box-shadow: 0 8px 20px var(--icon-shadow);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.meta-info {
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
gap: 16px;
|
|
104
|
+
font-size: 15px;
|
|
105
|
+
color: var(--text-secondary);
|
|
106
|
+
font-weight: 500;
|
|
107
|
+
margin-left: 60px; /* 对齐文字 */
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.meta-item { display: flex; align-items: center; gap: 6px; }
|
|
111
|
+
.live-dot { width: 6px; height: 6px; background-color: #22c55e; border-radius: 50%; box-shadow: 0 0 8px #22c55e; }
|
|
112
|
+
|
|
113
|
+
.price-group {
|
|
114
|
+
text-align: right;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.current-price {
|
|
118
|
+
font-family: 'Roboto Mono', 'Trebuchet MS', monospace;
|
|
119
|
+
font-size: 64px;
|
|
120
|
+
font-weight: normal;
|
|
121
|
+
color: var(--main-color);
|
|
122
|
+
line-height: 1;
|
|
123
|
+
letter-spacing: -2px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.price-change {
|
|
127
|
+
margin-top: 8px;
|
|
128
|
+
display: flex;
|
|
129
|
+
align-items: center;
|
|
130
|
+
justify-content: flex-end;
|
|
131
|
+
gap: 12px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.change-badge {
|
|
135
|
+
background-color: var(--change-badge-bg);
|
|
136
|
+
color: var(--main-color);
|
|
137
|
+
padding: 4px 10px;
|
|
138
|
+
border-radius: 6px;
|
|
139
|
+
font-size: 16px;
|
|
140
|
+
font-weight: 600;
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: 4px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* 图表区域优化:自适应高度 */
|
|
147
|
+
.chart-wrapper {
|
|
148
|
+
position: relative;
|
|
149
|
+
flex: 1; /* 占据剩余所有空间 */
|
|
150
|
+
width: 100%;
|
|
151
|
+
min-height: 0; /* Flexbox 溢出修复 */
|
|
152
|
+
margin: 16px 0;
|
|
153
|
+
border-radius: 12px;
|
|
154
|
+
overflow: hidden;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
canvas {
|
|
158
|
+
display: block;
|
|
159
|
+
width: 100%;
|
|
160
|
+
height: 100%; /* 填满 wrapper */
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* 底部数据栏优化 */
|
|
164
|
+
.footer {
|
|
165
|
+
display: grid;
|
|
166
|
+
grid-template-columns: repeat(4, 1fr);
|
|
167
|
+
background: var(--card-bg); /* 改为背景色,通过 border 分割 */
|
|
168
|
+
border-top: 1px solid var(--border-color);
|
|
169
|
+
margin-top: auto; /* 推到底部 */
|
|
170
|
+
padding-top: 24px;
|
|
171
|
+
flex-shrink: 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.stat-box {
|
|
175
|
+
padding: 0 24px;
|
|
176
|
+
display: flex;
|
|
177
|
+
flex-direction: column;
|
|
178
|
+
border-right: 1px solid var(--border-color);
|
|
179
|
+
}
|
|
180
|
+
.stat-box:last-child { border-right: none; }
|
|
181
|
+
|
|
182
|
+
.stat-label {
|
|
183
|
+
font-size: 13px;
|
|
184
|
+
color: var(--text-secondary);
|
|
185
|
+
text-transform: uppercase;
|
|
186
|
+
margin-bottom: 6px;
|
|
187
|
+
letter-spacing: 0.5px;
|
|
188
|
+
font-weight: 600;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.stat-value {
|
|
192
|
+
font-size: 20px;
|
|
193
|
+
font-weight: 600;
|
|
194
|
+
color: var(--text-primary);
|
|
195
|
+
font-family: 'Roboto Mono', monospace;
|
|
196
|
+
letter-spacing: -0.5px;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.update-time {
|
|
200
|
+
position: absolute;
|
|
201
|
+
bottom: 8px;
|
|
202
|
+
right: 8px;
|
|
203
|
+
font-size: 12px;
|
|
204
|
+
color: var(--text-secondary);
|
|
205
|
+
opacity: 0.9;
|
|
206
|
+
z-index: 2; /* make sure it's above footer */
|
|
207
|
+
}
|
|
208
|
+
</style>
|
|
209
|
+
</head>
|
|
210
|
+
<body>
|
|
211
|
+
<div class="card">
|
|
212
|
+
<div class="header">
|
|
213
|
+
<div class="title-group">
|
|
214
|
+
<div class="stock-name">
|
|
215
|
+
<div class="stock-icon">⚡</div>
|
|
216
|
+
{{STOCK_NAME}}
|
|
217
|
+
</div>
|
|
218
|
+
<div class="meta-info">
|
|
219
|
+
<div class="meta-item"><div class="live-dot"></div> {{VIEW_LABEL}}</div>
|
|
220
|
+
<div class="meta-item" style="opacity: 0.5">|</div>
|
|
221
|
+
<div class="meta-item">{{CURRENT_TIME}}</div>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
<div class="price-group">
|
|
225
|
+
<div class="current-price">{{CURRENT_PRICE}}</div>
|
|
226
|
+
<div class="price-change">
|
|
227
|
+
<span style="font-size: 18px; font-weight: 600; color: var(--main-color); opacity: 0.9;">{{CHANGE_VALUE}}</span>
|
|
228
|
+
<span class="change-badge">{{CHANGE_ICON}} {{CHANGE_PERCENT}}%</span>
|
|
229
|
+
</div>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<div class="chart-wrapper">
|
|
234
|
+
<!-- 增加 Canvas 分辨率以保证清晰度,CSS 会将其缩小显示 -->
|
|
235
|
+
<canvas id="chart" width="1856" height="900"></canvas>
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
<div class="footer">
|
|
239
|
+
<div class="stat-box">
|
|
240
|
+
<div class="stat-label">最高 High</div>
|
|
241
|
+
<div class="stat-value">{{HIGH_PRICE}}</div>
|
|
242
|
+
</div>
|
|
243
|
+
<div class="stat-box">
|
|
244
|
+
<div class="stat-label">最低 Low</div>
|
|
245
|
+
<div class="stat-value">{{LOW_PRICE}}</div>
|
|
246
|
+
</div>
|
|
247
|
+
<div class="stat-box">
|
|
248
|
+
<div class="stat-label">开盘 Open</div>
|
|
249
|
+
<div class="stat-value">{{START_PRICE}}</div>
|
|
250
|
+
</div>
|
|
251
|
+
<div class="stat-box">
|
|
252
|
+
<div class="stat-label">振幅 Amp</div>
|
|
253
|
+
<div class="stat-value">{{AMPLITUDE}}%</div>
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
<div class="update-time">数据更新于 {{UPDATE_TIME}}</div>
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<script>
|
|
260
|
+
const canvas = document.getElementById('chart');
|
|
261
|
+
const ctx = canvas.getContext('2d');
|
|
262
|
+
|
|
263
|
+
// 数据注入
|
|
264
|
+
const prices = JSON.parse('{{PRICES}}');
|
|
265
|
+
const times = JSON.parse('{{TIMES}}');
|
|
266
|
+
const timestamps = JSON.parse('{{TIMESTAMPS}}');
|
|
267
|
+
|
|
268
|
+
// 布局参数 - 适配新的 Canvas 尺寸
|
|
269
|
+
const W = canvas.width;
|
|
270
|
+
const H = canvas.height;
|
|
271
|
+
// 调整内边距,给字体更多呼吸空间
|
|
272
|
+
const padding = { top: 60, bottom: 80, left: 20, right: 160 };
|
|
273
|
+
|
|
274
|
+
// 数据计算
|
|
275
|
+
const maxPrice = Math.max(...prices);
|
|
276
|
+
const minPrice = Math.min(...prices);
|
|
277
|
+
const priceRange = maxPrice - minPrice || 1;
|
|
278
|
+
// 增加上下留白 (20%) 让曲线更平缓美观
|
|
279
|
+
const yMin = minPrice - priceRange * 0.2;
|
|
280
|
+
const yMax = maxPrice + priceRange * 0.2;
|
|
281
|
+
const yRange = yMax - yMin;
|
|
282
|
+
|
|
283
|
+
const tStart = timestamps[0];
|
|
284
|
+
const tEnd = timestamps[timestamps.length - 1];
|
|
285
|
+
const tRange = tEnd - tStart || 1;
|
|
286
|
+
|
|
287
|
+
// 坐标映射函数
|
|
288
|
+
const getX = t => padding.left + ((t - tStart) / tRange) * (W - padding.left - padding.right);
|
|
289
|
+
const getY = p => H - padding.bottom - ((p - yMin) / yRange) * (H - padding.top - padding.bottom);
|
|
290
|
+
|
|
291
|
+
// 1. 绘制网格线 (Grid) - 样式优化:更细、更淡
|
|
292
|
+
ctx.strokeStyle = 'rgba(42, 46, 57, 0.6)';
|
|
293
|
+
ctx.lineWidth = 2;
|
|
294
|
+
ctx.setLineDash([8, 8]); // 更稀疏的虚线
|
|
295
|
+
|
|
296
|
+
const gridCount = 4; // 减少网格线数量,更简洁
|
|
297
|
+
for (let i = 0; i <= gridCount; i++) {
|
|
298
|
+
const y = H - padding.bottom - (i / gridCount) * (H - padding.top - padding.bottom);
|
|
299
|
+
|
|
300
|
+
// 只画横线
|
|
301
|
+
ctx.beginPath();
|
|
302
|
+
ctx.moveTo(padding.left, y);
|
|
303
|
+
ctx.lineTo(W - padding.right, y);
|
|
304
|
+
ctx.stroke();
|
|
305
|
+
|
|
306
|
+
// Y轴标签 - 字体优化:变小、颜色变淡、更现代
|
|
307
|
+
const val = yMin + (i / gridCount) * yRange;
|
|
308
|
+
ctx.fillStyle = '#64748b'; // Slate-500
|
|
309
|
+
// 修改字体:使用 Trebuchet MS,尺寸调整
|
|
310
|
+
ctx.font = '500 28px "Trebuchet MS", monospace';
|
|
311
|
+
ctx.textAlign = 'left';
|
|
312
|
+
ctx.textBaseline = 'middle';
|
|
313
|
+
// 增加一点左边距
|
|
314
|
+
ctx.fillText(val.toFixed(2), W - padding.right + 24, y);
|
|
315
|
+
}
|
|
316
|
+
ctx.setLineDash([]);
|
|
317
|
+
|
|
318
|
+
// 2. 准备路径点
|
|
319
|
+
const points = prices.map((p, i) => ({
|
|
320
|
+
x: getX(timestamps[i]),
|
|
321
|
+
y: getY(p)
|
|
322
|
+
}));
|
|
323
|
+
|
|
324
|
+
// 3. 绘制渐变填充 (Area)
|
|
325
|
+
const gradient = ctx.createLinearGradient(0, padding.top, 0, H - padding.bottom);
|
|
326
|
+
// 使用 hex 转 rgba 模拟透明度变化 (这里假设 main color 逻辑在后端处理,此处使用 css 变量占位符不太好操作 canvas 渐变,
|
|
327
|
+
// 但保留原逻辑即可,因为 placeholder 会被替换)
|
|
328
|
+
gradient.addColorStop(0, '{{GRADIENT_START}}');
|
|
329
|
+
gradient.addColorStop(1, 'rgba(0,0,0,0)'); // 透明结尾
|
|
330
|
+
|
|
331
|
+
ctx.beginPath();
|
|
332
|
+
ctx.moveTo(points[0].x, H - padding.bottom);
|
|
333
|
+
|
|
334
|
+
if (points.length > 1) {
|
|
335
|
+
ctx.lineTo(points[0].x, points[0].y);
|
|
336
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
337
|
+
const p0 = points[i];
|
|
338
|
+
const p1 = points[i + 1];
|
|
339
|
+
const midX = (p0.x + p1.x) / 2;
|
|
340
|
+
const midY = (p0.y + p1.y) / 2;
|
|
341
|
+
ctx.quadraticCurveTo(p0.x, p0.y, midX, midY);
|
|
342
|
+
}
|
|
343
|
+
const last = points[points.length - 1];
|
|
344
|
+
ctx.lineTo(last.x, last.y);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
ctx.lineTo(points[points.length - 1].x, H - padding.bottom);
|
|
348
|
+
ctx.closePath();
|
|
349
|
+
ctx.fillStyle = gradient;
|
|
350
|
+
ctx.fill();
|
|
351
|
+
|
|
352
|
+
// 4. 绘制主线 (Line)
|
|
353
|
+
ctx.beginPath();
|
|
354
|
+
ctx.lineWidth = 6; // 线条加粗一点点
|
|
355
|
+
ctx.strokeStyle = '{{MAIN_COLOR}}';
|
|
356
|
+
ctx.lineCap = 'round';
|
|
357
|
+
ctx.lineJoin = 'round';
|
|
358
|
+
|
|
359
|
+
if (points.length > 1) {
|
|
360
|
+
ctx.moveTo(points[0].x, points[0].y);
|
|
361
|
+
for (let i = 0; i < points.length - 1; i++) {
|
|
362
|
+
const p0 = points[i];
|
|
363
|
+
const p1 = points[i + 1];
|
|
364
|
+
const midX = (p0.x + p1.x) / 2;
|
|
365
|
+
const midY = (p0.y + p1.y) / 2;
|
|
366
|
+
ctx.quadraticCurveTo(p0.x, p0.y, midX, midY);
|
|
367
|
+
}
|
|
368
|
+
ctx.lineTo(points[points.length - 1].x, points[points.length - 1].y);
|
|
369
|
+
}
|
|
370
|
+
ctx.stroke();
|
|
371
|
+
|
|
372
|
+
// 5. 绘制当前价格指示线 (Crosshair Line)
|
|
373
|
+
const lastPoint = points[points.length - 1];
|
|
374
|
+
ctx.beginPath();
|
|
375
|
+
ctx.setLineDash([4, 6]); // 更紧密的点状线
|
|
376
|
+
ctx.strokeStyle = '{{MAIN_COLOR}}';
|
|
377
|
+
ctx.lineWidth = 2;
|
|
378
|
+
ctx.moveTo(padding.left, lastPoint.y);
|
|
379
|
+
ctx.lineTo(W - padding.right, lastPoint.y);
|
|
380
|
+
ctx.stroke();
|
|
381
|
+
ctx.setLineDash([]);
|
|
382
|
+
|
|
383
|
+
// 6. 绘制当前价格标签 (Price Label)
|
|
384
|
+
const currentPriceStr = prices[prices.length - 1].toFixed(2);
|
|
385
|
+
// 标签字体优化
|
|
386
|
+
ctx.font = 'bold 32px "Trebuchet MS", monospace';
|
|
387
|
+
const textMetrics = ctx.measureText(currentPriceStr);
|
|
388
|
+
const labelPadX = 24;
|
|
389
|
+
const labelPadY = 16;
|
|
390
|
+
const labelWidth = textMetrics.width + (labelPadX * 2);
|
|
391
|
+
const labelHeight = 52;
|
|
392
|
+
const labelX = W - padding.right;
|
|
393
|
+
const labelY = lastPoint.y - labelHeight / 2;
|
|
394
|
+
|
|
395
|
+
// 标签背景
|
|
396
|
+
ctx.fillStyle = '{{MAIN_COLOR}}';
|
|
397
|
+
ctx.beginPath();
|
|
398
|
+
ctx.roundRect(labelX, labelY, labelWidth, labelHeight, 8); // 圆角更大
|
|
399
|
+
ctx.fill();
|
|
400
|
+
|
|
401
|
+
// 标签文字
|
|
402
|
+
ctx.fillStyle = '#ffffff';
|
|
403
|
+
ctx.textAlign = 'left';
|
|
404
|
+
ctx.textBaseline = 'middle';
|
|
405
|
+
ctx.fillText(currentPriceStr, labelX + labelPadX, lastPoint.y + 2);
|
|
406
|
+
|
|
407
|
+
// 7. 绘制呼吸灯圆点
|
|
408
|
+
const glow = ctx.createRadialGradient(lastPoint.x, lastPoint.y, 0, lastPoint.x, lastPoint.y, 40);
|
|
409
|
+
glow.addColorStop(0, '{{GLOW_COLOR}}');
|
|
410
|
+
glow.addColorStop(1, 'rgba(0,0,0,0)');
|
|
411
|
+
ctx.fillStyle = glow;
|
|
412
|
+
ctx.beginPath();
|
|
413
|
+
ctx.arc(lastPoint.x, lastPoint.y, 40, 0, Math.PI * 2);
|
|
414
|
+
ctx.fill();
|
|
415
|
+
|
|
416
|
+
ctx.fillStyle = '#ffffff';
|
|
417
|
+
ctx.beginPath();
|
|
418
|
+
ctx.arc(lastPoint.x, lastPoint.y, 8, 0, Math.PI * 2);
|
|
419
|
+
ctx.fill();
|
|
420
|
+
|
|
421
|
+
// 8. X轴时间标签 (Time Labels) - 字体与布局优化
|
|
422
|
+
ctx.textAlign = 'center';
|
|
423
|
+
ctx.textBaseline = 'top';
|
|
424
|
+
ctx.fillStyle = '#64748b'; // Slate-500
|
|
425
|
+
// 修改字体:System UI font, lighter weight
|
|
426
|
+
ctx.font = '500 24px -apple-system, BlinkMacSystemFont, "Inter", sans-serif';
|
|
427
|
+
|
|
428
|
+
const occupied = [];
|
|
429
|
+
const addLabel = (text, x) => {
|
|
430
|
+
const w = ctx.measureText(text).width;
|
|
431
|
+
const left = x - w / 2;
|
|
432
|
+
const right = x + w / 2;
|
|
433
|
+
for (const r of occupied) {
|
|
434
|
+
if (left < r.right + 40 && right > r.left - 40) return false; // 增加间距判断
|
|
435
|
+
}
|
|
436
|
+
if (left < 0 || right > W) return false;
|
|
437
|
+
|
|
438
|
+
occupied.push({ left, right });
|
|
439
|
+
ctx.fillText(text, x, H - padding.bottom + 24); // 下移一点
|
|
440
|
+
return true;
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// 逻辑保持不变,但参数微调
|
|
444
|
+
addLabel(times[0], getX(timestamps[0]));
|
|
445
|
+
|
|
446
|
+
const lastIdx = times.length - 1;
|
|
447
|
+
if (lastIdx > 0) {
|
|
448
|
+
const lastX = getX(timestamps[lastIdx]);
|
|
449
|
+
const lastText = times[lastIdx];
|
|
450
|
+
const lastW = ctx.measureText(lastText).width;
|
|
451
|
+
const lastRect = { left: lastX - lastW/2, right: lastX + lastW/2 };
|
|
452
|
+
|
|
453
|
+
const totalW = W - padding.left - padding.right;
|
|
454
|
+
const singleW = ctx.measureText("00:00").width + 80;
|
|
455
|
+
const maxCount = Math.floor(totalW / singleW);
|
|
456
|
+
const step = Math.max(1, Math.ceil((times.length - 2) / (maxCount - 2)));
|
|
457
|
+
|
|
458
|
+
for (let i = step; i < lastIdx; i += step) {
|
|
459
|
+
if (i >= lastIdx) break;
|
|
460
|
+
const x = getX(timestamps[i]);
|
|
461
|
+
const text = times[i];
|
|
462
|
+
const w = ctx.measureText(text).width;
|
|
463
|
+
const left = x - w/2;
|
|
464
|
+
const right = x + w/2;
|
|
465
|
+
let hit = false;
|
|
466
|
+
for (const r of occupied) {
|
|
467
|
+
if (left < r.right + 40 && right > r.left - 40) hit = true;
|
|
468
|
+
}
|
|
469
|
+
if (left < lastRect.right + 40 && right > lastRect.left - 40) hit = true;
|
|
470
|
+
|
|
471
|
+
if (!hit) {
|
|
472
|
+
addLabel(text, x);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
ctx.fillText(lastText, lastX, H - padding.bottom + 24);
|
|
476
|
+
}
|
|
477
|
+
</script>
|
|
478
|
+
</body>
|
|
469
479
|
</html>
|