dsh-api-runner 0.1.0 → 0.2.0
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/README.md +58 -14
- package/client/client.js +1824 -1604
- package/package.json +71 -77
- package/src/java-runner.js +3 -3
- package/src/main.js +31 -2
- package/src/ops.js +218 -0
- package/src/restart.js +43 -12
- package/test/client.mjs +162 -109
- package/test/plugin.mjs +34 -0
- package/test/smoke.mjs +85 -0
package/client/client.js
CHANGED
|
@@ -1,1604 +1,1824 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-api-runner 侧边栏面板(Client half)。
|
|
3
|
-
*
|
|
4
|
-
* 这是给 DSH Web 前端加载的**经典脚本**(不是 ESM):由 client-modules 注入
|
|
5
|
-
* window.__ModuleLoader__,我们把自己的 factory 注册进去,由它提供 require。
|
|
6
|
-
* 导出 inject / apply,与 host half 的 ESM 形态不同,不要混用。
|
|
7
|
-
*
|
|
8
|
-
* 视觉:与 dsh-db-tool 一致的「inset grouped / iOS 分段控件」风格——
|
|
9
|
-
* · 顶部整条分段控件(接口 / 服务 / 设置)
|
|
10
|
-
* · 卡片用半透明灰膜 + 大圆角,不用描边
|
|
11
|
-
* · 输入框无边框、填充式;按钮为胶囊填充
|
|
12
|
-
* · 列表一张卡片多行,行间 hairline
|
|
13
|
-
* 颜色:中性色用 rgba 灰膜(明暗主题都成立),强调色/状态色优先取
|
|
14
|
-
* --dsw-alias-* 主题 token,取不到时回落到固定色;不写死正文文字色,直接继承。
|
|
15
|
-
*/
|
|
16
|
-
window.__ModuleLoader__.load({
|
|
17
|
-
id: 'dsh-api-runner',
|
|
18
|
-
factory: (require) => {
|
|
19
|
-
var module = { exports: {} };
|
|
20
|
-
var exports = module.exports;
|
|
21
|
-
|
|
22
|
-
const React = require('react');
|
|
23
|
-
const h = React.createElement;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
font-
|
|
35
|
-
|
|
36
|
-
--ar-
|
|
37
|
-
--ar-surface
|
|
38
|
-
--ar-
|
|
39
|
-
--ar-
|
|
40
|
-
--ar-
|
|
41
|
-
--ar-
|
|
42
|
-
--ar-
|
|
43
|
-
--ar-r-
|
|
44
|
-
--ar-r-
|
|
45
|
-
--ar-
|
|
46
|
-
--ar-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
--ar-
|
|
52
|
-
--ar-
|
|
53
|
-
--ar-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.ar-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
border
|
|
63
|
-
|
|
64
|
-
.ar-
|
|
65
|
-
.ar-tab
|
|
66
|
-
.ar-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.ar-
|
|
77
|
-
.ar-
|
|
78
|
-
.ar-
|
|
79
|
-
.ar-
|
|
80
|
-
.ar-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
.ar-sec
|
|
85
|
-
.ar-sec
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.ar-tabs.sub
|
|
93
|
-
.ar-tabs.sub .ar-tab
|
|
94
|
-
.ar-tabs.sub .ar-tab.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
.ar-tabs.sub .ar-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.ar-tabs.ar-projects
|
|
103
|
-
.ar-tabs.ar-projects
|
|
104
|
-
.ar-tabs.ar-projects .ar-tab
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
.ar-
|
|
115
|
-
.ar-
|
|
116
|
-
.ar-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
.ar-badge.
|
|
124
|
-
.ar-badge.
|
|
125
|
-
.ar-badge.
|
|
126
|
-
.ar-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
.ar-m.
|
|
131
|
-
.ar-m.
|
|
132
|
-
.ar-m.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.ar-url
|
|
137
|
-
.ar-url .
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
.ar-
|
|
145
|
-
.ar-btn:disabled {
|
|
146
|
-
.ar-btn
|
|
147
|
-
.ar-btn.
|
|
148
|
-
.ar-btn.
|
|
149
|
-
.ar-btn.
|
|
150
|
-
.ar-btn.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
.ar-btn
|
|
154
|
-
.ar-btn.
|
|
155
|
-
.ar-btn.
|
|
156
|
-
.ar-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
.ar-field
|
|
162
|
-
.ar-field
|
|
163
|
-
.ar-field
|
|
164
|
-
.ar-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
.ar-sel {
|
|
170
|
-
.ar-
|
|
171
|
-
.ar-
|
|
172
|
-
.ar-in
|
|
173
|
-
.ar-
|
|
174
|
-
.ar-check
|
|
175
|
-
.ar-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
.ar-banner > .ar-x:
|
|
190
|
-
.ar-banner.
|
|
191
|
-
.ar-banner.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
.ar-seg
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
.ar-seg > button
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
.ar-empty
|
|
206
|
-
.ar-empty-
|
|
207
|
-
.ar-empty-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
.ar-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
.ar-
|
|
216
|
-
|
|
217
|
-
.ar-
|
|
218
|
-
.ar-
|
|
219
|
-
|
|
220
|
-
.ar-
|
|
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
|
-
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
return {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
return
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
headersText:
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
function
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
h('
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
h(
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
h('div', { className: 'ar-
|
|
481
|
-
|
|
482
|
-
h('
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
h('span', { className: 'ar-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
h('
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
h('
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
className: 'ar-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}),
|
|
749
|
-
h('span', { className: 'ar-
|
|
750
|
-
h('
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
h('
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
const
|
|
816
|
-
const
|
|
817
|
-
const [
|
|
818
|
-
const
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
const
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
const
|
|
908
|
-
return (
|
|
909
|
-
}, [
|
|
910
|
-
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
const
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
const
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
const
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
try {
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
:
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
await postApi('ui/
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
await
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
}
|
|
1042
|
-
};
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
title: '
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
item,
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
:
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
? (
|
|
1333
|
-
|
|
1334
|
-
:
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
})))
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
const
|
|
1351
|
-
h(
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
'
|
|
1384
|
-
|
|
1385
|
-
h('
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
:
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
:
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
h('div', { className: 'ar-
|
|
1561
|
-
|
|
1562
|
-
h('div', { className: 'ar-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1
|
+
/**
|
|
2
|
+
* dsh-api-runner 侧边栏面板(Client half)。
|
|
3
|
+
*
|
|
4
|
+
* 这是给 DSH Web 前端加载的**经典脚本**(不是 ESM):由 client-modules 注入
|
|
5
|
+
* window.__ModuleLoader__,我们把自己的 factory 注册进去,由它提供 require。
|
|
6
|
+
* 导出 inject / apply,与 host half 的 ESM 形态不同,不要混用。
|
|
7
|
+
*
|
|
8
|
+
* 视觉:与 dsh-db-tool 一致的「inset grouped / iOS 分段控件」风格——
|
|
9
|
+
* · 顶部整条分段控件(接口 / 服务 / 设置)
|
|
10
|
+
* · 卡片用半透明灰膜 + 大圆角,不用描边
|
|
11
|
+
* · 输入框无边框、填充式;按钮为胶囊填充
|
|
12
|
+
* · 列表一张卡片多行,行间 hairline
|
|
13
|
+
* 颜色:中性色用 rgba 灰膜(明暗主题都成立),强调色/状态色优先取
|
|
14
|
+
* --dsw-alias-* 主题 token,取不到时回落到固定色;不写死正文文字色,直接继承。
|
|
15
|
+
*/
|
|
16
|
+
window.__ModuleLoader__.load({
|
|
17
|
+
id: 'dsh-api-runner',
|
|
18
|
+
factory: (require) => {
|
|
19
|
+
var module = { exports: {} };
|
|
20
|
+
var exports = module.exports;
|
|
21
|
+
|
|
22
|
+
const React = require('react');
|
|
23
|
+
const h = React.createElement;
|
|
24
|
+
|
|
25
|
+
/** 面板 id:既是左栏全局页在 `main` 里的 key,也是 `sidebar.panellist` 的 id */
|
|
26
|
+
const TAB_ID = 'dsh-api-runner';
|
|
27
|
+
const API = '/dsh-api-runner/api';
|
|
28
|
+
const STYLE_ID = 'dsh-api-runner-style';
|
|
29
|
+
const METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'];
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------- 样式
|
|
32
|
+
const CSS = `
|
|
33
|
+
.ar-root { display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0; box-sizing: border-box;
|
|
34
|
+
font-size: 13px; line-height: 1.45; -webkit-font-smoothing: antialiased;
|
|
35
|
+
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
|
|
36
|
+
--ar-accent: var(--dsw-alias-brand-primary, #0a84ff);
|
|
37
|
+
--ar-surface: rgba(120, 120, 128, .12);
|
|
38
|
+
--ar-surface-strong: rgba(120, 120, 128, .18);
|
|
39
|
+
--ar-sep: rgba(120, 120, 128, .22);
|
|
40
|
+
--ar-danger: var(--dsw-alias-state-error-primary, #ff453a);
|
|
41
|
+
--ar-success: var(--dsw-alias-state-success-primary, #30d158);
|
|
42
|
+
--ar-warn: var(--dsw-alias-state-warn-primary, #ffd60a);
|
|
43
|
+
--ar-r-card: 12px;
|
|
44
|
+
--ar-r-ctrl: 8px;
|
|
45
|
+
--ar-r-pill: 6px;
|
|
46
|
+
--ar-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
47
|
+
--ar-ease: cubic-bezier(.25, .1, .25, 1);
|
|
48
|
+
}
|
|
49
|
+
@media (prefers-color-scheme: light) {
|
|
50
|
+
.ar-root { --ar-surface: rgba(120, 120, 128, .09); --ar-surface-strong: rgba(120, 120, 128, .15);
|
|
51
|
+
--ar-sep: rgba(60, 60, 67, .16);
|
|
52
|
+
--ar-danger: var(--dsw-alias-state-error-primary, #ff3b30);
|
|
53
|
+
--ar-success: var(--dsw-alias-state-success-primary, #34c759);
|
|
54
|
+
--ar-warn: var(--dsw-alias-state-warn-primary, #ff9f0a); }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/* ---- 顶部:整条分段控件 ---- */
|
|
58
|
+
.ar-top { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; padding: 10px 12px 8px; }
|
|
59
|
+
.ar-tabs { flex: 1 1 auto; display: flex; gap: 2px; padding: 2px; min-width: 0;
|
|
60
|
+
background: var(--ar-surface); border-radius: var(--ar-r-ctrl); }
|
|
61
|
+
.ar-tab { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
|
|
62
|
+
border: 0; background: transparent; color: inherit; cursor: pointer; padding: 5px 8px; font: inherit; font-size: 12.5px;
|
|
63
|
+
border-radius: var(--ar-r-pill); white-space: nowrap; opacity: .68;
|
|
64
|
+
transition: background-color .18s var(--ar-ease), opacity .18s var(--ar-ease), box-shadow .18s var(--ar-ease); }
|
|
65
|
+
.ar-tab:hover { opacity: .9; }
|
|
66
|
+
.ar-tab.on { opacity: 1; font-weight: 600; background: var(--ar-surface-strong); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
|
|
67
|
+
.ar-count { font-size: 10px; font-weight: 600; line-height: 1; padding: 2px 4px; border-radius: 4px;
|
|
68
|
+
background: var(--ar-surface-strong); opacity: .85; }
|
|
69
|
+
.ar-tab.on .ar-count { background: var(--ar-accent); color: #fff; opacity: 1; }
|
|
70
|
+
|
|
71
|
+
.ar-body { flex: 1 1 auto; min-height: 0; min-width: 0; overflow-y: auto; padding: 2px 12px 24px;
|
|
72
|
+
display: flex; flex-direction: column; gap: 10px; }
|
|
73
|
+
.ar-pane { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
|
|
74
|
+
|
|
75
|
+
/* ---- 排版 ---- */
|
|
76
|
+
.ar-mono { font-family: var(--ar-mono); }
|
|
77
|
+
.ar-muted { opacity: .6; }
|
|
78
|
+
.ar-faint { opacity: .45; }
|
|
79
|
+
.ar-cut { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
80
|
+
.ar-spacer { flex: 1 1 auto; min-width: 0; }
|
|
81
|
+
.ar-row { display: flex; align-items: center; gap: 6px; }
|
|
82
|
+
|
|
83
|
+
/* 分组标题:一行小标题 + 右延细线 */
|
|
84
|
+
.ar-sec { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
|
|
85
|
+
.ar-sec .t { font-size: 12.5px; font-weight: 600; letter-spacing: .01em; opacity: .72; white-space: nowrap; }
|
|
86
|
+
.ar-sec::after { content: ''; flex: 1 1 auto; height: 1px; background: var(--ar-sep); }
|
|
87
|
+
|
|
88
|
+
/* 二级页签:和顶部同一套分段控件,但用颜色区分层级——
|
|
89
|
+
顶部(接口/服务/设置)是灰底 + 灰白选中块,二级(已接管/运行中/…、项目分类)去掉灰底容器、
|
|
90
|
+
选中态用品牌色实心块。这样一眼能看出「当前在哪一层」,不会和顶部混成同一排。
|
|
91
|
+
注意:选中态用实心 accent 而不是半透明混合,避免依赖 color-mix,浅色/深色主题都稳。 */
|
|
92
|
+
.ar-tabs.sub { flex: none; background: transparent; padding: 0; gap: 4px; }
|
|
93
|
+
.ar-tabs.sub .ar-tab { padding: 4px 8px; font-size: 12px; background: var(--ar-surface); opacity: .72; }
|
|
94
|
+
.ar-tabs.sub .ar-tab:hover { opacity: .95; }
|
|
95
|
+
.ar-tabs.sub .ar-tab.on {
|
|
96
|
+
background: var(--ar-accent); color: #fff; opacity: 1; font-weight: 600;
|
|
97
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
|
|
98
|
+
}
|
|
99
|
+
.ar-tabs.sub .ar-count { font-size: 9.5px; padding: 1px 4px; background: var(--ar-surface-strong); opacity: .9; }
|
|
100
|
+
.ar-tabs.sub .ar-tab.on .ar-count { background: rgba(255, 255, 255, .26); color: #fff; opacity: 1; }
|
|
101
|
+
/* 项目多的时候横向滚动,不换行、不压扁页签 */
|
|
102
|
+
.ar-tabs.ar-projects { overflow-x: auto; scrollbar-width: none; }
|
|
103
|
+
.ar-tabs.ar-projects::-webkit-scrollbar { display: none; }
|
|
104
|
+
.ar-tabs.ar-projects .ar-tab { flex: 0 0 auto; max-width: 132px; }
|
|
105
|
+
.ar-tabs.ar-projects .ar-tab .l { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
106
|
+
|
|
107
|
+
/* ---- inset grouped 卡片 ---- */
|
|
108
|
+
.ar-card { display: flex; flex-direction: column; gap: 9px; padding: 12px;
|
|
109
|
+
background: var(--ar-surface); border: 0; border-radius: var(--ar-r-card); }
|
|
110
|
+
.ar-group { display: flex; flex-direction: column; background: var(--ar-surface);
|
|
111
|
+
border-radius: var(--ar-r-card); overflow: hidden; }
|
|
112
|
+
.ar-item { display: flex; flex-direction: column; gap: 6px; padding: 11px 12px;
|
|
113
|
+
transition: background-color .15s var(--ar-ease); }
|
|
114
|
+
.ar-item + .ar-item { border-top: 1px solid var(--ar-sep); }
|
|
115
|
+
.ar-head { display: flex; align-items: flex-start; gap: 8px; }
|
|
116
|
+
.ar-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
|
|
117
|
+
.ar-name { font-size: 13px; font-weight: 600; }
|
|
118
|
+
|
|
119
|
+
/* ---- 徽章 / 方法标 ---- */
|
|
120
|
+
.ar-badge { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: var(--ar-r-pill);
|
|
121
|
+
font-size: 11px; font-weight: 500; white-space: nowrap; line-height: 1;
|
|
122
|
+
background: var(--ar-surface-strong); opacity: .9; }
|
|
123
|
+
.ar-badge.ok { color: var(--ar-success); background: rgba(48, 209, 88, .14); opacity: 1; }
|
|
124
|
+
.ar-badge.warn { color: var(--ar-warn); background: rgba(255, 214, 10, .14); opacity: 1; }
|
|
125
|
+
.ar-badge.err { color: var(--ar-danger); background: rgba(255, 69, 58, .14); opacity: 1; }
|
|
126
|
+
.ar-badge.brand { color: var(--ar-accent); background: rgba(10, 132, 255, .14); opacity: 1; }
|
|
127
|
+
.ar-m { display: inline-flex; align-items: center; justify-content: center; flex: none;
|
|
128
|
+
min-width: 46px; height: 19px; padding: 0 5px; border-radius: 5px;
|
|
129
|
+
font-family: var(--ar-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }
|
|
130
|
+
.ar-m.get { color: #0a84ff; background: rgba(10, 132, 255, .14); }
|
|
131
|
+
.ar-m.post { color: #34c759; background: rgba(52, 199, 89, .16); }
|
|
132
|
+
.ar-m.put, .ar-m.patch { color: #ff9f0a; background: rgba(255, 159, 10, .16); }
|
|
133
|
+
.ar-m.del { color: #ff3b30; background: rgba(255, 59, 48, .14); }
|
|
134
|
+
|
|
135
|
+
/* ---- 地址:host 弱、path 强 ---- */
|
|
136
|
+
.ar-url { font-family: var(--ar-mono); font-size: 11.5px; overflow-wrap: anywhere; }
|
|
137
|
+
.ar-url .h { opacity: .5; }
|
|
138
|
+
.ar-url .p { opacity: .95; }
|
|
139
|
+
|
|
140
|
+
/* ---- 按钮:胶囊填充 ---- */
|
|
141
|
+
.ar-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px;
|
|
142
|
+
border: 0; border-radius: var(--ar-r-ctrl); padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 500;
|
|
143
|
+
cursor: pointer; white-space: nowrap; color: inherit; background: var(--ar-surface);
|
|
144
|
+
transition: background-color .18s var(--ar-ease), filter .18s var(--ar-ease), transform .18s var(--ar-ease), opacity .18s var(--ar-ease); }
|
|
145
|
+
.ar-btn:active:not(:disabled) { transform: scale(.97); }
|
|
146
|
+
.ar-btn:disabled { opacity: .38; cursor: default; transform: none; }
|
|
147
|
+
.ar-btn.primary { background: var(--ar-accent); color: #fff; }
|
|
148
|
+
.ar-btn.tonal { background: var(--ar-surface-strong); }
|
|
149
|
+
.ar-btn.ghost { background: transparent; opacity: .62; padding: 5px 9px; }
|
|
150
|
+
.ar-btn.danger { color: var(--ar-danger); }
|
|
151
|
+
.ar-btn.icon { padding: 5px; width: 28px; }
|
|
152
|
+
@media (hover: hover) and (pointer: fine) {
|
|
153
|
+
.ar-btn:hover:not(:disabled) { background: var(--ar-surface-strong); }
|
|
154
|
+
.ar-btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--ar-accent); }
|
|
155
|
+
.ar-btn.ghost:hover:not(:disabled) { background: var(--ar-surface); opacity: .95; }
|
|
156
|
+
.ar-btn.danger:hover:not(:disabled) { background: rgba(255, 69, 58, .12); }
|
|
157
|
+
.ar-item:hover { background: var(--ar-surface-strong); }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* ---- 表单:无边框填充 ---- */
|
|
161
|
+
.ar-field { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; align-items: center; }
|
|
162
|
+
.ar-field.top { align-items: start; }
|
|
163
|
+
.ar-field > label { font-size: 12px; opacity: .62; }
|
|
164
|
+
.ar-field.top > label { padding-top: 7px; }
|
|
165
|
+
.ar-in, .ar-sel, .ar-ta { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px;
|
|
166
|
+
color: inherit; background: var(--ar-surface-strong); border: 0; border-radius: var(--ar-r-ctrl);
|
|
167
|
+
padding: 6px 10px; outline: 2px solid transparent; outline-offset: -1px;
|
|
168
|
+
transition: outline-color .18s var(--ar-ease); }
|
|
169
|
+
.ar-in, .ar-sel { height: 30px; padding-top: 0; padding-bottom: 0; }
|
|
170
|
+
.ar-sel { cursor: pointer; }
|
|
171
|
+
.ar-ta { min-height: 60px; resize: vertical; font-family: var(--ar-mono); font-size: 12px; line-height: 1.5; }
|
|
172
|
+
.ar-in:focus, .ar-sel:focus, .ar-ta:focus { outline-color: var(--ar-accent); }
|
|
173
|
+
.ar-in::placeholder, .ar-ta::placeholder { color: inherit; opacity: .38; }
|
|
174
|
+
.ar-check { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; }
|
|
175
|
+
.ar-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--ar-accent); cursor: pointer; flex: none; }
|
|
176
|
+
.ar-hint { font-size: 11.5px; opacity: .55; line-height: 1.55; }
|
|
177
|
+
|
|
178
|
+
/* ---- 提示条 ---- */
|
|
179
|
+
.ar-banner { display: flex; align-items: flex-start; gap: 7px; padding: 8px 11px;
|
|
180
|
+
border-radius: var(--ar-r-ctrl); font-size: 12.5px; line-height: 1.5;
|
|
181
|
+
background: var(--ar-surface); }
|
|
182
|
+
.ar-banner > span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
|
|
183
|
+
/* 关闭按钮做成「纯文字 ×」:无边框无底色,颜色跟着提示条走,位置钉在最后一行右侧 */
|
|
184
|
+
.ar-banner > .ar-x { flex: none; margin-left: auto; align-self: center;
|
|
185
|
+
appearance: none; -webkit-appearance: none; border: 0 none; background: none; box-shadow: none;
|
|
186
|
+
color: inherit; cursor: pointer; font-family: inherit; font-size: 15px; line-height: 1;
|
|
187
|
+
padding: 0 1px 2px; border-radius: 4px; opacity: .55;
|
|
188
|
+
transition: opacity .16s var(--ar-ease); }
|
|
189
|
+
.ar-banner > .ar-x:hover { opacity: .95; }
|
|
190
|
+
.ar-banner > .ar-x:focus-visible { outline: 1px solid currentColor; outline-offset: 1px; opacity: .95; }
|
|
191
|
+
.ar-banner.err { color: var(--ar-danger); background: rgba(255, 69, 58, .12); }
|
|
192
|
+
.ar-banner.ok { color: var(--ar-success); background: rgba(52, 199, 89, .12); }
|
|
193
|
+
|
|
194
|
+
/* ---- 响应查看 ---- */
|
|
195
|
+
.ar-pre { margin: 0; padding: 10px 11px; border-radius: var(--ar-r-ctrl);
|
|
196
|
+
background: var(--ar-surface-strong); font-family: var(--ar-mono); font-size: 12px; line-height: 1.55;
|
|
197
|
+
white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; }
|
|
198
|
+
.ar-seg { display: flex; gap: 2px; padding: 2px; background: var(--ar-surface); border-radius: var(--ar-r-pill); }
|
|
199
|
+
.ar-seg > button { border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; font-size: 11.5px;
|
|
200
|
+
padding: 3px 9px; border-radius: 5px; opacity: .62; transition: background-color .18s var(--ar-ease), opacity .18s var(--ar-ease); }
|
|
201
|
+
.ar-seg > button:hover { opacity: .9; }
|
|
202
|
+
.ar-seg > button.on { opacity: 1; font-weight: 600; background: var(--ar-surface-strong); }
|
|
203
|
+
|
|
204
|
+
/* ---- 空态 ---- */
|
|
205
|
+
.ar-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 16px; text-align: center; }
|
|
206
|
+
.ar-empty-icon { font-size: 22px; opacity: .3; line-height: 1; }
|
|
207
|
+
.ar-empty-title { font-size: 13px; font-weight: 600; }
|
|
208
|
+
.ar-empty-hint { font-size: 12px; opacity: .55; line-height: 1.6; max-width: 230px; }
|
|
209
|
+
|
|
210
|
+
/* ---- 一键启动进度 ---- */
|
|
211
|
+
.ar-batch { display: flex; flex-direction: column; gap: 6px; padding: 9px 11px; border-radius: var(--ar-r-card);
|
|
212
|
+
background: var(--ar-surface); }
|
|
213
|
+
.ar-batch-top { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
|
|
214
|
+
.ar-batch-bar { height: 4px; border-radius: 2px; background: var(--ar-surface-strong); overflow: hidden; }
|
|
215
|
+
.ar-batch-bar > i { display: block; height: 100%; border-radius: 2px; background: var(--ar-accent);
|
|
216
|
+
transition: width .25s var(--ar-ease); }
|
|
217
|
+
.ar-batch-line { display: flex; align-items: baseline; gap: 6px; font-size: 12px; }
|
|
218
|
+
.ar-batch-line > .n { flex: 0 0 auto; font-family: var(--ar-mono); }
|
|
219
|
+
.ar-batch-line.ok > .n { color: var(--ar-success); }
|
|
220
|
+
.ar-batch-line.err > .n { color: var(--ar-danger); }
|
|
221
|
+
.ar-batch-line.skip > .n { color: var(--ar-warn); }
|
|
222
|
+
|
|
223
|
+
/* ---- 键值行 ---- */
|
|
224
|
+
.ar-kv { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
|
|
225
|
+
.ar-kv > .k { flex: 0 0 55px; opacity: .55; }
|
|
226
|
+
.ar-kv > .v { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
|
|
227
|
+
|
|
228
|
+
/* ---- 服务详情 / 实时日志 ---- */
|
|
229
|
+
.ar-detail { display: flex; flex-direction: column; gap: 9px; min-width: 0; }
|
|
230
|
+
.ar-detail-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
|
|
231
|
+
.ar-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ar-success); }
|
|
232
|
+
.ar-dot.off { background: var(--ar-danger); }
|
|
233
|
+
/* 已忽略的服务整体压暗,但仍可操作(取消忽略) */
|
|
234
|
+
.ar-ignored { opacity: .55; }
|
|
235
|
+
/* 日志容器:宽度必须被父级约束住,否则 flex 的 min-width:auto 会让它按内容撑开,
|
|
236
|
+
看起来就像「不换行」(踩过:只设 white-space:pre-wrap 但父级没 min-width:0 时无效)。 */
|
|
237
|
+
.ar-log { margin: 0; padding: 10px 11px; border-radius: var(--ar-r-ctrl); width: 100%; box-sizing: border-box;
|
|
238
|
+
background: var(--ar-surface-strong); font-family: var(--ar-mono); font-size: 11.5px; line-height: 1.62;
|
|
239
|
+
white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
|
|
240
|
+
max-height: 58vh; min-height: 140px; overflow-y: auto; overflow-x: hidden; tab-size: 4; }
|
|
241
|
+
.ar-log.nowrap { white-space: pre; overflow-wrap: normal; word-break: normal; overflow-x: auto; }
|
|
242
|
+
.ar-log:empty::before { content: '(暂无日志输出)'; opacity: .45; }
|
|
243
|
+
|
|
244
|
+
@media (prefers-reduced-motion: reduce) {
|
|
245
|
+
.ar-root * { transition: none !important; animation: none !important; }
|
|
246
|
+
}
|
|
247
|
+
`;
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* 插入样式表。
|
|
251
|
+
* 优先用宿主给动态 Client half 的 styles.insert(由 DSH 管理生命周期、
|
|
252
|
+
* 保证插到正确的文档根);取不到才退回 document.head,与 dsh-db-tool 同法。
|
|
253
|
+
*/
|
|
254
|
+
function installStyles(ctx) {
|
|
255
|
+
let api;
|
|
256
|
+
if (typeof styles !== 'undefined' && styles && typeof styles.insert === 'function') api = styles;
|
|
257
|
+
else if (ctx && typeof ctx.get === 'function') api = ctx.get('styles');
|
|
258
|
+
if (api && typeof api.insert === 'function') {
|
|
259
|
+
api.insert(CSS);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
263
|
+
const el = document.createElement('style');
|
|
264
|
+
el.id = STYLE_ID;
|
|
265
|
+
el.textContent = CSS;
|
|
266
|
+
(document.head || document.documentElement).appendChild(el);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// ---------------------------------------------------------------- 工具
|
|
270
|
+
async function request(path, init) {
|
|
271
|
+
const res = await fetch(`${API}/${path}`, init);
|
|
272
|
+
let data;
|
|
273
|
+
try {
|
|
274
|
+
data = await res.json();
|
|
275
|
+
} catch {
|
|
276
|
+
data = undefined;
|
|
277
|
+
}
|
|
278
|
+
if (res.status === 401) throw new Error('需要先登录 DSH 网页端(请求未通过鉴权)');
|
|
279
|
+
if (!data) throw new Error(`接口无 JSON 响应(HTTP ${res.status})`);
|
|
280
|
+
return data;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async function copyText(text) {
|
|
284
|
+
try {
|
|
285
|
+
await navigator.clipboard.writeText(text);
|
|
286
|
+
return true;
|
|
287
|
+
} catch {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function pretty(value) {
|
|
293
|
+
try {
|
|
294
|
+
return JSON.stringify(value, null, 2);
|
|
295
|
+
} catch {
|
|
296
|
+
return String(value);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function byteSize(value) {
|
|
301
|
+
try {
|
|
302
|
+
const text = typeof value === 'string' ? value : JSON.stringify(value);
|
|
303
|
+
const bytes = new TextEncoder().encode(text || '').length;
|
|
304
|
+
return bytes < 1024 ? `${bytes} B` : `${(bytes / 1024).toFixed(1)} KB`;
|
|
305
|
+
} catch {
|
|
306
|
+
return '';
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function splitUrl(url) {
|
|
311
|
+
const text = String(url || '');
|
|
312
|
+
const match = /^([a-z]+:\/\/[^/]+)([\s\S]*)$/i.exec(text);
|
|
313
|
+
if (!match) return { host: '', path: text };
|
|
314
|
+
return { host: match[1], path: match[2] || '/' };
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function methodClass(method) {
|
|
318
|
+
const m = String(method || 'GET').toLowerCase();
|
|
319
|
+
if (m === 'get' || m === 'head') return 'ar-m get';
|
|
320
|
+
if (m === 'post') return 'ar-m post';
|
|
321
|
+
if (m === 'put' || m === 'patch') return 'ar-m put';
|
|
322
|
+
if (m === 'delete') return 'ar-m del';
|
|
323
|
+
return 'ar-m';
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function emptyForm(baseUrl) {
|
|
327
|
+
return {
|
|
328
|
+
id: '', name: '', method: 'GET', url: '', baseUrl: baseUrl || '', description: '',
|
|
329
|
+
headersText: '', bodyText: '', sampleText: '', useToken: '',
|
|
330
|
+
isLogin: false, tokenPath: 'token', authHeader: 'Authorization', prefix: 'Bearer ',
|
|
331
|
+
timeoutMs: 30000,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function formFromApi(api) {
|
|
336
|
+
return {
|
|
337
|
+
id: api.id,
|
|
338
|
+
name: api.name || api.id,
|
|
339
|
+
method: api.method || 'GET',
|
|
340
|
+
url: api.url || '',
|
|
341
|
+
baseUrl: api.baseUrl || '',
|
|
342
|
+
description: api.description || '',
|
|
343
|
+
headersText: api.headersText || '',
|
|
344
|
+
bodyText: api.bodyText || '',
|
|
345
|
+
sampleText: api.sampleText || '',
|
|
346
|
+
useToken: api.useToken || '',
|
|
347
|
+
isLogin: Boolean(api.isLogin),
|
|
348
|
+
tokenPath: api.tokenPath || 'token',
|
|
349
|
+
authHeader: api.header || 'Authorization',
|
|
350
|
+
prefix: api.prefix === undefined ? 'Bearer ' : api.prefix,
|
|
351
|
+
timeoutMs: api.timeoutMs || 30000,
|
|
352
|
+
source: api.source,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function parseJsonField(text, label) {
|
|
357
|
+
const trimmed = String(text || '').trim();
|
|
358
|
+
if (trimmed === '') return undefined;
|
|
359
|
+
try {
|
|
360
|
+
return JSON.parse(trimmed);
|
|
361
|
+
} catch (error) {
|
|
362
|
+
throw new Error(`${label} 不是合法 JSON:${error.message}`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function placeholderNames(api) {
|
|
367
|
+
const out = new Set(Array.isArray(api.params) ? api.params : []);
|
|
368
|
+
const scan = (value) => {
|
|
369
|
+
if (typeof value === 'string') {
|
|
370
|
+
for (const match of value.matchAll(/\{([A-Za-z_][A-Za-z0-9_.-]*)\}/g)) out.add(match[1]);
|
|
371
|
+
} else if (Array.isArray(value)) value.forEach(scan);
|
|
372
|
+
else if (value && typeof value === 'object') Object.values(value).forEach(scan);
|
|
373
|
+
};
|
|
374
|
+
scan(api.url);
|
|
375
|
+
scan(api.bodyText);
|
|
376
|
+
return [...out];
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// ---------------------------------------------------------------- 组件
|
|
380
|
+
function Field(props) {
|
|
381
|
+
return h('div', { className: props.top ? 'ar-field top' : 'ar-field' },
|
|
382
|
+
h('label', {}, props.label), props.children);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** 提示条:err/ok 用色区分,点 × 可关掉(提示不该一直占着版面) */
|
|
386
|
+
function Banner(props) {
|
|
387
|
+
const { kind, text, onClose } = props;
|
|
388
|
+
if (!text) return null;
|
|
389
|
+
// 用 span 而不是 button:button 会带上浏览器/主题的默认边框底色,跟提示条融不进去
|
|
390
|
+
const close = onClose
|
|
391
|
+
? h('span', {
|
|
392
|
+
className: 'ar-x',
|
|
393
|
+
role: 'button',
|
|
394
|
+
tabIndex: 0,
|
|
395
|
+
title: '关闭',
|
|
396
|
+
'aria-label': '关闭',
|
|
397
|
+
onClick: onClose,
|
|
398
|
+
onKeyDown: (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onClose(); } },
|
|
399
|
+
}, '×')
|
|
400
|
+
: null;
|
|
401
|
+
return h('div', { className: kind ? `ar-banner ${kind}` : 'ar-banner' }, h('span', {}, text), close);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function Empty(props) {
|
|
405
|
+
return h('div', { className: 'ar-empty' },
|
|
406
|
+
props.icon ? h('div', { className: 'ar-empty-icon' }, props.icon) : null,
|
|
407
|
+
h('div', { className: 'ar-empty-title' }, props.title),
|
|
408
|
+
props.hint ? h('div', { className: 'ar-empty-hint' }, props.hint) : null,
|
|
409
|
+
props.action || null);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function Url(props) {
|
|
413
|
+
const parts = splitUrl(props.value);
|
|
414
|
+
return h('div', { className: 'ar-url', title: props.value },
|
|
415
|
+
parts.host ? h('span', { className: 'h' }, parts.host) : null,
|
|
416
|
+
h('span', { className: 'p' }, parts.path));
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* 项目 key 是归一化后的绝对路径,页签上只给末段目录名,够区分又不占地方。
|
|
421
|
+
* 末段撞车(两个都叫 api)时退回上一级,避免两个页签长一样。
|
|
422
|
+
*/
|
|
423
|
+
function projectLabel(key, allKeys) {
|
|
424
|
+
const parts = String(key || '').split('/').filter(Boolean);
|
|
425
|
+
if (parts.length === 0) return key || 'default';
|
|
426
|
+
const last = parts[parts.length - 1];
|
|
427
|
+
const dup = (allKeys || []).filter((item) => {
|
|
428
|
+
const other = String(item || '').split('/').filter(Boolean);
|
|
429
|
+
return other.length > 0 && other[other.length - 1] === last;
|
|
430
|
+
});
|
|
431
|
+
return dup.length > 1 && parts.length > 1 ? `${parts[parts.length - 2]}/${last}` : last;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function ApiRow(props) {
|
|
435
|
+
const { api, tokens, busy, onTest, onLogin, onEdit, onDelete, onClearToken } = props;
|
|
436
|
+
const tokenId = api.tokenFrom || '';
|
|
437
|
+
const token = tokenId ? tokens[tokenId] : undefined;
|
|
438
|
+
const params = Array.isArray(api.params) ? api.params : [];
|
|
439
|
+
return h('div', { className: 'ar-item' },
|
|
440
|
+
h('div', { className: 'ar-head' },
|
|
441
|
+
h('span', { className: methodClass(api.method) }, api.method),
|
|
442
|
+
h('div', { className: 'ar-main' },
|
|
443
|
+
h('div', { className: 'ar-row', style: { flexWrap: 'wrap', gap: '5px' } },
|
|
444
|
+
h('span', { className: 'ar-name ar-cut' }, api.name || api.id),
|
|
445
|
+
api.source === 'file' ? h('span', { className: 'ar-badge', title: '来自 .dsh/api-runner.yml,请在文件里修改' }, 'YAML') : null,
|
|
446
|
+
api.isLogin ? h('span', { className: 'ar-badge warn' }, '登录') : null,
|
|
447
|
+
token ? h('span', { className: 'ar-badge ok', title: '调用时会自动带上这个 token' }, token.masked) : null),
|
|
448
|
+
h(Url, { value: api.url }),
|
|
449
|
+
api.description ? h('div', { className: 'ar-hint ar-cut', title: api.description }, api.description) : null,
|
|
450
|
+
params.length > 0 ? h('div', { className: 'ar-hint ar-mono' }, `参数 ${params.join(' · ')}`) : null)),
|
|
451
|
+
// 项目页签切过去之后,行内的测试/登录/编辑/删除都作用于那个项目自己的配置
|
|
452
|
+
// (请求带 project,后端按项目桶读写),所以这里不再有只读分支。
|
|
453
|
+
h('div', { className: 'ar-row' },
|
|
454
|
+
h('button', { className: 'ar-btn primary', disabled: Boolean(busy), title: '用「示例参数」调用一次', onClick: () => onTest(api) }, '测试'),
|
|
455
|
+
api.isLogin ? h('button', { className: 'ar-btn tonal', disabled: Boolean(busy), title: '调登录接口并把 token 存起来', onClick: () => onLogin(api) }, '登录并保存') : null,
|
|
456
|
+
h('span', { className: 'ar-spacer' }),
|
|
457
|
+
h('button', { className: 'ar-btn ghost icon', title: '复制完整地址', onClick: () => copyText(api.url) }, '⧉'),
|
|
458
|
+
token ? h('button', { className: 'ar-btn ghost', title: `忘掉 ${tokenId} 的 token`, onClick: () => onClearToken(tokenId) }, '清除 token') : null,
|
|
459
|
+
h('button', { className: 'ar-btn ghost', onClick: () => onEdit(api) }, '编辑'),
|
|
460
|
+
api.source === 'file' ? null : h('button', { className: 'ar-btn ghost danger', onClick: () => onDelete(api) }, '删除')),
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function EditForm(props) {
|
|
465
|
+
const { value, onChange, onSave, onCancel, tokens, busy } = props;
|
|
466
|
+
const set = (key, next) => onChange({ ...value, [key]: next });
|
|
467
|
+
const placeholders = placeholderNames(value);
|
|
468
|
+
return h('div', { className: 'ar-card' },
|
|
469
|
+
h('div', { className: 'ar-name' }, value.id ? `编辑 ${value.id}` : '新增接口'),
|
|
470
|
+
h(Field, { label: 'id' }, h('input', { className: 'ar-in', value: value.id, placeholder: '唯一标识,如 login', onChange: (e) => set('id', e.target.value) })),
|
|
471
|
+
h(Field, { label: '名称' }, h('input', { className: 'ar-in', value: value.name, placeholder: '显示名,留空则用 id', onChange: (e) => set('name', e.target.value) })),
|
|
472
|
+
h(Field, { label: '方法' }, h('select', { className: 'ar-sel', value: value.method, onChange: (e) => set('method', e.target.value) },
|
|
473
|
+
METHODS.map((m) => h('option', { key: m, value: m }, m)))),
|
|
474
|
+
h(Field, { label: '路径' }, h('input', { className: 'ar-in', value: value.url, placeholder: '/auth/login 或完整地址,支持 {id}', onChange: (e) => set('url', e.target.value) })),
|
|
475
|
+
h(Field, { label: 'baseUrl' }, h('input', { className: 'ar-in', value: value.baseUrl, placeholder: '留空则用「设置」里的 baseUrl', onChange: (e) => set('baseUrl', e.target.value) })),
|
|
476
|
+
h(Field, { label: '说明' }, h('input', { className: 'ar-in', value: value.description, onChange: (e) => set('description', e.target.value) })),
|
|
477
|
+
h(Field, { label: '请求头', top: true }, h('textarea', { className: 'ar-ta', value: value.headersText, placeholder: '{"X-Token":"${DEMO_TOKEN}"}', onChange: (e) => set('headersText', e.target.value) })),
|
|
478
|
+
h(Field, { label: 'body', top: true }, h('textarea', { className: 'ar-ta', value: value.bodyText, placeholder: '{"username":"{user}","password":"{pwd}"}', onChange: (e) => set('bodyText', e.target.value) })),
|
|
479
|
+
h(Field, { label: '示例参数', top: true }, h('textarea', { className: 'ar-ta', value: value.sampleText, placeholder: '「测试」按钮用它填 {占位},如 {"user":"alice"}', onChange: (e) => set('sampleText', e.target.value) })),
|
|
480
|
+
placeholders.length > 0 ? h('div', { className: 'ar-hint ar-mono' }, `占位参数:${placeholders.join(' · ')}`) : null,
|
|
481
|
+
h(Field, { label: '用 token' }, h('select', { className: 'ar-sel', value: value.useToken, onChange: (e) => set('useToken', e.target.value) },
|
|
482
|
+
h('option', { value: '' }, '自动(项目里只有一个 token 时用它)'),
|
|
483
|
+
Object.keys(tokens || {}).map((id) => h('option', { key: id, value: id }, `${id}(${tokens[id].masked})`)))),
|
|
484
|
+
h('label', { className: 'ar-check' },
|
|
485
|
+
h('input', { type: 'checkbox', checked: value.isLogin, onChange: (e) => set('isLogin', e.target.checked) }),
|
|
486
|
+
h('span', {}, '这是登录接口,调用成功后保存 token')),
|
|
487
|
+
value.isLogin
|
|
488
|
+
? h('div', { className: 'ar-card', style: { background: 'var(--ar-surface-strong)' } },
|
|
489
|
+
h(Field, { label: 'token 路径' }, h('input', { className: 'ar-in', value: value.tokenPath, placeholder: '响应 JSON 路径,如 data.token', onChange: (e) => set('tokenPath', e.target.value) })),
|
|
490
|
+
h(Field, { label: '注入头' }, h('input', { className: 'ar-in', value: value.authHeader, placeholder: 'Authorization', onChange: (e) => set('authHeader', e.target.value) })),
|
|
491
|
+
h(Field, { label: '前缀' }, h('input', { className: 'ar-in', value: value.prefix, placeholder: 'Bearer (不需要就留空)', onChange: (e) => set('prefix', e.target.value) })),
|
|
492
|
+
h('div', { className: 'ar-hint' }, '留空 token 路径时,会在响应里找形如 *token* 的字段,只有一个就直接用。'))
|
|
493
|
+
: null,
|
|
494
|
+
h('div', { className: 'ar-row' },
|
|
495
|
+
h('button', { className: 'ar-btn primary', disabled: Boolean(busy), onClick: () => onSave(value) }, '保存'),
|
|
496
|
+
h('button', { className: 'ar-btn ghost', onClick: onCancel }, '取消')));
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* 端口只有一个数字时用户会问「为什么这个服务显示监听两个端口」——
|
|
501
|
+
* 所以每个端口都标上角色:HTTP 业务端口 / 私有协议端口 / 调试端口。
|
|
502
|
+
*/
|
|
503
|
+
function Ports(props) {
|
|
504
|
+
const { item } = props;
|
|
505
|
+
const list = Array.isArray(item.portList) ? item.portList : [];
|
|
506
|
+
if (list.length === 0) {
|
|
507
|
+
if (!item.primaryPort) return h('span', { className: 'ar-hint' }, ' · 未监听端口');
|
|
508
|
+
return h('span', { className: 'ar-hint' }, ` · 监听 ${item.primaryPort}`);
|
|
509
|
+
}
|
|
510
|
+
return h('span', { className: 'ar-hint' },
|
|
511
|
+
' · ',
|
|
512
|
+
list.map((port, index) => h('span', { key: port.port },
|
|
513
|
+
index > 0 ? ' / ' : '',
|
|
514
|
+
h('span', {
|
|
515
|
+
className: port.role === 'http' ? 'ar-mono' : 'ar-mono ar-muted',
|
|
516
|
+
title: port.reason ? `${port.label}(${port.reason})` : port.label,
|
|
517
|
+
style: { fontWeight: port.role === 'http' ? 600 : 400 },
|
|
518
|
+
}, port.port),
|
|
519
|
+
h('span', { className: 'ar-muted' }, ` ${port.role === 'http' ? 'HTTP' : port.role === 'sentinel' ? '私有协议' : port.role === 'debug' ? 'debug' : ''}`))));
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function JavaRow(props) {
|
|
523
|
+
const { item, onUseBaseUrl, onTakeOver, onStop, onRestart, onDetail, onIgnore, onUnignore, onSave, busy, muted } = props;
|
|
524
|
+
const profiles = Array.isArray(item.profiles) ? item.profiles : [];
|
|
525
|
+
const managed = item.owner === 'plugin';
|
|
526
|
+
const running = managed ? Boolean(item.alive) : true;
|
|
527
|
+
/** 只有探测到「真的讲 HTTP」的端口才能当接口地址,私有协议/调试端口不能点 */
|
|
528
|
+
const httpPort = item.httpPort || (managed ? item.primaryPort : 0);
|
|
529
|
+
const ignored = Boolean(item.ignored);
|
|
530
|
+
return h('div', { className: muted ? 'ar-item ar-ignored' : 'ar-item' },
|
|
531
|
+
h('div', { className: 'ar-row', style: { flexWrap: 'wrap', gap: '5px' } },
|
|
532
|
+
httpPort ? h('span', { className: 'ar-badge brand ar-mono' }, `:${httpPort}`) : null,
|
|
533
|
+
h('span', { className: 'ar-name ar-cut', style: { flex: '0 1 auto' } }, item.name),
|
|
534
|
+
managed
|
|
535
|
+
? h('span', { className: `ar-badge ${running ? 'ok' : ''}`, title: '由插件启动(可停止、可看日志)' }, running ? '插件启动' : '已停止')
|
|
536
|
+
: item.owner === 'idea'
|
|
537
|
+
? h('span', { className: 'ar-badge warn', title: '由 IDEA 启动;插件不能直接重启它,只能「接管」' }, 'IDEA 启动')
|
|
538
|
+
: h('span', { className: 'ar-badge', title: '不是 IDEA 起的,也不是插件起的' }, '其它'),
|
|
539
|
+
ignored ? h('span', { className: 'ar-badge', title: '已忽略:在「正在运行」里不显示' }, '已忽略') : null,
|
|
540
|
+
item.debugPort ? h('span', { className: 'ar-badge', title: '调试端口(jdwp)' }, `debug ${item.debugPort}`) : null,
|
|
541
|
+
profiles.map((p) => h('span', { key: p, className: 'ar-badge' }, p))),
|
|
542
|
+
h('div', { className: 'ar-hint ar-mono ar-cut', title: item.mainClass || '' }, item.mainClass || ''),
|
|
543
|
+
h('div', { style: { fontSize: '12px' } },
|
|
544
|
+
h('span', { className: 'ar-hint ar-mono' }, `pid ${item.pid}`),
|
|
545
|
+
h(Ports, { item }),
|
|
546
|
+
managed && item.startedAt ? h('span', { className: 'ar-hint' }, ` · 启动于 ${String(item.startedAt).slice(11, 19)}`) : null),
|
|
547
|
+
h('div', { className: 'ar-row', style: { flexWrap: 'wrap' } },
|
|
548
|
+
httpPort ? h('button', { className: 'ar-btn ghost icon', title: `把项目 baseUrl 设为 http://127.0.0.1:${httpPort}`, onClick: () => onUseBaseUrl(item) }, '⌁') : null,
|
|
549
|
+
// 「查询详情」= 日志页:托管进程读插件输出,IDEA 进程读它自己的 logback 文件
|
|
550
|
+
h('button', { className: 'ar-btn tonal', disabled: busy !== '', title: '查看进程信息与日志', onClick: () => onDetail(item) }, '查询详情'),
|
|
551
|
+
// 被忽略的服务只留「取消忽略」:它不在正常列表里,给启动/停止按钮容易误操作
|
|
552
|
+
ignored
|
|
553
|
+
? null
|
|
554
|
+
: (managed
|
|
555
|
+
? (running
|
|
556
|
+
? h('button', { className: 'ar-btn', disabled: busy !== '', onClick: () => onRestart(item) }, '重启')
|
|
557
|
+
: h('button', { className: 'ar-btn', disabled: busy !== '', onClick: () => onRestart(item) }, '启动'))
|
|
558
|
+
: h('button', { className: 'ar-btn primary', disabled: busy !== '', title: '结束 IDEA 起的进程,改用插件启动(会先编译,再拉起);之后就能在插件里停止/重启/看日志', onClick: () => onTakeOver(item) }, '接管启动')),
|
|
559
|
+
!ignored && managed && running ? h('button', { className: 'ar-btn ghost danger', disabled: busy !== '', onClick: () => onStop(item) }, '停止') : null,
|
|
560
|
+
// 保存配方:之后即使 IDEA 里没跑,也能直接从这里启动
|
|
561
|
+
!ignored && onSave && running ? h('button', { className: 'ar-btn ghost', disabled: busy !== '', title: '把这套启动参数(classpath/主类/JVM 参数)存下来,以后不用先在 IDEA 里跑也能启动', onClick: () => onSave(item) }, '保存') : null,
|
|
562
|
+
h('span', { className: 'ar-spacer' }),
|
|
563
|
+
ignored
|
|
564
|
+
? h('button', { className: 'ar-btn ghost', title: '重新显示在「正在运行」里', onClick: () => onUnignore(item) }, '取消忽略')
|
|
565
|
+
: h('button', { className: 'ar-btn ghost', title: '不再显示在「正在运行」里(不影响进程本身)', onClick: () => onIgnore(item) }, '忽略')));
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/** 已保存的服务:不需要现有进程,按配方直接启动 */
|
|
569
|
+
/**
|
|
570
|
+
* 一键启动的进度卡片。
|
|
571
|
+
*
|
|
572
|
+
* 编译 + 拉起一批服务要几分钟,期间必须让用户看到「到哪了」,
|
|
573
|
+
* 否则点完按钮页面没反应,会以为卡死。逐条显示每个服务的结局。
|
|
574
|
+
*/
|
|
575
|
+
function BatchProgress(props) {
|
|
576
|
+
const { batch, onDismiss } = props;
|
|
577
|
+
const total = Number(batch.total) || 0;
|
|
578
|
+
const done = Number(batch.done) || 0;
|
|
579
|
+
const pct = total > 0 ? Math.min(100, Math.round((done / total) * 100)) : 0;
|
|
580
|
+
const items = Array.isArray(batch.items) ? batch.items : [];
|
|
581
|
+
return h('div', { className: 'ar-batch' },
|
|
582
|
+
h('div', { className: 'ar-batch-top' },
|
|
583
|
+
h('span', null, batch.finished ? '一键启动完成' : '正在启动服务…'),
|
|
584
|
+
h('span', { className: 'ar-spacer' }),
|
|
585
|
+
h('span', { className: 'ar-mono ar-muted', style: { fontSize: '11.5px', fontWeight: '400' } }, `${done}/${total}`),
|
|
586
|
+
batch.finished ? h('button', { className: 'ar-btn ghost icon', title: '关闭', onClick: onDismiss }, '×') : null),
|
|
587
|
+
h('div', { className: 'ar-batch-bar' }, h('i', { style: { width: `${pct}%` } })),
|
|
588
|
+
!batch.finished && batch.current
|
|
589
|
+
? h('div', { className: 'ar-hint ar-mono' }, `正在处理 ${batch.current}`)
|
|
590
|
+
: null,
|
|
591
|
+
items.length > 0
|
|
592
|
+
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '3px' } },
|
|
593
|
+
items.map((item) => h('div', {
|
|
594
|
+
key: item.id,
|
|
595
|
+
className: `ar-batch-line ${item.skipped ? 'skip' : item.ok ? 'ok' : 'err'}`,
|
|
596
|
+
},
|
|
597
|
+
h('span', { className: 'n' }, item.skipped ? '·' : item.ok ? '✓' : '✗'),
|
|
598
|
+
h('span', { className: 'ar-cut', style: { flex: '0 1 auto' } }, item.id),
|
|
599
|
+
h('span', { className: 'ar-hint ar-cut', style: { flex: '1 1 auto', minWidth: 0 } },
|
|
600
|
+
item.skipped ? '已在运行,跳过' : item.ok ? (item.port ? `已启动 · 端口 ${item.port}` : '已启动') : (item.message || item.code || '失败')))))
|
|
601
|
+
: null);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function SavedRow(props) {
|
|
605
|
+
const { item, busy, onStart, onDelete } = props;
|
|
606
|
+
return h('div', { className: 'ar-item' },
|
|
607
|
+
h('div', { className: 'ar-row', style: { flexWrap: 'wrap', gap: '5px' } },
|
|
608
|
+
item.port ? h('span', { className: 'ar-badge brand ar-mono' }, `:${item.port}`) : null,
|
|
609
|
+
h('span', { className: 'ar-name ar-cut', style: { flex: '0 1 auto' } }, item.name || item.id),
|
|
610
|
+
h('span', { className: 'ar-badge', title: '启动参数已保存' }, '已保存')),
|
|
611
|
+
h('div', { className: 'ar-hint ar-mono ar-cut', title: item.mainClass || '' }, item.mainClass || ''),
|
|
612
|
+
h('div', { className: 'ar-hint ar-mono ar-cut', title: item.module?.rootDir || '' },
|
|
613
|
+
`${item.module?.artifactId || '未识别模块'}${item.savedAt ? ` · 保存于 ${String(item.savedAt).slice(5, 16).replace('T', ' ')}` : ''}`),
|
|
614
|
+
h('div', { className: 'ar-row', style: { flexWrap: 'wrap' } },
|
|
615
|
+
h('button', { className: 'ar-btn primary', disabled: busy !== '', title: '编译后按保存的参数拉起(不需要 IDEA 里先有进程)', onClick: () => onStart(item) }, '启动'),
|
|
616
|
+
h('span', { className: 'ar-spacer' }),
|
|
617
|
+
h('button', { className: 'ar-btn ghost danger', disabled: busy !== '', onClick: () => onDelete(item) }, '删除')));
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* 服务详情 = 日志页。
|
|
622
|
+
*
|
|
623
|
+
* 日志来源:
|
|
624
|
+
* 插件托管的进程 → `<数据目录>/java-logs/<服务名>/<时间戳>.log`(插件写的 stdout,
|
|
625
|
+
* 每次启动一个文件,最接近 IDEA 控制台,也能翻历史几次启动)
|
|
626
|
+
* IDEA 起的进程 → 它自己的 logback 文件 `<user.dir>/logs/<服务名>/info.log`
|
|
627
|
+
* (IDEA 控制台不是文件,拿不到;应用日志内容一样)
|
|
628
|
+
* 按字节偏移增量拉,只在可见时轮询,切走就停。
|
|
629
|
+
*/
|
|
630
|
+
function ServiceDetail(props) {
|
|
631
|
+
const { item, visible, get, onClose, onStop, onRestart, onTakeOver, onIgnore, onUnignore, busy } = props;
|
|
632
|
+
const [detail, setDetail] = React.useState(null);
|
|
633
|
+
const [text, setText] = React.useState('');
|
|
634
|
+
const [source, setSource] = React.useState('');
|
|
635
|
+
const [auto, setAuto] = React.useState(true);
|
|
636
|
+
const [wrap, setWrap] = React.useState(true);
|
|
637
|
+
/** 首屏行数:和 IDEA 控制台一样先给最近一段,不够再加 */
|
|
638
|
+
const [lines, setLines] = React.useState(200);
|
|
639
|
+
/** 自定义行数输入框的草稿(回车/失焦生效) */
|
|
640
|
+
const [linesText, setLinesText] = React.useState('');
|
|
641
|
+
const [error, setError] = React.useState('');
|
|
642
|
+
const [loading, setLoading] = React.useState(false);
|
|
643
|
+
const boxRef = React.useRef(null);
|
|
644
|
+
const offsetRef = React.useRef(0);
|
|
645
|
+
const sourceRef = React.useRef('');
|
|
646
|
+
|
|
647
|
+
const target = item.runId || item.pid;
|
|
648
|
+
const alive = detail ? detail.alive : Boolean(item.alive) || item.owner !== 'plugin';
|
|
649
|
+
|
|
650
|
+
/** 首屏:拿详情(进程信息 + 日志文件清单)并从文件末尾读一段 */
|
|
651
|
+
const load = React.useCallback(async (nextSource, nextLines) => {
|
|
652
|
+
try {
|
|
653
|
+
setLoading(true);
|
|
654
|
+
const key = nextSource !== undefined ? nextSource : sourceRef.current || '';
|
|
655
|
+
const size = Number(nextLines) || lines;
|
|
656
|
+
const query = `java/detail?id=${encodeURIComponent(target)}&lines=${size}&max_bytes=65536${key ? `&source=${encodeURIComponent(key)}` : ''}`;
|
|
657
|
+
const data = await get(query);
|
|
658
|
+
if (!data.ok) {
|
|
659
|
+
setError(data.message || '读取详情失败');
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
setError('');
|
|
663
|
+
const log = data.log || {};
|
|
664
|
+
sourceRef.current = data.source || '';
|
|
665
|
+
offsetRef.current = log.nextOffset || 0;
|
|
666
|
+
setSource(data.source || '');
|
|
667
|
+
setDetail(data);
|
|
668
|
+
setText(log.text || '');
|
|
669
|
+
} catch (e) {
|
|
670
|
+
setError(e.message);
|
|
671
|
+
} finally {
|
|
672
|
+
setLoading(false);
|
|
673
|
+
}
|
|
674
|
+
}, [get, target, lines]);
|
|
675
|
+
|
|
676
|
+
/** 增量:只取 offset 之后的新内容,追加到已有文本 */
|
|
677
|
+
const follow = React.useCallback(async () => {
|
|
678
|
+
if (!sourceRef.current) return;
|
|
679
|
+
try {
|
|
680
|
+
const data = await get(`java/detail?id=${encodeURIComponent(target)}&from=${offsetRef.current}&source=${encodeURIComponent(sourceRef.current)}&max_bytes=262144`);
|
|
681
|
+
if (!data.ok) return;
|
|
682
|
+
const log = data.log || {};
|
|
683
|
+
if (typeof log.nextOffset === 'number') {
|
|
684
|
+
// 变小说明文件被轮转/截断了,这时整段重来
|
|
685
|
+
if (log.nextOffset < offsetRef.current) {
|
|
686
|
+
setText(log.text || '');
|
|
687
|
+
} else if (log.text) {
|
|
688
|
+
setText((prev) => (prev + log.text).slice(-400_000));
|
|
689
|
+
}
|
|
690
|
+
offsetRef.current = log.nextOffset;
|
|
691
|
+
}
|
|
692
|
+
setDetail((prev) => (prev ? { ...data, log: undefined } : data));
|
|
693
|
+
} catch {
|
|
694
|
+
// 轮询失败不打断阅读,下一轮再试
|
|
695
|
+
}
|
|
696
|
+
}, [get, target]);
|
|
697
|
+
|
|
698
|
+
/** 自定义行数:1–5000,回车或失焦时生效 */
|
|
699
|
+
const applyLines = React.useCallback(() => {
|
|
700
|
+
const wanted = Number(String(linesText || '').trim());
|
|
701
|
+
if (!Number.isFinite(wanted) || wanted <= 0) return;
|
|
702
|
+
const size = Math.min(5000, Math.max(1, Math.round(wanted)));
|
|
703
|
+
setLines(size);
|
|
704
|
+
setLinesText('');
|
|
705
|
+
load(sourceRef.current, size);
|
|
706
|
+
}, [linesText, load]);
|
|
707
|
+
|
|
708
|
+
React.useEffect(() => {
|
|
709
|
+
offsetRef.current = 0;
|
|
710
|
+
sourceRef.current = '';
|
|
711
|
+
setText('');
|
|
712
|
+
setDetail(null);
|
|
713
|
+
setSource('');
|
|
714
|
+
load('');
|
|
715
|
+
}, [target]);
|
|
716
|
+
React.useEffect(() => {
|
|
717
|
+
if (!visible || !auto || !sourceRef.current) return undefined;
|
|
718
|
+
const timer = setInterval(() => { follow(); }, 1500);
|
|
719
|
+
return () => clearInterval(timer);
|
|
720
|
+
}, [visible, auto, follow, source]);
|
|
721
|
+
|
|
722
|
+
// 新内容进来自动滚到底,除非用户往上翻了
|
|
723
|
+
React.useEffect(() => {
|
|
724
|
+
const box = boxRef.current;
|
|
725
|
+
if (!box) return;
|
|
726
|
+
const nearBottom = box.scrollHeight - box.scrollTop - box.clientHeight < 80;
|
|
727
|
+
if (nearBottom) box.scrollTop = box.scrollHeight;
|
|
728
|
+
}, [text]);
|
|
729
|
+
|
|
730
|
+
const shown = text.length > 400_000 ? text.slice(-400_000) : text;
|
|
731
|
+
const sources = (detail && Array.isArray(detail.sources) && detail.sources) || [];
|
|
732
|
+
const ports = [detail && detail.portList, detail && detail.ports, item.portList].find((value) => Array.isArray(value)) || [];
|
|
733
|
+
|
|
734
|
+
return h('div', { className: 'ar-detail' },
|
|
735
|
+
h('div', { className: 'ar-row' },
|
|
736
|
+
h('button', { className: 'ar-btn ghost icon', title: '返回列表', onClick: onClose }, '‹'),
|
|
737
|
+
h('div', { className: 'ar-detail-head', style: { flex: '1 1 auto', minWidth: 0 } },
|
|
738
|
+
h('span', { className: `ar-dot ${alive ? '' : 'off'}` }),
|
|
739
|
+
h('span', { className: 'ar-name ar-cut' }, item.name),
|
|
740
|
+
h('span', { className: 'ar-hint ar-mono' }, alive ? `pid ${detail ? detail.pid : item.pid}` : '已停止')),
|
|
741
|
+
h('button', { className: 'ar-btn ghost', disabled: loading, onClick: () => load(source) }, '刷新')),
|
|
742
|
+
h('div', { className: 'ar-row', style: { flexWrap: 'wrap' } },
|
|
743
|
+
(detail && detail.port ? h('span', { className: 'ar-badge brand ar-mono' }, `:${detail.port}`) : null),
|
|
744
|
+
ports.map((p) => h('span', {
|
|
745
|
+
key: p.port,
|
|
746
|
+
className: `ar-badge ${p.role === 'http' ? 'brand' : ''}`,
|
|
747
|
+
title: p.reason ? `${p.label}(${p.reason})` : p.label,
|
|
748
|
+
}, `${p.port} ${p.role === 'http' ? 'HTTP' : p.role === 'sentinel' ? '私有协议' : p.role === 'debug' ? 'debug' : ''}`)),
|
|
749
|
+
(detail && detail.debugPort ? h('span', { className: 'ar-badge' }, `debug ${detail.debugPort}`) : null),
|
|
750
|
+
(Array.isArray(detail && detail.profiles) ? detail.profiles : []).map((p) => h('span', { key: p, className: 'ar-badge' }, p)),
|
|
751
|
+
h('span', { className: 'ar-spacer' }),
|
|
752
|
+
h('button', { className: `ar-btn ${auto ? 'tonal' : 'ghost'}`, title: '每 1.5 秒增量拉取新日志', onClick: () => setAuto(!auto) }, auto ? '自动刷新 开' : '自动刷新 关')),
|
|
753
|
+
// 有多个日志文件(info.log / error.log / 插件输出)时让用户切换
|
|
754
|
+
sources.length > 1
|
|
755
|
+
? h('div', { className: 'ar-row', style: { flexWrap: 'wrap' } },
|
|
756
|
+
sources.map((s) => h('button', {
|
|
757
|
+
key: s.key,
|
|
758
|
+
className: `ar-btn ${s.key === source ? 'tonal' : 'ghost'}`,
|
|
759
|
+
title: s.path,
|
|
760
|
+
onClick: () => { setText(''); offsetRef.current = 0; sourceRef.current = s.key; load(s.key); },
|
|
761
|
+
}, s.label)))
|
|
762
|
+
: null,
|
|
763
|
+
h('div', { className: 'ar-row', style: { flexWrap: 'wrap' } },
|
|
764
|
+
item.owner === 'plugin'
|
|
765
|
+
? (alive
|
|
766
|
+
? h('span', null,
|
|
767
|
+
h('button', { className: 'ar-btn', disabled: busy !== '', onClick: () => onRestart(item) }, '重启'),
|
|
768
|
+
h('button', { className: 'ar-btn ghost danger', disabled: busy !== '', onClick: () => onStop(item) }, '停止'))
|
|
769
|
+
: h('button', { className: 'ar-btn primary', disabled: busy !== '', onClick: () => onRestart(item) }, '启动'))
|
|
770
|
+
: h('span', null,
|
|
771
|
+
// 已忽略的服务只提供「取消忽略」:它不在正常列表里,直接给「接管启动」容易误点
|
|
772
|
+
item.ignored
|
|
773
|
+
? h('button', { className: 'ar-btn ghost', onClick: () => onUnignore(item) }, '取消忽略')
|
|
774
|
+
: h('span', null,
|
|
775
|
+
h('button', { className: 'ar-btn primary', disabled: busy !== '', onClick: () => onTakeOver(item) }, '接管启动'),
|
|
776
|
+
h('button', { className: 'ar-btn ghost', onClick: () => onIgnore(item) }, '忽略'))),
|
|
777
|
+
h('span', { className: 'ar-spacer' }),
|
|
778
|
+
detail && detail.cwd ? h('span', { className: 'ar-hint ar-mono ar-cut', title: detail.cwd }, detail.cwd) : null),
|
|
779
|
+
// 日志视图开关:行数(首屏读多少)与自动换行,尽量贴近 IDEA 控制台
|
|
780
|
+
h('div', { className: 'ar-row', style: { flexWrap: 'wrap' } },
|
|
781
|
+
h('span', { className: 'ar-hint' }, '行数'),
|
|
782
|
+
[100, 200, 500, 1000].map((n) => h('button', {
|
|
783
|
+
key: n,
|
|
784
|
+
className: `ar-btn ${lines === n ? 'tonal' : 'ghost'}`,
|
|
785
|
+
title: `从文件末尾读最近 ${n} 行`,
|
|
786
|
+
onClick: () => { setLines(n); load(sourceRef.current, n); },
|
|
787
|
+
}, String(n))),
|
|
788
|
+
h('input', {
|
|
789
|
+
className: 'ar-in ar-mono',
|
|
790
|
+
style: { width: '64px', flex: 'none' },
|
|
791
|
+
value: linesText,
|
|
792
|
+
placeholder: '自定义',
|
|
793
|
+
title: '自己填行数,回车生效(1–5000)',
|
|
794
|
+
onChange: (e) => setLinesText(e.target.value.replace(/[^\d]/g, '')),
|
|
795
|
+
onKeyDown: (e) => { if (e.key === 'Enter') applyLines(); },
|
|
796
|
+
onBlur: applyLines,
|
|
797
|
+
}),
|
|
798
|
+
h('span', { className: 'ar-spacer' }),
|
|
799
|
+
h('button', {
|
|
800
|
+
className: `ar-btn ${wrap ? 'tonal' : 'ghost'}`,
|
|
801
|
+
title: '长日志行是否折行显示(关闭后横向滚动,更接近 IDEA 的竖排对齐)',
|
|
802
|
+
onClick: () => setWrap(!wrap),
|
|
803
|
+
}, wrap ? '自动换行 开' : '自动换行 关')),
|
|
804
|
+
h(Banner, { kind: error ? 'err' : '', text: error, onClose: () => setError('') }),
|
|
805
|
+
h(Banner, { text: detail && detail.note ? detail.note : '' }),
|
|
806
|
+
loading && !detail ? h('div', { className: 'ar-hint' }, '读取中…') : null,
|
|
807
|
+
h('pre', { className: wrap ? 'ar-log' : 'ar-log nowrap', ref: boxRef }, shown),
|
|
808
|
+
h('div', { className: 'ar-hint ar-mono ar-cut', title: (detail && detail.log && detail.log.logPath) || '' },
|
|
809
|
+
detail && detail.log && detail.log.logPath
|
|
810
|
+
? `${detail.log.logPath}${detail.log.size ? ` · ${(detail.log.size / 1024).toFixed(1)} KB` : ''}`
|
|
811
|
+
: '没有可读的日志文件'));
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
function ResultCard(props) {
|
|
815
|
+
const { result, onClose } = props;
|
|
816
|
+
const payload = result.payload;
|
|
817
|
+
const [view, setView] = React.useState('body');
|
|
818
|
+
const ok = Boolean(payload.ok);
|
|
819
|
+
const json = payload.json !== undefined ? payload.json : payload.body;
|
|
820
|
+
const views = [
|
|
821
|
+
{ id: 'body', label: '响应' },
|
|
822
|
+
{ id: 'headers', label: '响应头' },
|
|
823
|
+
{ id: 'request', label: '请求' },
|
|
824
|
+
];
|
|
825
|
+
const content = view === 'headers'
|
|
826
|
+
? pretty(payload.headers || {})
|
|
827
|
+
: view === 'request'
|
|
828
|
+
? pretty({ method: payload.request?.method || '', url: payload.request?.url || payload.url || '', headers: payload.request?.headers || {} })
|
|
829
|
+
: payload.error
|
|
830
|
+
? String(payload.error)
|
|
831
|
+
: json !== undefined ? pretty(json) : String(payload.body || '');
|
|
832
|
+
return h('div', { className: 'ar-card' },
|
|
833
|
+
h('div', { className: 'ar-row', style: { flexWrap: 'wrap' } },
|
|
834
|
+
h('span', { className: `ar-badge ${ok ? 'ok' : 'err'}` }, ok ? `HTTP ${payload.status}` : '失败'),
|
|
835
|
+
typeof payload.durationMs === 'number' ? h('span', { className: 'ar-hint ar-mono' }, `${payload.durationMs} ms`) : null,
|
|
836
|
+
h('span', { className: 'ar-hint ar-mono' }, byteSize(json !== undefined ? json : payload.body)),
|
|
837
|
+
h('span', { className: 'ar-spacer' }),
|
|
838
|
+
h('div', { className: 'ar-seg' }, views.map((v) => h('button', { key: v.id, className: view === v.id ? 'on' : '', onClick: () => setView(v.id) }, v.label))),
|
|
839
|
+
h('button', { className: 'ar-btn ghost icon', title: '复制这段内容', onClick: () => copyText(content) }, '⧉'),
|
|
840
|
+
h('button', { className: 'ar-btn ghost icon', title: '关闭', onClick: onClose }, '×')),
|
|
841
|
+
h('div', { className: 'ar-row', style: { minWidth: 0 } },
|
|
842
|
+
h('span', { className: methodClass(payload.method) }, payload.method || 'GET'),
|
|
843
|
+
h('div', { style: { flex: '1 1 auto', minWidth: 0 } }, h(Url, { value: payload.url || payload.request?.url || '' })),
|
|
844
|
+
h('span', { className: 'ar-hint' }, result.apiId)),
|
|
845
|
+
payload.message ? h('div', { className: `ar-banner ${payload.ok ? 'ok' : 'err'}` }, payload.message) : null,
|
|
846
|
+
payload.token ? h('div', { className: 'ar-hint ar-mono' }, `token ${payload.token.masked} · 来自 ${payload.token.from} · 注入 ${payload.token.header}`) : null,
|
|
847
|
+
h('pre', { className: 'ar-pre' }, content));
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
// ---------------------------------------------------------------- 面板
|
|
851
|
+
function Panel(props) {
|
|
852
|
+
const scope = props.scope || {};
|
|
853
|
+
const visible = props.visible !== false;
|
|
854
|
+
const cwd = scope.cwd || scope.workspacePath || '';
|
|
855
|
+
const sessionId = scope.sessionId || '';
|
|
856
|
+
|
|
857
|
+
const [tab, setTab] = React.useState('apis');
|
|
858
|
+
const [state, setState] = React.useState(null);
|
|
859
|
+
const [java, setJava] = React.useState(null);
|
|
860
|
+
const [error, setError] = React.useState('');
|
|
861
|
+
const [notice, setNotice] = React.useState('');
|
|
862
|
+
const [busy, setBusy] = React.useState('');
|
|
863
|
+
const [form, setForm] = React.useState(null);
|
|
864
|
+
const [result, setResult] = React.useState(null);
|
|
865
|
+
const [baseUrl, setBaseUrl] = React.useState('');
|
|
866
|
+
const [draft, setDraft] = React.useState('');
|
|
867
|
+
const [filter, setFilter] = React.useState('');
|
|
868
|
+
const [detail, setDetail] = React.useState(null);
|
|
869
|
+
/** 接口页二级页签选中的项目:'' 表示跟着会话工作区走 */
|
|
870
|
+
const [projectTab, setProjectTab] = React.useState('');
|
|
871
|
+
/** 服务页二级页签:已接管 / 运行中 / 已保存 / 已忽略 */
|
|
872
|
+
const [group, setGroup] = React.useState('managed');
|
|
873
|
+
/** 用户点过页签之后就不要自动跳了 */
|
|
874
|
+
const groupTouched = React.useRef(false);
|
|
875
|
+
const [settings, setSettings] = React.useState(null);
|
|
876
|
+
const [dataDirDraft, setDataDirDraft] = React.useState('');
|
|
877
|
+
const [workspaceDraft, setWorkspaceDraft] = React.useState('');
|
|
878
|
+
const [mavenHomeDraft, setMavenHomeDraft] = React.useState('');
|
|
879
|
+
/** 一键启动的后台批次进度(null = 没有正在进行的批次) */
|
|
880
|
+
const [batch, setBatch] = React.useState(null);
|
|
881
|
+
|
|
882
|
+
const headers = React.useMemo(() => ({ 'Content-Type': 'application/json', 'x-dsh-session-id': sessionId }), [sessionId]);
|
|
883
|
+
const get = React.useCallback(async (path) => {
|
|
884
|
+
const sep = path.includes('?') ? '&' : '?';
|
|
885
|
+
return request(`${path}${sep}cwd=${encodeURIComponent(cwd)}`, { headers });
|
|
886
|
+
}, [cwd, headers]);
|
|
887
|
+
const post = React.useCallback(async (path, body) => {
|
|
888
|
+
return request(path, { method: 'POST', headers, body: JSON.stringify({ ...(body || {}), cwd }) });
|
|
889
|
+
}, [cwd, headers]);
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* 接口相关的请求带上「接口页」选中的项目。
|
|
893
|
+
*
|
|
894
|
+
* 只有接口这套(ui / call / login)跟项目走;服务与设置永远是会话工作区的事,
|
|
895
|
+
* 否则切到别的项目时「服务」页会突然变空、「设置」也会读到别的项目的值。
|
|
896
|
+
*/
|
|
897
|
+
const withProject = (path) => {
|
|
898
|
+
if (!projectTab) return path;
|
|
899
|
+
const sep = path.includes('?') ? '&' : '?';
|
|
900
|
+
return `${path}${sep}project=${encodeURIComponent(projectTab)}`;
|
|
901
|
+
};
|
|
902
|
+
const getApi = React.useCallback(async (path) => {
|
|
903
|
+
const sep = path.includes('?') ? '&' : '?';
|
|
904
|
+
return request(withProject(`${path}${sep}cwd=${encodeURIComponent(cwd)}`), { headers });
|
|
905
|
+
}, [cwd, headers, projectTab]);
|
|
906
|
+
const postApi = React.useCallback(async (path, body) => {
|
|
907
|
+
const extra = projectTab ? { project: projectTab } : {};
|
|
908
|
+
return request(path, { method: 'POST', headers, body: JSON.stringify({ ...(body || {}), ...extra, cwd }) });
|
|
909
|
+
}, [cwd, headers, projectTab]);
|
|
910
|
+
|
|
911
|
+
const refresh = React.useCallback(async () => {
|
|
912
|
+
try {
|
|
913
|
+
const data = await getApi('ui');
|
|
914
|
+
setState(data);
|
|
915
|
+
setBaseUrl(data.baseUrl || '');
|
|
916
|
+
setDraft(data.baseUrl || '');
|
|
917
|
+
setError('');
|
|
918
|
+
} catch (e) {
|
|
919
|
+
setError(e.message);
|
|
920
|
+
}
|
|
921
|
+
}, [getApi]);
|
|
922
|
+
|
|
923
|
+
const refreshJava = React.useCallback(async () => {
|
|
924
|
+
try {
|
|
925
|
+
const data = await get('java');
|
|
926
|
+
setJava(data);
|
|
927
|
+
return data;
|
|
928
|
+
} catch (e) {
|
|
929
|
+
setJava({ ok: false, message: e.message, processes: [] });
|
|
930
|
+
return null;
|
|
931
|
+
}
|
|
932
|
+
}, [get]);
|
|
933
|
+
|
|
934
|
+
const refreshSettings = React.useCallback(async () => {
|
|
935
|
+
try {
|
|
936
|
+
const data = await get('settings');
|
|
937
|
+
setSettings(data);
|
|
938
|
+
setDataDirDraft(data.dataDir || '');
|
|
939
|
+
setWorkspaceDraft(data.workspace || '');
|
|
940
|
+
setMavenHomeDraft(data.mavenHome || '');
|
|
941
|
+
} catch (e) {
|
|
942
|
+
setSettings({ ok: false, message: e.message });
|
|
943
|
+
}
|
|
944
|
+
}, [get]);
|
|
945
|
+
|
|
946
|
+
React.useEffect(() => {
|
|
947
|
+
if (!visible) return undefined;
|
|
948
|
+
refresh();
|
|
949
|
+
refreshJava();
|
|
950
|
+
refreshSettings();
|
|
951
|
+
const timer = setInterval(() => { refreshJava(); }, 5000);
|
|
952
|
+
return () => clearInterval(timer);
|
|
953
|
+
}, [visible, refresh, refreshJava, refreshSettings]);
|
|
954
|
+
|
|
955
|
+
// 成功提示过几秒自己消失,别一直挂在顶上;出错提示留着,等用户处理或手动关掉
|
|
956
|
+
React.useEffect(() => {
|
|
957
|
+
if (!notice) return undefined;
|
|
958
|
+
const timer = setTimeout(() => setNotice(''), 6000);
|
|
959
|
+
return () => clearTimeout(timer);
|
|
960
|
+
}, [notice]);
|
|
961
|
+
|
|
962
|
+
const apis = (state && state.apis) || [];
|
|
963
|
+
const tokens = (state && state.tokens) || {};
|
|
964
|
+
const processes = (java && java.processes) || [];
|
|
965
|
+
/** 已保存的配方:没有进程也能启动 */
|
|
966
|
+
const savedList = (java && java.saved) || [];
|
|
967
|
+
const keyword = filter.trim().toLowerCase();
|
|
968
|
+
const shown = keyword === '' ? apis : apis.filter((api) => `${api.id} ${api.name || ''} ${api.url}`.toLowerCase().includes(keyword));
|
|
969
|
+
/**
|
|
970
|
+
* 接口页按项目分类:页签列的是所有已知项目(会话工作区、设置里的默认工作区、
|
|
971
|
+
* 配过接口的项目),切过去就是真的切过去——接口、token、baseUrl 都换,
|
|
972
|
+
* 在那边点测试/登录/新增/编辑/删除也作用于那个项目自己的配置。
|
|
973
|
+
*/
|
|
974
|
+
const allProjects = (state && Array.isArray(state.projects)) ? state.projects : [];
|
|
975
|
+
const cwdProjectKey = (state && state.cwdProjectKey) || '';
|
|
976
|
+
/** '' 表示跟随会话工作区;有选中就以选中为准 */
|
|
977
|
+
const activeKey = projectTab || cwdProjectKey;
|
|
978
|
+
/** 选中的项目从清单里消失(目录删了、配置清了)就退回跟随工作区 */
|
|
979
|
+
React.useEffect(() => {
|
|
980
|
+
if (projectTab !== '' && !allProjects.some((item) => item.key === projectTab)) setProjectTab('');
|
|
981
|
+
}, [projectTab, allProjects.length]);
|
|
982
|
+
/** 服务分三组:插件接管过的 / 正在运行的(IDEA 或其它)/ 已忽略的 */
|
|
983
|
+
const managedList = processes.filter((item) => item.owner === 'plugin');
|
|
984
|
+
const ignoredList = processes.filter((item) => item.ignored);
|
|
985
|
+
const runningList = processes.filter((item) => item.owner !== 'plugin' && !item.ignored);
|
|
986
|
+
|
|
987
|
+
// 一进来「已接管」是空的、但确实有进程在跑,就直接落在「运行中」,省一次点击;
|
|
988
|
+
// 用户自己点过页签之后就不再干预。
|
|
989
|
+
React.useEffect(() => {
|
|
990
|
+
if (groupTouched.current) return;
|
|
991
|
+
if (managedList.length === 0 && runningList.length > 0) setGroup('running');
|
|
992
|
+
}, [managedList.length, runningList.length]);
|
|
993
|
+
|
|
994
|
+
const saveApi = async (value) => {
|
|
995
|
+
setBusy('save');
|
|
996
|
+
setError('');
|
|
997
|
+
try {
|
|
998
|
+
const api = {
|
|
999
|
+
id: value.id.trim(),
|
|
1000
|
+
name: value.name.trim() || value.id.trim(),
|
|
1001
|
+
method: value.method,
|
|
1002
|
+
url: value.url.trim(),
|
|
1003
|
+
baseUrl: value.baseUrl.trim(),
|
|
1004
|
+
description: value.description.trim(),
|
|
1005
|
+
headers: parseJsonField(value.headersText, '请求头') || {},
|
|
1006
|
+
body: parseJsonField(value.bodyText, 'body'),
|
|
1007
|
+
sampleParams: parseJsonField(value.sampleText, '示例参数') || {},
|
|
1008
|
+
useToken: value.useToken,
|
|
1009
|
+
timeoutMs: Number(value.timeoutMs) || 30000,
|
|
1010
|
+
login: value.isLogin
|
|
1011
|
+
? { tokenPath: value.tokenPath.trim() || 'token', header: value.authHeader.trim() || 'Authorization', prefix: value.prefix }
|
|
1012
|
+
: undefined,
|
|
1013
|
+
};
|
|
1014
|
+
if (!api.id) throw new Error('id 不能为空');
|
|
1015
|
+
if (!api.url) throw new Error('url 不能为空');
|
|
1016
|
+
const res = await postApi('ui/api', { api });
|
|
1017
|
+
if (res.ok === false) throw new Error(res.message || '保存失败');
|
|
1018
|
+
setForm(null);
|
|
1019
|
+
setNotice(res.message || '已保存');
|
|
1020
|
+
await refresh();
|
|
1021
|
+
} catch (e) {
|
|
1022
|
+
setError(e.message);
|
|
1023
|
+
} finally {
|
|
1024
|
+
setBusy('');
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
const deleteApi = async (api) => {
|
|
1029
|
+
if (!window.confirm(`删除接口 ${api.id}?`)) return;
|
|
1030
|
+
setBusy('delete');
|
|
1031
|
+
try {
|
|
1032
|
+
const res = await postApi('ui/api/delete', { id: api.id });
|
|
1033
|
+
if (res.ok === false) throw new Error(res.message || '删除失败');
|
|
1034
|
+
if (result && result.apiId === api.id) setResult(null);
|
|
1035
|
+
setNotice(`已删除 ${api.id}`);
|
|
1036
|
+
await refresh();
|
|
1037
|
+
} catch (e) {
|
|
1038
|
+
setError(e.message);
|
|
1039
|
+
} finally {
|
|
1040
|
+
setBusy('');
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
|
|
1044
|
+
const doCall = async (api, mode) => {
|
|
1045
|
+
setBusy(mode === 'login' ? 'login' : 'call');
|
|
1046
|
+
setError('');
|
|
1047
|
+
setNotice('');
|
|
1048
|
+
try {
|
|
1049
|
+
const params = parseJsonField(api.sampleText, '示例参数') || {};
|
|
1050
|
+
const payload = mode === 'login'
|
|
1051
|
+
? await postApi('login', { api_id: api.id, params })
|
|
1052
|
+
: await postApi('call', { api_id: api.id, params });
|
|
1053
|
+
setResult({ apiId: api.id, mode, payload });
|
|
1054
|
+
if (payload.ok && mode === 'login') {
|
|
1055
|
+
setNotice(payload.message || '已保存 token');
|
|
1056
|
+
await refresh();
|
|
1057
|
+
}
|
|
1058
|
+
} catch (e) {
|
|
1059
|
+
setError(e.message);
|
|
1060
|
+
} finally {
|
|
1061
|
+
setBusy('');
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
|
|
1065
|
+
const clearToken = async (loginId) => {
|
|
1066
|
+
try {
|
|
1067
|
+
await postApi('ui/token/clear', { login_id: loginId });
|
|
1068
|
+
setNotice(`已清除 ${loginId} 的 token`);
|
|
1069
|
+
await refresh();
|
|
1070
|
+
} catch (e) {
|
|
1071
|
+
setError(e.message);
|
|
1072
|
+
}
|
|
1073
|
+
};
|
|
1074
|
+
|
|
1075
|
+
const saveBaseUrl = async () => {
|
|
1076
|
+
try {
|
|
1077
|
+
await postApi('ui/base-url', { baseUrl: draft });
|
|
1078
|
+
setNotice('baseUrl 已保存');
|
|
1079
|
+
await refresh();
|
|
1080
|
+
} catch (e) {
|
|
1081
|
+
setError(e.message);
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
const useBaseUrl = async (item) => {
|
|
1086
|
+
try {
|
|
1087
|
+
await postApi('ui/base-url', { baseUrl: item.baseUrl });
|
|
1088
|
+
setNotice(`baseUrl 已设为 ${item.baseUrl}`);
|
|
1089
|
+
await refresh();
|
|
1090
|
+
} catch (e) {
|
|
1091
|
+
setError(e.message);
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
|
|
1095
|
+
/** 接管:结束 IDEA 的进程,编译后由插件拉起;之后这个服务就归插件管 */
|
|
1096
|
+
const takeOver = async (item) => {
|
|
1097
|
+
const ok = window.confirm(
|
|
1098
|
+
`接管 ${item.name}?\n\n` +
|
|
1099
|
+
`1. 先编译(mvn compile,可能要几十秒;失败则不动原进程)\n` +
|
|
1100
|
+
`2. 结束 IDEA 起的进程 pid ${item.pid}\n` +
|
|
1101
|
+
`3. 由插件用同样的启动参数重新拉起,日志写到 ${item.managedLogPath || '本地文件'}\n\n` +
|
|
1102
|
+
`之后这个服务在 IDEA 里会显示为已退出,停止/重启请在插件里操作。`,
|
|
1103
|
+
);
|
|
1104
|
+
if (!ok) return;
|
|
1105
|
+
setBusy('takeover');
|
|
1106
|
+
setError('');
|
|
1107
|
+
setNotice('');
|
|
1108
|
+
try {
|
|
1109
|
+
const payload = await post('java/start', { pid: item.pid, port: item.httpPort || item.primaryPort || 0, compile: true });
|
|
1110
|
+
if (payload.ok) {
|
|
1111
|
+
setNotice(payload.note || `已接管 ${item.name}`);
|
|
1112
|
+
await refreshJava();
|
|
1113
|
+
setDetail({ runId: payload.id || item.name, name: item.name, pid: payload.pid, owner: 'plugin', alive: true });
|
|
1114
|
+
} else {
|
|
1115
|
+
setError(payload.message || '接管失败');
|
|
1116
|
+
}
|
|
1117
|
+
await refresh();
|
|
1118
|
+
} catch (e) {
|
|
1119
|
+
setError(e.message);
|
|
1120
|
+
} finally {
|
|
1121
|
+
setBusy('');
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
const stopRun = async (item) => {
|
|
1126
|
+
if (!window.confirm(`停止 ${item.name}(pid ${item.pid})?之后再启动请回这里点「启动」。`)) return;
|
|
1127
|
+
setBusy('stop');
|
|
1128
|
+
try {
|
|
1129
|
+
const payload = await post('java/stop', { id: item.runId || item.pid });
|
|
1130
|
+
if (payload.ok) setNotice(payload.message || '已停止');
|
|
1131
|
+
else setError(payload.message || '停止失败');
|
|
1132
|
+
await refreshJava();
|
|
1133
|
+
} catch (e) {
|
|
1134
|
+
setError(e.message);
|
|
1135
|
+
} finally {
|
|
1136
|
+
setBusy('');
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
const restartRun = async (item) => {
|
|
1141
|
+
setBusy('restart');
|
|
1142
|
+
setError('');
|
|
1143
|
+
try {
|
|
1144
|
+
const payload = await post('java/restart', { id: item.runId || item.pid, compile: true });
|
|
1145
|
+
if (payload.ok) setNotice(`已重启 ${item.name}(pid ${payload.pid})`);
|
|
1146
|
+
else setError(payload.message || '重启失败');
|
|
1147
|
+
await refreshJava();
|
|
1148
|
+
} catch (e) {
|
|
1149
|
+
setError(e.message);
|
|
1150
|
+
} finally {
|
|
1151
|
+
setBusy('');
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
/** 忽略:只记进项目配置,不动进程本身 */
|
|
1156
|
+
const ignoreJava = async (item) => {
|
|
1157
|
+
try {
|
|
1158
|
+
const payload = await post('java/ignore', { item: { mainClass: item.mainClass, name: item.name, kind: item.kind } });
|
|
1159
|
+
if (payload.ok) setNotice(payload.message || `已忽略 ${item.name}`);
|
|
1160
|
+
else setError(payload.message || '忽略失败');
|
|
1161
|
+
await refreshJava();
|
|
1162
|
+
await refresh();
|
|
1163
|
+
} catch (e) {
|
|
1164
|
+
setError(e.message);
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
const unignoreJava = async (item) => {
|
|
1169
|
+
try {
|
|
1170
|
+
const payload = await post('java/unignore', { item: { mainClass: item.mainClass, name: item.name, kind: item.kind } });
|
|
1171
|
+
if (payload.ok) setNotice(payload.message || `已取消忽略 ${item.name}`);
|
|
1172
|
+
else setError(payload.message || '取消忽略失败');
|
|
1173
|
+
await refreshJava();
|
|
1174
|
+
await refresh();
|
|
1175
|
+
} catch (e) {
|
|
1176
|
+
setError(e.message);
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
/** 保存配方:把这套启动参数记下来,以后不用先在 IDEA 里跑 */
|
|
1181
|
+
const saveJava = async (item) => {
|
|
1182
|
+
setBusy('save');
|
|
1183
|
+
setError('');
|
|
1184
|
+
try {
|
|
1185
|
+
const payload = await post('java/save', { id: item.runId || item.pid, pid: item.pid });
|
|
1186
|
+
if (payload.ok) setNotice(payload.message || '已保存');
|
|
1187
|
+
else setError(payload.message || '保存失败');
|
|
1188
|
+
await refreshJava();
|
|
1189
|
+
} catch (e) {
|
|
1190
|
+
setError(e.message);
|
|
1191
|
+
} finally {
|
|
1192
|
+
setBusy('');
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
const startSaved = async (item) => {
|
|
1197
|
+
setBusy('start-saved');
|
|
1198
|
+
setError('');
|
|
1199
|
+
setNotice('');
|
|
1200
|
+
try {
|
|
1201
|
+
const payload = await post('java/start-saved', { id: item.id });
|
|
1202
|
+
if (payload.ok) {
|
|
1203
|
+
setNotice(payload.note || `已启动 ${item.id}(pid ${payload.pid})`);
|
|
1204
|
+
await refreshJava();
|
|
1205
|
+
} else {
|
|
1206
|
+
setError(payload.message || '启动失败');
|
|
1207
|
+
}
|
|
1208
|
+
} catch (e) {
|
|
1209
|
+
setError(e.message);
|
|
1210
|
+
} finally {
|
|
1211
|
+
setBusy('');
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* 一键启动:把「已保存」里还没跑的服务全拉起来。
|
|
1217
|
+
*
|
|
1218
|
+
* 后台跑(host 逐个编译要几分钟),这里只负责起批次 + 轮询进度;
|
|
1219
|
+
* 轮询到 finished 就停,并刷一次服务列表把新进程显示出来。
|
|
1220
|
+
*/
|
|
1221
|
+
const startAllSaved = async () => {
|
|
1222
|
+
setBusy('start-all');
|
|
1223
|
+
setError('');
|
|
1224
|
+
setNotice('');
|
|
1225
|
+
try {
|
|
1226
|
+
const payload = await post('java/start-all', {});
|
|
1227
|
+
if (!payload.ok) {
|
|
1228
|
+
setError(payload.message || '一键启动失败');
|
|
1229
|
+
setBusy('');
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
setBatch({
|
|
1233
|
+
batchId: payload.batchId,
|
|
1234
|
+
total: payload.total || 0,
|
|
1235
|
+
done: 0,
|
|
1236
|
+
current: '',
|
|
1237
|
+
items: [],
|
|
1238
|
+
finished: false,
|
|
1239
|
+
result: null,
|
|
1240
|
+
});
|
|
1241
|
+
setNotice(payload.message || '已开始一键启动');
|
|
1242
|
+
} catch (e) {
|
|
1243
|
+
setError(e.message);
|
|
1244
|
+
setBusy('');
|
|
1245
|
+
}
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
// 批次进度轮询:只在有未完成批次时跑,1 秒一次,完成即停并刷新服务列表
|
|
1249
|
+
React.useEffect(() => {
|
|
1250
|
+
if (!batch || batch.finished || !batch.batchId) return undefined;
|
|
1251
|
+
let cancelled = false;
|
|
1252
|
+
const timer = setInterval(async () => {
|
|
1253
|
+
try {
|
|
1254
|
+
const data = await request(`java/start-all/status?batch=${encodeURIComponent(batch.batchId)}`, { headers });
|
|
1255
|
+
if (cancelled) return;
|
|
1256
|
+
if (!data.ok) return;
|
|
1257
|
+
setBatch(data);
|
|
1258
|
+
if (data.finished) {
|
|
1259
|
+
setBusy('');
|
|
1260
|
+
await refreshJava();
|
|
1261
|
+
if (data.result && data.result.ok === false) setError(data.result.message || '部分服务启动失败');
|
|
1262
|
+
else if (data.result) setNotice(data.result.message || '一键启动完成');
|
|
1263
|
+
}
|
|
1264
|
+
} catch {
|
|
1265
|
+
/* 轮询失败下次再来,不打断用户操作 */
|
|
1266
|
+
}
|
|
1267
|
+
}, 1000);
|
|
1268
|
+
return () => {
|
|
1269
|
+
cancelled = true;
|
|
1270
|
+
clearInterval(timer);
|
|
1271
|
+
};
|
|
1272
|
+
}, [batch && batch.batchId, batch && batch.finished, headers, refreshJava]);
|
|
1273
|
+
|
|
1274
|
+
const deleteSaved = async (item) => {
|
|
1275
|
+
if (!window.confirm(`删除已保存的服务 ${item.id}?(只删除启动配方,不影响正在运行的进程)`)) return;
|
|
1276
|
+
setBusy('delete-saved');
|
|
1277
|
+
try {
|
|
1278
|
+
const payload = await post('java/unsave', { id: item.id });
|
|
1279
|
+
if (payload.ok) setNotice(`已删除 ${item.id}`);
|
|
1280
|
+
else setError(payload.message || '删除失败');
|
|
1281
|
+
await refreshJava();
|
|
1282
|
+
} catch (e) {
|
|
1283
|
+
setError(e.message);
|
|
1284
|
+
} finally {
|
|
1285
|
+
setBusy('');
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
const saveSettings = async (patch, okText) => {
|
|
1290
|
+
setBusy('settings');
|
|
1291
|
+
setError('');
|
|
1292
|
+
try {
|
|
1293
|
+
const payload = await post('settings', patch);
|
|
1294
|
+
if (!payload.ok) throw new Error(payload.message || '保存失败');
|
|
1295
|
+
setNotice(okText);
|
|
1296
|
+
await refreshSettings();
|
|
1297
|
+
await refreshJava();
|
|
1298
|
+
} catch (e) {
|
|
1299
|
+
setError(e.message);
|
|
1300
|
+
} finally {
|
|
1301
|
+
setBusy('');
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
|
|
1305
|
+
const tabs = [
|
|
1306
|
+
{ id: 'apis', label: '接口', count: apis.length },
|
|
1307
|
+
{ id: 'services', label: '服务', count: runningList.length },
|
|
1308
|
+
{ id: 'settings', label: '设置', count: 0 },
|
|
1309
|
+
];
|
|
1310
|
+
|
|
1311
|
+
const apisPane = h('div', { className: 'ar-pane' },
|
|
1312
|
+
// 项目分段控件:只有一个项目时没有分类的意义,整排省掉,别白占一行
|
|
1313
|
+
allProjects.length > 1
|
|
1314
|
+
? h('div', { className: 'ar-tabs sub ar-projects' },
|
|
1315
|
+
allProjects.map((item) => {
|
|
1316
|
+
const isCurrent = item.key === activeKey;
|
|
1317
|
+
const label = projectLabel(item.key, allProjects.map((p) => p.key));
|
|
1318
|
+
const title = `${item.key}${item.key === cwdProjectKey ? '(会话当前工作区)' : ''}`;
|
|
1319
|
+
return h('button', {
|
|
1320
|
+
key: item.key,
|
|
1321
|
+
className: isCurrent ? 'ar-tab on' : 'ar-tab',
|
|
1322
|
+
title,
|
|
1323
|
+
onClick: () => { setForm(null); setProjectTab(item.key === cwdProjectKey ? '' : item.key); },
|
|
1324
|
+
}, h('span', { className: 'l' }, label), item.apiCount > 0 ? h('span', { className: 'ar-count' }, item.apiCount) : null);
|
|
1325
|
+
}))
|
|
1326
|
+
: null,
|
|
1327
|
+
h('div', { className: 'ar-row' },
|
|
1328
|
+
h('input', { className: 'ar-in', value: filter, placeholder: '筛选接口…', onChange: (e) => setFilter(e.target.value) }),
|
|
1329
|
+
form ? null : h('button', { className: 'ar-btn tonal', onClick: () => setForm(emptyForm(baseUrl)) }, '新增')),
|
|
1330
|
+
form ? h(EditForm, { value: form, onChange: setForm, onSave: saveApi, onCancel: () => setForm(null), tokens, busy }) : null,
|
|
1331
|
+
apis.length === 0 && !form
|
|
1332
|
+
? h(Empty, {
|
|
1333
|
+
icon: '⌁',
|
|
1334
|
+
title: '还没有接口',
|
|
1335
|
+
hint: '点「新增」在面板里配一个,或在 .dsh/api-runner.yml 里写(YAML 里的接口只能改文件)。',
|
|
1336
|
+
action: h('button', { className: 'ar-btn primary', style: { marginTop: '2px' }, onClick: () => setForm(emptyForm(baseUrl)) }, '新增接口'),
|
|
1337
|
+
})
|
|
1338
|
+
: shown.length === 0
|
|
1339
|
+
? h('div', { className: 'ar-hint', style: { padding: '8px 2px' } }, `没有匹配「${filter}」的接口。`)
|
|
1340
|
+
: h('div', { className: 'ar-group' }, shown.map((api) => h(ApiRow, {
|
|
1341
|
+
key: api.id, api, tokens, busy,
|
|
1342
|
+
onTest: (item) => doCall(item, 'call'),
|
|
1343
|
+
onLogin: (item) => doCall(item, 'login'),
|
|
1344
|
+
onEdit: (item) => setForm(formFromApi(item)),
|
|
1345
|
+
onDelete: deleteApi,
|
|
1346
|
+
onClearToken: clearToken,
|
|
1347
|
+
}))),
|
|
1348
|
+
result ? h(ResultCard, { result, onClose: () => setResult(null) }) : null);
|
|
1349
|
+
|
|
1350
|
+
const servicesPane = detail
|
|
1351
|
+
? h(ServiceDetail, {
|
|
1352
|
+
item: detail,
|
|
1353
|
+
visible,
|
|
1354
|
+
get,
|
|
1355
|
+
busy,
|
|
1356
|
+
onClose: () => { setDetail(null); refreshJava(); },
|
|
1357
|
+
onStop: async (item) => { await stopRun(item); await refreshJava(); },
|
|
1358
|
+
onRestart: async (item) => { await restartRun(item); },
|
|
1359
|
+
onTakeOver: takeOver,
|
|
1360
|
+
onIgnore: ignoreJava,
|
|
1361
|
+
onUnignore: unignoreJava,
|
|
1362
|
+
})
|
|
1363
|
+
: h('div', { className: 'ar-pane' },
|
|
1364
|
+
h('div', { className: 'ar-row' },
|
|
1365
|
+
// 二级页签:和顶部「接口/服务/设置」同一套分段控件,只是小一号
|
|
1366
|
+
h('div', { className: 'ar-tabs sub' }, [
|
|
1367
|
+
{ id: 'managed', label: '已接管', count: managedList.length },
|
|
1368
|
+
{ id: 'running', label: '运行中', count: runningList.length },
|
|
1369
|
+
{ id: 'saved', label: '已保存', count: savedList.length },
|
|
1370
|
+
{ id: 'ignored', label: '已忽略', count: ignoredList.length },
|
|
1371
|
+
].map((item) => h('button', {
|
|
1372
|
+
key: item.id,
|
|
1373
|
+
className: item.id === group ? 'ar-tab on' : 'ar-tab',
|
|
1374
|
+
onClick: () => { groupTouched.current = true; setGroup(item.id); },
|
|
1375
|
+
}, item.label, item.count > 0 ? h('span', { className: 'ar-count' }, item.count) : null))),
|
|
1376
|
+
h('button', { className: 'ar-btn ghost icon', disabled: busy !== '', title: '重新扫描 Java 进程', onClick: refreshJava }, '↻')),
|
|
1377
|
+
h(Banner, { kind: 'err', text: java && java.ok === false ? (java.message || '无法读取 Java 进程') : '' }),
|
|
1378
|
+
|
|
1379
|
+
group === 'managed'
|
|
1380
|
+
? (managedList.length === 0
|
|
1381
|
+
? h(Empty, {
|
|
1382
|
+
icon: '☕',
|
|
1383
|
+
title: '还没有接管任何服务',
|
|
1384
|
+
hint: '在「正在运行」里选一个 IDEA 起的服务,点「接管启动」,之后就能在这里停止、重启、看日志。',
|
|
1385
|
+
action: h('button', { className: 'ar-btn tonal', style: { marginTop: '2px' }, onClick: () => setGroup('running') }, '去看正在运行的服务'),
|
|
1386
|
+
})
|
|
1387
|
+
: h('div', { className: 'ar-group' }, managedList.map((item) => h(JavaRow, {
|
|
1388
|
+
key: `plugin-${item.runId || item.pid}`,
|
|
1389
|
+
item,
|
|
1390
|
+
busy,
|
|
1391
|
+
onUseBaseUrl: useBaseUrl,
|
|
1392
|
+
onTakeOver: takeOver,
|
|
1393
|
+
onStop: stopRun,
|
|
1394
|
+
onRestart: restartRun,
|
|
1395
|
+
onDetail: (target) => setDetail(target),
|
|
1396
|
+
onIgnore: ignoreJava,
|
|
1397
|
+
onUnignore: unignoreJava,
|
|
1398
|
+
onSave: saveJava,
|
|
1399
|
+
}))))
|
|
1400
|
+
: null,
|
|
1401
|
+
|
|
1402
|
+
group === 'running'
|
|
1403
|
+
? (runningList.length === 0
|
|
1404
|
+
? h(Empty, {
|
|
1405
|
+
icon: '☕',
|
|
1406
|
+
title: '没有运行中的 Java 服务',
|
|
1407
|
+
hint: '在 IDEA 里启动一个 Spring Boot 应用,再回来看;已经保存过启动参数的服务可以在「已保存」里直接启动。',
|
|
1408
|
+
})
|
|
1409
|
+
: h('div', { className: 'ar-group' }, runningList.map((item) => h(JavaRow, {
|
|
1410
|
+
key: `run-${item.owner}-${item.runId || item.pid}`,
|
|
1411
|
+
item,
|
|
1412
|
+
busy,
|
|
1413
|
+
onUseBaseUrl: useBaseUrl,
|
|
1414
|
+
onTakeOver: takeOver,
|
|
1415
|
+
onStop: stopRun,
|
|
1416
|
+
onRestart: restartRun,
|
|
1417
|
+
onDetail: (target) => setDetail(target),
|
|
1418
|
+
onIgnore: ignoreJava,
|
|
1419
|
+
onUnignore: unignoreJava,
|
|
1420
|
+
onSave: saveJava,
|
|
1421
|
+
}))))
|
|
1422
|
+
: null,
|
|
1423
|
+
|
|
1424
|
+
group === 'saved'
|
|
1425
|
+
? (savedList.length === 0
|
|
1426
|
+
? h(Empty, {
|
|
1427
|
+
icon: '☕',
|
|
1428
|
+
title: '还没有保存的服务',
|
|
1429
|
+
hint: '在「正在运行」里选一个服务点「保存」,把它那套启动参数(classpath/主类/JVM 参数)记下来。以后不用先在 IDEA 里跑,直接在这里启动。',
|
|
1430
|
+
action: h('button', { className: 'ar-btn tonal', style: { marginTop: '2px' }, onClick: () => setGroup('running') }, '去看正在运行的服务'),
|
|
1431
|
+
})
|
|
1432
|
+
: h('div', { className: 'ar-group' },
|
|
1433
|
+
// 一键启动:逐个编译+拉起,已运行的跳过,单个失败不影响其余
|
|
1434
|
+
h('div', { className: 'ar-row', style: { marginBottom: '2px' } },
|
|
1435
|
+
h('button', {
|
|
1436
|
+
className: 'ar-btn primary',
|
|
1437
|
+
disabled: busy !== '',
|
|
1438
|
+
title: '把「已保存」里的服务全部拉起来(已在运行的跳过;逐个编译,可能要几分钟)',
|
|
1439
|
+
onClick: startAllSaved,
|
|
1440
|
+
}, busy === 'start-all' ? '启动中…' : '一键启动全部'),
|
|
1441
|
+
h('span', { className: 'ar-hint', style: { flex: '1 1 auto', minWidth: 0 } },
|
|
1442
|
+
`${savedList.length} 个已保存`)),
|
|
1443
|
+
batch ? h(BatchProgress, { batch, onDismiss: () => setBatch(null) }) : null,
|
|
1444
|
+
savedList.map((item) => h(SavedRow, {
|
|
1445
|
+
key: `saved-${item.id}`,
|
|
1446
|
+
item,
|
|
1447
|
+
busy,
|
|
1448
|
+
onStart: startSaved,
|
|
1449
|
+
onDelete: deleteSaved,
|
|
1450
|
+
}))))
|
|
1451
|
+
: null,
|
|
1452
|
+
|
|
1453
|
+
group === 'ignored'
|
|
1454
|
+
? (ignoredList.length === 0
|
|
1455
|
+
? h(Empty, { icon: '•', title: '没有已忽略的服务', hint: '不想在「正在运行」里看到的服务,点它右边的「忽略」就会挪到这里,不影响进程本身。' })
|
|
1456
|
+
: h('div', { className: 'ar-group' }, ignoredList.map((item) => h(JavaRow, {
|
|
1457
|
+
key: `ignored-${item.owner}-${item.runId || item.pid}`,
|
|
1458
|
+
item,
|
|
1459
|
+
muted: true,
|
|
1460
|
+
busy,
|
|
1461
|
+
onUseBaseUrl: useBaseUrl,
|
|
1462
|
+
onTakeOver: takeOver,
|
|
1463
|
+
onStop: stopRun,
|
|
1464
|
+
onRestart: restartRun,
|
|
1465
|
+
onDetail: (target) => setDetail(target),
|
|
1466
|
+
onIgnore: ignoreJava,
|
|
1467
|
+
onUnignore: unignoreJava,
|
|
1468
|
+
onSave: saveJava,
|
|
1469
|
+
}))))
|
|
1470
|
+
: null);
|
|
1471
|
+
|
|
1472
|
+
const settingsPane = h('div', { className: 'ar-pane' },
|
|
1473
|
+
h('div', null,
|
|
1474
|
+
h('div', { className: 'ar-sec' }, h('span', {}, '数据目录')),
|
|
1475
|
+
h('div', { className: 'ar-card' },
|
|
1476
|
+
h('div', { className: 'ar-hint' },
|
|
1477
|
+
'插件自己的东西(服务日志、状态、面板配置)放这里。默认在 DSH_HOME 下,想换盘就填个绝对路径,保存后新日志立刻写过去。'),
|
|
1478
|
+
h('div', { className: 'ar-row' },
|
|
1479
|
+
h('input', {
|
|
1480
|
+
className: 'ar-in ar-mono',
|
|
1481
|
+
value: dataDirDraft,
|
|
1482
|
+
placeholder: settings?.effectiveDataDir || '绝对路径,例如 <你的目录>/dsh-api-runner-data',
|
|
1483
|
+
onChange: (e) => setDataDirDraft(e.target.value),
|
|
1484
|
+
}),
|
|
1485
|
+
h('button', {
|
|
1486
|
+
className: 'ar-btn primary',
|
|
1487
|
+
disabled: busy !== '' || dataDirDraft === (settings?.dataDir || ''),
|
|
1488
|
+
onClick: () => saveSettings({ dataDir: dataDirDraft }, '数据目录已保存'),
|
|
1489
|
+
}, '保存'),
|
|
1490
|
+
dataDirDraft ? h('button', {
|
|
1491
|
+
className: 'ar-btn ghost',
|
|
1492
|
+
title: '改回默认(DSH_HOME 下)',
|
|
1493
|
+
onClick: () => { setDataDirDraft(''); saveSettings({ dataDir: '' }, '已改回默认数据目录'); },
|
|
1494
|
+
}, '默认') : null),
|
|
1495
|
+
settings && settings.effectiveDataDir
|
|
1496
|
+
? h('div', { className: 'ar-kv' }, h('span', { className: 'k' }, '当前'), h('span', { className: 'v ar-mono ar-muted ar-cut', title: settings.effectiveDataDir }, settings.effectiveDataDir))
|
|
1497
|
+
: null,
|
|
1498
|
+
settings && settings.settingsFile
|
|
1499
|
+
? h('div', { className: 'ar-kv' }, h('span', { className: 'k' }, '设置文件'), h('span', { className: 'v ar-mono ar-muted ar-cut', title: settings.settingsFile }, settings.settingsFile))
|
|
1500
|
+
: null)),
|
|
1501
|
+
h('div', null,
|
|
1502
|
+
h('div', { className: 'ar-sec' }, h('span', {}, '默认工作区')),
|
|
1503
|
+
h('div', { className: 'ar-card' },
|
|
1504
|
+
h('div', { className: 'ar-hint' },
|
|
1505
|
+
'在没有会话上下文时(比如直接调接口、从工具里启动服务)用它当项目目录。填你的项目根目录,日志和面板配置就会按它归档。'),
|
|
1506
|
+
h('div', { className: 'ar-row' },
|
|
1507
|
+
h('input', {
|
|
1508
|
+
className: 'ar-in ar-mono',
|
|
1509
|
+
value: workspaceDraft,
|
|
1510
|
+
placeholder: '你的项目根目录的绝对路径',
|
|
1511
|
+
onChange: (e) => setWorkspaceDraft(e.target.value),
|
|
1512
|
+
}),
|
|
1513
|
+
h('button', {
|
|
1514
|
+
className: 'ar-btn primary',
|
|
1515
|
+
disabled: busy !== '' || workspaceDraft === (settings?.workspace || ''),
|
|
1516
|
+
onClick: () => saveSettings({ workspace: workspaceDraft }, '默认工作区已保存'),
|
|
1517
|
+
}, '保存')))),
|
|
1518
|
+
h('div', null,
|
|
1519
|
+
h('div', { className: 'ar-sec' }, h('span', {}, 'Maven 主路径')),
|
|
1520
|
+
h('div', { className: 'ar-card' },
|
|
1521
|
+
h('div', { className: 'ar-hint' },
|
|
1522
|
+
'接管启动前编译 Java 服务用。留空会自动探测:MAVEN_HOME → PATH → IDEA 自带 Maven(并读取 .idea 里的 settings.xml 和本地仓库)。'),
|
|
1523
|
+
h('div', { className: 'ar-row' },
|
|
1524
|
+
h('input', {
|
|
1525
|
+
className: 'ar-in ar-mono',
|
|
1526
|
+
value: mavenHomeDraft,
|
|
1527
|
+
placeholder: 'Maven 安装目录(到根为止,不含 bin)',
|
|
1528
|
+
onChange: (e) => setMavenHomeDraft(e.target.value),
|
|
1529
|
+
}),
|
|
1530
|
+
h('button', {
|
|
1531
|
+
className: 'ar-btn primary',
|
|
1532
|
+
disabled: busy !== '' || mavenHomeDraft === (settings?.mavenHome || ''),
|
|
1533
|
+
onClick: () => saveSettings({ mavenHome: mavenHomeDraft }, 'Maven 主路径已保存'),
|
|
1534
|
+
}, '保存'),
|
|
1535
|
+
mavenHomeDraft ? h('button', {
|
|
1536
|
+
className: 'ar-btn ghost',
|
|
1537
|
+
title: '清空后恢复自动探测',
|
|
1538
|
+
onClick: () => { setMavenHomeDraft(''); saveSettings({ mavenHome: '' }, '已改回自动探测'); },
|
|
1539
|
+
}, '自动') : null))),
|
|
1540
|
+
h('div', null,
|
|
1541
|
+
h('div', { className: 'ar-sec' }, h('span', {}, '接口基地址')),
|
|
1542
|
+
h('div', { className: 'ar-card' },
|
|
1543
|
+
h('div', { className: 'ar-hint' }, '接口自己没填 baseUrl 时用它。在「服务」页签点一下,就能直接设成某个 Java 服务的端口。'),
|
|
1544
|
+
h('div', { className: 'ar-row' },
|
|
1545
|
+
h('input', { className: 'ar-in ar-mono', value: draft, placeholder: 'http://127.0.0.1:8080', onChange: (e) => setDraft(e.target.value) }),
|
|
1546
|
+
h('button', { className: 'ar-btn primary', disabled: draft === baseUrl, onClick: saveBaseUrl }, '保存')))),
|
|
1547
|
+
h('div', null,
|
|
1548
|
+
h('div', { className: 'ar-sec' }, h('span', {}, `已保存 token · ${Object.keys(tokens).length}`)),
|
|
1549
|
+
h('div', { className: 'ar-card' },
|
|
1550
|
+
Object.keys(tokens).length === 0
|
|
1551
|
+
? h('div', { className: 'ar-hint' }, '还没有 token。把登录接口勾成「登录接口」,再点「登录并保存」。')
|
|
1552
|
+
: Object.entries(tokens).map(([id, item]) => h('div', { key: id, className: 'ar-row' },
|
|
1553
|
+
h('span', { className: 'ar-name', style: { flex: '0 0 auto' } }, id),
|
|
1554
|
+
h('span', { className: 'ar-mono ar-muted ar-cut', style: { flex: '1 1 auto', fontSize: '12px' } }, item.masked),
|
|
1555
|
+
h('button', { className: 'ar-btn ghost danger', onClick: () => clearToken(id) }, '清除'))))),
|
|
1556
|
+
h('div', null,
|
|
1557
|
+
h('div', { className: 'ar-sec' }, h('span', {}, '配置来源')),
|
|
1558
|
+
h('div', { className: 'ar-card' },
|
|
1559
|
+
h('div', { className: 'ar-kv' }, h('span', { className: 'k' }, '项目'), h('span', { className: 'v ar-mono ar-muted ar-cut', title: cwd }, cwd || '(未取到项目路径,回落到 default)')),
|
|
1560
|
+
state && state.projectKey ? h('div', { className: 'ar-kv' }, h('span', { className: 'k' }, 'key'), h('span', { className: 'v ar-mono ar-muted ar-cut' }, state.projectKey)) : null,
|
|
1561
|
+
state && state.sources && state.sources.length > 0
|
|
1562
|
+
? state.sources.map((s) => h('div', { key: s, className: 'ar-kv' }, h('span', { className: 'k' }, '来源'), h('span', { className: 'v ar-mono ar-muted ar-cut', title: s }, s)))
|
|
1563
|
+
: h('div', { className: 'ar-kv' }, h('span', { className: 'k' }, '来源'), h('span', { className: 'v ar-muted' }, '暂无 YAML 文件,接口全部来自面板')))));
|
|
1564
|
+
|
|
1565
|
+
return h('div', { className: 'ar-root' },
|
|
1566
|
+
h('div', { className: 'ar-top' },
|
|
1567
|
+
h('div', { className: 'ar-tabs' }, tabs.map((item) => h('button', {
|
|
1568
|
+
key: item.id,
|
|
1569
|
+
className: item.id === tab ? 'ar-tab on' : 'ar-tab',
|
|
1570
|
+
onClick: () => setTab(item.id),
|
|
1571
|
+
}, item.label, item.count > 0 ? h('span', { className: 'ar-count' }, item.count) : null))),
|
|
1572
|
+
h('button', { className: 'ar-btn ghost icon', disabled: busy !== '', title: '重新读取配置与进程列表', onClick: () => { refresh(); refreshJava(); } }, '↻')),
|
|
1573
|
+
h('div', { className: 'ar-body' },
|
|
1574
|
+
h(Banner, { kind: 'err', text: error, onClose: () => setError('') }),
|
|
1575
|
+
h(Banner, { kind: 'ok', text: error ? '' : notice, onClose: () => setNotice('') }),
|
|
1576
|
+
tab === 'apis' ? apisPane : null,
|
|
1577
|
+
tab === 'services' ? servicesPane : null,
|
|
1578
|
+
tab === 'settings' ? settingsPane : null));
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* 设置里的插件主页面。
|
|
1583
|
+
*
|
|
1584
|
+
* 侧边栏那个页签是「干活的地方」,这里只放全局项:默认工作区与数据目录。
|
|
1585
|
+
* 没有会话上下文,cwd 传空串,host 会回落到设置里的默认工作区。
|
|
1586
|
+
*/
|
|
1587
|
+
function SettingsPage() {
|
|
1588
|
+
const [settings, setSettings] = React.useState(null);
|
|
1589
|
+
const [error, setError] = React.useState('');
|
|
1590
|
+
const [notice, setNotice] = React.useState('');
|
|
1591
|
+
const [busy, setBusy] = React.useState('');
|
|
1592
|
+
const [workspace, setWorkspace] = React.useState('');
|
|
1593
|
+
const [dataDir, setDataDir] = React.useState('');
|
|
1594
|
+
|
|
1595
|
+
const load = React.useCallback(async () => {
|
|
1596
|
+
try {
|
|
1597
|
+
const data = await request('settings', { headers: { 'Content-Type': 'application/json' } });
|
|
1598
|
+
if (data.ok === false) throw new Error(data.message || '读取设置失败');
|
|
1599
|
+
setSettings(data);
|
|
1600
|
+
setWorkspace(data.workspace || '');
|
|
1601
|
+
setDataDir(data.dataDir || '');
|
|
1602
|
+
setError('');
|
|
1603
|
+
} catch (e) {
|
|
1604
|
+
setError(e.message);
|
|
1605
|
+
}
|
|
1606
|
+
}, []);
|
|
1607
|
+
|
|
1608
|
+
React.useEffect(() => { load(); }, [load]);
|
|
1609
|
+
|
|
1610
|
+
const save = async (patch, message) => {
|
|
1611
|
+
setBusy('save');
|
|
1612
|
+
setError('');
|
|
1613
|
+
setNotice('');
|
|
1614
|
+
try {
|
|
1615
|
+
const data = await request('settings', {
|
|
1616
|
+
method: 'POST',
|
|
1617
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1618
|
+
body: JSON.stringify({ settings: patch }),
|
|
1619
|
+
});
|
|
1620
|
+
if (data.ok === false) throw new Error(data.message || '保存失败');
|
|
1621
|
+
setSettings(data);
|
|
1622
|
+
setWorkspace(data.workspace || '');
|
|
1623
|
+
setDataDir(data.dataDir || '');
|
|
1624
|
+
setNotice(message);
|
|
1625
|
+
} catch (e) {
|
|
1626
|
+
setError(e.message);
|
|
1627
|
+
} finally {
|
|
1628
|
+
setBusy('');
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
|
|
1632
|
+
return h('div', { className: 'ar-root' },
|
|
1633
|
+
h('div', { className: 'ar-body' },
|
|
1634
|
+
h(Banner, { kind: 'err', text: error, onClose: () => setError('') }),
|
|
1635
|
+
h(Banner, { kind: 'ok', text: error ? '' : notice, onClose: () => setNotice('') }),
|
|
1636
|
+
h('div', null,
|
|
1637
|
+
h('div', { className: 'ar-sec' }, h('span', { className: 't' }, '默认工作区')),
|
|
1638
|
+
h('div', { className: 'ar-card' },
|
|
1639
|
+
h('div', { className: 'ar-hint' },
|
|
1640
|
+
'没有会话上下文时(直接调接口、从工具里启动服务)用它当项目目录。填你的项目根目录的绝对路径。'),
|
|
1641
|
+
h('div', { className: 'ar-row' },
|
|
1642
|
+
h('input', {
|
|
1643
|
+
className: 'ar-in ar-mono',
|
|
1644
|
+
value: workspace,
|
|
1645
|
+
placeholder: '你的项目根目录的绝对路径',
|
|
1646
|
+
onChange: (e) => setWorkspace(e.target.value),
|
|
1647
|
+
}),
|
|
1648
|
+
h('button', {
|
|
1649
|
+
className: 'ar-btn primary',
|
|
1650
|
+
disabled: busy !== '' || workspace === (settings?.workspace || ''),
|
|
1651
|
+
onClick: () => save({ workspace }, '默认工作区已保存'),
|
|
1652
|
+
}, '保存')))),
|
|
1653
|
+
h('div', null,
|
|
1654
|
+
h('div', { className: 'ar-sec' }, h('span', { className: 't' }, '数据目录')),
|
|
1655
|
+
h('div', { className: 'ar-card' },
|
|
1656
|
+
h('div', { className: 'ar-hint' },
|
|
1657
|
+
'插件自己产生的东西(服务日志、状态文件、面板配置)放这里。默认在 DSH_HOME 下;想换盘就填绝对路径,保存后新的日志立刻写过去。'),
|
|
1658
|
+
h('div', { className: 'ar-row' },
|
|
1659
|
+
h('input', {
|
|
1660
|
+
className: 'ar-in ar-mono',
|
|
1661
|
+
value: dataDir,
|
|
1662
|
+
placeholder: settings?.effectiveDataDir || '绝对路径,例如 <你的目录>/dsh-api-runner-data',
|
|
1663
|
+
onChange: (e) => setDataDir(e.target.value),
|
|
1664
|
+
}),
|
|
1665
|
+
h('button', {
|
|
1666
|
+
className: 'ar-btn primary',
|
|
1667
|
+
disabled: busy !== '' || dataDir === (settings?.dataDir || ''),
|
|
1668
|
+
onClick: () => save({ dataDir }, '数据目录已保存'),
|
|
1669
|
+
}, '保存'),
|
|
1670
|
+
h('button', {
|
|
1671
|
+
className: 'ar-btn ghost',
|
|
1672
|
+
disabled: busy !== '' || (settings?.dataDir || '') === '',
|
|
1673
|
+
onClick: () => save({ dataDir: '' }, '已改回默认数据目录'),
|
|
1674
|
+
}, '恢复默认')),
|
|
1675
|
+
settings && settings.effectiveDataDir
|
|
1676
|
+
? h('div', { className: 'ar-kv' }, h('span', { className: 'k' }, '当前生效'), h('span', { className: 'v ar-mono ar-muted ar-cut', title: settings.effectiveDataDir }, settings.effectiveDataDir))
|
|
1677
|
+
: null,
|
|
1678
|
+
settings && settings.settingsFile
|
|
1679
|
+
? h('div', { className: 'ar-kv' }, h('span', { className: 'k' }, '设置文件'), h('span', { className: 'v ar-mono ar-muted ar-cut', title: settings.settingsFile }, settings.settingsFile))
|
|
1680
|
+
: null)),
|
|
1681
|
+
h('div', null,
|
|
1682
|
+
h('div', { className: 'ar-sec' }, h('span', { className: 't' }, '说明')),
|
|
1683
|
+
h('div', { className: 'ar-card' },
|
|
1684
|
+
h('div', { className: 'ar-hint' },
|
|
1685
|
+
'接口、token、已保存的服务都按项目归档,在侧边栏「接口调试」页签里配。这里只放跨项目的全局项。')))));
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
// ---------------------------------------------------------------- 注册
|
|
1689
|
+
//
|
|
1690
|
+
// 全部注册到 DSH **自带**的 slot 席位,不依赖任何第三方侧边栏插件:
|
|
1691
|
+
//
|
|
1692
|
+
// sidebar.panellist 左栏图标(id 即 main 的 key)
|
|
1693
|
+
// main 中栏整页(keyed,按面板 id 分发)
|
|
1694
|
+
// sidebar.right.pane.tab / .title
|
|
1695
|
+
// 右侧栏页签(会话级,与终端/文件/任务并列)
|
|
1696
|
+
// settings.section 设置页里的插件主页(可选通道)
|
|
1697
|
+
//
|
|
1698
|
+
// 每个席位都用 ctx.slots.inject 包一层:席位由宿主声明,声明还没出现时
|
|
1699
|
+
// 先等着,声明撤掉时自动卸载贡献,之后重新声明再装回来。
|
|
1700
|
+
// 不写死 inject 里的服务名——cordis 的 ctx 是 Proxy,读未 inject 的服务会抛
|
|
1701
|
+
// `cannot get property "slots" without inject`,所以统一用 ctx.get('slots')
|
|
1702
|
+
// 判空,缺席位时安静跳过而不是让整个 client half 不激活。
|
|
1703
|
+
const inject = ['slots'];
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* 左栏/中栏面板(全局页)。
|
|
1707
|
+
*
|
|
1708
|
+
* `main` 是 root 级 keyed 席位,本身不带会话绑定,但 root 标准 props 里有
|
|
1709
|
+
* `useSessions`:按「被主视图 retain 的那个会话」取 id(和宿主 DocumentTitle
|
|
1710
|
+
* 同一判据),再把 id 交给 host 解析 cwd。这样在全局页里打开的也是当前会话
|
|
1711
|
+
* 的工作区,而不是永远落到设置里的默认工作区。
|
|
1712
|
+
*/
|
|
1713
|
+
function GlobalPanel(props) {
|
|
1714
|
+
const sessionId = typeof props.useSessions === 'function'
|
|
1715
|
+
? props.useSessions((state) => {
|
|
1716
|
+
try {
|
|
1717
|
+
const rows = state && state.byId ? Object.values(state.byId) : [];
|
|
1718
|
+
const current = rows.find((row) => row && row.retainedBy && (row.retainedBy.mainView ?? 0) > 0);
|
|
1719
|
+
return current && current.id ? current.id : '';
|
|
1720
|
+
} catch {
|
|
1721
|
+
return '';
|
|
1722
|
+
}
|
|
1723
|
+
})
|
|
1724
|
+
: '';
|
|
1725
|
+
return h(Panel, { visible: true, scope: { sessionId: sessionId || '' } });
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
/**
|
|
1729
|
+
* 右侧栏页签正文(会话级席位)。
|
|
1730
|
+
*
|
|
1731
|
+
* 会话 id 从 standard props 拿,请求头带上它,host 就能解析出该会话的 cwd;
|
|
1732
|
+
* 可见性跟着页签走,页签没被选中时不轮询(省掉后台会话的定时刷新)。
|
|
1733
|
+
*/
|
|
1734
|
+
function RightTabPanel(props) {
|
|
1735
|
+
const info = typeof props.useTabInfo === 'function' ? props.useTabInfo() : undefined;
|
|
1736
|
+
return h(Panel, {
|
|
1737
|
+
visible: info ? info.tab.visible !== false : true,
|
|
1738
|
+
scope: { sessionId: props.sessionId || '' },
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
/**
|
|
1743
|
+
* 面板图标:宿主给 size/active,只画一个 ⚡ 字形,不引宿主 primitives。
|
|
1744
|
+
* 左栏 `sidebar.panellist` 和右侧栏 guide 卡都用它。
|
|
1745
|
+
*/
|
|
1746
|
+
function PanelIcon(props) {
|
|
1747
|
+
const size = Number(props.size) || 16;
|
|
1748
|
+
return h('span', {
|
|
1749
|
+
style: {
|
|
1750
|
+
display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
|
|
1751
|
+
width: `${size}px`, height: `${size}px`,
|
|
1752
|
+
fontSize: `${Math.round(size * 0.82)}px`, lineHeight: 1,
|
|
1753
|
+
opacity: props.active ? 1 : 0.7,
|
|
1754
|
+
},
|
|
1755
|
+
'aria-hidden': 'true',
|
|
1756
|
+
}, '⚡');
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
function apply(ctx) {
|
|
1760
|
+
installStyles(ctx);
|
|
1761
|
+
const slots = typeof ctx.get === 'function' ? ctx.get('slots') : undefined;
|
|
1762
|
+
if (!slots || typeof slots.register !== 'function') return;
|
|
1763
|
+
|
|
1764
|
+
const wait = (name, register) => {
|
|
1765
|
+
if (typeof slots.inject !== 'function') return register();
|
|
1766
|
+
const dispose = slots.inject(name, register);
|
|
1767
|
+
return typeof dispose === 'function' ? dispose : () => {};
|
|
1768
|
+
};
|
|
1769
|
+
|
|
1770
|
+
// 左栏图标 + 中栏整页:一对,id 必须一致,点图标才切得过去
|
|
1771
|
+
ctx.effect(() => wait('sidebar.panellist', () => slots.register({
|
|
1772
|
+
name: 'sidebar.panellist',
|
|
1773
|
+
id: TAB_ID,
|
|
1774
|
+
order: 42,
|
|
1775
|
+
label: () => '接口调试',
|
|
1776
|
+
}, PanelIcon)), 'dsh-api-runner: panellist');
|
|
1777
|
+
|
|
1778
|
+
ctx.effect(() => wait('main', () => slots.register({
|
|
1779
|
+
name: 'main',
|
|
1780
|
+
key: TAB_ID,
|
|
1781
|
+
}, GlobalPanel)), 'dsh-api-runner: main panel');
|
|
1782
|
+
|
|
1783
|
+
// 右侧栏页签:定义注册进 sidebarRightTabs,正文和标题按同一个 id 落到两个 keyed 席位
|
|
1784
|
+
ctx.effect(() => {
|
|
1785
|
+
const tabs = typeof ctx.get === 'function' ? ctx.get('sidebarRightTabs') : undefined;
|
|
1786
|
+
if (!tabs || typeof tabs.register !== 'function') return () => {};
|
|
1787
|
+
return tabs.register({
|
|
1788
|
+
id: TAB_ID,
|
|
1789
|
+
kind: TAB_ID,
|
|
1790
|
+
title: () => '接口调试',
|
|
1791
|
+
guide: [{
|
|
1792
|
+
id: TAB_ID,
|
|
1793
|
+
order: 42,
|
|
1794
|
+
title: () => '接口调试',
|
|
1795
|
+
description: () => '配置接口、登录保存 token、调用测试、查看本机 Java 服务',
|
|
1796
|
+
icon: PanelIcon,
|
|
1797
|
+
}],
|
|
1798
|
+
}) ?? (() => {});
|
|
1799
|
+
}, 'dsh-api-runner: right tab type');
|
|
1800
|
+
|
|
1801
|
+
ctx.effect(() => wait('sidebar.right.pane.tab', () => slots.register({
|
|
1802
|
+
name: 'sidebar.right.pane.tab',
|
|
1803
|
+
key: TAB_ID,
|
|
1804
|
+
}, RightTabPanel)), 'dsh-api-runner: right tab body');
|
|
1805
|
+
|
|
1806
|
+
ctx.effect(() => wait('sidebar.right.pane.tab.title', () => slots.register({
|
|
1807
|
+
name: 'sidebar.right.pane.tab.title',
|
|
1808
|
+
key: TAB_ID,
|
|
1809
|
+
}, () => h('span', { style: { fontSize: '12.5px' } }, '接口调试'))), 'dsh-api-runner: right tab title');
|
|
1810
|
+
|
|
1811
|
+
// 设置页里的插件主页:全局项(默认工作区、数据目录、Maven 主路径)
|
|
1812
|
+
ctx.effect(() => wait('settings.section', () => slots.register({
|
|
1813
|
+
name: 'settings.section',
|
|
1814
|
+
id: TAB_ID,
|
|
1815
|
+
order: 80,
|
|
1816
|
+
label: () => '接口调试',
|
|
1817
|
+
}, () => h(SettingsPage, {}))), 'dsh-api-runner: settings section');
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
exports.inject = inject;
|
|
1821
|
+
exports.apply = apply;
|
|
1822
|
+
return module.exports;
|
|
1823
|
+
},
|
|
1824
|
+
});
|