dsh-plugin-admin 0.4.1 → 0.4.3
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 +11 -11
- package/cordis.patch.yml +7 -7
- package/lib/client.js +2345 -2299
- package/lib/index.js +2157 -2157
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -1,2299 +1,2345 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({ id: 'dsh-plugin-admin', factory: (require) => {
|
|
2
|
-
var module = { exports: {} }; var exports = module.exports;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* dsh-plugin-admin browser half:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'@keyframes dsh-admin-
|
|
24
|
-
'
|
|
25
|
-
'[data-dsh-admin-section]
|
|
26
|
-
'[data-dsh-admin-section]
|
|
27
|
-
'[data-dsh-admin-section] .
|
|
28
|
-
'[data-dsh-admin-section] .
|
|
29
|
-
'[data-dsh-admin-section] .
|
|
30
|
-
'[data-dsh-admin-section] .
|
|
31
|
-
'[data-dsh-admin-section] .
|
|
32
|
-
'[data-dsh-admin-section] .
|
|
33
|
-
'[data-dsh-admin-section] .
|
|
34
|
-
'[data-dsh-admin-section] .
|
|
35
|
-
'[data-dsh-admin-section] .search-
|
|
36
|
-
'[data-dsh-admin-section] .
|
|
37
|
-
'[data-dsh-admin-section] .
|
|
38
|
-
'[data-dsh-admin-section] .
|
|
39
|
-
'[data-dsh-admin-section] .
|
|
40
|
-
'[data-dsh-admin-section] .
|
|
41
|
-
'[data-dsh-admin-section] .
|
|
42
|
-
'[data-dsh-admin-section] .
|
|
43
|
-
'[data-dsh-admin-section] .
|
|
44
|
-
'[data-dsh-admin-section] .
|
|
45
|
-
'[data-dsh-admin-section] .
|
|
46
|
-
'[data-dsh-admin-section] .
|
|
47
|
-
'[data-dsh-admin-section] .
|
|
48
|
-
'[data-dsh-admin-section] .btn
|
|
49
|
-
'[data-dsh-admin-section] .btn:
|
|
50
|
-
'[data-dsh-admin-section] .
|
|
51
|
-
'[data-dsh-admin-section] .
|
|
52
|
-
'[data-dsh-admin-section] .btn:active:not(:disabled) {
|
|
53
|
-
'[data-dsh-admin-section] .btn
|
|
54
|
-
'[data-dsh-admin-section] .btn:disabled {
|
|
55
|
-
'[data-dsh-admin-section] .btn.
|
|
56
|
-
'[data-dsh-admin-section] .btn.
|
|
57
|
-
'[data-dsh-admin-section] .btn.
|
|
58
|
-
'[data-dsh-admin-section] .btn.
|
|
59
|
-
'[data-dsh-admin-section] .
|
|
60
|
-
'[data-dsh-admin-section] .
|
|
61
|
-
'[data-dsh-admin-section] .
|
|
62
|
-
'[data-dsh-admin-section] .
|
|
63
|
-
'[data-dsh-admin-section] .
|
|
64
|
-
'[data-dsh-admin-section] .
|
|
65
|
-
'[data-dsh-admin-section] .list {
|
|
66
|
-
'[data-dsh-admin-section] .list::-webkit-scrollbar {
|
|
67
|
-
'[data-dsh-admin-section] .
|
|
68
|
-
'[data-dsh-admin-section] .
|
|
69
|
-
'[data-dsh-admin-section] .group-header
|
|
70
|
-
'[data-dsh-admin-section] .group-
|
|
71
|
-
'[data-dsh-admin-section] .group-
|
|
72
|
-
'[data-dsh-admin-section] .group-
|
|
73
|
-
'[data-dsh-admin-section] .group-header .btn.sm { margin-left:
|
|
74
|
-
'[data-dsh-admin-section] .group-
|
|
75
|
-
'[data-dsh-admin-section] .
|
|
76
|
-
'[data-dsh-admin-section] .card {
|
|
77
|
-
'[data-dsh-admin-section] .card
|
|
78
|
-
'[data-dsh-admin-section] .card-
|
|
79
|
-
'[data-dsh-admin-section] .card-title {
|
|
80
|
-
'[data-dsh-admin-section] .card-
|
|
81
|
-
'[data-dsh-admin-section] .
|
|
82
|
-
'[data-dsh-admin-section] .summary-
|
|
83
|
-
'[data-dsh-admin-section] .
|
|
84
|
-
'[data-dsh-admin-section] .card-sub {
|
|
85
|
-
'[data-dsh-admin-section] .card-
|
|
86
|
-
'[data-dsh-admin-section] .
|
|
87
|
-
'[data-dsh-admin-section] .tag {
|
|
88
|
-
'[data-dsh-admin-section] .tag.
|
|
89
|
-
'[data-dsh-admin-section] .tag.
|
|
90
|
-
'[data-dsh-admin-section] .tag.update { background: rgba(
|
|
91
|
-
'[data-dsh-admin-section] .
|
|
92
|
-
'[data-dsh-admin-section] .
|
|
93
|
-
'[data-dsh-admin-section] .tag.
|
|
94
|
-
'[data-dsh-admin-section] .tag.
|
|
95
|
-
'[data-dsh-admin-section] .tag.
|
|
96
|
-
'[data-dsh-admin-section] .
|
|
97
|
-
'[data-dsh-admin-section] .dot {
|
|
98
|
-
'[data-dsh-admin-section] .dot.
|
|
99
|
-
'[data-dsh-admin-section] .
|
|
100
|
-
'[data-dsh-admin-section] .confirm-
|
|
101
|
-
'[data-dsh-admin-section] .confirm-
|
|
102
|
-
'[data-dsh-admin-section] .
|
|
103
|
-
'[data-dsh-admin-section] .
|
|
104
|
-
'[data-dsh-admin-section] .update-strip {
|
|
105
|
-
'[data-dsh-admin-section] .update-strip
|
|
106
|
-
'[data-dsh-admin-section] .update-strip.
|
|
107
|
-
'[data-dsh-admin-section] .update-strip.
|
|
108
|
-
'[data-dsh-admin-section] .update-strip.has-
|
|
109
|
-
'[data-dsh-admin-section] .
|
|
110
|
-
'[data-dsh-admin-section] .
|
|
111
|
-
'[data-dsh-admin-section] .
|
|
112
|
-
'[data-dsh-admin-section] .footer {
|
|
113
|
-
'[data-dsh-admin-section] .footer .
|
|
114
|
-
'[data-dsh-admin-section] .
|
|
115
|
-
'[data-dsh-admin-section] .
|
|
116
|
-
'[data-dsh-admin-section] .mcp-test
|
|
117
|
-
'[data-dsh-admin-section] .mcp-test { display:
|
|
118
|
-
'[data-dsh-admin-section] .mcp-test
|
|
119
|
-
'[data-dsh-admin-section] .mcp-test-
|
|
120
|
-
'[data-dsh-admin-section] .mcp-test-
|
|
121
|
-
'[data-dsh-admin-section] .mcp-test-
|
|
122
|
-
'[data-dsh-admin-section] .mcp-test-
|
|
123
|
-
'[data-dsh-admin-section] .
|
|
124
|
-
'@
|
|
125
|
-
'@keyframes dsh-toast-
|
|
126
|
-
'
|
|
127
|
-
'.dsh-admin-toast {
|
|
128
|
-
'.dsh-admin-toast.
|
|
129
|
-
'.dsh-admin-toast.
|
|
130
|
-
'.dsh-admin-toast.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
tag.dataset.
|
|
139
|
-
tag.
|
|
140
|
-
tag
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
var
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
function
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
var
|
|
311
|
-
var
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
var nt = norm(title)
|
|
362
|
-
var
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
})
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
//
|
|
449
|
-
var
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
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
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
var
|
|
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
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
|
|
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
|
-
if (!
|
|
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
|
-
})
|
|
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
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
function
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
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
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
function
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
function
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
/**
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
for (var
|
|
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
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
var
|
|
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
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
function
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
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
|
-
|
|
1351
|
-
|
|
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
|
-
|
|
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
|
-
var
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
createElement('
|
|
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
|
-
createElement('span', {
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
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
|
-
createElement('div', {
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
onClick: function (id) { return function () {
|
|
1611
|
-
}, '
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
},
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
}
|
|
1736
|
-
),
|
|
1737
|
-
createElement('
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
function
|
|
1803
|
-
var
|
|
1804
|
-
for (var
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
}
|
|
1828
|
-
var
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
actionChildren
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
*
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
return
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
'
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
createElement('span', { className: '
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
var
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
1
|
+
window.__ModuleLoader__.load({ id: 'dsh-plugin-admin', factory: (require) => {
|
|
2
|
+
var module = { exports: {} }; var exports = module.exports;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* dsh-plugin-admin browser half: administration surfaces parked where the
|
|
6
|
+
* settings shell already renders their domain.
|
|
7
|
+
*
|
|
8
|
+
* Three slot contributions (all assembled with the platform-shared React,
|
|
9
|
+
* module-table seed word, same instance the shell renders with):
|
|
10
|
+
* - 扩展插件: a tab inside the shell-owned 插件 section (`settings.plugins.tab`),
|
|
11
|
+
* after 插件配置 and 插件列表;
|
|
12
|
+
* - MCP服务器 / 历史会话: standalone `settings.section` pages in the settings nav.
|
|
13
|
+
* Panels talk to the host over the /api RPC gateway.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
var React = require('react')
|
|
17
|
+
var createElement = React.createElement
|
|
18
|
+
var useState = React.useState
|
|
19
|
+
var useRef = React.useRef
|
|
20
|
+
var useEffect = React.useEffect
|
|
21
|
+
|
|
22
|
+
var CSS_TEXT = [
|
|
23
|
+
'@keyframes dsh-admin-spin { to { transform: rotate(360deg); } }',
|
|
24
|
+
'@keyframes dsh-admin-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.85); } }',
|
|
25
|
+
'[data-dsh-admin-section] { display: flex; flex-direction: column; width: 100%; gap: 14px; padding: 2px; font-size: 13px; line-height: 1.5; color: var(--dsw-alias-label-primary, #222); max-height: calc(100vh - 140px); overflow: hidden; }',
|
|
26
|
+
'[data-dsh-admin-section] * { box-sizing: border-box; }',
|
|
27
|
+
'[data-dsh-admin-section] .toolbar { display: flex; gap: 8px; align-items: center; padding: 10px; border: 1px solid var(--dsw-alias-border-subtle, rgba(200,200,210,0.4)); border-radius: 12px; background: var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-base, transparent)); box-shadow: 0 1px 2px rgba(0,0,0,0.02); }',
|
|
28
|
+
'[data-dsh-admin-section] .toolbar .input { height: 32px; padding: 0 12px; border-radius: 8px; border-color: var(--dsw-alias-border-subtle, rgba(200,200,210,0.5)); }',
|
|
29
|
+
'[data-dsh-admin-section] .search-wrap { flex: 1.6; min-width: 0; position: relative; display: flex; align-items: center; height: 32px; }',
|
|
30
|
+
'[data-dsh-admin-section] .search-wrap .input { flex: 1; min-width: 0; padding-left: 30px; font-size: 13px; }',
|
|
31
|
+
'[data-dsh-admin-section] .session-search { flex: 1; height: 32px; }',
|
|
32
|
+
'[data-dsh-admin-section] .session-search .input { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; border-color: var(--dsw-alias-border-subtle, rgba(200,200,210,0.5)); }',
|
|
33
|
+
'[data-dsh-admin-section] .install-wrap { flex: 1; min-width: 0; display: flex; align-items: center; height: 32px; }',
|
|
34
|
+
'[data-dsh-admin-section] .install-wrap .input { flex: 1; min-width: 0; font-size: 13px; border-radius: 8px; border-color: var(--dsw-alias-border-subtle, rgba(200,200,210,0.5)); }',
|
|
35
|
+
'[data-dsh-admin-section] .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: 0.7; pointer-events: none; z-index: 1; }',
|
|
36
|
+
'[data-dsh-admin-section] .input { width: 100%; padding: 7px 12px; border-radius: 9px; border: 1px solid var(--dsw-alias-border-subtle, rgba(200,200,210,0.5)); background: var(--dsw-alias-bg-base, transparent); color: inherit; font: inherit; outline: none; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s; }',
|
|
37
|
+
'[data-dsh-admin-section] .input:hover { border-color: var(--dsw-alias-label-tertiary, rgba(180,180,195,0.6)); }',
|
|
38
|
+
'[data-dsh-admin-section] .input:focus { border-color: var(--dsw-static-blue-500, #3b82f6); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16); }',
|
|
39
|
+
'[data-dsh-admin-section] .filter-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }',
|
|
40
|
+
'[data-dsh-admin-section] .pill { font-size: 11px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--dsw-alias-border-subtle, rgba(200,200,210,0.45)); background: transparent; cursor: pointer; color: var(--dsw-alias-label-secondary, #555); transition: all 0.12s; font-family: inherit; }',
|
|
41
|
+
'[data-dsh-admin-section] .pill:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(200,200,210,0.3)); }',
|
|
42
|
+
'[data-dsh-admin-section] .pill.active { background: var(--dsw-alias-interactive-bg-hover, rgba(200,200,210,0.4)); color: var(--dsw-static-blue-500, #3b82f6); font-weight: 600; border-color: currentColor; }',
|
|
43
|
+
'[data-dsh-admin-section] .btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 32px; padding: 0 14px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit; transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease; border: 1px solid var(--dsw-alias-border-subtle, rgba(200,200,210,0.5)); background: var(--dsw-alias-interactive-bg-hover, rgba(240,240,245,0.6)); color: var(--dsw-alias-label-secondary, #555); white-space: nowrap; flex: none; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }',
|
|
44
|
+
'[data-dsh-admin-section] .btn:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(220,220,230,0.7)); border-color: var(--dsw-alias-label-tertiary, rgba(180,180,195,0.65)); color: var(--dsw-alias-label-primary, #222); box-shadow: 0 2px 4px rgba(0,0,0,0.06); }',
|
|
45
|
+
'[data-dsh-admin-section] .search-wrap .btn.sm { background: transparent; border: none; box-shadow: none; padding: 2px 6px; color: var(--dsw-alias-label-tertiary, #888); }',
|
|
46
|
+
'[data-dsh-admin-section] .search-wrap .btn.sm:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, rgba(200,200,210,0.4)); color: var(--dsw-alias-label-primary, #222); }',
|
|
47
|
+
'[data-dsh-admin-section] .btn:active:not(:disabled) { transform: translateY(1px); }',
|
|
48
|
+
'[data-dsh-admin-section] .btn:focus-visible, [data-dsh-admin-section] .pill:focus-visible { outline: 2px solid var(--dsw-static-blue-500, #3b82f6); outline-offset: 2px; }',
|
|
49
|
+
'[data-dsh-admin-section] .btn:disabled { opacity: 0.45; cursor: not-allowed; }',
|
|
50
|
+
'[data-dsh-admin-section] .btn.primary { background: var(--dsw-static-blue-500, #3b82f6); color: #fff; border-color: transparent; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }',
|
|
51
|
+
'[data-dsh-admin-section] .btn.primary:hover:not(:disabled) { background: var(--dsw-static-blue-400, #60a5fa); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.14); }',
|
|
52
|
+
'[data-dsh-admin-section] .btn.primary:active:not(:disabled) { background: var(--dsw-static-blue-600, #2563eb); color: #fff; }',
|
|
53
|
+
'[data-dsh-admin-section] .btn.danger { color: var(--dsw-alias-state-error-primary, #dc2626); border-color: var(--dsw-alias-border-subtle, rgba(200,200,210,0.4)); }',
|
|
54
|
+
'[data-dsh-admin-section] .btn.danger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover-danger, rgba(239,68,68,0.1)); border-color: rgba(220,38,38,0.35); color: #b91c1c; }',
|
|
55
|
+
'[data-dsh-admin-section] .btn.danger-solid { background: var(--dsw-alias-state-error-primary, #dc2626); color: #fff; border-color: transparent; }',
|
|
56
|
+
'[data-dsh-admin-section] .btn.danger-solid:hover:not(:disabled) { background: #b91c1c; color: #fff; }',
|
|
57
|
+
'[data-dsh-admin-section] .btn.danger-solid:active:not(:disabled) { background: #991b1b; color: #fff; }',
|
|
58
|
+
'[data-dsh-admin-section] .btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }',
|
|
59
|
+
'[data-dsh-admin-section] .spinner { width: 12px; height: 12px; border: 2px solid transparent; border-top-color: currentColor; border-radius: 50%; animation: dsh-admin-spin 0.7s linear infinite; display: inline-block; flex: none; }',
|
|
60
|
+
'[data-dsh-admin-section] .list { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; min-height: 0; max-height: 560px; overflow-y: auto; padding: 2px 4px 2px 2px; scrollbar-width: thin; scrollbar-color: var(--dsw-alias-border-subtle, rgba(200,200,210,0.4)) transparent; }',
|
|
61
|
+
'[data-dsh-admin-section] .list.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-content: start; }',
|
|
62
|
+
'[data-dsh-admin-section] .list.grid2 .empty { grid-column: 1 / -1; }',
|
|
63
|
+
'[data-dsh-admin-section] .list.grid2 .card { cursor: pointer; }',
|
|
64
|
+
'[data-dsh-admin-section] .list.grid2 .card:hover { transform: none; border-color: var(--dsw-alias-border-subtle, rgba(200,200,210,0.4)); background: var(--dsw-alias-interactive-bg-hover, rgba(200,200,210,0.25)); box-shadow: none; }',
|
|
65
|
+
'[data-dsh-admin-section] .list::-webkit-scrollbar { width: 6px; }',
|
|
66
|
+
'[data-dsh-admin-section] .list::-webkit-scrollbar-thumb { border-radius: 99px; background: var(--dsw-alias-border-subtle, rgba(200,200,210,0.4)); }',
|
|
67
|
+
'[data-dsh-admin-section] .session-group { display: flex; flex-direction: column; gap: 6px; }',
|
|
68
|
+
'[data-dsh-admin-section] .group-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px 8px 12px; font-size: 13px; font-weight: 600; color: var(--dsw-alias-label-primary); border: 1px solid var(--dsw-alias-border-subtle, rgba(200,200,210,0.4)); border-radius: 10px; background: var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-base, transparent)); box-shadow: 0 1px 2px rgba(0,0,0,0.02); margin-bottom: 4px; }',
|
|
69
|
+
'[data-dsh-admin-section] .group-header:first-child { margin-top: 2px; }',
|
|
70
|
+
'[data-dsh-admin-section] .group-title { display: inline-flex; align-items: center; gap: 6px; }',
|
|
71
|
+
'[data-dsh-admin-section] .group-count { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--dsw-alias-interactive-bg-hover, rgba(200,200,210,0.3)); color: var(--dsw-alias-label-secondary, #555); font-weight: 500; }',
|
|
72
|
+
'[data-dsh-admin-section] .group-header .btn.sm { margin-left: auto; }',
|
|
73
|
+
'[data-dsh-admin-section] .group-header .btn.sm + .btn.sm { margin-left: 0; }',
|
|
74
|
+
'[data-dsh-admin-section] .group-path { font-family: monospace; font-size: 10px; color: var(--dsw-alias-label-tertiary, #888); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; text-align: right; }',
|
|
75
|
+
'[data-dsh-admin-section] .card { display: flex; flex-direction: column; gap: 7px; padding: 12px; border-radius: 12px; border: 1px solid var(--dsw-alias-border-subtle, rgba(200,200,210,0.4)); background: var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-base, transparent)); box-shadow: 0 1px 2px rgba(0,0,0,0.02); transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease; }',
|
|
76
|
+
'[data-dsh-admin-section] .card:hover { transform: translateY(-1px); border-color: var(--dsw-alias-label-tertiary, rgba(180,180,195,0.6)); box-shadow: 0 8px 20px rgba(0,0,0,0.06); }',
|
|
77
|
+
'[data-dsh-admin-section] .card-header { display: flex; align-items: center; gap: 8px; min-width: 0; }',
|
|
78
|
+
'[data-dsh-admin-section] .card-title { font-size: 13px; font-weight: 600; color: var(--dsw-alias-label-primary); display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; }',
|
|
79
|
+
'[data-dsh-admin-section] .card-title-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }',
|
|
80
|
+
'[data-dsh-admin-section] .card-summary { display: flex; align-items: flex-start; gap: 6px; padding: 6px 9px; border-radius: 6px; background: var(--dsw-alias-interactive-bg-hover, rgba(200,200,210,0.25)); border-left: 2px solid var(--dsw-static-blue-500, #3b82f6); font-size: 12px; line-height: 1.45; color: var(--dsw-alias-label-secondary, #555); margin-top: 1px; margin-bottom: 1px; }',
|
|
81
|
+
'[data-dsh-admin-section] .summary-icon { font-size: 11px; line-height: 1.45; flex: none; opacity: 0.85; }',
|
|
82
|
+
'[data-dsh-admin-section] .summary-text { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; word-break: break-word; }',
|
|
83
|
+
'[data-dsh-admin-section] .card-sub { font-size: 11px; color: var(--dsw-alias-label-secondary, #666); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }',
|
|
84
|
+
'[data-dsh-admin-section] .card-sub-item { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }',
|
|
85
|
+
'[data-dsh-admin-section] .card-actions { display: flex; gap: 5px; align-items: center; flex: none; }',
|
|
86
|
+
'[data-dsh-admin-section] .tag { font-size: 10px; font-weight: 500; padding: 1px 6px; border-radius: 4px; flex: none; display: inline-flex; align-items: center; gap: 4px; background: var(--dsw-alias-interactive-bg-hover, rgba(200,200,210,0.25)); color: var(--dsw-alias-label-secondary, #555); }',
|
|
87
|
+
'[data-dsh-admin-section] .tag.plugin { background: rgba(16, 185, 129, 0.12); color: var(--dsw-alias-state-success-primary, #10b981); }',
|
|
88
|
+
'[data-dsh-admin-section] .tag.local { background: rgba(59, 130, 246, 0.12); color: var(--dsw-static-blue-500, #3b82f6); }',
|
|
89
|
+
'[data-dsh-admin-section] .tag.update { background: rgba(245, 158, 11, 0.14); color: #d97706; font-weight: 600; border: 1px solid rgba(217, 119, 6, 0.25); }',
|
|
90
|
+
'[data-dsh-admin-section] .tag.update-error { background: rgba(239, 68, 68, 0.1); color: var(--dsw-alias-state-error-primary, #ef4444); }',
|
|
91
|
+
'[data-dsh-admin-section] .plugin-path { font-family: monospace; font-size: 11px; line-height: 1.4; color: var(--dsw-alias-label-secondary, #555); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 4px 9px; border-radius: 6px; background: var(--dsw-alias-interactive-bg-hover, rgba(200,200,210,0.25)); }',
|
|
92
|
+
'[data-dsh-admin-section] .tag.version { font-family: monospace; }',
|
|
93
|
+
'[data-dsh-admin-section] .tag.live { background: rgba(16, 185, 129, 0.12); color: var(--dsw-alias-state-success-primary, #10b981); font-weight: 600; }',
|
|
94
|
+
'[data-dsh-admin-section] .tag.archived { background: rgba(245, 158, 11, 0.12); color: var(--dsw-alias-state-warn-label, #f59e0b); }',
|
|
95
|
+
'[data-dsh-admin-section] .tag.turns { background: rgba(59, 130, 246, 0.12); color: var(--dsw-static-blue-500, #3b82f6); font-weight: 500; }',
|
|
96
|
+
'[data-dsh-admin-section] .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--dsw-alias-label-tertiary, #999); }',
|
|
97
|
+
'[data-dsh-admin-section] .dot.live { background: var(--dsw-alias-state-success-primary, #10b981); box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25); animation: dsh-admin-pulse 2s infinite ease-in-out; }',
|
|
98
|
+
'[data-dsh-admin-section] .dot.archived { background: var(--dsw-alias-state-warn-label, #f59e0b); }',
|
|
99
|
+
'[data-dsh-admin-section] .confirm-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: 6px; background: var(--dsw-alias-interactive-bg-hover-danger, rgba(239,68,68,0.08)); border: 1px solid rgba(239,68,68,0.2); }',
|
|
100
|
+
'[data-dsh-admin-section] .confirm-text { font-size: 11px; color: var(--dsw-alias-state-error-primary, #ef4444); font-weight: 500; }',
|
|
101
|
+
'[data-dsh-admin-section] .confirm-actions { display: flex; gap: 5px; flex: none; }',
|
|
102
|
+
'[data-dsh-admin-section] .busy-banner { display: flex; align-items: center; gap: 8px; padding: 7px 11px; border-radius: 7px; background: rgba(59, 130, 246, 0.08); color: var(--dsw-static-blue-500, #3b82f6); font-size: 11px; }',
|
|
103
|
+
'[data-dsh-admin-section] .update-strip { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 8px; font-size: 12px; font-weight: 500; line-height: 1.4; }',
|
|
104
|
+
'[data-dsh-admin-section] .update-strip .btn.sm { margin-left: auto; flex: none; }',
|
|
105
|
+
'[data-dsh-admin-section] .update-strip.checking { background: rgba(59, 130, 246, 0.08); color: var(--dsw-static-blue-500, #3b82f6); }',
|
|
106
|
+
'[data-dsh-admin-section] .update-strip.ok { background: rgba(16, 185, 129, 0.1); color: var(--dsw-alias-state-success-primary, #10b981); }',
|
|
107
|
+
'[data-dsh-admin-section] .update-strip.has-updates { background: rgba(245, 158, 11, 0.12); color: #d97706; border: 1px solid rgba(217, 119, 6, 0.25); }',
|
|
108
|
+
'[data-dsh-admin-section] .update-strip.has-errors { background: rgba(239, 68, 68, 0.08); color: var(--dsw-alias-state-error-primary, #ef4444); }',
|
|
109
|
+
'[data-dsh-admin-section] .empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px 12px; color: var(--dsw-alias-label-tertiary, #999); gap: 4px; font-size: 12px; text-align: center; }',
|
|
110
|
+
'[data-dsh-admin-section] .error { padding: 7px 11px; border-radius: 7px; color: var(--dsw-alias-state-error-primary, #ef4444); background: var(--dsw-alias-interactive-bg-hover-danger, rgba(239,68,68,0.08)); font-size: 12px; white-space: pre-wrap; max-height: 100px; overflow-y: auto; }',
|
|
111
|
+
'[data-dsh-admin-section] .footer { display: flex; justify-content: space-between; align-items: center; padding-top: 4px; font-size: 11px; color: var(--dsw-alias-label-tertiary, #888); border-top: 1px solid var(--dsw-alias-border-subtle, rgba(200,200,210,0.3)); flex: none; }',
|
|
112
|
+
'[data-dsh-admin-section] .footer .path { max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }',
|
|
113
|
+
'[data-dsh-admin-section] .footer .hint { font-style: normal; }',
|
|
114
|
+
'[data-dsh-admin-section] .session-id-badge { font-family: monospace; font-size: 10px; opacity: 0.75; }',
|
|
115
|
+
'[data-dsh-admin-section] .mcp-test-row { padding: 6px 9px; border-radius: 6px; background: var(--dsw-alias-interactive-bg-hover, rgba(200,200,210,0.25)); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }',
|
|
116
|
+
'[data-dsh-admin-section] .mcp-test { display: inline-flex; align-items: center; gap: 5px; }',
|
|
117
|
+
'[data-dsh-admin-section] .mcp-test.mcp-test-list { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }',
|
|
118
|
+
'[data-dsh-admin-section] .mcp-test-busy { color: var(--dsw-alias-label-secondary, #666); }',
|
|
119
|
+
'[data-dsh-admin-section] .mcp-test-ok { color: #16a34a; }',
|
|
120
|
+
'[data-dsh-admin-section] .mcp-test-fail { color: var(--dsw-alias-state-error-primary, #ef4444); }',
|
|
121
|
+
'[data-dsh-admin-section] .mcp-test-warn { color: #d97706; opacity: 0.95; }',
|
|
122
|
+
'[data-dsh-admin-section] .mcp-test-cached { font-size: 10px; color: var(--dsw-alias-label-tertiary, #999); }',
|
|
123
|
+
'@media (max-width: 520px) { [data-dsh-admin-section] { gap: 10px; } [data-dsh-admin-section] .list.grid2 { grid-template-columns: 1fr; } [data-dsh-admin-section] .toolbar { align-items: stretch; flex-wrap: wrap; padding: 8px; } [data-dsh-admin-section] .toolbar .input-wrap { flex-basis: 100%; } [data-dsh-admin-section] .card-header { align-items: flex-start; } [data-dsh-admin-section] .card-actions { flex-wrap: wrap; justify-content: flex-end; } [data-dsh-admin-section] .footer { gap: 6px; align-items: flex-start; flex-direction: column; } [data-dsh-admin-section] .footer .path { max-width: 100%; } }',
|
|
124
|
+
'@keyframes dsh-toast-in { 0% { opacity: 0; transform: translateY(-12px) scale(0.96); } 100% { opacity: 1; transform: translateY(0) scale(1); } }',
|
|
125
|
+
'@keyframes dsh-toast-out { 0% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-8px) scale(0.96); } }',
|
|
126
|
+
'.dsh-admin-toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 99999; padding: 10px 20px; border-radius: 10px; font-size: 13px; font-weight: 500; line-height: 1.4; box-shadow: 0 8px 30px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08); display: flex; align-items: center; gap: 8px; pointer-events: none; animation: dsh-toast-in 0.25s ease-out forwards; max-width: 90vw; word-break: break-word; }',
|
|
127
|
+
'.dsh-admin-toast.success { background: rgba(16, 185, 129, 0.95); color: #fff; }',
|
|
128
|
+
'.dsh-admin-toast.error { background: rgba(239, 68, 68, 0.95); color: #fff; }',
|
|
129
|
+
'.dsh-admin-toast.info { background: rgba(22, 119, 255, 0.95); color: #fff; }',
|
|
130
|
+
'.dsh-admin-toast.leaving { animation: dsh-toast-out 0.2s ease-in forwards; }',
|
|
131
|
+
].join('\n')
|
|
132
|
+
|
|
133
|
+
function injectStyles() {
|
|
134
|
+
var tagId = 'dsh-plugin-admin/unified-section.css'
|
|
135
|
+
if (document.querySelector('style[data-plugin-css="' + tagId + '"]') === null) {
|
|
136
|
+
var tag = document.createElement('style')
|
|
137
|
+
tag.dataset.plugin = 'dsh-plugin-admin'
|
|
138
|
+
tag.dataset.pluginCss = tagId
|
|
139
|
+
tag.textContent = CSS_TEXT
|
|
140
|
+
document.head.appendChild(tag)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function baseName(path) {
|
|
145
|
+
if (path === null || path === '') return '(无工作目录)'
|
|
146
|
+
var parts = path.replace(/\\/g, '/').split('/')
|
|
147
|
+
var last = parts[parts.length - 1]
|
|
148
|
+
return last === '' ? parts[parts.length - 2] || path : last
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function formatDate(ms) {
|
|
152
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms)) return ''
|
|
153
|
+
var d = new Date(ms)
|
|
154
|
+
var pad = function (n) { return (n < 10 ? '0' : '') + String(n) }
|
|
155
|
+
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate())
|
|
156
|
+
+ ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes())
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function messageOf(error) {
|
|
160
|
+
if (error !== null && typeof error === 'object' && typeof error.message === 'string') return error.message
|
|
161
|
+
if (typeof error === 'string') return error
|
|
162
|
+
return JSON.stringify(error)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Single-toast singleton: at most ONE floating toast exists at any time. A
|
|
166
|
+
// new showToast REPLACES the in-flight toast in place (same node, refreshed
|
|
167
|
+
// type/text, restarted countdown) instead of stacking another fixed-position
|
|
168
|
+
// node on top — rapid consecutive failures would otherwise overlap and hide
|
|
169
|
+
// the earlier message behind the latest. A toast mid-fade (leaving) is
|
|
170
|
+
// revived by a replacement rather than left to vanish.
|
|
171
|
+
var activeToast = null
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Show a floating toast notification at the top of the viewport.
|
|
175
|
+
* Auto-dismisses after `duration` ms. Supports 'success', 'error', 'info'.
|
|
176
|
+
* Single-slot: a new toast replaces the current one (if any).
|
|
177
|
+
*/
|
|
178
|
+
function showToast(type, text, duration) {
|
|
179
|
+
if (typeof document === 'undefined') return
|
|
180
|
+
duration = duration || 3000
|
|
181
|
+
|
|
182
|
+
function quit(state) {
|
|
183
|
+
if (state.leaving) return
|
|
184
|
+
state.leaving = true
|
|
185
|
+
clearTimeout(state.timer)
|
|
186
|
+
state.el.classList.add('leaving')
|
|
187
|
+
state.removalTimer = setTimeout(function () {
|
|
188
|
+
if (state.el.parentNode) state.el.parentNode.removeChild(state.el)
|
|
189
|
+
if (activeToast === state) activeToast = null
|
|
190
|
+
}, 200)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
var current = activeToast
|
|
194
|
+
if (current !== null && current.el.parentNode !== null) {
|
|
195
|
+
// Replace: revive a mid-fade toast, swap class/text, restart the countdown.
|
|
196
|
+
clearTimeout(current.timer)
|
|
197
|
+
clearTimeout(current.removalTimer)
|
|
198
|
+
current.leaving = false
|
|
199
|
+
current.el.className = 'dsh-admin-toast ' + type
|
|
200
|
+
current.el.textContent = text
|
|
201
|
+
current.timer = setTimeout(function () { quit(current) }, duration)
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
var toast = document.createElement('div')
|
|
206
|
+
toast.className = 'dsh-admin-toast ' + type
|
|
207
|
+
toast.textContent = text
|
|
208
|
+
document.body.appendChild(toast)
|
|
209
|
+
var state = { el: toast, timer: null, removalTimer: null, leaving: false }
|
|
210
|
+
activeToast = state
|
|
211
|
+
toast.addEventListener('click', function () { quit(state) })
|
|
212
|
+
state.timer = setTimeout(function () { quit(state) }, duration)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Copy text to the clipboard. Uses the async Clipboard API when available;
|
|
217
|
+
* falls back to a hidden textarea + execCommand for older browsers or
|
|
218
|
+
* non-secure contexts.
|
|
219
|
+
*/
|
|
220
|
+
function copyTextToClipboard(text) {
|
|
221
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
222
|
+
navigator.clipboard.writeText(text).then(function () {
|
|
223
|
+
showToast('success', '📋 会话 ID 已复制')
|
|
224
|
+
}, function () {
|
|
225
|
+
fallbackCopy(text)
|
|
226
|
+
})
|
|
227
|
+
return
|
|
228
|
+
}
|
|
229
|
+
fallbackCopy(text)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function fallbackCopy(text) {
|
|
233
|
+
try {
|
|
234
|
+
var ta = document.createElement('textarea')
|
|
235
|
+
ta.value = text
|
|
236
|
+
ta.style.cssText = 'position:fixed;top:-9999px;left:-9999px;opacity:0'
|
|
237
|
+
document.body.appendChild(ta)
|
|
238
|
+
ta.select()
|
|
239
|
+
ta.setSelectionRange(0, text.length)
|
|
240
|
+
document.execCommand('copy')
|
|
241
|
+
document.body.removeChild(ta)
|
|
242
|
+
} catch (e) {
|
|
243
|
+
showToast('error', '❌ 复制失败:' + messageOf(e))
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/* ========================================================================== */
|
|
248
|
+
/* Menu Popup Injection (Sessions & Workspaces) */
|
|
249
|
+
/* ========================================================================== */
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Inject plugin items into the existing three-dot menu popup. The workspace
|
|
253
|
+
* bundle renders a Menu component (@deepseek-ai/dsh-client-ui-primitives)
|
|
254
|
+
* with portal:true, so the popup lives as a div[role="menu"] inside
|
|
255
|
+
* document.body with position:fixed. A MutationObserver detects when this
|
|
256
|
+
* popup appears, identifies it as a session or workspace menu by checking
|
|
257
|
+
* the existing button labels, and injects additional items.
|
|
258
|
+
*/
|
|
259
|
+
function setupMenuInjection(call, refreshSessions) {
|
|
260
|
+
if (typeof document === 'undefined') return function () {}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Extract the session title from the row's aria-label. The anchor button
|
|
264
|
+
* aria-label is: 会话"<title>"的操作 (zh) / Session "<title>" actions (en).
|
|
265
|
+
* Extracting from the DOM keeps the injection synchronous — no RPC needed
|
|
266
|
+
* just to show the button, so the menu can't close before it appears.
|
|
267
|
+
*/
|
|
268
|
+
function sessionTitleFromRow(row) {
|
|
269
|
+
var btn = row.querySelector('button[aria-label*="会话" i][aria-label*="操作" i], button[aria-label*="session" i][aria-label*="actions" i]')
|
|
270
|
+
if (btn === null) return null
|
|
271
|
+
var label = btn.getAttribute('aria-label') || ''
|
|
272
|
+
// zh: 会话"xxx"的操作 → strip 会话"/"的操作
|
|
273
|
+
var zh = /会话["“]([^"”]+)["”]/.exec(label)
|
|
274
|
+
if (zh) return zh[1].trim()
|
|
275
|
+
// en: Session "xxx" actions
|
|
276
|
+
var en = /session\s*["“]([^"”]+)["”]/i.exec(label)
|
|
277
|
+
if (en) return en[1].trim()
|
|
278
|
+
// fallback: whole label minus known prefixes/suffixes
|
|
279
|
+
return label.replace(/^会话/, '').replace(/^session/i, '').replace(/["“”]|的操作|actions$/gi, '').trim() || null
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** Find the treeitem row for the anchor button nearest the menu. */
|
|
283
|
+
function rowForMenu(menuEl) {
|
|
284
|
+
var menuRect = menuEl ? menuEl.getBoundingClientRect() : null
|
|
285
|
+
var allRows = document.querySelectorAll('[role="treeitem"]')
|
|
286
|
+
if (allRows.length === 0) return null
|
|
287
|
+
var rows = []
|
|
288
|
+
for (var i = 0; i < allRows.length; i++) {
|
|
289
|
+
var r = allRows[i]
|
|
290
|
+
// Only rows that contain a session/workspace action button
|
|
291
|
+
if (r.querySelector('button[aria-label*="会话" i][aria-label*="操作" i], button[aria-label*="工作区" i][aria-label*="操作" i], button[aria-label*="session" i][aria-label*="actions" i], button[aria-label*="workspace" i][aria-label*="actions" i]')) {
|
|
292
|
+
rows.push(r)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (rows.length === 0) return null
|
|
296
|
+
|
|
297
|
+
// The Menu component renders with side="bottom": menu top sits just
|
|
298
|
+
// below the anchor button (button.bottom + 4). Match the row whose
|
|
299
|
+
// center is closest to the MENU TOP, not the menu center — the menu
|
|
300
|
+
// can be tall (several items), so its center drifts far from the
|
|
301
|
+
// clicked row.
|
|
302
|
+
if (menuRect === null || menuRect.height === 0) {
|
|
303
|
+
// No reliable menu rect. With a single candidate row the choice is
|
|
304
|
+
// unambiguous, so return it (jsdom/test environments have zero rects);
|
|
305
|
+
// with several rows refuse to guess rather than act on the wrong
|
|
306
|
+
// session.
|
|
307
|
+
if (rows.length === 1) return rows[0]
|
|
308
|
+
return null
|
|
309
|
+
}
|
|
310
|
+
var closest = rows[0]
|
|
311
|
+
var closestDist = Infinity
|
|
312
|
+
for (var j = 0; j < rows.length; j++) {
|
|
313
|
+
var rect = rows[j].getBoundingClientRect()
|
|
314
|
+
if (rect.height === 0) continue
|
|
315
|
+
var rowCenter = rect.top + rect.height / 2
|
|
316
|
+
var dist = Math.abs(rowCenter - menuRect.top)
|
|
317
|
+
if (dist < closestDist) {
|
|
318
|
+
closestDist = dist
|
|
319
|
+
closest = rows[j]
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return closest
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
function injectItems(menuEl) {
|
|
326
|
+
if (menuEl.querySelector('[data-dsh-admin-injected]')) return
|
|
327
|
+
|
|
328
|
+
var text = menuEl.textContent || ''
|
|
329
|
+
var isSession = text.indexOf('归档会话') !== -1 || text.indexOf('Archive session') !== -1
|
|
330
|
+
var isWorkspace = !isSession && (text.indexOf('删除') !== -1 || text.indexOf('Delete workspace') !== -1)
|
|
331
|
+
if (!isSession && !isWorkspace) return
|
|
332
|
+
|
|
333
|
+
var viewport = menuEl.querySelector('[role="presentation"]')
|
|
334
|
+
if (viewport === null) return
|
|
335
|
+
|
|
336
|
+
var row = rowForMenu(menuEl)
|
|
337
|
+
if (row === null) return
|
|
338
|
+
|
|
339
|
+
if (isSession) {
|
|
340
|
+
var title = sessionTitleFromRow(row)
|
|
341
|
+
if (title === null) return
|
|
342
|
+
// Resolve sessions by title lazily at click time (fresh RPC) so the
|
|
343
|
+
// match is always current. Copy-id keeps the fuzzy matcher (a wrong
|
|
344
|
+
// match only mis-copies an id); delete must never guess, so it
|
|
345
|
+
// resolves by exact title only and refuses duplicate titles — the
|
|
346
|
+
// panel's rows act on ids and can disambiguate.
|
|
347
|
+
function fetchSessions(done) {
|
|
348
|
+
call('sessionAdmin/list', {}).then(function (listResult) {
|
|
349
|
+
done((listResult && listResult.ok && listResult.value && listResult.value.sessions) || [])
|
|
350
|
+
}, function () { showToast('error', '❌ 无法加载会话列表') })
|
|
351
|
+
}
|
|
352
|
+
// Normalize a title for comparison: trim, collapse spaces, drop
|
|
353
|
+
// trailing ellipsis and truncation artifacts.
|
|
354
|
+
function norm(v) {
|
|
355
|
+
return (v || '').replace(/\s+/g, ' ').replace(/\.{3,}\s*$/, '').trim().toLowerCase()
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function resolveSessionFuzzy(cb) {
|
|
359
|
+
fetchSessions(function (sessions) {
|
|
360
|
+
var match = null
|
|
361
|
+
var nt = norm(title)
|
|
362
|
+
for (var i = 0; i < sessions.length; i++) {
|
|
363
|
+
var s = sessions[i]
|
|
364
|
+
var st = norm(s.title)
|
|
365
|
+
if (st === nt) { match = s; break }
|
|
366
|
+
// substring both ways (skip too-short needles)
|
|
367
|
+
if (nt.length > 3 && st.indexOf(nt) !== -1) { match = s; break }
|
|
368
|
+
if (st.length > 3 && nt.indexOf(st) !== -1) { match = s; break }
|
|
369
|
+
// fall back to cwd basename match
|
|
370
|
+
var cwdBase = s.cwd ? s.cwd.replace(/\\/g, '/').split('/').pop() : ''
|
|
371
|
+
if (cwdBase && (cwdBase === nt || nt.indexOf(cwdBase) !== -1 || cwdBase.indexOf(nt) !== -1)) { match = s; break }
|
|
372
|
+
}
|
|
373
|
+
if (match === null) { showToast('error', '❌ 未找到匹配的会话'); return }
|
|
374
|
+
cb(match)
|
|
375
|
+
})
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function resolveSessionExact(cb) {
|
|
379
|
+
fetchSessions(function (sessions) {
|
|
380
|
+
var nt = norm(title)
|
|
381
|
+
var exact = []
|
|
382
|
+
for (var i = 0; i < sessions.length; i++) {
|
|
383
|
+
if (norm(sessions[i].title) === nt) exact.push(sessions[i])
|
|
384
|
+
}
|
|
385
|
+
if (exact.length === 0) { showToast('error', '❌ 未找到匹配的会话'); return }
|
|
386
|
+
if (exact.length > 1) {
|
|
387
|
+
showToast('error', '❌ 存在 ' + String(exact.length) + ' 个同名会话,无法确定要删除的目标;请在 设置 → 历史会话 中按会话 ID 删除')
|
|
388
|
+
return
|
|
389
|
+
}
|
|
390
|
+
cb(exact[0])
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Copy the session id to the clipboard.
|
|
395
|
+
appendMenuItem(viewport, '复制会话 ID', 'normal', function () {
|
|
396
|
+
resolveSessionFuzzy(function (session) {
|
|
397
|
+
copyTextToClipboard(session.id)
|
|
398
|
+
})
|
|
399
|
+
})
|
|
400
|
+
|
|
401
|
+
// Delete the session. Online sessions are now closable through the
|
|
402
|
+
// captured AgentHandle (closeSession disposes the live agent/session
|
|
403
|
+
// first, so removing the log cannot resurrect it) — this stops a
|
|
404
|
+
// running conversation in that session. The item arms on the first
|
|
405
|
+
// click and only fires on a second click within 4s (confirmText below)
|
|
406
|
+
// — deletion is physical, so one misclick must never be enough.
|
|
407
|
+
appendMenuItem(viewport, '删除会话', 'danger', function () {
|
|
408
|
+
resolveSessionExact(function (match) {
|
|
409
|
+
var method = match.live ? 'sessionAdmin/closeSession' : 'sessionAdmin/deleteSession'
|
|
410
|
+
call(method, { sessionId: match.id }).then(function (result) {
|
|
411
|
+
if (result && result.ok) {
|
|
412
|
+
showToast('success', '🗑️ 会话已删除')
|
|
413
|
+
// Nudge the sidebar so the removed session vanishes now
|
|
414
|
+
// instead of lingering in 未分组 until reload.
|
|
415
|
+
if (refreshSessions) refreshSessions()
|
|
416
|
+
} else {
|
|
417
|
+
showToast('error', '❌ 删除会话失败:' + messageOf(result && result.error))
|
|
418
|
+
}
|
|
419
|
+
}, function (err) { showToast('error', '❌ 删除会话失败:' + messageOf(err)) })
|
|
420
|
+
})
|
|
421
|
+
}, '⚠️ 再点一次确认删除(在线会话将先关停)')
|
|
422
|
+
} else {
|
|
423
|
+
// Workspace: reveal in file manager. Path is resolved lazily at click.
|
|
424
|
+
var wsTitle = (row.querySelector('[class*="_title"]') || {}).textContent || ''
|
|
425
|
+
wsTitle = wsTitle.trim()
|
|
426
|
+
if (wsTitle === '') return
|
|
427
|
+
appendMenuItem(viewport, '在资源管理器打开', 'normal', function () {
|
|
428
|
+
call('sessionAdmin/list', {}).then(function (listResult) {
|
|
429
|
+
var workspaces = (listResult && listResult.ok && listResult.value && listResult.value.workspaces) || []
|
|
430
|
+
var wsPath = null
|
|
431
|
+
for (var i = 0; i < workspaces.length; i++) {
|
|
432
|
+
var w = workspaces[i]
|
|
433
|
+
var wTitle = (w && w.title) || ''
|
|
434
|
+
if (wTitle === wsTitle || (wsTitle !== '' && wTitle !== '' && (wsTitle.indexOf(wTitle) !== -1 || wTitle.indexOf(wsTitle) !== -1))) { wsPath = w && w.path; break }
|
|
435
|
+
}
|
|
436
|
+
if (wsPath === null) { showToast('error', '❌ 打开失败:未找到工作区路径'); return }
|
|
437
|
+
call('fsAdmin/reveal', { path: wsPath }).then(function (result) {
|
|
438
|
+
// Success needs no toast — the Explorer window opening is the
|
|
439
|
+
// feedback itself. Only failures get a hint.
|
|
440
|
+
if (!(result && result.ok)) showToast('error', '❌ 打开失败:' + messageOf(result && result.error))
|
|
441
|
+
}, function (err) { showToast('error', '❌ 打开失败:' + messageOf(err)) })
|
|
442
|
+
}, function () { showToast('error', '❌ 打开失败:无法加载工作区列表') })
|
|
443
|
+
})
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function appendMenuItem(viewport, label, kind, onClick, confirmText) {
|
|
448
|
+
// Separator (only if there are already items — always, to visually group)
|
|
449
|
+
var sep = document.createElement('div')
|
|
450
|
+
sep.setAttribute('role', 'separator')
|
|
451
|
+
sep.setAttribute('data-dsh-admin-injected', '')
|
|
452
|
+
sep.style.cssText = 'margin:3px 0;border-top:1px solid var(--dsw-alias-border-subtle,rgba(200,200,210,0.3))'
|
|
453
|
+
viewport.appendChild(sep)
|
|
454
|
+
|
|
455
|
+
var btn = document.createElement('button')
|
|
456
|
+
btn.type = 'button'
|
|
457
|
+
btn.setAttribute('role', 'menuitem')
|
|
458
|
+
btn.setAttribute('data-dsh-admin-injected', '')
|
|
459
|
+
btn.textContent = label
|
|
460
|
+
var color = kind === 'danger' ? '#ef4444' : 'inherit'
|
|
461
|
+
var hoverBg = kind === 'danger' ? 'rgba(239,68,68,0.12)' : 'rgba(200,200,210,0.3)'
|
|
462
|
+
btn.style.cssText = 'display:flex;align-items:center;gap:8px;width:100%;padding:6px 10px;border:0;background:transparent;cursor:pointer;font:inherit;font-size:12px;color:' + color + ';border-radius:5px;text-align:left'
|
|
463
|
+
btn.addEventListener('mouseenter', function () { btn.style.background = hoverBg })
|
|
464
|
+
btn.addEventListener('mouseleave', function () { btn.style.background = 'transparent' })
|
|
465
|
+
// Optional two-step confirm (confirmText): the first click arms the
|
|
466
|
+
// item and relabels it; only a second click within 4s runs onClick —
|
|
467
|
+
// destructive items must never fire on a single misclick.
|
|
468
|
+
var armed = false
|
|
469
|
+
var disarmTimer = null
|
|
470
|
+
btn.addEventListener('click', function (e) {
|
|
471
|
+
e.stopPropagation()
|
|
472
|
+
if (confirmText === undefined) { onClick(); return }
|
|
473
|
+
if (!armed) {
|
|
474
|
+
armed = true
|
|
475
|
+
btn.textContent = confirmText
|
|
476
|
+
disarmTimer = setTimeout(function () {
|
|
477
|
+
armed = false
|
|
478
|
+
btn.textContent = label
|
|
479
|
+
}, 4000)
|
|
480
|
+
return
|
|
481
|
+
}
|
|
482
|
+
clearTimeout(disarmTimer)
|
|
483
|
+
armed = false
|
|
484
|
+
btn.textContent = label
|
|
485
|
+
onClick()
|
|
486
|
+
})
|
|
487
|
+
viewport.appendChild(btn)
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
var observer = new MutationObserver(function (mutations) {
|
|
491
|
+
for (var i = 0; i < mutations.length; i++) {
|
|
492
|
+
var added = mutations[i].addedNodes
|
|
493
|
+
if (!added || added.length === 0) continue
|
|
494
|
+
for (var j = 0; j < added.length; j++) {
|
|
495
|
+
var node = added[j]
|
|
496
|
+
if (node.nodeType !== 1) continue
|
|
497
|
+
var el = node
|
|
498
|
+
if (el.getAttribute && el.getAttribute('role') === 'menu') {
|
|
499
|
+
injectItems(el)
|
|
500
|
+
} else {
|
|
501
|
+
var menu = el.querySelector && el.querySelector('[role="menu"]')
|
|
502
|
+
if (menu) injectItems(menu)
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
observer.observe(document.body, { childList: true, subtree: true })
|
|
509
|
+
|
|
510
|
+
return function () {
|
|
511
|
+
observer.disconnect()
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* 扩展插件 tab contribution: plugin management rendered inside the shell-owned
|
|
517
|
+
* 插件 settings section (after 插件配置 and 插件列表).
|
|
518
|
+
*/
|
|
519
|
+
function PluginsSection(props) {
|
|
520
|
+
// Lazy initializer: the seed object (and its localStorage read) must be
|
|
521
|
+
// built once at mount, not re-parsed on every render.
|
|
522
|
+
var pairPlugins = useState(function () {
|
|
523
|
+
return {
|
|
524
|
+
profileDir: '',
|
|
525
|
+
plugins: [],
|
|
526
|
+
busy: false,
|
|
527
|
+
error: '',
|
|
528
|
+
spec: '',
|
|
529
|
+
confirming: null,
|
|
530
|
+
note: '',
|
|
531
|
+
output: '',
|
|
532
|
+
filter: 'all',
|
|
533
|
+
needle: '',
|
|
534
|
+
checkingUpdates: false,
|
|
535
|
+
updateChecked: false, // true once a check finished (even if no updates)
|
|
536
|
+
// Seed from persisted reminders so the ⬆ 有新版本 badge is visible the
|
|
537
|
+
// moment the panel mounts (before the fresh host check resolves) — the
|
|
538
|
+
// reminder is only dropped once a check confirms the upgrade completed.
|
|
539
|
+
updates: loadUpdateReminders(), // name -> { latest, updateAvailable, error?, at? }
|
|
540
|
+
}
|
|
541
|
+
})
|
|
542
|
+
var pView = pairPlugins[0]
|
|
543
|
+
var setPView = pairPlugins[1]
|
|
544
|
+
|
|
545
|
+
var alive = useRef(false)
|
|
546
|
+
// In-flight check guard as a ref, not state: the state field drives the
|
|
547
|
+
// disabled button visuals, but gating ASYNC handlers on it races — a stale
|
|
548
|
+
// closure reads TRUE after an earlier check already settled and silently
|
|
549
|
+
// skips a required follow-up (the post-upgrade refresh), or FALSE mid-flight
|
|
550
|
+
// and lets a second one through. Refs are immune to closure staleness.
|
|
551
|
+
var checkingRef = useRef(false)
|
|
552
|
+
|
|
553
|
+
function patchPlugin(partial) {
|
|
554
|
+
setPView(function (cur) {
|
|
555
|
+
var next = {}
|
|
556
|
+
for (var k in cur) next[k] = cur[k]
|
|
557
|
+
for (var pk in partial) next[pk] = partial[pk]
|
|
558
|
+
return next
|
|
559
|
+
})
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function callRemote(method, args) {
|
|
563
|
+
return props.call(method, args)
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Reload the plugin layer list from the host.
|
|
568
|
+
* @param keepFeedback - when true, refresh ONLY the rows: busy/error/note
|
|
569
|
+
* stay untouched. Failure branches use this after patching the error —
|
|
570
|
+
* patch + reload in the same microtask otherwise batch into one render
|
|
571
|
+
* (React 18) and the just-set error text never paints, so a failed
|
|
572
|
+
* 安装/更新/卸载 would look like "nothing happened".
|
|
573
|
+
*/
|
|
574
|
+
function reloadPlugins(keepFeedback) {
|
|
575
|
+
if (!keepFeedback) patchPlugin({ busy: true, error: '', note: '' })
|
|
576
|
+
callRemote('pluginAdmin/list', {}).then(function (result) {
|
|
577
|
+
if (!alive.current) return
|
|
578
|
+
if (result.ok) {
|
|
579
|
+
var next = {
|
|
580
|
+
profileDir: (result.value && result.value.profileDir) || '',
|
|
581
|
+
plugins: (result.value && result.value.plugins) || [],
|
|
582
|
+
}
|
|
583
|
+
if (!keepFeedback) next.busy = false
|
|
584
|
+
patchPlugin(next)
|
|
585
|
+
} else if (!keepFeedback) {
|
|
586
|
+
patchPlugin({ busy: false, error: '加载插件失败:' + messageOf(result.error) })
|
|
587
|
+
}
|
|
588
|
+
// keepFeedback: the visible error stays; a failed follow-up list just
|
|
589
|
+
// leaves the rows stale.
|
|
590
|
+
}, function (failure) {
|
|
591
|
+
if (!alive.current) return
|
|
592
|
+
if (!keepFeedback) patchPlugin({ busy: false, error: '调用失败:' + messageOf(failure) })
|
|
593
|
+
})
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Query the npm registry for newer versions of registry-installed bundles
|
|
598
|
+
* and stash per-plugin results. The resolution MERGES the fresh authoritative
|
|
599
|
+
* results onto the previously persisted reminders:
|
|
600
|
+
* - newer version confirmed -> (re)arm & persist the reminder
|
|
601
|
+
* - confirmed up to date -> drop the reminder (更新完删除提醒)
|
|
602
|
+
* - per-plugin check error -> keep the known reminder (a transient
|
|
603
|
+
* registry failure must not erase it);
|
|
604
|
+
* with no known reminder the failure
|
|
605
|
+
* itself is recorded so cards/strip/
|
|
606
|
+
* note can surface it
|
|
607
|
+
* - no longer a registry install -> drop stale reminders
|
|
608
|
+
* The AUTO check on panel open is cache-friendly; a manual check passes
|
|
609
|
+
* force=true so the host bypasses its 5-minute TTL, re-queries the registry
|
|
610
|
+
* and refreshes the cached content (检查更新 = 强制重新查,而不是回放缓存).
|
|
611
|
+
* Runs concurrently with the list so the panel stays responsive; failures
|
|
612
|
+
* are per-plugin, never fatal.
|
|
613
|
+
* @param force - true to force the host to bypass its update cache.
|
|
614
|
+
*/
|
|
615
|
+
function checkUpdates(force) {
|
|
616
|
+
if (checkingRef.current) return
|
|
617
|
+
checkingRef.current = true
|
|
618
|
+
patchPlugin({ checkingUpdates: true, note: '' })
|
|
619
|
+
callRemote('pluginAdmin/checkUpdates', { force: force === true }).then(function (result) {
|
|
620
|
+
checkingRef.current = false
|
|
621
|
+
if (!alive.current) return
|
|
622
|
+
if (!result.ok) {
|
|
623
|
+
patchPlugin({ checkingUpdates: false, error: '检查更新失败:' + messageOf(result.error) })
|
|
624
|
+
// A failed call must not wipe previously known reminders — they stay
|
|
625
|
+
// seeded from localStorage and keep rendering on the cards.
|
|
626
|
+
return
|
|
627
|
+
}
|
|
628
|
+
var list = (result.value && result.value.updates) || []
|
|
629
|
+
// Merge INSIDE the functional updater against the LATEST committed
|
|
630
|
+
// state, never the render closure's snapshot: a reminder armed by an
|
|
631
|
+
// in-flight check resolving alongside an upgrade commit must survive
|
|
632
|
+
// (a stale-snapshot full replace erased it). The updater stays pure —
|
|
633
|
+
// localStorage persistence is owned by the mirror effect below.
|
|
634
|
+
setPView(function (cur) {
|
|
635
|
+
var next = {}
|
|
636
|
+
for (var k in cur) next[k] = cur[k]
|
|
637
|
+
next.checkingUpdates = false
|
|
638
|
+
next.updates = mergeUpdateReminders(cur.updates || {}, list)
|
|
639
|
+
next.updateChecked = true
|
|
640
|
+
next.note = updateCheckNote(next.updates, list.length)
|
|
641
|
+
return next
|
|
642
|
+
})
|
|
643
|
+
}, function (failure) {
|
|
644
|
+
checkingRef.current = false
|
|
645
|
+
if (!alive.current) return
|
|
646
|
+
patchPlugin({ checkingUpdates: false, error: '检查更新调用失败:' + messageOf(failure) })
|
|
647
|
+
})
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/** Upgrade one plugin to its latest version (registry install by name). */
|
|
651
|
+
function upgradePlugin(name) {
|
|
652
|
+
if (pView.busy) return
|
|
653
|
+
var spec = name + '@latest'
|
|
654
|
+
patchPlugin({ busy: true, error: '', confirming: null, note: '' })
|
|
655
|
+
callRemote('pluginAdmin/install', { spec: spec }).then(function (result) {
|
|
656
|
+
if (!alive.current) return
|
|
657
|
+
if (result.ok) {
|
|
658
|
+
// The upgrade consumed this reminder: strip it from the CURRENT state
|
|
659
|
+
// inside the updater (更新完删除提醒) — never from the click-time
|
|
660
|
+
// closure snapshot, which may miss reminders an in-flight check armed
|
|
661
|
+
// meanwhile (erasing those was exactly scenario 7's stale-snapshot
|
|
662
|
+
// bug). localStorage follows via the shared mirror effect; the forced
|
|
663
|
+
// refresh below confirms the new version is current.
|
|
664
|
+
setPView(function (cur) {
|
|
665
|
+
var next = {}
|
|
666
|
+
for (var k in cur) next[k] = cur[k]
|
|
667
|
+
next.busy = false
|
|
668
|
+
next.note = '已更新 ' + name + '。更改在重启 dsh 后生效'
|
|
669
|
+
next.output = (result.value && result.value.output) || ''
|
|
670
|
+
next.profileDir = (result.value && result.value.profileDir) || ''
|
|
671
|
+
next.plugins = (result.value && result.value.plugins) || []
|
|
672
|
+
var remaining = {}
|
|
673
|
+
for (var rk in cur.updates) {
|
|
674
|
+
if (rk !== name) remaining[rk] = cur.updates[rk]
|
|
675
|
+
}
|
|
676
|
+
next.updates = remaining
|
|
677
|
+
return next
|
|
678
|
+
})
|
|
679
|
+
// Refresh the update map so the upgraded entry stops flagging.
|
|
680
|
+
// Force: the @latest spec installed the registry's CURRENT latest,
|
|
681
|
+
// but the host TTL cache may still hold an older latest published
|
|
682
|
+
// minutes ago — comparing against that would re-flag the freshly
|
|
683
|
+
// upgraded plugin. Bypass the cache and resync its content instead.
|
|
684
|
+
checkUpdates(true)
|
|
685
|
+
return
|
|
686
|
+
}
|
|
687
|
+
var failMessage = '更新失败:' + messageOf(result.error)
|
|
688
|
+
patchPlugin({ busy: false, error: failMessage })
|
|
689
|
+
// Floating toast for the failure in addition to the persistent panel
|
|
690
|
+
// error bar (the toast demands attention, the bar keeps the detail).
|
|
691
|
+
showToast('error', failMessage)
|
|
692
|
+
reloadPlugins(true)
|
|
693
|
+
}, function (failure) {
|
|
694
|
+
if (!alive.current) return
|
|
695
|
+
patchPlugin({ busy: false, error: '调用失败:' + messageOf(failure) })
|
|
696
|
+
})
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function installPlugin() {
|
|
700
|
+
if (pView.busy || pView.spec.trim() === '') return
|
|
701
|
+
var spec = pView.spec.trim()
|
|
702
|
+
patchPlugin({ busy: true, error: '', confirming: null, note: '' })
|
|
703
|
+
callRemote('pluginAdmin/install', { spec: spec }).then(function (result) {
|
|
704
|
+
if (!alive.current) return
|
|
705
|
+
if (result.ok) {
|
|
706
|
+
patchPlugin({
|
|
707
|
+
busy: false,
|
|
708
|
+
note: '安装完成。更改在重启 dsh 后生效',
|
|
709
|
+
output: (result.value && result.value.output) || '',
|
|
710
|
+
profileDir: (result.value && result.value.profileDir) || '',
|
|
711
|
+
plugins: (result.value && result.value.plugins) || [],
|
|
712
|
+
spec: '',
|
|
713
|
+
})
|
|
714
|
+
return
|
|
715
|
+
}
|
|
716
|
+
var failMessage = '安装失败:' + messageOf(result.error)
|
|
717
|
+
patchPlugin({ busy: false, error: failMessage })
|
|
718
|
+
showToast('error', failMessage)
|
|
719
|
+
reloadPlugins(true)
|
|
720
|
+
}, function (failure) {
|
|
721
|
+
if (!alive.current) return
|
|
722
|
+
patchPlugin({ busy: false, error: '调用失败:' + messageOf(failure) })
|
|
723
|
+
})
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function removePlugin(name) {
|
|
727
|
+
patchPlugin({ busy: true, error: '', confirming: null, note: '' })
|
|
728
|
+
callRemote('pluginAdmin/remove', { name: name }).then(function (result) {
|
|
729
|
+
if (!alive.current) return
|
|
730
|
+
if (result.ok) {
|
|
731
|
+
patchPlugin({
|
|
732
|
+
busy: false,
|
|
733
|
+
note: '卸载完成。更改在重启 dsh 后生效',
|
|
734
|
+
output: (result.value && result.value.output) || '',
|
|
735
|
+
profileDir: (result.value && result.value.profileDir) || '',
|
|
736
|
+
plugins: (result.value && result.value.plugins) || [],
|
|
737
|
+
})
|
|
738
|
+
return
|
|
739
|
+
}
|
|
740
|
+
var failMessage = '卸载失败:' + messageOf(result.error)
|
|
741
|
+
patchPlugin({ busy: false, error: failMessage })
|
|
742
|
+
showToast('error', failMessage)
|
|
743
|
+
reloadPlugins(true)
|
|
744
|
+
}, function (failure) {
|
|
745
|
+
if (!alive.current) return
|
|
746
|
+
patchPlugin({ busy: false, error: '调用失败:' + messageOf(failure) })
|
|
747
|
+
})
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
useEffect(function () {
|
|
751
|
+
alive.current = true
|
|
752
|
+
reloadPlugins()
|
|
753
|
+
// Auto-check for remote updates on mount (the panel loads lazily when
|
|
754
|
+
// the 扩展插件 tab is opened, so this runs once per open). The auto path
|
|
755
|
+
// is cache-friendly: the host serves its 5-minute cache, so re-opening
|
|
756
|
+
// the tab shortly after does not re-hit the registry. The manual
|
|
757
|
+
// ⬆ 检查更新 button is the force path — it bypasses the cache and
|
|
758
|
+
// refreshes its content.
|
|
759
|
+
checkUpdates()
|
|
760
|
+
return function () { alive.current = false }
|
|
761
|
+
}, [])
|
|
762
|
+
|
|
763
|
+
// Single persistence point: localStorage always mirrors the LATEST
|
|
764
|
+
// committed reminders. Moving saves out of the async handlers (and out of
|
|
765
|
+
// the functional updaters, which must stay pure) removes drift by
|
|
766
|
+
// construction — whatever merge won the last commit is what survives
|
|
767
|
+
// dialog reopen and dsh restarts (best-effort; unavailable storage just
|
|
768
|
+
// degrades to session-only badges).
|
|
769
|
+
useEffect(function () {
|
|
770
|
+
saveUpdateReminders(pView.updates || {})
|
|
771
|
+
}, [pView.updates])
|
|
772
|
+
|
|
773
|
+
return createElement('div', { 'data-dsh-admin-section': '' },
|
|
774
|
+
renderPluginsView(pView, patchPlugin, installPlugin, removePlugin, checkUpdates, upgradePlugin))
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* 历史会话 settings section (standalone settings-nav page).
|
|
779
|
+
*/
|
|
780
|
+
function SessionsSection(props) {
|
|
781
|
+
var pairSessions = useState({
|
|
782
|
+
sessions: [],
|
|
783
|
+
workspaces: [],
|
|
784
|
+
busy: false,
|
|
785
|
+
error: '',
|
|
786
|
+
needle: '',
|
|
787
|
+
confirming: null,
|
|
788
|
+
filter: 'all',
|
|
789
|
+
})
|
|
790
|
+
var sView = pairSessions[0]
|
|
791
|
+
var setSView = pairSessions[1]
|
|
792
|
+
|
|
793
|
+
var alive = useRef(false)
|
|
794
|
+
|
|
795
|
+
function patchSession(partial) {
|
|
796
|
+
setSView(function (cur) {
|
|
797
|
+
var next = {}
|
|
798
|
+
for (var k in cur) next[k] = cur[k]
|
|
799
|
+
for (var pk in partial) next[pk] = partial[pk]
|
|
800
|
+
return next
|
|
801
|
+
})
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function callRemote(method, args) {
|
|
805
|
+
return props.call(method, args)
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function reloadSessions() {
|
|
809
|
+
patchSession({ busy: true, error: '' })
|
|
810
|
+
callRemote('sessionAdmin/list', {}).then(function (result) {
|
|
811
|
+
if (!alive.current) return
|
|
812
|
+
if (result.ok) {
|
|
813
|
+
patchSession({
|
|
814
|
+
busy: false,
|
|
815
|
+
sessions: (result.value && result.value.sessions) || [],
|
|
816
|
+
workspaces: (result.value && result.value.workspaces) || [],
|
|
817
|
+
})
|
|
818
|
+
} else {
|
|
819
|
+
patchSession({ busy: false, error: '加载会话失败:' + messageOf(result.error) })
|
|
820
|
+
}
|
|
821
|
+
}, function (failure) {
|
|
822
|
+
if (!alive.current) return
|
|
823
|
+
patchSession({ busy: false, error: '调用失败:' + messageOf(failure) })
|
|
824
|
+
})
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
function actSession(method, sessionId) {
|
|
828
|
+
patchSession({ busy: true, error: '', confirming: null })
|
|
829
|
+
callRemote('sessionAdmin/' + method, { sessionId: sessionId }).then(function (result) {
|
|
830
|
+
if (!alive.current) return
|
|
831
|
+
if (result.ok) {
|
|
832
|
+
// Refresh this panel's own list, and nudge the sidebar (via the
|
|
833
|
+
// sessions service) so a deleted session disappears immediately
|
|
834
|
+
// instead of lingering until reload.
|
|
835
|
+
if ((method === 'deleteSession' || method === 'closeSession') && props.refreshSessions) props.refreshSessions()
|
|
836
|
+
return reloadSessions()
|
|
837
|
+
}
|
|
838
|
+
patchSession({ busy: false, error: '操作失败:' + messageOf(result.error) })
|
|
839
|
+
}, function (failure) {
|
|
840
|
+
if (!alive.current) return
|
|
841
|
+
patchSession({ busy: false, error: '调用失败:' + messageOf(failure) })
|
|
842
|
+
})
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
useEffect(function () {
|
|
846
|
+
alive.current = true
|
|
847
|
+
reloadSessions()
|
|
848
|
+
return function () { alive.current = false }
|
|
849
|
+
}, [])
|
|
850
|
+
|
|
851
|
+
return createElement('div', { 'data-dsh-admin-section': '' },
|
|
852
|
+
renderSessionsView(sView, patchSession, reloadSessions, actSession))
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* MCP服务器 settings section (standalone settings-nav page).
|
|
857
|
+
*/
|
|
858
|
+
|
|
859
|
+
/* ------------------------------------------------------------------------ */
|
|
860
|
+
/* MCP test-result cache */
|
|
861
|
+
/* */
|
|
862
|
+
/* Successful connectivity probes are persisted to localStorage so the */
|
|
863
|
+
/* panel shows the last known status after tab switches or reopening the */
|
|
864
|
+
/* dialog instead of an empty state. Only OK results are cached (failures */
|
|
865
|
+
/* are usually transient); a cached row is labelled with its probe time, */
|
|
866
|
+
/* and the cache entry is invalidated when the config is saved or removed, */
|
|
867
|
+
/* or pruned when the entry disappears from the host list. */
|
|
868
|
+
/* ------------------------------------------------------------------------ */
|
|
869
|
+
|
|
870
|
+
var MCP_TEST_CACHE_KEY = 'dsh-plugin-admin/mcp-test-results'
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Touch localStorage safely: on some environments (jsdom with an opaque
|
|
874
|
+
* origin, hardened browsers, privacy modes) merely READING window.localStorage
|
|
875
|
+
* throws a SecurityError, so the access itself has to sit inside try/catch.
|
|
876
|
+
* Returns null when storage is unavailable.
|
|
877
|
+
*/
|
|
878
|
+
function safeLocalStorage() {
|
|
879
|
+
try {
|
|
880
|
+
if (typeof window === 'undefined' || !window.localStorage) return null
|
|
881
|
+
return window.localStorage
|
|
882
|
+
} catch (e) {
|
|
883
|
+
return null
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
function mcpTestStorage() {
|
|
888
|
+
return safeLocalStorage()
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
function loadMcpTestCache() {
|
|
892
|
+
var store = mcpTestStorage()
|
|
893
|
+
if (store === null) return {}
|
|
894
|
+
try {
|
|
895
|
+
var parsed = JSON.parse(store.getItem(MCP_TEST_CACHE_KEY))
|
|
896
|
+
if (parsed === null || typeof parsed !== 'object') return {}
|
|
897
|
+
// Purge failure records persisted by older builds: only a durable OK is
|
|
898
|
+
// worth restoring on mount; a stale ❌ from a past outage must not
|
|
899
|
+
// outlive the session it happened in.
|
|
900
|
+
var out = {}
|
|
901
|
+
for (var id in parsed) {
|
|
902
|
+
var entry = parsed[id]
|
|
903
|
+
if (entry && entry.result && entry.result.ok === true) out[id] = entry
|
|
904
|
+
}
|
|
905
|
+
return out
|
|
906
|
+
} catch (e) {
|
|
907
|
+
return {}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/** Mirror settled, successful probes into localStorage (best-effort). */
|
|
912
|
+
function saveMcpTestCache(state) {
|
|
913
|
+
var store = mcpTestStorage()
|
|
914
|
+
if (store === null) return
|
|
915
|
+
try {
|
|
916
|
+
var out = {}
|
|
917
|
+
for (var id in state) {
|
|
918
|
+
var s = state[id]
|
|
919
|
+
// Busy rows keep the previous cached result; failures stay ephemeral —
|
|
920
|
+
// INCLUDING structured {ok:false} probes (timeout, connection refused),
|
|
921
|
+
// which arrive as a truthy result object and need their own ok check.
|
|
922
|
+
if (!s || s.busy || s.result === null || s.result === undefined
|
|
923
|
+
|| s.result.ok !== true) continue
|
|
924
|
+
out[id] = { result: s.result, at: typeof s.at === 'number' ? s.at : Date.now() }
|
|
925
|
+
}
|
|
926
|
+
store.setItem(MCP_TEST_CACHE_KEY, JSON.stringify(out))
|
|
927
|
+
} catch (e) {
|
|
928
|
+
// Quota exceeded / storage blocked — the cache is optional, never fatal.
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/** Drop one entry's cached probe (config saved or entry removed). */
|
|
933
|
+
function clearMcpTestCacheEntry(id) {
|
|
934
|
+
var store = mcpTestStorage()
|
|
935
|
+
if (store === null) return
|
|
936
|
+
try {
|
|
937
|
+
var state = loadMcpTestCache()
|
|
938
|
+
if (state[id] === undefined) return
|
|
939
|
+
delete state[id]
|
|
940
|
+
store.setItem(MCP_TEST_CACHE_KEY, JSON.stringify(state))
|
|
941
|
+
} catch (e) { /* ignore */ }
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/** Drop test states whose entry no longer exists in the host list. */
|
|
945
|
+
function pruneMcpTestState(map, entries) {
|
|
946
|
+
var valid = {}
|
|
947
|
+
for (var i = 0; i < entries.length; i++) valid[entries[i].id] = true
|
|
948
|
+
var next = {}
|
|
949
|
+
var changed = false
|
|
950
|
+
for (var id in map) {
|
|
951
|
+
if (valid[id]) next[id] = map[id]
|
|
952
|
+
else changed = true
|
|
953
|
+
}
|
|
954
|
+
if (changed) saveMcpTestCache(next)
|
|
955
|
+
return next
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/** Compact timestamp for a cached probe ("14:32" today, "6-1 14:32" older). */
|
|
959
|
+
function formatTestTime(ms) {
|
|
960
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms)) return ''
|
|
961
|
+
var d = new Date(ms)
|
|
962
|
+
var pad = function (n) { return (n < 10 ? '0' : '') + String(n) }
|
|
963
|
+
var hm = pad(d.getHours()) + ':' + pad(d.getMinutes())
|
|
964
|
+
var now = new Date()
|
|
965
|
+
if (d.getFullYear() === now.getFullYear() && d.getMonth() === now.getMonth() && d.getDate() === now.getDate()) return hm
|
|
966
|
+
return (d.getMonth() + 1) + '-' + d.getDate() + ' ' + hm
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/* Update-reminder persistence */
|
|
970
|
+
/* */
|
|
971
|
+
/* A "⬆ 有新版本" reminder is a durable fact, not a transient fetch result: */
|
|
972
|
+
/* once a newer version is detected it is kept in localStorage until a */
|
|
973
|
+
/* check confirms the installed version is current again (i.e. the update */
|
|
974
|
+
/* actually completed). This is what keeps the badge visible after closing */
|
|
975
|
+
/* and reopening the dialog, across dsh restarts, and even when a later */
|
|
976
|
+
/* re-check hits a transient network failure — and what clears it only once */
|
|
977
|
+
/* the plugin is upgraded (更新完删除提醒). */
|
|
978
|
+
/* ------------------------------------------------------------------------ */
|
|
979
|
+
|
|
980
|
+
var UPDATE_REMINDER_KEY = 'dsh-plugin-admin/update-reminders'
|
|
981
|
+
|
|
982
|
+
/** Shape-merge a reminder entry (keeps the original truthy fields). */
|
|
983
|
+
function mergeReminder(entry, partial) {
|
|
984
|
+
var next = {}
|
|
985
|
+
for (var k in entry) next[k] = entry[k]
|
|
986
|
+
for (var pk in partial) next[pk] = partial[pk]
|
|
987
|
+
return next
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Load persisted update reminders as state entries:
|
|
992
|
+
* { name: { latest, at, updateAvailable, error } }. Storage-unavailable
|
|
993
|
+
* environments (opaque-origin jsdom, privacy modes) just get an empty map.
|
|
994
|
+
*/
|
|
995
|
+
function loadUpdateReminders() {
|
|
996
|
+
var store = safeLocalStorage()
|
|
997
|
+
if (store === null) return {}
|
|
998
|
+
try {
|
|
999
|
+
var parsed = JSON.parse(store.getItem(UPDATE_REMINDER_KEY))
|
|
1000
|
+
var out = {}
|
|
1001
|
+
if (parsed !== null && typeof parsed === 'object') {
|
|
1002
|
+
for (var name in parsed) {
|
|
1003
|
+
var r = parsed[name]
|
|
1004
|
+
if (r && typeof r.latest === 'string' && r.latest.length > 0) {
|
|
1005
|
+
out[name] = {
|
|
1006
|
+
latest: r.latest,
|
|
1007
|
+
at: typeof r.at === 'number' ? r.at : 0,
|
|
1008
|
+
updateAvailable: true,
|
|
1009
|
+
error: '',
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
return out
|
|
1015
|
+
} catch (e) {
|
|
1016
|
+
return {}
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/** Mirror the current reminder set into localStorage (best-effort). */
|
|
1021
|
+
function saveUpdateReminders(map) {
|
|
1022
|
+
var store = safeLocalStorage()
|
|
1023
|
+
if (store === null) return
|
|
1024
|
+
try {
|
|
1025
|
+
var out = {}
|
|
1026
|
+
for (var name in map) {
|
|
1027
|
+
var r = map[name]
|
|
1028
|
+
if (r && r.updateAvailable === true && typeof r.latest === 'string' && r.latest.length > 0) {
|
|
1029
|
+
out[name] = { latest: r.latest, at: typeof r.at === 'number' ? r.at : Date.now() }
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
store.setItem(UPDATE_REMINDER_KEY, JSON.stringify(out))
|
|
1033
|
+
} catch (e) {
|
|
1034
|
+
// Quota exceeded / storage blocked — the reminder is optional, never fatal.
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* Merge one check response into the CURRENT reminder map. Pure on purpose:
|
|
1040
|
+
* it runs inside the setPView updater, so it reads only its arguments and
|
|
1041
|
+
* must never touch localStorage or other component state. Per-entry semantics
|
|
1042
|
+
* (list = fresh host results, one row per live registry install):
|
|
1043
|
+
* - updateAvailable -> (re)arm the reminder
|
|
1044
|
+
* - confirmed current -> drop any entry (更新完删除提醒)
|
|
1045
|
+
* - query error -> keep a prior reminder untouched (error attached);
|
|
1046
|
+
* without one, record an ephemeral failure
|
|
1047
|
+
* ({updateAvailable:false}) so cards/strip/note can
|
|
1048
|
+
* surface it — saveUpdateReminders skips those
|
|
1049
|
+
* - entries absent from `list` are no longer live registry installs ->
|
|
1050
|
+
* stale reminders dropped
|
|
1051
|
+
* @param curMap - the CURRENT updates state ({ name -> entry }).
|
|
1052
|
+
* @param list - per-plugin check results.
|
|
1053
|
+
* @returns the complete next map.
|
|
1054
|
+
*/
|
|
1055
|
+
function mergeUpdateReminders(curMap, list) {
|
|
1056
|
+
var liveNames = {}
|
|
1057
|
+
for (var a = 0; a < list.length; a++) liveNames[list[a].name] = true
|
|
1058
|
+
var map = {}
|
|
1059
|
+
for (var k in curMap) {
|
|
1060
|
+
if (curMap[k] && liveNames[k]) map[k] = curMap[k]
|
|
1061
|
+
}
|
|
1062
|
+
for (var i = 0; i < list.length; i++) {
|
|
1063
|
+
var u = list[i]
|
|
1064
|
+
if (u.updateAvailable === true) {
|
|
1065
|
+
map[u.name] = { latest: u.latest, updateAvailable: true, error: '', at: Date.now() }
|
|
1066
|
+
} else if (u.error) {
|
|
1067
|
+
// A prior reminder survives untouched with the transient error
|
|
1068
|
+
// alongside; WITHOUT one the failure itself lands in the map so an
|
|
1069
|
+
// all-failed first check cannot claim 全部为最新版本.
|
|
1070
|
+
map[u.name] = map[u.name]
|
|
1071
|
+
? mergeReminder(map[u.name], { error: u.error || '' })
|
|
1072
|
+
: { latest: '', updateAvailable: false, error: u.error || '', at: Date.now() }
|
|
1073
|
+
} else if (u.latest !== null && u.latest !== undefined) {
|
|
1074
|
+
delete map[u.name]
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
return map
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/** Aggregate summary line for a finished check (pure). */
|
|
1081
|
+
function updateCheckNote(map, checkedCount) {
|
|
1082
|
+
var updateCount = 0
|
|
1083
|
+
var checkErrorCount = 0
|
|
1084
|
+
for (var n in map) {
|
|
1085
|
+
if (map[n].updateAvailable === true) updateCount++
|
|
1086
|
+
if (map[n].error) checkErrorCount++
|
|
1087
|
+
}
|
|
1088
|
+
if (updateCount > 0) return '发现 ' + updateCount + ' 个插件有新版本'
|
|
1089
|
+
if (checkErrorCount > 0) {
|
|
1090
|
+
return '已检查 ' + checkedCount + ' 个插件(' + checkErrorCount + ' 个查询失败)'
|
|
1091
|
+
+ (checkedCount > checkErrorCount ? ',其余均为最新版本' : '')
|
|
1092
|
+
}
|
|
1093
|
+
return checkedCount > 0 ? '已检查 ' + checkedCount + ' 个插件,均为最新版本' : ''
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
function McpSection(props) {
|
|
1097
|
+
var pairMcp = useState({
|
|
1098
|
+
mcpEntries: [],
|
|
1099
|
+
mcpBusy: false,
|
|
1100
|
+
mcpError: '',
|
|
1101
|
+
mcpEditorOpen: false,
|
|
1102
|
+
mcpDraft: null,
|
|
1103
|
+
// entryId -> { busy?, result?, error?, at? }; previous successful probes
|
|
1104
|
+
// are restored from localStorage so statuses survive panel remounts.
|
|
1105
|
+
mcpTestState: loadMcpTestCache(),
|
|
1106
|
+
})
|
|
1107
|
+
var mView = pairMcp[0]
|
|
1108
|
+
var setMView = pairMcp[1]
|
|
1109
|
+
|
|
1110
|
+
var alive = useRef(false)
|
|
1111
|
+
|
|
1112
|
+
function patchMcp(partial) {
|
|
1113
|
+
setMView(function (cur) {
|
|
1114
|
+
var next = {}
|
|
1115
|
+
for (var k in cur) next[k] = cur[k]
|
|
1116
|
+
for (var pk in partial) next[pk] = partial[pk]
|
|
1117
|
+
return next
|
|
1118
|
+
})
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// Merge a partial into the CURRENT mcpDraft via a functional update, so
|
|
1122
|
+
// rapid successive field edits (React batching) never lose earlier input.
|
|
1123
|
+
function patchDraft(partial) {
|
|
1124
|
+
setMView(function (cur) {
|
|
1125
|
+
var next = {}
|
|
1126
|
+
for (var k in cur) next[k] = cur[k]
|
|
1127
|
+
next.mcpDraft = mergeDraft(cur.mcpDraft, partial)
|
|
1128
|
+
return next
|
|
1129
|
+
})
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
function callRemote(method, args) {
|
|
1133
|
+
return props.call(method, args)
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
function reloadMcp() {
|
|
1137
|
+
patchMcp({ mcpBusy: true, mcpError: '' })
|
|
1138
|
+
callRemote('mcpAdmin/list', {}).then(function (result) {
|
|
1139
|
+
if (!alive.current) return
|
|
1140
|
+
if (result.ok) {
|
|
1141
|
+
var entries = (result.value && result.value.entries) || []
|
|
1142
|
+
setMView(function (cur) {
|
|
1143
|
+
var next = {}
|
|
1144
|
+
for (var k in cur) next[k] = cur[k]
|
|
1145
|
+
next.mcpBusy = false
|
|
1146
|
+
next.mcpEntries = entries
|
|
1147
|
+
// Drop cached probes whose entry no longer exists on the host.
|
|
1148
|
+
next.mcpTestState = pruneMcpTestState(cur.mcpTestState, entries)
|
|
1149
|
+
return next
|
|
1150
|
+
})
|
|
1151
|
+
} else {
|
|
1152
|
+
patchMcp({ mcpBusy: false, mcpError: '加载 MCP 配置失败:' + messageOf(result.error) })
|
|
1153
|
+
}
|
|
1154
|
+
}, function (failure) {
|
|
1155
|
+
if (!alive.current) return
|
|
1156
|
+
patchMcp({ mcpBusy: false, mcpError: '调用失败:' + messageOf(failure) })
|
|
1157
|
+
})
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
function openMcpEditor(entry) {
|
|
1161
|
+
if (entry !== null && entry !== undefined && (entry.config === null || entry.config === undefined)) {
|
|
1162
|
+
patchMcp({ mcpError: '该 MCP 配置无法安全解析,已禁止在此覆盖;请在 cordis.patch.yml 中手动编辑。' })
|
|
1163
|
+
return
|
|
1164
|
+
}
|
|
1165
|
+
var source = entry !== null && entry !== undefined ? entry.config : null
|
|
1166
|
+
var draft = source ? {
|
|
1167
|
+
id: entry.id,
|
|
1168
|
+
isNew: false,
|
|
1169
|
+
serverName: source.serverName || entry.id,
|
|
1170
|
+
transport: source.transport,
|
|
1171
|
+
command: source.command || '',
|
|
1172
|
+
url: source.url || '',
|
|
1173
|
+
args: (source.args || []).join(' '),
|
|
1174
|
+
argsOriginal: source.args || [],
|
|
1175
|
+
argsChanged: false,
|
|
1176
|
+
env: Object.keys(source.env || {}).map(function (key) { return key + '=' + source.env[key] }).join('\n'),
|
|
1177
|
+
envOriginal: source.env || {},
|
|
1178
|
+
envChanged: false,
|
|
1179
|
+
cwd: source.cwd || '',
|
|
1180
|
+
headers: Object.keys(source.headers || {}).map(function (k) { return k + '=' + source.headers[k] }).join('\n'),
|
|
1181
|
+
headersOriginal: source.headers || {},
|
|
1182
|
+
headersChanged: false,
|
|
1183
|
+
toolCallTimeoutMs: source.toolCallTimeoutMs,
|
|
1184
|
+
failOnStartupError: source.failOnStartupError === true,
|
|
1185
|
+
reconnectEnabled: source.reconnect ? source.reconnect.enabled === true : false,
|
|
1186
|
+
reconnectInitialDelayMs: source.reconnect ? source.reconnect.initialDelayMs : 1000,
|
|
1187
|
+
reconnectMaxDelayMs: source.reconnect ? source.reconnect.maxDelayMs : 30000,
|
|
1188
|
+
reconnectMaxAttempts: source.reconnect ? source.reconnect.maxAttempts : 10,
|
|
1189
|
+
} : {
|
|
1190
|
+
// New server: pre-fill a collision-free id so the user does not have to
|
|
1191
|
+
// invent one; they can still edit it or regenerate it.
|
|
1192
|
+
id: generateMcpId(mView.mcpEntries),
|
|
1193
|
+
isNew: true,
|
|
1194
|
+
serverName: '',
|
|
1195
|
+
transport: 'stdio',
|
|
1196
|
+
command: '',
|
|
1197
|
+
url: '',
|
|
1198
|
+
args: '',
|
|
1199
|
+
argsOriginal: [],
|
|
1200
|
+
argsChanged: false,
|
|
1201
|
+
env: '',
|
|
1202
|
+
envOriginal: {},
|
|
1203
|
+
envChanged: false,
|
|
1204
|
+
cwd: '',
|
|
1205
|
+
headers: '',
|
|
1206
|
+
headersOriginal: {},
|
|
1207
|
+
headersChanged: false,
|
|
1208
|
+
toolCallTimeoutMs: undefined,
|
|
1209
|
+
failOnStartupError: false,
|
|
1210
|
+
reconnectEnabled: false,
|
|
1211
|
+
reconnectInitialDelayMs: 1000,
|
|
1212
|
+
reconnectMaxDelayMs: 30000,
|
|
1213
|
+
reconnectMaxAttempts: 10,
|
|
1214
|
+
}
|
|
1215
|
+
patchMcp({ mcpEditorOpen: true, mcpDraft: draft, mcpError: '' })
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1218
|
+
function closeMcpEditor() {
|
|
1219
|
+
patchMcp({ mcpEditorOpen: false, mcpDraft: null, mcpError: '' })
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
function saveMcpDraft() {
|
|
1223
|
+
var draft = mView.mcpDraft
|
|
1224
|
+
if (draft === null) return
|
|
1225
|
+
// A NEW entry must not collide with an existing id: the host's upsert
|
|
1226
|
+
// locates its target block by id and would replace that entry in place,
|
|
1227
|
+
// silently destroying its config. The edit form keeps its own id (the
|
|
1228
|
+
// field is disabled), so this guard only ever fires on the add form.
|
|
1229
|
+
if (draft.isNew) {
|
|
1230
|
+
for (var ci = 0; ci < mView.mcpEntries.length; ci++) {
|
|
1231
|
+
if (mView.mcpEntries[ci].id === draft.id) {
|
|
1232
|
+
patchMcp({ mcpError: 'ID \'' + draft.id + '\' 已被其他 MCP 条目占用,请换一个再保存。' })
|
|
1233
|
+
return
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
var config
|
|
1238
|
+
if (draft.transport === 'streamable-http') {
|
|
1239
|
+
config = { transport: 'streamable-http', serverName: draft.serverName, url: draft.url }
|
|
1240
|
+
var headersStr = Object.keys(draft.headersOriginal || {}).map(function (k) { return k + '=' + draft.headersOriginal[k] }).join('\n')
|
|
1241
|
+
var headers = (draft.headersChanged && draft.headers !== headersStr) ? {} : draft.headersOriginal
|
|
1242
|
+
if (draft.headersChanged && draft.headers !== headersStr && draft.headers !== '') {
|
|
1243
|
+
// Newline-only split: header values legitimately contain ';'/','
|
|
1244
|
+
// (Cookie, Accept), which must never become pair separators.
|
|
1245
|
+
var pairs = draft.headers.split('\n').map(function (s) { return s.trim() }).filter(Boolean)
|
|
1246
|
+
for (var i = 0; i < pairs.length; i++) {
|
|
1247
|
+
var eq = pairs[i].indexOf('=')
|
|
1248
|
+
if (eq > 0) headers[pairs[i].slice(0, eq).trim()] = pairs[i].slice(eq + 1).trim()
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
if (Object.keys(headers).length > 0) config.headers = headers
|
|
1252
|
+
} else {
|
|
1253
|
+
config = { transport: 'stdio', serverName: draft.serverName, command: draft.command }
|
|
1254
|
+
var argsStr = (draft.argsOriginal || []).join(' ')
|
|
1255
|
+
var args = (draft.argsChanged && draft.args !== argsStr) ? draft.args.split(/\s+/).filter(Boolean) : draft.argsOriginal
|
|
1256
|
+
if (args.length > 0) config.args = args
|
|
1257
|
+
var envStr = Object.keys(draft.envOriginal || {}).map(function (k) { return k + '=' + draft.envOriginal[k] }).join('\n')
|
|
1258
|
+
var env = (draft.envChanged && draft.env !== envStr) ? {} : draft.envOriginal
|
|
1259
|
+
if (draft.envChanged && draft.env !== envStr && draft.env !== '') {
|
|
1260
|
+
// Newline-only split: values like PATH=C:\a;C:\b would lose their
|
|
1261
|
+
// tail (and Windows paths carry ';' everywhere).
|
|
1262
|
+
var pairs = draft.env.split('\n').map(function (s) { return s.trim() }).filter(Boolean)
|
|
1263
|
+
for (var i = 0; i < pairs.length; i++) {
|
|
1264
|
+
var eq = pairs[i].indexOf('=')
|
|
1265
|
+
if (eq > 0) env[pairs[i].slice(0, eq).trim()] = pairs[i].slice(eq + 1).trim()
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
if (Object.keys(env).length > 0) config.env = env
|
|
1269
|
+
if (draft.cwd !== '') config.cwd = draft.cwd
|
|
1270
|
+
}
|
|
1271
|
+
if (draft.toolCallTimeoutMs !== undefined) config.toolCallTimeoutMs = draft.toolCallTimeoutMs
|
|
1272
|
+
if (draft.failOnStartupError) config.failOnStartupError = true
|
|
1273
|
+
if (draft.reconnectEnabled) {
|
|
1274
|
+
config.reconnect = {
|
|
1275
|
+
enabled: true,
|
|
1276
|
+
initialDelayMs: Number(draft.reconnectInitialDelayMs),
|
|
1277
|
+
maxDelayMs: Number(draft.reconnectMaxDelayMs),
|
|
1278
|
+
maxAttempts: Number(draft.reconnectMaxAttempts),
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
patchMcp({ mcpBusy: true, mcpError: '' })
|
|
1282
|
+
callRemote('mcpAdmin/upsert', { entry: { id: draft.id, config: config } }).then(function (result) {
|
|
1283
|
+
if (!alive.current) return
|
|
1284
|
+
if (result.ok) {
|
|
1285
|
+
// The config changed, so any cached probe no longer describes this
|
|
1286
|
+
// server — drop it from storage and from the panel.
|
|
1287
|
+
clearMcpTestCacheEntry(draft.id)
|
|
1288
|
+
patchMcpTest(draft.id, { busy: false, result: null, error: null })
|
|
1289
|
+
patchMcp({ mcpBusy: false, mcpEntries: (result.value && result.value.entries) || [], mcpEditorOpen: false, mcpDraft: null })
|
|
1290
|
+
} else {
|
|
1291
|
+
patchMcp({ mcpBusy: false, mcpError: '保存 MCP 配置失败:' + messageOf(result.error) })
|
|
1292
|
+
}
|
|
1293
|
+
}, function (failure) {
|
|
1294
|
+
if (!alive.current) return
|
|
1295
|
+
patchMcp({ mcpBusy: false, mcpError: '调用失败:' + messageOf(failure) })
|
|
1296
|
+
})
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
function removeMcpEntry(id) {
|
|
1300
|
+
patchMcp({ mcpBusy: true, mcpError: '' })
|
|
1301
|
+
callRemote('mcpAdmin/remove', { id: id }).then(function (result) {
|
|
1302
|
+
if (!alive.current) return
|
|
1303
|
+
if (result.ok) {
|
|
1304
|
+
// The entry is gone — its cached probe must not linger in storage.
|
|
1305
|
+
clearMcpTestCacheEntry(id)
|
|
1306
|
+
patchMcp({ mcpBusy: false, mcpEntries: (result.value && result.value.entries) || [] })
|
|
1307
|
+
} else {
|
|
1308
|
+
patchMcp({ mcpBusy: false, mcpError: '移除 MCP 配置失败:' + messageOf(result.error) })
|
|
1309
|
+
}
|
|
1310
|
+
}, function (failure) {
|
|
1311
|
+
if (!alive.current) return
|
|
1312
|
+
patchMcp({ mcpBusy: false, mcpError: '调用失败:' + messageOf(failure) })
|
|
1313
|
+
})
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* Set one entry's connectivity-test status against the CURRENT state.
|
|
1318
|
+
* Settled successful probes are mirrored into localStorage so the last
|
|
1319
|
+
* known status survives tab switches and reopening the settings dialog.
|
|
1320
|
+
*/
|
|
1321
|
+
function patchMcpTest(id, partial) {
|
|
1322
|
+
setMView(function (cur) {
|
|
1323
|
+
var nextTestState = mergeTestState(cur.mcpTestState, id, partial)
|
|
1324
|
+
saveMcpTestCache(nextTestState)
|
|
1325
|
+
var next = {}
|
|
1326
|
+
for (var k in cur) next[k] = cur[k]
|
|
1327
|
+
next.mcpTestState = nextTestState
|
|
1328
|
+
return next
|
|
1329
|
+
})
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
/** Run a host-side connectivity probe for one entry and stash the result. */
|
|
1333
|
+
function testMcpEntry(id) {
|
|
1334
|
+
patchMcpTest(id, { busy: true, result: null, error: null })
|
|
1335
|
+
callRemote('mcpAdmin/test', { id: id }).then(function (result) {
|
|
1336
|
+
if (!alive.current) return
|
|
1337
|
+
if (result.ok && result.value !== null && typeof result.value === 'object') {
|
|
1338
|
+
// `at` timestamps the probe; it is what the cached label renders.
|
|
1339
|
+
patchMcpTest(id, { busy: false, result: result.value, at: Date.now() })
|
|
1340
|
+
} else {
|
|
1341
|
+
patchMcpTest(id, { busy: false, result: null, error: messageOf(result.error) })
|
|
1342
|
+
}
|
|
1343
|
+
}, function (failure) {
|
|
1344
|
+
if (!alive.current) return
|
|
1345
|
+
patchMcpTest(id, { busy: false, result: null, error: messageOf(failure) })
|
|
1346
|
+
})
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
useEffect(function () {
|
|
1350
|
+
alive.current = true
|
|
1351
|
+
reloadMcp()
|
|
1352
|
+
return function () { alive.current = false }
|
|
1353
|
+
}, [])
|
|
1354
|
+
|
|
1355
|
+
return createElement('div', { 'data-dsh-admin-section': '' },
|
|
1356
|
+
renderMcpSection(mView, patchDraft, reloadMcp, openMcpEditor, closeMcpEditor, saveMcpDraft, removeMcpEntry, testMcpEntry))
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
/* ========================================================================== */
|
|
1360
|
+
/* Render Plugins View */
|
|
1361
|
+
/* ========================================================================== */
|
|
1362
|
+
|
|
1363
|
+
function renderPluginsView(view, patch, install, remove, checkUpdates, upgrade) {
|
|
1364
|
+
var elements = []
|
|
1365
|
+
|
|
1366
|
+
// Toolbar, two rows: search alone on the first (it gets the full width),
|
|
1367
|
+
// install input + actions on the second.
|
|
1368
|
+
elements.push(createElement('div', { className: 'toolbar', key: 'toolbar-search' },
|
|
1369
|
+
createElement('div', { className: 'search-wrap', key: 'search-wrap' },
|
|
1370
|
+
createElement('span', { className: 'search-icon', key: 'icon' }, '🔍'),
|
|
1371
|
+
createElement('input', {
|
|
1372
|
+
className: 'input',
|
|
1373
|
+
key: 'search-input',
|
|
1374
|
+
placeholder: '搜索插件(名称/版本/路径)...',
|
|
1375
|
+
value: view.needle,
|
|
1376
|
+
onChange: function (e) { patch({ needle: e.target.value }) },
|
|
1377
|
+
}),
|
|
1378
|
+
view.needle !== '' ? createElement('button', {
|
|
1379
|
+
type: 'button',
|
|
1380
|
+
key: 'btn-clear-search',
|
|
1381
|
+
className: 'btn sm',
|
|
1382
|
+
title: '清空搜索',
|
|
1383
|
+
onClick: function () { patch({ needle: '' }) },
|
|
1384
|
+
}, '✕') : null
|
|
1385
|
+
),
|
|
1386
|
+
))
|
|
1387
|
+
elements.push(createElement('div', { className: 'toolbar', key: 'toolbar-install' },
|
|
1388
|
+
createElement('div', { className: 'input-wrap install-wrap', key: 'install-wrap' },
|
|
1389
|
+
createElement('input', {
|
|
1390
|
+
className: 'input',
|
|
1391
|
+
placeholder: '安装包名/路径...',
|
|
1392
|
+
value: view.spec,
|
|
1393
|
+
disabled: view.busy,
|
|
1394
|
+
onChange: function (e) { patch({ spec: e.target.value }) },
|
|
1395
|
+
onKeyDown: function (e) { if (e.key === 'Enter') install() },
|
|
1396
|
+
})
|
|
1397
|
+
),
|
|
1398
|
+
createElement('button', {
|
|
1399
|
+
type: 'button',
|
|
1400
|
+
key: 'btn-install',
|
|
1401
|
+
className: 'btn primary',
|
|
1402
|
+
disabled: view.busy || view.spec.trim() === '',
|
|
1403
|
+
onClick: install,
|
|
1404
|
+
},
|
|
1405
|
+
view.busy ? createElement('span', { className: 'spinner', key: 'spin' }) : null,
|
|
1406
|
+
'安装'
|
|
1407
|
+
),
|
|
1408
|
+
createElement('button', {
|
|
1409
|
+
type: 'button',
|
|
1410
|
+
key: 'btn-check-updates',
|
|
1411
|
+
className: 'btn',
|
|
1412
|
+
disabled: view.busy || view.checkingUpdates,
|
|
1413
|
+
title: '强制绕过 5 分钟缓存,重新查询 registry 并刷新缓存',
|
|
1414
|
+
onClick: function () { checkUpdates(true) },
|
|
1415
|
+
},
|
|
1416
|
+
view.checkingUpdates ? createElement('span', { className: 'spinner', key: 'spin' }) : null,
|
|
1417
|
+
view.checkingUpdates ? '检查中...' : '⬆️ 检查更新'
|
|
1418
|
+
),
|
|
1419
|
+
))
|
|
1420
|
+
|
|
1421
|
+
// Filter Pills
|
|
1422
|
+
var totalPlugins = view.plugins.length
|
|
1423
|
+
var thirdPartyCount = 0
|
|
1424
|
+
var builtinCount = 0
|
|
1425
|
+
for (var i = 0; i < view.plugins.length; i++) {
|
|
1426
|
+
if (view.plugins[i].removable) thirdPartyCount++
|
|
1427
|
+
else builtinCount++
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
elements.push(createElement('div', { className: 'filter-bar', key: 'filters' },
|
|
1431
|
+
createElement('button', {
|
|
1432
|
+
type: 'button',
|
|
1433
|
+
key: 'filter-all',
|
|
1434
|
+
className: 'pill' + (view.filter === 'all' ? ' active' : ''),
|
|
1435
|
+
onClick: function () { patch({ filter: 'all' }) },
|
|
1436
|
+
}, '全部 (' + String(totalPlugins) + ')'),
|
|
1437
|
+
createElement('button', {
|
|
1438
|
+
type: 'button',
|
|
1439
|
+
key: 'filter-plugin',
|
|
1440
|
+
className: 'pill' + (view.filter === 'plugin' ? ' active' : ''),
|
|
1441
|
+
onClick: function () { patch({ filter: 'plugin' }) },
|
|
1442
|
+
}, '扩展插件 (' + String(thirdPartyCount) + ')'),
|
|
1443
|
+
createElement('button', {
|
|
1444
|
+
type: 'button',
|
|
1445
|
+
key: 'filter-builtin',
|
|
1446
|
+
className: 'pill' + (view.filter === 'builtin' ? ' active' : ''),
|
|
1447
|
+
onClick: function () { patch({ filter: 'builtin' }) },
|
|
1448
|
+
}, '系统内置 (' + String(builtinCount) + ')')
|
|
1449
|
+
))
|
|
1450
|
+
|
|
1451
|
+
// Busy banner / Error
|
|
1452
|
+
if (view.busy) {
|
|
1453
|
+
elements.push(createElement('div', { className: 'busy-banner', key: 'busy' },
|
|
1454
|
+
createElement('span', { className: 'spinner', key: 'spin' }),
|
|
1455
|
+
'正在执行 pnpm 操作(可能需要数秒至数分钟,请勿关闭窗口)...'
|
|
1456
|
+
))
|
|
1457
|
+
}
|
|
1458
|
+
if (view.error !== '') {
|
|
1459
|
+
elements.push(createElement('div', { className: 'error', key: 'error' }, view.error))
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
// Update-check status strip: gives the auto-check a visible outcome instead
|
|
1463
|
+
// of hiding it in the footer. Checking → spinner; done with updates →
|
|
1464
|
+
// orange; done without updates → green; per-plugin query failures surface
|
|
1465
|
+
// on the strip rather than vanishing. Purely informational — the single
|
|
1466
|
+
// re-check entry point is the toolbar「⬆️ 检查更新」button (which forces a
|
|
1467
|
+
// fresh registry query), so no redundant button lives in the strip.
|
|
1468
|
+
if (view.checkingUpdates) {
|
|
1469
|
+
elements.push(createElement('div', { className: 'update-strip checking', key: 'update-checking' },
|
|
1470
|
+
createElement('span', { className: 'spinner', key: 'spin' }),
|
|
1471
|
+
'正在检查插件版本更新…'
|
|
1472
|
+
))
|
|
1473
|
+
} else if (view.updateChecked) {
|
|
1474
|
+
var upCount = 0
|
|
1475
|
+
var errCount = 0
|
|
1476
|
+
for (var un in view.updates) {
|
|
1477
|
+
if (view.updates[un].updateAvailable === true) upCount++
|
|
1478
|
+
if (view.updates[un].error) errCount++
|
|
1479
|
+
}
|
|
1480
|
+
var stripClass = upCount > 0 ? 'update-strip has-updates'
|
|
1481
|
+
: (errCount > 0 ? 'update-strip has-errors' : 'update-strip ok')
|
|
1482
|
+
var stripText = upCount > 0
|
|
1483
|
+
? '⬆️ 发现 ' + upCount + ' 个插件有新版本,可点击卡片上的「更新」升级'
|
|
1484
|
+
: (errCount > 0
|
|
1485
|
+
? '⚠️ 有 ' + errCount + ' 个插件查询版本失败(网络或 registry 不可达)'
|
|
1486
|
+
: '✅ 已自动检查版本更新,全部为最新版本')
|
|
1487
|
+
elements.push(createElement('div', { className: stripClass, key: 'update-result' },
|
|
1488
|
+
createElement('span', { key: 't' }, stripText)
|
|
1489
|
+
))
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
// Filter and render rows
|
|
1493
|
+
var needle = view.needle.trim().toLowerCase()
|
|
1494
|
+
var filtered = filterPlugins(view.plugins, view.filter, needle)
|
|
1495
|
+
var rows = []
|
|
1496
|
+
for (var j = 0; j < filtered.length; j++) {
|
|
1497
|
+
var p = filtered[j]
|
|
1498
|
+
rows.push(renderPluginCard(p, view, remove, patch, upgrade))
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
if (rows.length === 0) {
|
|
1502
|
+
rows.push(createElement('div', { className: 'empty', key: 'empty' },
|
|
1503
|
+
createElement('div', null, needle !== '' ? '🔍 无匹配的插件(试试其他关键词)' : '📦 暂无匹配的插件层')
|
|
1504
|
+
))
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
elements.push(createElement('div', { className: 'list grid2', key: 'list' }, rows))
|
|
1508
|
+
|
|
1509
|
+
// Footer
|
|
1510
|
+
var hintText = view.note !== '' ? view.note : '更改在重启 dsh 后生效(关闭 dsh 进程后重新运行即可)'
|
|
1511
|
+
var hintTitle = view.output !== '' ? 'pnpm 输出:\n' + view.output : undefined
|
|
1512
|
+
elements.push(createElement('div', { className: 'footer', key: 'footer' },
|
|
1513
|
+
createElement('span', { className: 'path', key: 'profile-path', title: view.profileDir }, view.profileDir || 'Profile: 默认'),
|
|
1514
|
+
createElement('span', { className: 'hint', key: 'hint', title: hintTitle }, hintText)
|
|
1515
|
+
))
|
|
1516
|
+
|
|
1517
|
+
return createElement('div', { key: 'plugins-panel', style: { display: 'flex', flexDirection: 'column', gap: '10px' } }, elements)
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
|
|
1521
|
+
function renderMcpSection(view, patchDraft, reloadMcp, openMcpEditor, closeMcpEditor, saveMcpDraft, removeMcpEntry, testMcpEntry) {
|
|
1522
|
+
var children = []
|
|
1523
|
+
var header = createElement('div', { className: 'group-header', key: 'mcp-header', style: { marginTop: 0 } },
|
|
1524
|
+
createElement('span', { className: 'group-title', key: 't' }, '🔌 MCP 配置'),
|
|
1525
|
+
createElement('span', { className: 'group-count', key: 'c' }, String(view.mcpEntries.length) + ' 个'),
|
|
1526
|
+
createElement('button', {
|
|
1527
|
+
type: 'button',
|
|
1528
|
+
key: 'btn-refresh-mcp',
|
|
1529
|
+
className: 'btn',
|
|
1530
|
+
disabled: view.mcpBusy,
|
|
1531
|
+
onClick: reloadMcp,
|
|
1532
|
+
}, '🔄 刷新'),
|
|
1533
|
+
createElement('button', {
|
|
1534
|
+
type: 'button',
|
|
1535
|
+
key: 'btn-add-mcp',
|
|
1536
|
+
className: 'btn primary',
|
|
1537
|
+
disabled: view.mcpBusy,
|
|
1538
|
+
onClick: function () { openMcpEditor(null) },
|
|
1539
|
+
}, '➕ 添加服务器'),
|
|
1540
|
+
)
|
|
1541
|
+
children.push(header)
|
|
1542
|
+
|
|
1543
|
+
if (view.mcpError !== '') {
|
|
1544
|
+
children.push(createElement('div', { className: 'error', key: 'mcp-error' }, view.mcpError))
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
var rows = []
|
|
1548
|
+
for (var i = 0; i < view.mcpEntries.length; i++) {
|
|
1549
|
+
var entry = view.mcpEntries[i]
|
|
1550
|
+
var tag = createElement('span', { className: 'tag plugin', key: 'mcp-tag-' + entry.id },
|
|
1551
|
+
'MCP ' + String(entry.serverName || entry.id))
|
|
1552
|
+
var testState = (view.mcpTestState && view.mcpTestState[entry.id]) || null
|
|
1553
|
+
var testIndicator = null
|
|
1554
|
+
if (testState !== null && testState.busy) {
|
|
1555
|
+
testIndicator = createElement('span', { className: 'mcp-test mcp-test-busy', key: 'test-busy' },
|
|
1556
|
+
createElement('span', { className: 'spinner', key: 'sp' }),
|
|
1557
|
+
' 检测中...')
|
|
1558
|
+
} else if (testState !== null && testState.result !== null && testState.result !== undefined) {
|
|
1559
|
+
var r = testState.result
|
|
1560
|
+
var ok = r.ok === true
|
|
1561
|
+
var label = ok ? '✅ 连通'
|
|
1562
|
+
: '❌ 不通'
|
|
1563
|
+
var detail = ok
|
|
1564
|
+
? (r.serverInfo ? (r.serverInfo.name || '') + (r.serverInfo.version ? ' v' + r.serverInfo.version : '') : '') +
|
|
1565
|
+
(typeof r.toolCount === 'number' ? ' · ' + r.toolCount + ' 个工具' : '') +
|
|
1566
|
+
(r.pingOk === false ? ' · 初始化成功但 ping 失败' : '')
|
|
1567
|
+
: (r.error || '连接失败') + (r.ms !== undefined ? ' (' + r.ms + 'ms)' : '')
|
|
1568
|
+
var detailChildren = [
|
|
1569
|
+
createElement('span', { key: 'lbl' }, label + (detail !== '' ? ' ' + detail : '')),
|
|
1570
|
+
]
|
|
1571
|
+
if (ok && Array.isArray(r.tools) && r.tools.length > 0) {
|
|
1572
|
+
detailChildren.push(createElement('span', { key: 'tools-hint', style: { opacity: 0.75 } },
|
|
1573
|
+
'工具:' + r.tools.join('、')))
|
|
1574
|
+
}
|
|
1575
|
+
if (r.warning) {
|
|
1576
|
+
detailChildren.push(createElement('span', { key: 'warn', className: 'mcp-test-warn', title: r.warning },
|
|
1577
|
+
'⚠️ ' + r.warning))
|
|
1578
|
+
}
|
|
1579
|
+
// Cached probe: label when it was taken so a restored status is never
|
|
1580
|
+
// mistaken for a just-run check. Clicking 🔌 测试 refreshes it.
|
|
1581
|
+
if (typeof testState.at === 'number') {
|
|
1582
|
+
detailChildren.push(createElement('span', {
|
|
1583
|
+
key: 'cached-at',
|
|
1584
|
+
className: 'mcp-test-cached',
|
|
1585
|
+
title: '上次检测结果(本地缓存)。点击「🔌 测试」可重新检测。',
|
|
1586
|
+
}, '· 缓存于 ' + formatTestTime(testState.at)))
|
|
1587
|
+
}
|
|
1588
|
+
testIndicator = createElement('div', {
|
|
1589
|
+
className: 'mcp-test mcp-test-list ' + (ok ? 'mcp-test-ok' : 'mcp-test-fail'),
|
|
1590
|
+
key: 'test-result',
|
|
1591
|
+
title: detail,
|
|
1592
|
+
}, detailChildren)
|
|
1593
|
+
} else if (testState !== null && testState.error !== null && testState.error !== undefined) {
|
|
1594
|
+
testIndicator = createElement('span', {
|
|
1595
|
+
className: 'mcp-test mcp-test-fail',
|
|
1596
|
+
key: 'test-error',
|
|
1597
|
+
title: testState.error,
|
|
1598
|
+
}, '❌ ' + testState.error)
|
|
1599
|
+
}
|
|
1600
|
+
var rowChildren = [
|
|
1601
|
+
createElement('div', { className: 'card-header', key: 'h' },
|
|
1602
|
+
createElement('span', { className: 'card-title-text', key: 'name' }, entry.id),
|
|
1603
|
+
tag,
|
|
1604
|
+
createElement('div', { className: 'card-actions', key: 'a' },
|
|
1605
|
+
createElement('button', {
|
|
1606
|
+
type: 'button',
|
|
1607
|
+
className: 'btn sm',
|
|
1608
|
+
disabled: view.mcpBusy || (testState !== null && testState.busy) || entry.config === null || entry.config === undefined,
|
|
1609
|
+
title: entry.config === null || entry.config === undefined ? '该配置无法安全解析,请手动编辑 cordis.patch.yml' : (testState !== null && testState.busy ? '检测中...' : (testState !== null && typeof testState.at === 'number' ? '重新检测该服务器的连通性(当前显示的是缓存结果)' : '测试该服务器的连通性')),
|
|
1610
|
+
onClick: function (id) { return function () { testMcpEntry(id) } }(entry.id),
|
|
1611
|
+
}, testState !== null && testState.busy ? '检测中' : '🔌 测试'),
|
|
1612
|
+
createElement('button', {
|
|
1613
|
+
type: 'button',
|
|
1614
|
+
className: 'btn sm',
|
|
1615
|
+
disabled: view.mcpBusy || (testState !== null && testState.busy) || entry.config === null || entry.config === undefined,
|
|
1616
|
+
title: entry.config === null || entry.config === undefined ? '该配置无法安全解析,请手动编辑 cordis.patch.yml' : undefined,
|
|
1617
|
+
onClick: function (value) { return function () { openMcpEditor(value) } }(entry),
|
|
1618
|
+
}, '编辑'),
|
|
1619
|
+
createElement('button', {
|
|
1620
|
+
type: 'button',
|
|
1621
|
+
className: 'btn danger sm',
|
|
1622
|
+
disabled: view.mcpBusy,
|
|
1623
|
+
onClick: function (id) { return function () { removeMcpEntry(id) } }(entry.id),
|
|
1624
|
+
}, '移除'),
|
|
1625
|
+
),
|
|
1626
|
+
),
|
|
1627
|
+
]
|
|
1628
|
+
if (testIndicator !== null) {
|
|
1629
|
+
rowChildren.push(createElement('div', { className: 'mcp-test-row', key: 'test-row' }, testIndicator))
|
|
1630
|
+
}
|
|
1631
|
+
rows.push(createElement('div', { className: 'card', key: 'mcp-' + entry.id }, rowChildren))
|
|
1632
|
+
}
|
|
1633
|
+
if (rows.length === 0) {
|
|
1634
|
+
rows.push(createElement('div', { className: 'empty', key: 'mcp-empty' },
|
|
1635
|
+
createElement('div', null, '🔌 暂无 MCP 服务器配置')
|
|
1636
|
+
))
|
|
1637
|
+
}
|
|
1638
|
+
children.push(createElement('div', { className: 'list', key: 'mcp-list' }, rows))
|
|
1639
|
+
|
|
1640
|
+
// Editor form. patchDraft merges against the CURRENT draft in state so
|
|
1641
|
+
// typing across fields never clobbers earlier edits (stale-closure guard).
|
|
1642
|
+
if (view.mcpEditorOpen && view.mcpDraft !== null) {
|
|
1643
|
+
var d = view.mcpDraft
|
|
1644
|
+
var fieldStyle = { display: 'flex', flexDirection: 'column', gap: '4px', marginBottom: '8px' }
|
|
1645
|
+
var labelStyle = { fontSize: '11px', color: 'var(--dsw-alias-label-secondary, #666)' }
|
|
1646
|
+
var editor = createElement('div', { className: 'card', key: 'mcp-editor' },
|
|
1647
|
+
createElement('div', { className: 'card-header', key: 'h' },
|
|
1648
|
+
createElement('span', { className: 'card-title-text', key: 't' }, d.isNew ? '添加 MCP 服务器' : '编辑 ' + d.id),
|
|
1649
|
+
),
|
|
1650
|
+
createElement('div', { style: fieldStyle, key: 'f-id' },
|
|
1651
|
+
createElement('label', { style: labelStyle }, 'ID(唯一标识,[A-Za-z0-9_-])'),
|
|
1652
|
+
createElement('div', { style: { display: 'flex', gap: '6px' } },
|
|
1653
|
+
createElement('input', {
|
|
1654
|
+
className: 'input',
|
|
1655
|
+
value: d.id,
|
|
1656
|
+
disabled: !d.isNew,
|
|
1657
|
+
onChange: function (e) { patchDraft({ id: e.target.value }) },
|
|
1658
|
+
}),
|
|
1659
|
+
d.isNew ? createElement('button', {
|
|
1660
|
+
type: 'button',
|
|
1661
|
+
className: 'btn sm',
|
|
1662
|
+
title: '重新生成一个随机 ID',
|
|
1663
|
+
onClick: function () { patchDraft({ id: generateMcpId(view.mcpEntries) }) },
|
|
1664
|
+
}, '🎲') : null,
|
|
1665
|
+
),
|
|
1666
|
+
),
|
|
1667
|
+
createElement('div', { style: fieldStyle, key: 'f-server' },
|
|
1668
|
+
createElement('label', { style: labelStyle }, 'serverName(模型命名空间)'),
|
|
1669
|
+
createElement('input', {
|
|
1670
|
+
className: 'input',
|
|
1671
|
+
value: d.serverName,
|
|
1672
|
+
onChange: function (e) { patchDraft({ serverName: e.target.value }) },
|
|
1673
|
+
}),
|
|
1674
|
+
),
|
|
1675
|
+
createElement('div', { style: fieldStyle, key: 'f-transport' },
|
|
1676
|
+
createElement('label', { style: labelStyle }, '传输方式'),
|
|
1677
|
+
createElement('select', {
|
|
1678
|
+
className: 'input',
|
|
1679
|
+
value: d.transport,
|
|
1680
|
+
onChange: function (e) { patchDraft({ transport: e.target.value }) },
|
|
1681
|
+
},
|
|
1682
|
+
createElement('option', { value: 'stdio' }, 'stdio(子进程)'),
|
|
1683
|
+
createElement('option', { value: 'streamable-http' }, 'streamable-http(HTTP)'),
|
|
1684
|
+
),
|
|
1685
|
+
),
|
|
1686
|
+
d.transport === 'stdio' ? createElement('div', { style: fieldStyle, key: 'f-cmd' },
|
|
1687
|
+
createElement('label', { style: labelStyle }, 'command(启动命令)'),
|
|
1688
|
+
createElement('input', {
|
|
1689
|
+
className: 'input',
|
|
1690
|
+
value: d.command,
|
|
1691
|
+
placeholder: 'npx -y @modelcontextprotocol/server-github',
|
|
1692
|
+
onChange: function (e) { patchDraft({ command: e.target.value }) },
|
|
1693
|
+
}),
|
|
1694
|
+
) : createElement('div', { style: fieldStyle, key: 'f-url' },
|
|
1695
|
+
createElement('label', { style: labelStyle }, 'url(MCP 端点)'),
|
|
1696
|
+
createElement('input', {
|
|
1697
|
+
className: 'input',
|
|
1698
|
+
value: d.url,
|
|
1699
|
+
placeholder: 'http://localhost:3000/mcp',
|
|
1700
|
+
onChange: function (e) { patchDraft({ url: e.target.value }) },
|
|
1701
|
+
}),
|
|
1702
|
+
),
|
|
1703
|
+
d.transport === 'streamable-http' ? createElement('div', { style: fieldStyle, key: 'f-headers' },
|
|
1704
|
+
createElement('label', { style: labelStyle }, 'headers(每行 KEY=VALUE,可选)'),
|
|
1705
|
+
createElement('textarea', {
|
|
1706
|
+
className: 'input',
|
|
1707
|
+
style: { minHeight: '48px' },
|
|
1708
|
+
value: d.headers,
|
|
1709
|
+
onChange: function (e) { patchDraft({ headers: e.target.value, headersChanged: true }) },
|
|
1710
|
+
}),
|
|
1711
|
+
) : null,
|
|
1712
|
+
d.transport === 'stdio' ? createElement('div', { style: fieldStyle, key: 'f-args' },
|
|
1713
|
+
createElement('label', { style: labelStyle }, 'args(空格分隔,可选)'),
|
|
1714
|
+
createElement('input', {
|
|
1715
|
+
className: 'input',
|
|
1716
|
+
value: d.args,
|
|
1717
|
+
onChange: function (e) { patchDraft({ args: e.target.value, argsChanged: true }) },
|
|
1718
|
+
}),
|
|
1719
|
+
) : null,
|
|
1720
|
+
d.transport === 'stdio' ? createElement('div', { style: fieldStyle, key: 'f-env' },
|
|
1721
|
+
createElement('label', { style: labelStyle }, 'env(每行 KEY=VALUE,可选)'),
|
|
1722
|
+
createElement('textarea', {
|
|
1723
|
+
className: 'input',
|
|
1724
|
+
style: { minHeight: '48px' },
|
|
1725
|
+
value: d.env,
|
|
1726
|
+
onChange: function (e) { patchDraft({ env: e.target.value, envChanged: true }) },
|
|
1727
|
+
}),
|
|
1728
|
+
) : null,
|
|
1729
|
+
createElement('div', { style: { display: 'flex', alignItems: 'center', gap: '6px', padding: '4px 0', marginBottom: '4px', borderTop: '1px solid var(--dsw-alias-border-subtle, rgba(200,200,210,0.3))', paddingTop: '8px' }, key: 'f-reconnect-header' },
|
|
1730
|
+
createElement('input', {
|
|
1731
|
+
type: 'checkbox',
|
|
1732
|
+
id: 'reconnect-toggle',
|
|
1733
|
+
checked: d.reconnectEnabled,
|
|
1734
|
+
onChange: function (e) { patchDraft({ reconnectEnabled: e.target.checked }) },
|
|
1735
|
+
style: { margin: '0' },
|
|
1736
|
+
}),
|
|
1737
|
+
createElement('label', { htmlFor: 'reconnect-toggle', style: { fontSize: '12px', fontWeight: 500, cursor: 'pointer', color: 'var(--dsw-alias-label-primary, #333)' } }, '启用自动重连'),
|
|
1738
|
+
),
|
|
1739
|
+
d.reconnectEnabled ? createElement('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '8px', marginBottom: '8px', paddingLeft: '4px' }, key: 'f-reconnect-fields' },
|
|
1740
|
+
createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: '2px', flex: '1 1 120px' }, key: 'f-reconnect-id' },
|
|
1741
|
+
createElement('label', { style: { fontSize: '10px', color: 'var(--dsw-alias-label-secondary, #666)' } }, 'initialDelayMs'),
|
|
1742
|
+
createElement('input', {
|
|
1743
|
+
className: 'input',
|
|
1744
|
+
type: 'number',
|
|
1745
|
+
min: 0,
|
|
1746
|
+
value: d.reconnectInitialDelayMs,
|
|
1747
|
+
onChange: function (e) { patchDraft({ reconnectInitialDelayMs: Number(e.target.value) }) },
|
|
1748
|
+
}),
|
|
1749
|
+
),
|
|
1750
|
+
createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: '2px', flex: '1 1 120px' }, key: 'f-reconnect-md' },
|
|
1751
|
+
createElement('label', { style: { fontSize: '10px', color: 'var(--dsw-alias-label-secondary, #666)' } }, 'maxDelayMs'),
|
|
1752
|
+
createElement('input', {
|
|
1753
|
+
className: 'input',
|
|
1754
|
+
type: 'number',
|
|
1755
|
+
min: 0,
|
|
1756
|
+
value: d.reconnectMaxDelayMs,
|
|
1757
|
+
onChange: function (e) { patchDraft({ reconnectMaxDelayMs: Number(e.target.value) }) },
|
|
1758
|
+
}),
|
|
1759
|
+
),
|
|
1760
|
+
createElement('div', { style: { display: 'flex', flexDirection: 'column', gap: '2px', flex: '1 1 120px' }, key: 'f-reconnect-ma' },
|
|
1761
|
+
createElement('label', { style: { fontSize: '10px', color: 'var(--dsw-alias-label-secondary, #666)' } }, 'maxAttempts'),
|
|
1762
|
+
createElement('input', {
|
|
1763
|
+
className: 'input',
|
|
1764
|
+
type: 'number',
|
|
1765
|
+
min: 0,
|
|
1766
|
+
value: d.reconnectMaxAttempts,
|
|
1767
|
+
onChange: function (e) { patchDraft({ reconnectMaxAttempts: Number(e.target.value) }) },
|
|
1768
|
+
}),
|
|
1769
|
+
),
|
|
1770
|
+
) : null,
|
|
1771
|
+
createElement('div', { className: 'card-actions', key: 'f-actions', style: { justifyContent: 'flex-end', gap: '6px' } },
|
|
1772
|
+
createElement('button', {
|
|
1773
|
+
type: 'button',
|
|
1774
|
+
className: 'btn',
|
|
1775
|
+
disabled: view.mcpBusy,
|
|
1776
|
+
onClick: closeMcpEditor,
|
|
1777
|
+
}, '取消'),
|
|
1778
|
+
createElement('button', {
|
|
1779
|
+
type: 'button',
|
|
1780
|
+
className: 'btn primary',
|
|
1781
|
+
disabled: view.mcpBusy || d.id.trim() === '' || d.serverName.trim() === '' ||
|
|
1782
|
+
(d.transport === 'stdio' ? d.command.trim() === '' : d.url.trim() === ''),
|
|
1783
|
+
onClick: saveMcpDraft,
|
|
1784
|
+
}, view.mcpBusy ? '保存中...' : '保存'),
|
|
1785
|
+
),
|
|
1786
|
+
)
|
|
1787
|
+
children.push(editor)
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
return createElement('div', { key: 'mcp-section', style: { display: 'flex', flexDirection: 'column', gap: '10px' } }, children)
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
// Characters allowed in an MCP entry id: [A-Za-z0-9_-]. The random part uses
|
|
1794
|
+
// alphanumerics only so the generated id reads cleanly and always matches the
|
|
1795
|
+
// host-side validation regex.
|
|
1796
|
+
var MCP_ID_ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
|
|
1797
|
+
|
|
1798
|
+
/**
|
|
1799
|
+
* Generate a fresh MCP entry id that is not already used by any listed entry
|
|
1800
|
+
* (an id collision would silently overwrite the existing entry on upsert).
|
|
1801
|
+
*/
|
|
1802
|
+
function generateMcpId(entries) {
|
|
1803
|
+
var taken = {}
|
|
1804
|
+
for (var i = 0; i < entries.length; i++) taken[entries[i].id] = true
|
|
1805
|
+
var candidate
|
|
1806
|
+
do {
|
|
1807
|
+
candidate = 'mcp-'
|
|
1808
|
+
for (var j = 0; j < 8; j++) {
|
|
1809
|
+
candidate += MCP_ID_ALPHABET.charAt(Math.floor(Math.random() * MCP_ID_ALPHABET.length))
|
|
1810
|
+
}
|
|
1811
|
+
} while (taken[candidate])
|
|
1812
|
+
return candidate
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
function mergeDraft(draft, partial) {
|
|
1816
|
+
var next = {}
|
|
1817
|
+
for (var k in draft) next[k] = draft[k]
|
|
1818
|
+
for (var pk in partial) next[pk] = partial[pk]
|
|
1819
|
+
return next
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
/** Set one entry's test status inside the shared mcpTestState map. */
|
|
1823
|
+
function mergeTestState(map, id, partial) {
|
|
1824
|
+
var next = {}
|
|
1825
|
+
for (var k in map) next[k] = map[k]
|
|
1826
|
+
next[id] = {}
|
|
1827
|
+
var cur = map[id] || {}
|
|
1828
|
+
for (var ck in cur) next[id][ck] = cur[ck]
|
|
1829
|
+
for (var pk in partial) next[id][pk] = partial[pk]
|
|
1830
|
+
return next
|
|
1831
|
+
}
|
|
1832
|
+
function renderPluginCard(plugin, view, remove, patch, upgrade) {
|
|
1833
|
+
var isConfirming = view.confirming === plugin.name
|
|
1834
|
+
|
|
1835
|
+
var titleChildren = [
|
|
1836
|
+
createElement('span', { className: 'card-title-text', key: 'name', title: plugin.name }, plugin.name),
|
|
1837
|
+
]
|
|
1838
|
+
if (plugin.version) {
|
|
1839
|
+
titleChildren.push(createElement('span', { className: 'tag version', key: 'version' }, 'v' + plugin.version))
|
|
1840
|
+
}
|
|
1841
|
+
var isLocal = Boolean(plugin.localPath)
|
|
1842
|
+
titleChildren.push(createElement('span', {
|
|
1843
|
+
className: plugin.removable ? (isLocal ? 'tag local' : 'tag plugin') : 'tag',
|
|
1844
|
+
key: 'type-tag',
|
|
1845
|
+
},
|
|
1846
|
+
plugin.removable ? (isLocal ? '本地安装' : '包安装') : '内置'
|
|
1847
|
+
))
|
|
1848
|
+
|
|
1849
|
+
// Remote update badge: only for registry-installed bundles (removable and
|
|
1850
|
+
// not a local path) after a check ran. `updates` is keyed by plugin name.
|
|
1851
|
+
var updateInfo = view.updates && view.updates[plugin.name]
|
|
1852
|
+
if (updateInfo && updateInfo.updateAvailable && updateInfo.latest) {
|
|
1853
|
+
titleChildren.push(createElement('span', {
|
|
1854
|
+
className: 'tag update',
|
|
1855
|
+
key: 'update-badge',
|
|
1856
|
+
title: '远程 registry 有新版本:v' + updateInfo.latest + '(当前 v' + plugin.version + ')'
|
|
1857
|
+
+ (typeof updateInfo.at === 'number' && updateInfo.at > 0 ? ',检测于 ' + formatTestTime(updateInfo.at) + ',更新后提醒自动消除' : ''),
|
|
1858
|
+
}, '⬆ 有新版本 v' + updateInfo.latest))
|
|
1859
|
+
} else if (updateInfo && updateInfo.error) {
|
|
1860
|
+
titleChildren.push(createElement('span', {
|
|
1861
|
+
className: 'tag update-error',
|
|
1862
|
+
key: 'update-error',
|
|
1863
|
+
title: updateInfo.error,
|
|
1864
|
+
}, '⚠ 更新检查失败'))
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
var headerChildren = [
|
|
1868
|
+
createElement('div', { className: 'card-title', key: 'title' }, titleChildren),
|
|
1869
|
+
]
|
|
1870
|
+
|
|
1871
|
+
if (plugin.removable && !isConfirming) {
|
|
1872
|
+
var actionChildren = []
|
|
1873
|
+
// 更新 button — only when an update is available and the plugin is a
|
|
1874
|
+
// registry install (not local path).
|
|
1875
|
+
if (updateInfo && updateInfo.updateAvailable && updateInfo.latest && !isLocal) {
|
|
1876
|
+
actionChildren.push(createElement('button', {
|
|
1877
|
+
type: 'button',
|
|
1878
|
+
key: 'btn-upgrade',
|
|
1879
|
+
className: 'btn sm',
|
|
1880
|
+
disabled: view.busy,
|
|
1881
|
+
title: '升级到 v' + updateInfo.latest + '(npm install ' + plugin.name + '@latest)',
|
|
1882
|
+
onClick: function () { upgrade(plugin.name) },
|
|
1883
|
+
}, '⬆ 更新'))
|
|
1884
|
+
}
|
|
1885
|
+
actionChildren.push(createElement('button', {
|
|
1886
|
+
type: 'button',
|
|
1887
|
+
key: 'btn-remove',
|
|
1888
|
+
className: 'btn danger sm',
|
|
1889
|
+
disabled: view.busy,
|
|
1890
|
+
onClick: function () { patch({ confirming: plugin.name }) },
|
|
1891
|
+
}, '卸载'))
|
|
1892
|
+
headerChildren.push(createElement('div', { className: 'card-actions', key: 'actions' }, actionChildren))
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
var header = createElement('div', { className: 'card-header', key: 'header' }, headerChildren)
|
|
1896
|
+
var cardChildren = [header]
|
|
1897
|
+
|
|
1898
|
+
if (plugin.localPath) {
|
|
1899
|
+
cardChildren.push(createElement('div', { className: 'plugin-path', key: 'path', title: plugin.localPath },
|
|
1900
|
+
'📂 ' + plugin.localPath
|
|
1901
|
+
))
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
if (isConfirming) {
|
|
1905
|
+
cardChildren.push(createElement('div', { className: 'confirm-bar', key: 'confirm' },
|
|
1906
|
+
createElement('span', { className: 'confirm-text', key: 'text' }, '⚠️ 确定要卸载该插件吗?'),
|
|
1907
|
+
createElement('div', { className: 'confirm-actions', key: 'actions' },
|
|
1908
|
+
createElement('button', {
|
|
1909
|
+
type: 'button',
|
|
1910
|
+
key: 'btn-confirm',
|
|
1911
|
+
className: 'btn danger-solid sm',
|
|
1912
|
+
disabled: view.busy,
|
|
1913
|
+
onClick: function () { remove(plugin.name) },
|
|
1914
|
+
}, '确认卸载'),
|
|
1915
|
+
createElement('button', {
|
|
1916
|
+
type: 'button',
|
|
1917
|
+
key: 'btn-cancel',
|
|
1918
|
+
className: 'btn sm',
|
|
1919
|
+
disabled: view.busy,
|
|
1920
|
+
onClick: function () { patch({ confirming: null }) },
|
|
1921
|
+
}, '取消')
|
|
1922
|
+
)
|
|
1923
|
+
))
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
return createElement('div', { key: plugin.name, className: 'card' }, cardChildren)
|
|
1927
|
+
}
|
|
1928
|
+
|
|
1929
|
+
/* ========================================================================== */
|
|
1930
|
+
/* Render Sessions View */
|
|
1931
|
+
/* ========================================================================== */
|
|
1932
|
+
|
|
1933
|
+
/**
|
|
1934
|
+
* Live-session display hint. "Online" means the session is still mounted in
|
|
1935
|
+
* the dsh host's in-memory SessionStore (created or opened at least once in
|
|
1936
|
+
* this process) — NOT that a turn is running. Online sessions can now be
|
|
1937
|
+
* closed directly: the admin panel's "关停并删除" disposes the captured agent
|
|
1938
|
+
* handle (stopping any running turn), removes the session from the store,
|
|
1939
|
+
* and then deletes the log — no restart needed.
|
|
1940
|
+
*/
|
|
1941
|
+
var LIVE_HINT = '会话在线:仍挂载于 dsh host 内存(本进程内创建或打开过的会话保持在线,不代表正在运行);可直接"关停并删除"(会中断该会话正在进行的对话)'
|
|
1942
|
+
|
|
1943
|
+
/**
|
|
1944
|
+
* Canonical session status. Live takes precedence over archived (a session
|
|
1945
|
+
* that is both live and in the archived set is shown as 会话在线); otherwise
|
|
1946
|
+
* archived wins over ended. Used by both the filter pills and the pill
|
|
1947
|
+
* counts so they can never disagree about membership.
|
|
1948
|
+
*/
|
|
1949
|
+
function sessionStatus(s) {
|
|
1950
|
+
if (s.live) return 'live'
|
|
1951
|
+
if (s.archived) return 'archived'
|
|
1952
|
+
return 'ended'
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
function filterSessions(sessions, filter, needle) {
|
|
1956
|
+
var result = []
|
|
1957
|
+
for (var i = 0; i < sessions.length; i++) {
|
|
1958
|
+
var s = sessions[i]
|
|
1959
|
+
if (filter !== 'all' && sessionStatus(s) !== filter) continue
|
|
1960
|
+
if (needle !== '') {
|
|
1961
|
+
var hay = ((s.title || '') + ' ' + (s.summary || '') + ' ' + (s.cwd || '') + ' '
|
|
1962
|
+
+ (s.workspaceTitle || '') + ' ' + s.id).toLowerCase()
|
|
1963
|
+
if (hay.indexOf(needle) === -1) continue
|
|
1964
|
+
}
|
|
1965
|
+
result.push(s)
|
|
1966
|
+
}
|
|
1967
|
+
return result
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* Display rank for the plugin list: 内置 first, then 包安装 (registry
|
|
1972
|
+
* install), then 本地安装 (local path). Host order is kept within a rank.
|
|
1973
|
+
*/
|
|
1974
|
+
function pluginSortRank(plugin) {
|
|
1975
|
+
if (!plugin.removable) return 0
|
|
1976
|
+
return plugin.localPath ? 2 : 1
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
/**
|
|
1980
|
+
* Filter plugin layers by the type pill and a fuzzy name/version/path query,
|
|
1981
|
+
* then sort 内置 → 包安装 → 本地安装 (stable: equal ranks keep host order).
|
|
1982
|
+
* The needle matches case-insensitively against the package name, the
|
|
1983
|
+
* installed version, and the local source path, so "tool" finds
|
|
1984
|
+
* dsh-custom-tool and "0.2" finds version rows.
|
|
1985
|
+
*/
|
|
1986
|
+
function filterPlugins(plugins, filter, needle) {
|
|
1987
|
+
var result = []
|
|
1988
|
+
for (var i = 0; i < plugins.length; i++) {
|
|
1989
|
+
var p = plugins[i]
|
|
1990
|
+
if (filter === 'plugin' && !p.removable) continue
|
|
1991
|
+
if (filter === 'builtin' && p.removable) continue
|
|
1992
|
+
if (needle !== '') {
|
|
1993
|
+
var hay = ((p.name || '') + ' ' + (p.version || '') + ' ' + (p.localPath || '')).toLowerCase()
|
|
1994
|
+
if (hay.indexOf(needle) === -1) continue
|
|
1995
|
+
}
|
|
1996
|
+
result.push(p)
|
|
1997
|
+
}
|
|
1998
|
+
return result.sort(function (a, b) { return pluginSortRank(a) - pluginSortRank(b) })
|
|
1999
|
+
}/**
|
|
2000
|
+
* Group sessions by their accounting workspace in registry order; sessions
|
|
2001
|
+
* without a workspace trail under an "未分组" bucket. Empty workspaces are
|
|
2002
|
+
* omitted so the user only sees groups that currently hold a session.
|
|
2003
|
+
*/
|
|
2004
|
+
function buildSessionGroups(filtered, workspaceOrder) {
|
|
2005
|
+
var byWs = new Map()
|
|
2006
|
+
for (var i = 0; i < workspaceOrder.length; i++) {
|
|
2007
|
+
var ws = workspaceOrder[i]
|
|
2008
|
+
byWs.set(ws.workspaceId, {
|
|
2009
|
+
workspaceId: ws.workspaceId, title: ws.title, path: ws.path, sessions: [],
|
|
2010
|
+
})
|
|
2011
|
+
}
|
|
2012
|
+
var ungrouped = []
|
|
2013
|
+
for (var j = 0; j < filtered.length; j++) {
|
|
2014
|
+
var s = filtered[j]
|
|
2015
|
+
var g = s.workspaceId ? byWs.get(s.workspaceId) : undefined
|
|
2016
|
+
if (g !== undefined) g.sessions.push(s)
|
|
2017
|
+
else ungrouped.push(s)
|
|
2018
|
+
}
|
|
2019
|
+
var groups = []
|
|
2020
|
+
for (var k = 0; k < workspaceOrder.length; k++) {
|
|
2021
|
+
var bucket = byWs.get(workspaceOrder[k].workspaceId)
|
|
2022
|
+
if (bucket !== undefined && bucket.sessions.length > 0) groups.push(bucket)
|
|
2023
|
+
}
|
|
2024
|
+
if (ungrouped.length > 0) {
|
|
2025
|
+
groups.push({ workspaceId: null, title: '未分组', path: null, sessions: ungrouped })
|
|
2026
|
+
}
|
|
2027
|
+
return groups
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
function renderSessionsView(view, patch, reload, act) {
|
|
2031
|
+
var elements = []
|
|
2032
|
+
|
|
2033
|
+
// Toolbar: full-width search with inline icon; the refresh action sits at
|
|
2034
|
+
// the row's end so the search field gets the whole width.
|
|
2035
|
+
elements.push(createElement('div', { className: 'toolbar', key: 'toolbar' },
|
|
2036
|
+
createElement('div', { className: 'search-wrap session-search', key: 'wrap' },
|
|
2037
|
+
createElement('span', { className: 'search-icon', key: 'icon' }, '🔍'),
|
|
2038
|
+
createElement('input', {
|
|
2039
|
+
className: 'input',
|
|
2040
|
+
placeholder: '搜索标题、内容摘要、目录或 Session ID...',
|
|
2041
|
+
value: view.needle,
|
|
2042
|
+
onChange: function (e) { patch({ needle: e.target.value }) },
|
|
2043
|
+
}),
|
|
2044
|
+
view.needle !== '' ? createElement('button', {
|
|
2045
|
+
type: 'button',
|
|
2046
|
+
key: 'btn-clear-search',
|
|
2047
|
+
className: 'btn sm',
|
|
2048
|
+
title: '清空搜索',
|
|
2049
|
+
onClick: function () { patch({ needle: '' }) },
|
|
2050
|
+
}, '✕') : null
|
|
2051
|
+
),
|
|
2052
|
+
createElement('button', {
|
|
2053
|
+
type: 'button',
|
|
2054
|
+
key: 'btn-refresh',
|
|
2055
|
+
className: 'btn',
|
|
2056
|
+
disabled: view.busy,
|
|
2057
|
+
onClick: reload,
|
|
2058
|
+
},
|
|
2059
|
+
view.busy ? createElement('span', { className: 'spinner', key: 'spin' }) : null,
|
|
2060
|
+
'🔄 刷新'
|
|
2061
|
+
)
|
|
2062
|
+
))
|
|
2063
|
+
|
|
2064
|
+
// Filter Pills
|
|
2065
|
+
var totalSessions = view.sessions.length
|
|
2066
|
+
var liveCount = 0
|
|
2067
|
+
var archivedCount = 0
|
|
2068
|
+
var endedCount = 0
|
|
2069
|
+
for (var i = 0; i < view.sessions.length; i++) {
|
|
2070
|
+
var s = view.sessions[i]
|
|
2071
|
+
var st = sessionStatus(s)
|
|
2072
|
+
if (st === 'live') liveCount++
|
|
2073
|
+
else if (st === 'archived') archivedCount++
|
|
2074
|
+
else endedCount++
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
elements.push(createElement('div', { className: 'filter-bar', key: 'filters' },
|
|
2078
|
+
createElement('button', {
|
|
2079
|
+
type: 'button',
|
|
2080
|
+
key: 'filter-all',
|
|
2081
|
+
className: 'pill' + (view.filter === 'all' ? ' active' : ''),
|
|
2082
|
+
onClick: function () { patch({ filter: 'all' }) },
|
|
2083
|
+
}, '全部 (' + String(totalSessions) + ')'),
|
|
2084
|
+
createElement('button', {
|
|
2085
|
+
type: 'button',
|
|
2086
|
+
key: 'filter-live',
|
|
2087
|
+
className: 'pill' + (view.filter === 'live' ? ' active' : ''),
|
|
2088
|
+
title: LIVE_HINT,
|
|
2089
|
+
onClick: function () { patch({ filter: 'live' }) },
|
|
2090
|
+
}, '在线 (' + String(liveCount) + ')'),
|
|
2091
|
+
createElement('button', {
|
|
2092
|
+
type: 'button',
|
|
2093
|
+
key: 'filter-archived',
|
|
2094
|
+
className: 'pill' + (view.filter === 'archived' ? ' active' : ''),
|
|
2095
|
+
onClick: function () { patch({ filter: 'archived' }) },
|
|
2096
|
+
}, '已归档 (' + String(archivedCount) + ')'),
|
|
2097
|
+
createElement('button', {
|
|
2098
|
+
type: 'button',
|
|
2099
|
+
key: 'filter-ended',
|
|
2100
|
+
className: 'pill' + (view.filter === 'ended' ? ' active' : ''),
|
|
2101
|
+
onClick: function () { patch({ filter: 'ended' }) },
|
|
2102
|
+
}, '已结束 (' + String(endedCount) + ')')
|
|
2103
|
+
))
|
|
2104
|
+
|
|
2105
|
+
if (view.error !== '') {
|
|
2106
|
+
elements.push(createElement('div', { className: 'error', key: 'error' }, view.error))
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
// Filter then group by workspace (registry order); sessions without an
|
|
2110
|
+
// accounting workspace trail under "未分组", matching the sidebar model.
|
|
2111
|
+
var needle = view.needle.trim().toLowerCase()
|
|
2112
|
+
var filtered = filterSessions(view.sessions, view.filter, needle)
|
|
2113
|
+
var groups = buildSessionGroups(filtered, view.workspaces || [])
|
|
2114
|
+
var rows = []
|
|
2115
|
+
for (var gi = 0; gi < groups.length; gi++) {
|
|
2116
|
+
var g = groups[gi]
|
|
2117
|
+
var groupKey = g.workspaceId === null ? 'ungrouped' : 'ws-' + g.workspaceId
|
|
2118
|
+
rows.push(createElement('div', { className: 'group-header', key: 'header-' + groupKey },
|
|
2119
|
+
createElement('span', { className: 'group-title', key: 'title' },
|
|
2120
|
+
(g.workspaceId === null ? '📂 ' : '📁 ') + (g.title || '未命名')
|
|
2121
|
+
),
|
|
2122
|
+
createElement('span', { className: 'group-count', key: 'count' }, String(g.sessions.length) + ' 个'),
|
|
2123
|
+
g.path !== null
|
|
2124
|
+
? createElement('span', { className: 'group-path', key: 'path', title: g.path }, g.path)
|
|
2125
|
+
: null
|
|
2126
|
+
))
|
|
2127
|
+
for (var si = 0; si < g.sessions.length; si++) {
|
|
2128
|
+
rows.push(renderSessionCard(g.sessions[si], view, act, patch))
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
|
|
2132
|
+
if (rows.length === 0) {
|
|
2133
|
+
rows.push(createElement('div', { className: 'empty', key: 'empty' },
|
|
2134
|
+
createElement('div', null, needle !== '' ? '🔍 无匹配的会话内容' : '💬 没有已持久化的会话')
|
|
2135
|
+
))
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
elements.push(createElement('div', { className: 'list', key: 'list' }, rows))
|
|
2139
|
+
|
|
2140
|
+
// Footer
|
|
2141
|
+
var summaryText = view.busy ? '加载中...'
|
|
2142
|
+
: '共 ' + String(totalSessions) + ' 个会话,当前展示 ' + String(filtered.length) + ' 个'
|
|
2143
|
+
|
|
2144
|
+
elements.push(createElement('div', { className: 'footer', key: 'footer' },
|
|
2145
|
+
createElement('span', { key: 'summary' }, summaryText),
|
|
2146
|
+
createElement('span', { className: 'hint', key: 'hint' }, '会话修改即时同步到侧边栏')
|
|
2147
|
+
))
|
|
2148
|
+
|
|
2149
|
+
return createElement('div', { key: 'sessions-panel', style: { display: 'flex', flexDirection: 'column', gap: '10px' } }, elements)
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
function renderSessionCard(session, view, act, patch) {
|
|
2153
|
+
var isConfirming = view.confirming === session.id
|
|
2154
|
+
var dotClass = 'dot' + (session.live ? ' live' : session.archived ? ' archived' : '')
|
|
2155
|
+
var dotTitle = session.live ? LIVE_HINT : session.archived ? '已归档' : '已结束'
|
|
2156
|
+
|
|
2157
|
+
var actions = []
|
|
2158
|
+
if (!isConfirming) {
|
|
2159
|
+
if (!session.archived && !session.live) {
|
|
2160
|
+
actions.push(createElement('button', {
|
|
2161
|
+
type: 'button',
|
|
2162
|
+
className: 'btn sm',
|
|
2163
|
+
key: 'btn-archive',
|
|
2164
|
+
disabled: view.busy,
|
|
2165
|
+
onClick: function () { act('archive', session.id) },
|
|
2166
|
+
}, '归档'))
|
|
2167
|
+
}
|
|
2168
|
+
if (session.archived) {
|
|
2169
|
+
actions.push(createElement('button', {
|
|
2170
|
+
type: 'button',
|
|
2171
|
+
className: 'btn sm',
|
|
2172
|
+
key: 'btn-unarchive',
|
|
2173
|
+
disabled: view.busy,
|
|
2174
|
+
onClick: function () { act('unarchive', session.id) },
|
|
2175
|
+
}, '取消归档'))
|
|
2176
|
+
}
|
|
2177
|
+
if (!session.live) {
|
|
2178
|
+
actions.push(createElement('button', {
|
|
2179
|
+
type: 'button',
|
|
2180
|
+
className: 'btn danger sm',
|
|
2181
|
+
key: 'btn-delete',
|
|
2182
|
+
disabled: view.busy,
|
|
2183
|
+
onClick: function () { patch({ confirming: session.id }) },
|
|
2184
|
+
}, '删除'))
|
|
2185
|
+
} else {
|
|
2186
|
+
// Online sessions can now be closed through the captured AgentHandle
|
|
2187
|
+
// (closeSession disposes the live agent/session first, so the log can
|
|
2188
|
+
// be removed without resurrection). This stops a running conversation,
|
|
2189
|
+
// so it is a destructive action with its own confirm flow.
|
|
2190
|
+
actions.push(createElement('button', {
|
|
2191
|
+
type: 'button',
|
|
2192
|
+
className: 'btn danger sm',
|
|
2193
|
+
key: 'btn-close',
|
|
2194
|
+
disabled: view.busy,
|
|
2195
|
+
title: '关停该在线会话(停止其 agent 运行)并永久删除日志记录',
|
|
2196
|
+
onClick: function () { patch({ confirming: session.id }) },
|
|
2197
|
+
}, '关停并删除'))
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
var titleChildren = [
|
|
2202
|
+
createElement('span', { className: dotClass, title: dotTitle, key: 'dot' }),
|
|
2203
|
+
createElement('div', { className: 'card-title', key: 'title' },
|
|
2204
|
+
createElement('span', { className: 'card-title-text', key: 'name', title: session.title || session.cwd },
|
|
2205
|
+
session.title || (session.cwd ? baseName(session.cwd) : '未命名会话')
|
|
2206
|
+
),
|
|
2207
|
+
session.live ? createElement('span', { className: 'tag live', key: 'tag-live', title: LIVE_HINT }, '会话在线')
|
|
2208
|
+
: session.archived ? createElement('span', { className: 'tag archived', key: 'tag-archived' }, '已归档')
|
|
2209
|
+
: null,
|
|
2210
|
+
session.messageCount > 0 ? createElement('span', { className: 'tag turns', key: 'tag-turns' }, String(session.messageCount) + ' 条消息') : null
|
|
2211
|
+
),
|
|
2212
|
+
]
|
|
2213
|
+
var headerChildren
|
|
2214
|
+
if (actions.length > 0) {
|
|
2215
|
+
headerChildren = titleChildren.concat([createElement('div', { className: 'card-actions', key: 'actions' }, actions)])
|
|
2216
|
+
} else {
|
|
2217
|
+
headerChildren = titleChildren
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
var header = createElement('div', { className: 'card-header', key: 'header' }, headerChildren)
|
|
2221
|
+
var cardChildren = [header]
|
|
2222
|
+
|
|
2223
|
+
// Content summary block
|
|
2224
|
+
if (session.summary) {
|
|
2225
|
+
cardChildren.push(createElement('div', { className: 'card-summary', key: 'summary', title: session.summary },
|
|
2226
|
+
createElement('span', { className: 'summary-icon', key: 'icon' }, '💬'),
|
|
2227
|
+
createElement('span', { className: 'summary-text', key: 'text' }, session.summary)
|
|
2228
|
+
))
|
|
2229
|
+
} else if (session.summaryError) {
|
|
2230
|
+
cardChildren.push(createElement('div', { className: 'error', key: 'summary-error' },
|
|
2231
|
+
'摘要读取失败:' + session.summaryError
|
|
2232
|
+
))
|
|
2233
|
+
}
|
|
2234
|
+
|
|
2235
|
+
// Sub metadata line
|
|
2236
|
+
var subChildren = [
|
|
2237
|
+
createElement('span', { className: 'card-sub-item', title: session.cwd || '无工作目录', key: 'path' },
|
|
2238
|
+
'📁 ' + (session.cwd ? baseName(session.cwd) + ' (' + session.cwd + ')' : '(无工作目录)')
|
|
2239
|
+
),
|
|
2240
|
+
createElement('span', { key: 'sep1' }, '·'),
|
|
2241
|
+
createElement('span', { className: 'card-sub-item', key: 'time' }, '🕒 ' + formatDate(session.createdAt)),
|
|
2242
|
+
]
|
|
2243
|
+
if (session.id) {
|
|
2244
|
+
subChildren.push(createElement('span', { key: 'sep2' }, '·'))
|
|
2245
|
+
subChildren.push(createElement('span', { className: 'card-sub-item session-id-badge', key: 'id', title: '会话 ID: ' + session.id },
|
|
2246
|
+
'🆔 ' + session.id.slice(0, 8)
|
|
2247
|
+
))
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
var sub = createElement('div', { className: 'card-sub', key: 'sub' }, subChildren)
|
|
2251
|
+
cardChildren.push(sub)
|
|
2252
|
+
|
|
2253
|
+
if (isConfirming) {
|
|
2254
|
+
cardChildren.push(createElement('div', { className: 'confirm-bar', key: 'confirm' },
|
|
2255
|
+
createElement('span', { className: 'confirm-text', key: 'text' },
|
|
2256
|
+
session.live
|
|
2257
|
+
? '⚠️ 将关停该在线会话(正在运行则会中断)并永久删除记录与日志,确定?'
|
|
2258
|
+
: '⚠️ 确定永久删除该会话记录及日志文件?'),
|
|
2259
|
+
createElement('div', { className: 'confirm-actions', key: 'actions' },
|
|
2260
|
+
createElement('button', {
|
|
2261
|
+
type: 'button',
|
|
2262
|
+
key: 'btn-confirm',
|
|
2263
|
+
className: 'btn danger-solid sm',
|
|
2264
|
+
disabled: view.busy,
|
|
2265
|
+
onClick: function () { act(session.live ? 'closeSession' : 'deleteSession', session.id) },
|
|
2266
|
+
}, '确认删除'),
|
|
2267
|
+
createElement('button', {
|
|
2268
|
+
type: 'button',
|
|
2269
|
+
key: 'btn-cancel',
|
|
2270
|
+
className: 'btn sm',
|
|
2271
|
+
disabled: view.busy,
|
|
2272
|
+
onClick: function () { patch({ confirming: null }) },
|
|
2273
|
+
}, '取消')
|
|
2274
|
+
)
|
|
2275
|
+
))
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
return createElement('div', { key: session.id, className: 'card' }, cardChildren)
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
/* ========================================================================== */
|
|
2282
|
+
/* Plugin Entrypoint */
|
|
2283
|
+
/* ========================================================================== */
|
|
2284
|
+
|
|
2285
|
+
function apply(ctx) {
|
|
2286
|
+
injectStyles()
|
|
2287
|
+
|
|
2288
|
+
var call = function (method, args) {
|
|
2289
|
+
return ctx.connection.rpc.call('/api', method, { args: args })
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2292
|
+
// Sidebar right-click menus: delete session (after archive) on session
|
|
2293
|
+
// rows, reveal in explorer on workspace rows. Mounted once for the page
|
|
2294
|
+
// lifetime; dispose when the plugin unmounts.
|
|
2295
|
+
// The sessions service lets us nudge the sidebar list after a delete so
|
|
2296
|
+
// the removed session disappears immediately instead of lingering in
|
|
2297
|
+
// "未分组" until the next reload.
|
|
2298
|
+
var refreshSessions = null
|
|
2299
|
+
try {
|
|
2300
|
+
var sessionsSvc = ctx.get && ctx.get('sessions')
|
|
2301
|
+
if (sessionsSvc && typeof sessionsSvc.refresh === 'function') {
|
|
2302
|
+
refreshSessions = function () { sessionsSvc.refresh().catch(function () {}) }
|
|
2303
|
+
}
|
|
2304
|
+
} catch (e) { refreshSessions = null }
|
|
2305
|
+
var disposeSidebar = ctx.effect(function () { return setupMenuInjection(call, refreshSessions) })
|
|
2306
|
+
|
|
2307
|
+
// Three surfaces replace the former single 管理中心 page, each parked where
|
|
2308
|
+
// the shell already renders its domain. 插件管理 joins the shell-owned 插件
|
|
2309
|
+
// section as its third tab (插件配置 0, 插件列表 10, 扩展插件 20); MCP and
|
|
2310
|
+
// sessions become standalone settings pages (MCP服务器 takes the 25 slot
|
|
2311
|
+
// right after Agent 预设; 历史会话 sorts last). inject() waits on each
|
|
2312
|
+
// slot's declaration, so registration order never matters.
|
|
2313
|
+
ctx.slots.inject('settings.plugins.tab', function () {
|
|
2314
|
+
return ctx.slots.register({
|
|
2315
|
+
name: 'settings.plugins.tab',
|
|
2316
|
+
id: 'extensions',
|
|
2317
|
+
order: 20,
|
|
2318
|
+
label: '扩展插件',
|
|
2319
|
+
inject: function () { return { call: call } },
|
|
2320
|
+
}, PluginsSection)
|
|
2321
|
+
})
|
|
2322
|
+
ctx.slots.inject('settings.section', function () {
|
|
2323
|
+
return ctx.slots.register({
|
|
2324
|
+
name: 'settings.section',
|
|
2325
|
+
id: 'mcp-servers',
|
|
2326
|
+
order: 25,
|
|
2327
|
+
label: 'MCP服务器',
|
|
2328
|
+
inject: function () { return { call: call } },
|
|
2329
|
+
}, McpSection)
|
|
2330
|
+
})
|
|
2331
|
+
ctx.slots.inject('settings.section', function () {
|
|
2332
|
+
return ctx.slots.register({
|
|
2333
|
+
name: 'settings.section',
|
|
2334
|
+
id: 'session-history',
|
|
2335
|
+
order: 100,
|
|
2336
|
+
label: '历史会话',
|
|
2337
|
+
inject: function () { return { call: call, refreshSessions: refreshSessions } },
|
|
2338
|
+
}, SessionsSection)
|
|
2339
|
+
})
|
|
2340
|
+
}
|
|
2341
|
+
|
|
2342
|
+
module.exports = { apply: apply, inject: ['slots', 'connection'] }
|
|
2343
|
+
return module.exports
|
|
2344
|
+
} });
|
|
2345
|
+
|