xinyu-pro 0.22.4 → 0.22.6
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/app/api/chat/route.ts +6 -8
- package/app/api/generate-svg/route.ts +5 -7
- package/app/api/generate-theme/route.ts +5 -7
- package/app/api/plugins/scan/route.ts +6 -21
- package/app/api/suggest-fields/route.ts +5 -7
- package/app/editor/page.tsx +6 -3
- package/app/extensions/edit/[id]/page.tsx +2412 -2342
- package/app/extensions/page.tsx +1576 -1572
- package/app/page.tsx +2 -2
- package/app/settings/page.tsx +1 -1
- package/bin/cli.js +226 -211
- package/components/ui/ThemeSwitcher.tsx +39 -37
- package/lib/db.ts +6 -9
- package/lib/get-ai-config.ts +33 -0
- package/lib/plugin-files.ts +186 -186
- package/package.json +2 -3
- package/version.json +7 -6
- package/.env.example +0 -17
- package/plugins/xinyu.auto-start-and-choices.xye +0 -0
- package/plugins/xinyu.bag-system.xye +0 -0
- package/plugins/xinyu.cache-optimizer.xye +0 -0
- package/plugins/xinyu.character-studio.xye +0 -0
- package/plugins/xinyu.dice-arbiter.xye +0 -0
- package/plugins/xinyu.game-auto-start-choices.xye +0 -0
- package/plugins/xinyu.markdown-render.xye +0 -0
- package/plugins/xinyu.slot-ui-beautify.xye +0 -0
- package/plugins/xinyu.world-info.xye +0 -0
|
@@ -1,2342 +1,2412 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
4
|
-
import { useRouter, useParams } from 'next/navigation';
|
|
5
|
-
import Editor, { type OnMount } from '@monaco-editor/react';
|
|
6
|
-
import { getPlugin, updatePlugin, scanPluginSecurity } from '@/lib/storage';
|
|
7
|
-
import { parseManifestFromCode } from '@/lib/manifest-parser';
|
|
8
|
-
import { useTheme } from '@/components/ui/ThemeProvider';
|
|
9
|
-
import {
|
|
10
|
-
PluginType,
|
|
11
|
-
PluginConfigField,
|
|
12
|
-
PluginDependency,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
{ id: 'vs
|
|
55
|
-
{ id: '
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
{
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
const [
|
|
291
|
-
const [
|
|
292
|
-
const [
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
inputRef.current?.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
{
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
{
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
{
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
{
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
<div
|
|
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
|
-
<div
|
|
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
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
document.body.style.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
isDragging.current
|
|
468
|
-
|
|
469
|
-
document.body.style.
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
window.addEventListener('
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
window.removeEventListener('
|
|
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
|
-
{ name: 'xinyu.ui.
|
|
518
|
-
{ name: 'xinyu.ui.
|
|
519
|
-
{ name: 'xinyu.ui.
|
|
520
|
-
{ name: 'xinyu.ui.
|
|
521
|
-
{ name: 'xinyu.ui.
|
|
522
|
-
{ name: 'xinyu.ui.dom.
|
|
523
|
-
{ name: 'xinyu.ui.dom.
|
|
524
|
-
{ name: 'xinyu.ui.dom.
|
|
525
|
-
{ name: 'xinyu.ui.dom.
|
|
526
|
-
{ name: 'xinyu.ui.dom.
|
|
527
|
-
{ name: 'xinyu.ui.
|
|
528
|
-
{ name: 'xinyu.ui.
|
|
529
|
-
{ name: 'xinyu.ui.
|
|
530
|
-
{ name: 'xinyu.ui.
|
|
531
|
-
{ name: 'xinyu.ui.
|
|
532
|
-
{ name: 'xinyu.
|
|
533
|
-
{ name: 'xinyu.plugin.
|
|
534
|
-
{ name: 'xinyu.
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
{ name: 'xinyu.game.
|
|
545
|
-
{ name: 'xinyu.game.
|
|
546
|
-
{ name: 'xinyu.game.
|
|
547
|
-
{ name: 'xinyu.
|
|
548
|
-
{ name: 'xinyu.chat.
|
|
549
|
-
{ name: 'xinyu.
|
|
550
|
-
{ name: 'xinyu.
|
|
551
|
-
{ name: 'xinyu.
|
|
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
|
-
{ name: 'xinyu.ai.
|
|
585
|
-
{ name: 'xinyu.ai.
|
|
586
|
-
{ name: 'xinyu.ai.
|
|
587
|
-
{ name: 'xinyu.
|
|
588
|
-
{ name: 'xinyu.
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
'
|
|
593
|
-
'
|
|
594
|
-
'
|
|
595
|
-
'
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
{ name: 'xinyu.
|
|
606
|
-
{ name: 'xinyu.chat.
|
|
607
|
-
{ name: 'xinyu.
|
|
608
|
-
{ name: 'xinyu.ui.
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
'
|
|
613
|
-
'
|
|
614
|
-
'
|
|
615
|
-
'
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
const
|
|
626
|
-
const
|
|
627
|
-
const
|
|
628
|
-
const
|
|
629
|
-
const
|
|
630
|
-
const
|
|
631
|
-
const
|
|
632
|
-
const [
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
const [
|
|
636
|
-
const [
|
|
637
|
-
const [
|
|
638
|
-
const [
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
const [
|
|
644
|
-
const [
|
|
645
|
-
const [
|
|
646
|
-
const [
|
|
647
|
-
const [
|
|
648
|
-
const [
|
|
649
|
-
const [
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
const [
|
|
653
|
-
const
|
|
654
|
-
const
|
|
655
|
-
const [
|
|
656
|
-
const [
|
|
657
|
-
const [
|
|
658
|
-
const [
|
|
659
|
-
const [
|
|
660
|
-
const [
|
|
661
|
-
const [
|
|
662
|
-
const [
|
|
663
|
-
const [
|
|
664
|
-
const [
|
|
665
|
-
const [
|
|
666
|
-
const [
|
|
667
|
-
const [
|
|
668
|
-
const [
|
|
669
|
-
const [
|
|
670
|
-
const [
|
|
671
|
-
const [
|
|
672
|
-
const [
|
|
673
|
-
const [
|
|
674
|
-
const [
|
|
675
|
-
const [
|
|
676
|
-
const [
|
|
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
|
-
if (manifest.
|
|
752
|
-
if (manifest.
|
|
753
|
-
if (manifest.
|
|
754
|
-
if (manifest.
|
|
755
|
-
if (manifest.
|
|
756
|
-
if (manifest.
|
|
757
|
-
if (manifest.
|
|
758
|
-
if (manifest.
|
|
759
|
-
|
|
760
|
-
if (manifest.
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
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
|
-
const
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
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
|
-
const updated = dependencies
|
|
900
|
-
setDependencies(updated);
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
};
|
|
907
|
-
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
case '
|
|
921
|
-
case '
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
const
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
return;
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
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
|
-
|
|
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
|
-
if (manifest.
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
if (
|
|
1119
|
-
|
|
1120
|
-
if (
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
if (
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
}
|
|
1153
|
-
if (
|
|
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
|
-
|
|
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
|
-
backgroundColor:
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
}
|
|
1465
|
-
>
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
<
|
|
1504
|
-
|
|
1505
|
-
</
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
</div>
|
|
1516
|
-
<div className="grid grid-cols-2 gap-3">
|
|
1517
|
-
<div>
|
|
1518
|
-
<label className="block text-xs mb-1" style={{ color: s.textMuted }}
|
|
1519
|
-
<
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
<div
|
|
1582
|
-
<
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
{
|
|
1592
|
-
<
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
>
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
<div className="grid grid-cols-2 gap-2">
|
|
1635
|
-
<div>
|
|
1636
|
-
<label className="block text-xs mb-1" style={{ color: s.textMuted }}
|
|
1637
|
-
<
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
/>
|
|
1642
|
-
</div>
|
|
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
|
-
|
|
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
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
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
|
-
style={{
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
</
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
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
|
-
|
|
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
|
-
className="
|
|
2045
|
-
style={{
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
>
|
|
2052
|
-
<
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
<div
|
|
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
|
-
className="
|
|
2096
|
-
style={{
|
|
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
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
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
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
|
4
|
+
import { useRouter, useParams } from 'next/navigation';
|
|
5
|
+
import Editor, { type OnMount } from '@monaco-editor/react';
|
|
6
|
+
import { getPlugin, getPlugins, updatePlugin, scanPluginSecurity } from '@/lib/storage';
|
|
7
|
+
import { parseManifestFromCode } from '@/lib/manifest-parser';
|
|
8
|
+
import { useTheme } from '@/components/ui/ThemeProvider';
|
|
9
|
+
import {
|
|
10
|
+
PluginType,
|
|
11
|
+
PluginConfigField,
|
|
12
|
+
PluginDependency,
|
|
13
|
+
PluginManifest,
|
|
14
|
+
SecurityScanResult,
|
|
15
|
+
PLUGIN_TYPE_LABELS,
|
|
16
|
+
UIPermission,
|
|
17
|
+
UI_PERMISSION_LABELS,
|
|
18
|
+
} from '@/lib/plugin-types';
|
|
19
|
+
import { useToast } from '@/components/ui/ToastProvider';
|
|
20
|
+
import FullPageLoader from '@/components/FullPageLoader';
|
|
21
|
+
import PageHeader from '@/components/ui/PageHeader';
|
|
22
|
+
import { PluginIcon } from '@/components/ui/PluginIcon';
|
|
23
|
+
import { useRouterHistory } from '@/lib/router-history';
|
|
24
|
+
import MathCurveLoader from '@/components/MathCurveLoader';
|
|
25
|
+
|
|
26
|
+
// ==================== 常量 ====================
|
|
27
|
+
|
|
28
|
+
const CONFIG_FIELD_TYPES: PluginConfigField['type'][] = ['text', 'number', 'boolean', 'select', 'textarea'];
|
|
29
|
+
const CONFIG_FIELD_TYPE_LABELS: Record<PluginConfigField['type'], string> = {
|
|
30
|
+
text: '文本',
|
|
31
|
+
number: '数字',
|
|
32
|
+
boolean: '布尔',
|
|
33
|
+
select: '下拉选择',
|
|
34
|
+
textarea: '多行文本',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// ==================== 通用样式辅助 ====================
|
|
38
|
+
|
|
39
|
+
const s = {
|
|
40
|
+
bgPrimary: 'var(--color-bg-primary)',
|
|
41
|
+
bgSecondary: 'var(--color-bg-secondary)',
|
|
42
|
+
bgTertiary: 'var(--color-bg-tertiary)',
|
|
43
|
+
textPrimary: 'var(--color-text-primary)',
|
|
44
|
+
textSecondary: 'var(--color-text-secondary)',
|
|
45
|
+
textMuted: 'var(--color-text-muted)',
|
|
46
|
+
accent: 'var(--color-accent)',
|
|
47
|
+
accentHover: 'var(--color-accent-hover)',
|
|
48
|
+
border: 'var(--color-border)',
|
|
49
|
+
shadow: 'var(--color-shadow)',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Monaco Editor 可选主题 */
|
|
53
|
+
const EDITOR_THEMES = [
|
|
54
|
+
{ id: 'vs', label: '浅色', color: '#f0f0f0' },
|
|
55
|
+
{ id: 'vs-dark', label: '深色', color: '#1e1e1e' },
|
|
56
|
+
{ id: 'hc-black', label: '高对比', color: '#000000' },
|
|
57
|
+
] as const;
|
|
58
|
+
|
|
59
|
+
// ==================== 子组件 ====================
|
|
60
|
+
|
|
61
|
+
function TextField({
|
|
62
|
+
value,
|
|
63
|
+
onChange,
|
|
64
|
+
placeholder,
|
|
65
|
+
mono = false,
|
|
66
|
+
type = 'text',
|
|
67
|
+
className = '',
|
|
68
|
+
readOnly = false,
|
|
69
|
+
}: {
|
|
70
|
+
value: string;
|
|
71
|
+
onChange: (v: string) => void;
|
|
72
|
+
placeholder?: string;
|
|
73
|
+
mono?: boolean;
|
|
74
|
+
type?: string;
|
|
75
|
+
className?: string;
|
|
76
|
+
readOnly?: boolean;
|
|
77
|
+
}) {
|
|
78
|
+
return (
|
|
79
|
+
<input
|
|
80
|
+
type={type}
|
|
81
|
+
value={value}
|
|
82
|
+
onChange={(e) => onChange(e.target.value)}
|
|
83
|
+
placeholder={placeholder}
|
|
84
|
+
readOnly={readOnly}
|
|
85
|
+
className={`w-full px-3 py-1.5 rounded-lg text-sm border outline-none transition-colors ${className}`}
|
|
86
|
+
style={{
|
|
87
|
+
backgroundColor: s.bgTertiary,
|
|
88
|
+
borderColor: s.border,
|
|
89
|
+
color: s.textPrimary,
|
|
90
|
+
fontFamily: mono ? 'monospace' : 'inherit',
|
|
91
|
+
}}
|
|
92
|
+
onFocus={(e) => (e.target.style.borderColor = s.accent)}
|
|
93
|
+
onBlur={(e) => (e.target.style.borderColor = s.border)}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function TextAreaField({
|
|
99
|
+
value,
|
|
100
|
+
onChange,
|
|
101
|
+
placeholder,
|
|
102
|
+
rows = 4,
|
|
103
|
+
}: {
|
|
104
|
+
value: string;
|
|
105
|
+
onChange: (v: string) => void;
|
|
106
|
+
placeholder?: string;
|
|
107
|
+
rows?: number;
|
|
108
|
+
}) {
|
|
109
|
+
return (
|
|
110
|
+
<textarea
|
|
111
|
+
value={value}
|
|
112
|
+
onChange={(e) => onChange(e.target.value)}
|
|
113
|
+
placeholder={placeholder}
|
|
114
|
+
rows={rows}
|
|
115
|
+
className="w-full px-3 py-2 rounded-lg text-sm border outline-none transition-colors resize-y"
|
|
116
|
+
style={{
|
|
117
|
+
backgroundColor: s.bgTertiary,
|
|
118
|
+
borderColor: s.border,
|
|
119
|
+
color: s.textPrimary,
|
|
120
|
+
}}
|
|
121
|
+
onFocus={(e) => (e.target.style.borderColor = s.accent)}
|
|
122
|
+
onBlur={(e) => (e.target.style.borderColor = s.border)}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function SelectField({
|
|
128
|
+
value,
|
|
129
|
+
onChange,
|
|
130
|
+
options,
|
|
131
|
+
}: {
|
|
132
|
+
value: string;
|
|
133
|
+
onChange: (v: string) => void;
|
|
134
|
+
options: { label: string; value: string }[];
|
|
135
|
+
}) {
|
|
136
|
+
return (
|
|
137
|
+
<select
|
|
138
|
+
value={value}
|
|
139
|
+
onChange={(e) => onChange(e.target.value)}
|
|
140
|
+
className="w-full px-3 py-1.5 rounded-lg text-sm border outline-none transition-colors cursor-pointer"
|
|
141
|
+
style={{
|
|
142
|
+
backgroundColor: s.bgTertiary,
|
|
143
|
+
borderColor: s.border,
|
|
144
|
+
color: s.textPrimary,
|
|
145
|
+
}}
|
|
146
|
+
onFocus={(e) => (e.target.style.borderColor = s.accent)}
|
|
147
|
+
onBlur={(e) => (e.target.style.borderColor = s.border)}
|
|
148
|
+
>
|
|
149
|
+
{options.map((opt) => (
|
|
150
|
+
<option key={opt.value} value={opt.value}>
|
|
151
|
+
{opt.label}
|
|
152
|
+
</option>
|
|
153
|
+
))}
|
|
154
|
+
</select>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// ==================== 文件树组件 ====================
|
|
159
|
+
|
|
160
|
+
function FileTree({
|
|
161
|
+
files,
|
|
162
|
+
activeFile,
|
|
163
|
+
depth,
|
|
164
|
+
onSelect,
|
|
165
|
+
onContextMenu,
|
|
166
|
+
theme,
|
|
167
|
+
}: {
|
|
168
|
+
files: Array<{ name: string; path: string; icon: string; editable: boolean; type: 'file' | 'dir'; children?: typeof files }>;
|
|
169
|
+
activeFile: string;
|
|
170
|
+
depth: number;
|
|
171
|
+
onSelect: (path: string, editable: boolean) => void;
|
|
172
|
+
onContextMenu: (e: React.MouseEvent, file: { name: string; path: string; editable: boolean; type: 'file' | 'dir' }) => void;
|
|
173
|
+
theme: Record<string, string>;
|
|
174
|
+
}) {
|
|
175
|
+
const [expandedDirs, setExpandedDirs] = useState<Set<string>>(() => {
|
|
176
|
+
// 默认展开所有目录
|
|
177
|
+
const set = new Set<string>();
|
|
178
|
+
const collect = (items: typeof files) => {
|
|
179
|
+
for (const item of items) {
|
|
180
|
+
if (item.type === 'dir') {
|
|
181
|
+
set.add(item.path);
|
|
182
|
+
if (item.children) collect(item.children);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
collect(files);
|
|
187
|
+
return set;
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const toggleDir = (dirPath: string) => {
|
|
191
|
+
setExpandedDirs(prev => {
|
|
192
|
+
const next = new Set(prev);
|
|
193
|
+
if (next.has(dirPath)) {
|
|
194
|
+
next.delete(dirPath);
|
|
195
|
+
} else {
|
|
196
|
+
next.add(dirPath);
|
|
197
|
+
}
|
|
198
|
+
return next;
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
return (
|
|
203
|
+
<div>
|
|
204
|
+
{files.map((file) => (
|
|
205
|
+
<div key={file.path}>
|
|
206
|
+
<button
|
|
207
|
+
className="w-full text-left px-3 py-1 text-xs flex items-center gap-1.5 transition-colors"
|
|
208
|
+
style={{
|
|
209
|
+
paddingLeft: `${12 + depth * 16}px`,
|
|
210
|
+
backgroundColor: activeFile === file.path ? theme.bgTertiary : 'transparent',
|
|
211
|
+
color: activeFile === file.path ? theme.accent : theme.textSecondary,
|
|
212
|
+
cursor: 'pointer',
|
|
213
|
+
opacity: file.type === 'file' && !file.editable ? 0.6 : 1,
|
|
214
|
+
}}
|
|
215
|
+
onClick={() => {
|
|
216
|
+
if (file.type === 'dir') {
|
|
217
|
+
toggleDir(file.path);
|
|
218
|
+
} else {
|
|
219
|
+
onSelect(file.path, file.editable);
|
|
220
|
+
}
|
|
221
|
+
}}
|
|
222
|
+
onContextMenu={(e) => onContextMenu(e, file)}
|
|
223
|
+
title={file.type === 'dir' ? file.path : (file.editable ? file.path : `${file.path}(只读)`)}
|
|
224
|
+
>
|
|
225
|
+
{file.type === 'dir' ? (
|
|
226
|
+
<i
|
|
227
|
+
className="fa-solid fa-chevron-right"
|
|
228
|
+
style={{
|
|
229
|
+
fontSize: '8px',
|
|
230
|
+
width: '14px',
|
|
231
|
+
textAlign: 'center',
|
|
232
|
+
transition: 'transform 0.15s',
|
|
233
|
+
transform: expandedDirs.has(file.path) ? 'rotate(90deg)' : 'rotate(0deg)',
|
|
234
|
+
flexShrink: 0,
|
|
235
|
+
}}
|
|
236
|
+
/>
|
|
237
|
+
) : (
|
|
238
|
+
<span style={{ width: '14px', flexShrink: 0 }} />
|
|
239
|
+
)}
|
|
240
|
+
<i className={file.type === 'dir'
|
|
241
|
+
? (expandedDirs.has(file.path) ? 'fa-solid fa-folder-open' : 'fa-solid fa-folder')
|
|
242
|
+
: file.icon
|
|
243
|
+
} style={{ fontSize: '11px', width: '14px', textAlign: 'center', flexShrink: 0 }} />
|
|
244
|
+
<span className="truncate">{file.name}</span>
|
|
245
|
+
{!file.editable && file.type === 'file' && (
|
|
246
|
+
<i className="fa-solid fa-eye text-[9px] ml-auto opacity-50" />
|
|
247
|
+
)}
|
|
248
|
+
</button>
|
|
249
|
+
{file.type === 'dir' && file.children && expandedDirs.has(file.path) && (
|
|
250
|
+
<FileTree
|
|
251
|
+
files={file.children}
|
|
252
|
+
activeFile={activeFile}
|
|
253
|
+
depth={depth + 1}
|
|
254
|
+
onSelect={onSelect}
|
|
255
|
+
onContextMenu={onContextMenu}
|
|
256
|
+
theme={theme}
|
|
257
|
+
/>
|
|
258
|
+
)}
|
|
259
|
+
</div>
|
|
260
|
+
))}
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ==================== 文件树右键菜单组件 ====================
|
|
266
|
+
|
|
267
|
+
function FileContextMenu({
|
|
268
|
+
x,
|
|
269
|
+
y,
|
|
270
|
+
file,
|
|
271
|
+
activeFile,
|
|
272
|
+
onClose,
|
|
273
|
+
onNewFile,
|
|
274
|
+
onNewFolder,
|
|
275
|
+
onDelete,
|
|
276
|
+
onRename,
|
|
277
|
+
theme,
|
|
278
|
+
}: {
|
|
279
|
+
x: number;
|
|
280
|
+
y: number;
|
|
281
|
+
file: { name: string; path: string; editable: boolean; type: 'file' | 'dir' };
|
|
282
|
+
activeFile: string;
|
|
283
|
+
onClose: () => void;
|
|
284
|
+
onNewFile: (dirPath: string) => void;
|
|
285
|
+
onNewFolder: (dirPath: string) => void;
|
|
286
|
+
onDelete: (path: string) => void;
|
|
287
|
+
onRename: (oldPath: string, newPath: string) => void;
|
|
288
|
+
theme: Record<string, string>;
|
|
289
|
+
}) {
|
|
290
|
+
const [renaming, setRenaming] = useState(false);
|
|
291
|
+
const [newName, setNewName] = useState(file.name);
|
|
292
|
+
const [creating, setCreating] = useState<'file' | 'dir' | null>(null);
|
|
293
|
+
const [newItemName, setNewItemName] = useState('');
|
|
294
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
295
|
+
|
|
296
|
+
useEffect(() => {
|
|
297
|
+
if (renaming || creating) {
|
|
298
|
+
inputRef.current?.focus();
|
|
299
|
+
inputRef.current?.select();
|
|
300
|
+
}
|
|
301
|
+
}, [renaming, creating]);
|
|
302
|
+
|
|
303
|
+
const handleRenameConfirm = () => {
|
|
304
|
+
if (!newName.trim()) { setRenaming(false); return; }
|
|
305
|
+
const dir = file.path.includes('/') ? file.path.substring(0, file.path.lastIndexOf('/') + 1) : '';
|
|
306
|
+
const newPath = dir + newName.trim();
|
|
307
|
+
if (newPath === file.path) { setRenaming(false); return; }
|
|
308
|
+
onRename(file.path, newPath);
|
|
309
|
+
setRenaming(false);
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
const handleCreateConfirm = () => {
|
|
313
|
+
if (!newItemName.trim()) { setCreating(null); return; }
|
|
314
|
+
const dir = file.type === 'dir' ? file.path + '/' : (file.path.includes('/') ? file.path.substring(0, file.path.lastIndexOf('/') + 1) : '');
|
|
315
|
+
if (creating === 'file') {
|
|
316
|
+
onNewFile(dir + newItemName.trim());
|
|
317
|
+
} else {
|
|
318
|
+
onNewFolder(dir + newItemName.trim());
|
|
319
|
+
}
|
|
320
|
+
setCreating(null);
|
|
321
|
+
setNewItemName('');
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const dirPath = file.type === 'dir' ? file.path : (file.path.includes('/') ? file.path.substring(0, file.path.lastIndexOf('/')) : '');
|
|
325
|
+
|
|
326
|
+
const [contextMenuOpen, setContextMenuOpen] = useState(true);
|
|
327
|
+
|
|
328
|
+
return (
|
|
329
|
+
<>
|
|
330
|
+
<div className="fixed inset-0 z-30" onClick={() => { setContextMenuOpen(false); onClose(); }} onContextMenu={(e) => { e.preventDefault(); setContextMenuOpen(false); onClose(); }} />
|
|
331
|
+
{contextMenuOpen && (
|
|
332
|
+
<div
|
|
333
|
+
className="fixed z-40 py-1 rounded-lg shadow-lg min-w-[160px]"
|
|
334
|
+
style={{
|
|
335
|
+
left: Math.min(x, window.innerWidth - 180),
|
|
336
|
+
top: Math.min(y, window.innerHeight - 200),
|
|
337
|
+
backgroundColor: theme.bgSecondary,
|
|
338
|
+
border: `1px solid ${theme.border}`,
|
|
339
|
+
}}
|
|
340
|
+
>
|
|
341
|
+
{/* 新建文件 */}
|
|
342
|
+
<button
|
|
343
|
+
className="w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 transition-colors hover:opacity-80"
|
|
344
|
+
style={{ color: theme.textPrimary }}
|
|
345
|
+
onClick={() => { setCreating('file'); setNewItemName(''); setContextMenuOpen(false); }}
|
|
346
|
+
>
|
|
347
|
+
<i className="fa-solid fa-file-circle-plus" style={{ fontSize: '10px', width: '14px', textAlign: 'center' }} />
|
|
348
|
+
新建文件
|
|
349
|
+
</button>
|
|
350
|
+
{/* 新建文件夹 */}
|
|
351
|
+
<button
|
|
352
|
+
className="w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 transition-colors hover:opacity-80"
|
|
353
|
+
style={{ color: theme.textPrimary }}
|
|
354
|
+
onClick={() => { setCreating('dir'); setNewItemName(''); setContextMenuOpen(false); }}
|
|
355
|
+
>
|
|
356
|
+
<i className="fa-solid fa-folder-plus" style={{ fontSize: '10px', width: '14px', textAlign: 'center' }} />
|
|
357
|
+
新建文件夹
|
|
358
|
+
</button>
|
|
359
|
+
{/* 重命名 */}
|
|
360
|
+
{file.path !== 'manifest.json' && (
|
|
361
|
+
<button
|
|
362
|
+
className="w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 transition-colors hover:opacity-80"
|
|
363
|
+
style={{ color: theme.textPrimary }}
|
|
364
|
+
onClick={() => { setRenaming(true); setNewName(file.name); setContextMenuOpen(false); }}
|
|
365
|
+
>
|
|
366
|
+
<i className="fa-solid fa-pen" style={{ fontSize: '10px', width: '14px', textAlign: 'center' }} />
|
|
367
|
+
重命名
|
|
368
|
+
</button>
|
|
369
|
+
)}
|
|
370
|
+
{/* 删除 */}
|
|
371
|
+
{file.path !== 'manifest.json' && (
|
|
372
|
+
<button
|
|
373
|
+
className="w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 transition-colors hover:opacity-80"
|
|
374
|
+
style={{ color: '#e74c3c' }}
|
|
375
|
+
onClick={() => { onDelete(file.path); setContextMenuOpen(false); onClose(); }}
|
|
376
|
+
>
|
|
377
|
+
<i className="fa-solid fa-trash" style={{ fontSize: '10px', width: '14px', textAlign: 'center' }} />
|
|
378
|
+
删除
|
|
379
|
+
</button>
|
|
380
|
+
)}
|
|
381
|
+
</div>
|
|
382
|
+
)}
|
|
383
|
+
{/* 重命名输入框 */}
|
|
384
|
+
{renaming && (
|
|
385
|
+
<>
|
|
386
|
+
<div className="fixed inset-0 z-30" onClick={() => setRenaming(false)} />
|
|
387
|
+
<div
|
|
388
|
+
className="fixed z-40 p-3 rounded-lg shadow-lg"
|
|
389
|
+
style={{
|
|
390
|
+
left: Math.min(x, window.innerWidth - 250),
|
|
391
|
+
top: Math.min(y, window.innerHeight - 60),
|
|
392
|
+
backgroundColor: theme.bgSecondary,
|
|
393
|
+
border: `1px solid ${theme.border}`,
|
|
394
|
+
}}
|
|
395
|
+
>
|
|
396
|
+
<div className="text-[10px] mb-1" style={{ color: theme.textMuted }}>重命名</div>
|
|
397
|
+
<input
|
|
398
|
+
ref={inputRef}
|
|
399
|
+
value={newName}
|
|
400
|
+
onChange={(e) => setNewName(e.target.value)}
|
|
401
|
+
onKeyDown={(e) => { if (e.key === 'Enter') handleRenameConfirm(); if (e.key === 'Escape') setRenaming(false); }}
|
|
402
|
+
className="w-full px-2 py-1 rounded text-xs outline-none"
|
|
403
|
+
style={{ backgroundColor: theme.bgTertiary, color: theme.textPrimary, border: `1px solid ${theme.border}` }}
|
|
404
|
+
/>
|
|
405
|
+
</div>
|
|
406
|
+
</>
|
|
407
|
+
)}
|
|
408
|
+
{/* 新建输入框 */}
|
|
409
|
+
{creating && (
|
|
410
|
+
<>
|
|
411
|
+
<div className="fixed inset-0 z-30" onClick={() => setCreating(null)} />
|
|
412
|
+
<div
|
|
413
|
+
className="fixed z-40 p-3 rounded-lg shadow-lg"
|
|
414
|
+
style={{
|
|
415
|
+
left: Math.min(x, window.innerWidth - 250),
|
|
416
|
+
top: Math.min(y, window.innerHeight - 60),
|
|
417
|
+
backgroundColor: theme.bgSecondary,
|
|
418
|
+
border: `1px solid ${theme.border}`,
|
|
419
|
+
}}
|
|
420
|
+
>
|
|
421
|
+
<div className="text-[10px] mb-1" style={{ color: theme.textMuted }}>
|
|
422
|
+
{creating === 'file' ? '新建文件' : '新建文件夹'}(在 {dirPath || '根目录'} 下)
|
|
423
|
+
</div>
|
|
424
|
+
<input
|
|
425
|
+
ref={inputRef}
|
|
426
|
+
value={newItemName}
|
|
427
|
+
onChange={(e) => setNewItemName(e.target.value)}
|
|
428
|
+
onKeyDown={(e) => { if (e.key === 'Enter') handleCreateConfirm(); if (e.key === 'Escape') setCreating(null); }}
|
|
429
|
+
placeholder={creating === 'file' ? '文件名.js' : '文件夹名'}
|
|
430
|
+
className="w-full px-2 py-1 rounded text-xs outline-none"
|
|
431
|
+
style={{ backgroundColor: theme.bgTertiary, color: theme.textPrimary, border: `1px solid ${theme.border}` }}
|
|
432
|
+
/>
|
|
433
|
+
</div>
|
|
434
|
+
</>
|
|
435
|
+
)}
|
|
436
|
+
</>
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// ==================== 拖拽分隔条组件 ====================
|
|
441
|
+
|
|
442
|
+
function ResizableDivider({
|
|
443
|
+
onResize,
|
|
444
|
+
}: {
|
|
445
|
+
onResize: (deltaX: number) => void;
|
|
446
|
+
}) {
|
|
447
|
+
const isDragging = useRef(false);
|
|
448
|
+
const lastX = useRef(0);
|
|
449
|
+
|
|
450
|
+
const handleMouseDown = useCallback((e: React.MouseEvent) => {
|
|
451
|
+
e.preventDefault();
|
|
452
|
+
isDragging.current = true;
|
|
453
|
+
lastX.current = e.clientX;
|
|
454
|
+
document.body.style.cursor = 'col-resize';
|
|
455
|
+
document.body.style.userSelect = 'none';
|
|
456
|
+
}, []);
|
|
457
|
+
|
|
458
|
+
useEffect(() => {
|
|
459
|
+
const handleMouseMove = (e: MouseEvent) => {
|
|
460
|
+
if (!isDragging.current) return;
|
|
461
|
+
const delta = e.clientX - lastX.current;
|
|
462
|
+
lastX.current = e.clientX;
|
|
463
|
+
onResize(delta);
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
const handleMouseUp = () => {
|
|
467
|
+
if (!isDragging.current) return;
|
|
468
|
+
isDragging.current = false;
|
|
469
|
+
document.body.style.cursor = '';
|
|
470
|
+
document.body.style.userSelect = '';
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
window.addEventListener('mousemove', handleMouseMove);
|
|
474
|
+
window.addEventListener('mouseup', handleMouseUp);
|
|
475
|
+
return () => {
|
|
476
|
+
window.removeEventListener('mousemove', handleMouseMove);
|
|
477
|
+
window.removeEventListener('mouseup', handleMouseUp);
|
|
478
|
+
};
|
|
479
|
+
}, [onResize]);
|
|
480
|
+
|
|
481
|
+
return (
|
|
482
|
+
<div
|
|
483
|
+
onMouseDown={handleMouseDown}
|
|
484
|
+
className="w-1.5 shrink-0 cursor-col-resize flex items-center justify-center group relative"
|
|
485
|
+
style={{ backgroundColor: s.border }}
|
|
486
|
+
>
|
|
487
|
+
<div
|
|
488
|
+
className="absolute inset-y-0 -left-1 -right-1 z-10"
|
|
489
|
+
/>
|
|
490
|
+
<div
|
|
491
|
+
className="w-0.5 h-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity"
|
|
492
|
+
style={{ backgroundColor: s.accent }}
|
|
493
|
+
/>
|
|
494
|
+
</div>
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// ==================== 插件指南数据 ====================
|
|
499
|
+
|
|
500
|
+
interface ApiEntry {
|
|
501
|
+
name: string;
|
|
502
|
+
desc: string;
|
|
503
|
+
example?: string;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
interface PluginGuide {
|
|
507
|
+
title: string;
|
|
508
|
+
icon: string;
|
|
509
|
+
description: string;
|
|
510
|
+
availableApis: ApiEntry[];
|
|
511
|
+
bestPractices: string[];
|
|
512
|
+
codeTemplate: string;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/** 全局 API(所有插件类型通用) */
|
|
516
|
+
const GLOBAL_APIS: ApiEntry[] = [
|
|
517
|
+
{ name: 'xinyu.ui.registerSlot(slotId, html, opts)', desc: '在预定义插槽位置注入自定义 UI(12 个可用位置)', example: "xinyu.ui.registerSlot('status-bar', '<div>状态信息</div>', { priority: 1 })" },
|
|
518
|
+
{ name: 'xinyu.ui.unregisterSlot(id)', desc: '移除之前注册的插槽内容' },
|
|
519
|
+
{ name: 'xinyu.ui.showModal(options)', desc: '显示自定义模态框(支持标题、内容、按钮)', example: "xinyu.ui.showModal({ title: '标题', content: '<div>内容</div>', actions: [{ text: '确认', primary: true, onClick: function() {} }] })" },
|
|
520
|
+
{ name: 'xinyu.ui.closeModal(modalId)', desc: '关闭指定模态框,返回 showModal 的 id' },
|
|
521
|
+
{ name: 'xinyu.ui.confirm(title, msg, opts)', desc: '显示确认对话框,返回 Promise<boolean>', example: "var ok = await xinyu.ui.confirm('确认?', '描述', { danger: true })" },
|
|
522
|
+
{ name: 'xinyu.ui.dom.create(tag, attrs, children)', desc: '创建 DOM 元素代理(需要 dom:free 权限)', example: "var el = xinyu.ui.dom.create('div', { className: 'my-panel' }, 'Hello')" },
|
|
523
|
+
{ name: 'xinyu.ui.dom.append(slotId, element)', desc: '将元素追加到指定容器(支持插槽 ID)' },
|
|
524
|
+
{ name: 'xinyu.ui.dom.remove(elementId)', desc: '移除插件创建的 DOM 元素' },
|
|
525
|
+
{ name: 'xinyu.ui.dom.update(id, props)', desc: '更新元素的属性、样式、内容' },
|
|
526
|
+
{ name: 'xinyu.ui.dom.query(slotId, selector)', desc: '在容器内查询插件自己的元素' },
|
|
527
|
+
{ name: 'xinyu.ui.dom.on(id, event, handler)', desc: '为插件元素绑定事件' },
|
|
528
|
+
{ name: 'xinyu.ui.injectStyle(css)', desc: '注入自定义 CSS 样式,返回 styleId', example: "xinyu.ui.injectStyle('.my-class { color: var(--color-accent); }')" },
|
|
529
|
+
{ name: 'xinyu.ui.removeStyle(styleId)', desc: '移除之前注入的 CSS 样式' },
|
|
530
|
+
{ name: 'xinyu.ui.onHostEvent(event, handler)', desc: '监听宿主 UI 事件(message:received 等)', example: "xinyu.ui.onHostEvent('message:received', function(data) { ... })" },
|
|
531
|
+
{ name: 'xinyu.ui.offHostEvent(event, handler)', desc: '取消监听宿主事件' },
|
|
532
|
+
{ name: 'xinyu.ui.toast(message, type)', desc: '显示 Toast 通知(info/success/warning/error)' },
|
|
533
|
+
{ name: 'xinyu.plugin.storage', desc: '插件独立持久化存储(get/set/remove/keys)' },
|
|
534
|
+
{ name: 'xinyu.plugin.on(hook, handler)', desc: '注册生命周期钩子(onLoad/onUnload/onGameStart 等)' },
|
|
535
|
+
{ name: 'xinyu.utils.eventBus', desc: '插件间通信的事件总线(on/off/emit)' },
|
|
536
|
+
];
|
|
537
|
+
|
|
538
|
+
const PLUGIN_GUIDES: Record<PluginType, PluginGuide> = {
|
|
539
|
+
'game-mechanics': {
|
|
540
|
+
title: '游戏机制插件',
|
|
541
|
+
icon: '\u{1F3AE}',
|
|
542
|
+
description: '扩展游戏核心玩法,如属性系统、骰子、战斗、背包等。通过注册游戏属性和快捷指令来增强角色扮演体验。',
|
|
543
|
+
availableApis: [
|
|
544
|
+
{ name: 'xinyu.game.registerAttribute(attr)', desc: '注册游戏属性(如金币、HP),显示在游戏界面顶部', example: "xinyu.game.registerAttribute({ key: 'gold', label: '金币', type: 'number', value: 100, icon: '\uD83D\uDCB0' })" },
|
|
545
|
+
{ name: 'xinyu.game.setAttribute(key, value)', desc: '在运行时修改属性值', example: "xinyu.game.setAttribute('gold', 50)" },
|
|
546
|
+
{ name: 'xinyu.game.getAttributes()', desc: '获取所有已注册的属性列表' },
|
|
547
|
+
{ name: 'xinyu.game.getState() / setState()', desc: '读写游戏全局状态(任意键值对)' },
|
|
548
|
+
{ name: 'xinyu.chat.registerCommand(cmd)', desc: '注册快捷指令(如 /roll、/attr)', example: "xinyu.chat.registerCommand({ name: '/roll', description: '\uD83C\uDFB2', icon: '\uD83C\uDFB2', handler: function(args) { ... } })" },
|
|
549
|
+
{ name: 'xinyu.chat.insertSystemMessage()', desc: '向对话中插入系统消息(灰色居中提示)' },
|
|
550
|
+
{ name: 'xinyu.ai.onPromptBuild(fn)', desc: '在 AI 系统提示词末尾追加内容(如注入属性状态)', example: "xinyu.ai.onPromptBuild(function(prompt) { return prompt + '\\n\u5F53\u524D\u91D1\u5E01: ' + gold; })" },
|
|
551
|
+
{ name: 'xinyu.utils.rollDice(notation)', desc: '解析骰子表达式(如 2d6+3)', example: "xinyu.utils.rollDice('2d6+3') // { rolls: [3,5], modifier: 3, total: 11 }" },
|
|
552
|
+
{ name: 'xinyu.plugin.storage', desc: '插件独立持久化存储(get/set/remove/keys)' },
|
|
553
|
+
],
|
|
554
|
+
bestPractices: [
|
|
555
|
+
'在 onLoad 钩子中初始化属性和注册指令',
|
|
556
|
+
'使用 ai.onPromptBuild 将游戏状态注入 AI 提示词,让 AI 了解当前属性',
|
|
557
|
+
'用 insertSystemMessage 显示骰子结果和属性变更,而非直接修改 AI 回复',
|
|
558
|
+
'属性变更后记得调用 setAttribute 更新界面显示',
|
|
559
|
+
'使用 plugin.storage 持久化插件数据,避免数据丢失',
|
|
560
|
+
],
|
|
561
|
+
codeTemplate: `function setup(xinyu) {\n // 1. 注册游戏属性\n xinyu.game.registerAttribute({\n key: 'gold',\n label: '\u91D1\u5E01',\n type: 'number',\n value: 100,\n icon: '\uD83D\uDCB0',\n group: '\u57FA\u7840\u5C5E\u6027'\n });\n\n // 2. 注册快捷指令\n xinyu.chat.registerCommand({\n name: '/roll',\n description: '\u6295\u9AB0\u5B50',\n icon: '\uD83C\uDFB2',\n handler: function(args) {\n var result = xinyu.utils.rollDice(args || '1d20');\n xinyu.chat.insertSystemMessage(\n '\uD83C\uDFB2 ' + result.notation + ' = [' + result.rolls.join(', ') + '] = ' + result.total\n );\n }\n });\n\n // 3. 注入 AI Prompt\n xinyu.ai.onPromptBuild(function(prompt) {\n var attrs = xinyu.game.getAttributes();\n var status = attrs.map(function(a) { return a.icon + ' ' + a.label + ': ' + a.value; });\n return prompt + '\\n\\n## \u89D2\u8272\u72B6\u6001\\n' + status.join('\\n');\n });\n}`,
|
|
562
|
+
},
|
|
563
|
+
'message-render': {
|
|
564
|
+
title: '消息渲染插件',
|
|
565
|
+
icon: '\u{1F3A8}',
|
|
566
|
+
description: '自定义 AI 消息的渲染方式,如 Markdown 解析、代码高亮、特殊格式(表格、卡片)等。不影响 AI 生成内容,只改变显示效果。',
|
|
567
|
+
availableApis: [
|
|
568
|
+
{ name: 'xinyu.chat.registerMessageRenderer(matcher, renderer)', desc: '注册消息渲染器,matcher 匹配消息,renderer 返回 HTML', example: "xinyu.chat.registerMessageRenderer(\n function(msg) { return msg.role === 'assistant'; },\n function(msg) { return msg.content.replace(/\\*\\*(.+?)\\*\\*/g, '<strong>$1</strong>'); }\n)" },
|
|
569
|
+
],
|
|
570
|
+
bestPractices: [
|
|
571
|
+
'渲染器仅对 AI 消息生效(matcher 中检查 role === "assistant")',
|
|
572
|
+
'返回的 HTML 字符串会被 dangerouslySetInnerHTML 渲染,注意 XSS 安全',
|
|
573
|
+
'不要修改原始消息内容,只改变显示形式',
|
|
574
|
+
'多个渲染器按注册顺序执行,第一个匹配的生效',
|
|
575
|
+
'使用 CSS 变量保持与主题系统一致(如 var(--color-accent))',
|
|
576
|
+
],
|
|
577
|
+
codeTemplate: `function setup(xinyu) {\n function renderMarkdown(text) {\n var html = text;\n html = html.replace(/\\*\\*(.+?)\\*\\*/g, '<strong>$1</strong>');\n html = html.replace(/\\*(.+?)\\*/g, '<em>$1</em>');\n html = html.replace(/\`(.+?)\`/g, '<code style=\"background:rgba(255,255,255,0.1);padding:1px 4px;border-radius:3px;\">$1</code>');\n return html;\n }\n\n xinyu.chat.registerMessageRenderer(\n function(msg) { return msg.role === 'assistant'; },\n function(msg) { return renderMarkdown(msg.content); }\n );\n}`,
|
|
578
|
+
},
|
|
579
|
+
'ai-prompt': {
|
|
580
|
+
title: 'AI Prompt 插件',
|
|
581
|
+
icon: '\u{1F916}',
|
|
582
|
+
description: '修改 AI 的系统提示词或拦截消息流,改变 AI 的行为方式。如注入 NPC 人格、修改叙事风格、添加世界观约束等。',
|
|
583
|
+
availableApis: [
|
|
584
|
+
{ name: 'xinyu.ai.onPromptBuild(fn)', desc: '修改最终发送给 AI 的系统提示词', example: "xinyu.ai.onPromptBuild(function(prompt) { return prompt + '\\n\u989D\u5916\u89C4\u5219\uFF1A...'; })" },
|
|
585
|
+
{ name: 'xinyu.ai.onBeforeSend(fn)', desc: '在发送前修改消息数组(可添加/删除/重排消息)', example: "xinyu.ai.onBeforeSend(function(messages) { return messages; })" },
|
|
586
|
+
{ name: 'xinyu.ai.onAfterReceive(fn)', desc: '修改 AI 回复内容(后处理)', example: "xinyu.ai.onAfterReceive(function(content) { return content.replace(/xxx/g, 'yyy'); })" },
|
|
587
|
+
{ name: 'xinyu.ai.onRequestConfig(fn)', desc: '修改 AI 请求参数(temperature、maxTokens、model)', example: "xinyu.ai.onRequestConfig(function(cfg) { cfg.temperature = 0.9; return cfg; })" },
|
|
588
|
+
{ name: 'xinyu.chat.registerCommand(cmd)', desc: '注册指令来动态调整 AI 行为' },
|
|
589
|
+
{ name: 'xinyu.plugin.storage', desc: '存储 NPC 设定等持久化数据' },
|
|
590
|
+
],
|
|
591
|
+
bestPractices: [
|
|
592
|
+
'onPromptBuild 是最常用的 Hook,适合追加世界观规则和 NPC 设定',
|
|
593
|
+
'追加的提示词应简洁明确,避免过长导致 token 浪费',
|
|
594
|
+
'使用 plugin.storage 保存用户设定的 NPC 人格等数据',
|
|
595
|
+
'onAfterReceive 可用于过滤或格式化 AI 回复,但不要过度修改',
|
|
596
|
+
'onRequestConfig 可临时调整 AI 参数(如战斗场景降低 temperature)',
|
|
597
|
+
],
|
|
598
|
+
codeTemplate: `function setup(xinyu) {\n xinyu.chat.registerCommand({\n name: '/npc',\n description: '\u8BBE\u5B9A NPC \u4EBA\u683C',\n icon: '\uD83E\uDDD9',\n handler: function(args) {\n var parts = args.trim().split(/\\s+/);\n var name = parts[0];\n var personality = parts.slice(1).join(' ');\n xinyu.plugin.storage.set('npc_name', name);\n xinyu.plugin.storage.set('npc_personality', personality);\n xinyu.chat.insertSystemMessage('\uD83E\uDDD9 NPC \"' + name + '\" \u4EBA\u683C\u5DF2\u8BBE\u5B9A');\n }\n });\n\n xinyu.ai.onPromptBuild(function(prompt) {\n var npcName = xinyu.plugin.storage.get('npc_name');\n var npcPersonality = xinyu.plugin.storage.get('npc_personality');\n if (npcName && npcPersonality) {\n return prompt + '\\n\\n## NPC \u8BBE\u5B9A\\n\"' + npcName + '\": ' + npcPersonality;\n }\n return prompt;\n });\n}`,
|
|
599
|
+
},
|
|
600
|
+
'input-enhance': {
|
|
601
|
+
title: '输入增强插件',
|
|
602
|
+
icon: '\u2328\uFE0F',
|
|
603
|
+
description: '增强用户输入体验,如在输入框上方添加快捷操作按钮、自动补全、快捷指令面板等。',
|
|
604
|
+
availableApis: [
|
|
605
|
+
{ name: 'xinyu.ui.registerInputToolbarButton(btn)', desc: '在输入框上方添加快捷按钮', example: "xinyu.ui.registerInputToolbarButton({ id: 'look', label: '\u89C2\u5BDF', icon: '\uD83D\uDC40', order: 1, onClick: function() { xinyu.chat.send('\u6211\u89C2\u5BDF\u5468\u56F4\u73AF\u5883'); } })" },
|
|
606
|
+
{ name: 'xinyu.chat.send(content)', desc: '程序化发送消息(等同于用户输入)' },
|
|
607
|
+
{ name: 'xinyu.chat.registerCommand(cmd)', desc: '注册快捷指令(用户输入 /xxx 触发)' },
|
|
608
|
+
{ name: 'xinyu.ui.registerSidebarPanel(panel)', desc: '注册侧边栏面板(高级功能)' },
|
|
609
|
+
{ name: 'xinyu.ui.toast(message, type)', desc: '显示 Toast 通知' },
|
|
610
|
+
],
|
|
611
|
+
bestPractices: [
|
|
612
|
+
'工具栏按钮的 order 值越小越靠前',
|
|
613
|
+
'按钮的 onClick 中使用 xinyu.chat.send() 发送预设消息',
|
|
614
|
+
'快捷指令名以 / 开头,handler 返回值会作为系统消息显示',
|
|
615
|
+
'不要注册过多按钮(建议不超过 6 个),避免界面拥挤',
|
|
616
|
+
'使用 toast 向用户反馈操作结果',
|
|
617
|
+
],
|
|
618
|
+
codeTemplate: `function setup(xinyu) {\n xinyu.ui.registerInputToolbarButton({\n id: 'look',\n label: '\u89C2\u5BDF',\n icon: '\uD83D\uDC40',\n order: 1,\n onClick: function() {\n xinyu.chat.send('\u6211\u4ED4\u7EC6\u89C2\u5BDF\u5468\u56F4\u7684\u73AF\u5883');\n }\n });\n\n xinyu.ui.registerInputToolbarButton({\n id: 'inventory',\n label: '\u7269\u54C1',\n icon: '\uD83C\uDF92',\n order: 2,\n onClick: function() {\n xinyu.chat.send('\u6211\u68C0\u67E5\u81EA\u5DF1\u7684\u968F\u8EAB\u7269\u54C1');\n }\n });\n\n xinyu.chat.registerCommand({\n name: '/help',\n description: '\u663E\u793A\u5E2E\u52A9\u4FE1\u606F',\n icon: '\u2753',\n handler: function() {\n xinyu.chat.insertSystemMessage('\uD83D\uDCD6 \u53EF\u7528\u6307\u4EE4\uFF1A/help - \u5E2E\u52A9');\n }\n });\n}`,
|
|
619
|
+
},
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
// ==================== 主页面 ====================
|
|
623
|
+
|
|
624
|
+
function EditPluginPageContent() {
|
|
625
|
+
const { activeTheme } = useTheme();
|
|
626
|
+
const router = useRouter();
|
|
627
|
+
const { navigate, back, canGoBack } = useRouterHistory();
|
|
628
|
+
const params = useParams();
|
|
629
|
+
const editId = params.id as string;
|
|
630
|
+
const { toast } = useToast();
|
|
631
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
632
|
+
const editorRef = useRef<Parameters<OnMount>[0] | null>(null);
|
|
633
|
+
const [midWidth, setMidWidth] = useState(380);
|
|
634
|
+
|
|
635
|
+
const [loading, setLoading] = useState(true);
|
|
636
|
+
const [name, setName] = useState('');
|
|
637
|
+
const [pluginId, setPluginId] = useState('');
|
|
638
|
+
const [version, setVersion] = useState('1.0.0');
|
|
639
|
+
const [author, setAuthor] = useState('');
|
|
640
|
+
|
|
641
|
+
type XyeFileItem = { name: string; path: string; icon: string; editable: boolean; type: 'file' | 'dir'; children?: XyeFileItem[] };
|
|
642
|
+
// .xye 插件包相关状态
|
|
643
|
+
const [isXye, setIsXye] = useState(false);
|
|
644
|
+
const [xyeFiles, setXyeFiles] = useState<XyeFileItem[]>([]);
|
|
645
|
+
const [activeFile, setActiveFile] = useState<string>('');
|
|
646
|
+
const [fileContents, setFileContents] = useState<Record<string, string>>({});
|
|
647
|
+
const [fileTreeOpen, setFileTreeOpen] = useState(true);
|
|
648
|
+
const [fileTreeWidth, setFileTreeWidth] = useState(180);
|
|
649
|
+
const [entryFileName, setEntryFileName] = useState('plugin.js');
|
|
650
|
+
const [contextMenu, setContextMenu] = useState<{ x: number; y: number; file: { name: string; path: string; editable: boolean; type: 'file' | 'dir' } } | null>(null);
|
|
651
|
+
// 工具栏新建输入框状态
|
|
652
|
+
const [toolbarCreating, setToolbarCreating] = useState<'file' | 'dir' | null>(null);
|
|
653
|
+
const [toolbarNewItemName, setToolbarNewItemName] = useState('');
|
|
654
|
+
const toolbarInputRef = useRef<HTMLInputElement>(null);
|
|
655
|
+
const [icon, setIcon] = useState('');
|
|
656
|
+
const [type, setType] = useState<PluginType>('game-mechanics');
|
|
657
|
+
const [description, setDescription] = useState('');
|
|
658
|
+
const [code, setCode] = useState('');
|
|
659
|
+
const [configSchema, setConfigSchema] = useState<PluginConfigField[]>([]);
|
|
660
|
+
const [commonPermissions, setCommonPermissions] = useState<UIPermission[]>([]);
|
|
661
|
+
const [exclusivePermissions, setExclusivePermissions] = useState<UIPermission[]>([]);
|
|
662
|
+
const [requiredPermissions, setRequiredPermissions] = useState<UIPermission[]>([]);
|
|
663
|
+
const [configSectionCollapsed, setConfigSectionCollapsed] = useState(true);
|
|
664
|
+
const [collapsedConfigItems, setCollapsedConfigItems] = useState<Set<number>>(new Set());
|
|
665
|
+
const [depSectionCollapsed, setDepSectionCollapsed] = useState(true);
|
|
666
|
+
const [permSectionCollapsed, setPermSectionCollapsed] = useState(true);
|
|
667
|
+
const [dependencies, setDependencies] = useState<PluginDependency[]>([]);
|
|
668
|
+
const [depStatuses, setDepStatuses] = useState<Record<string, 'satisfied' | 'missing' | 'version_mismatch'>>({});
|
|
669
|
+
const [showAddDep, setShowAddDep] = useState(false);
|
|
670
|
+
const [newDepId, setNewDepId] = useState('');
|
|
671
|
+
const [newDepVersion, setNewDepVersion] = useState('');
|
|
672
|
+
const [newDepOptional, setNewDepOptional] = useState(false);
|
|
673
|
+
const [installedPlugins, setInstalledPlugins] = useState<PluginManifest[]>([]);
|
|
674
|
+
const [pluginPickerSearch, setPluginPickerSearch] = useState('');
|
|
675
|
+
const [saving, setSaving] = useState(false);
|
|
676
|
+
const [scanResult, setScanResult] = useState<SecurityScanResult | null>(null);
|
|
677
|
+
const [scanning, setScanning] = useState(false);
|
|
678
|
+
const [editorTheme, setEditorTheme] = useState<string>('vs-dark');
|
|
679
|
+
const [themeMenuOpen, setThemeMenuOpen] = useState(false);
|
|
680
|
+
|
|
681
|
+
// 初始化编辑器主题:跟随应用主题的 isDark 属性
|
|
682
|
+
useEffect(() => {
|
|
683
|
+
setEditorTheme(activeTheme.isDark ? 'vs-dark' : 'vs');
|
|
684
|
+
}, [activeTheme.isDark]);
|
|
685
|
+
|
|
686
|
+
// 工具栏新建输入框自动聚焦
|
|
687
|
+
useEffect(() => {
|
|
688
|
+
if (toolbarCreating) {
|
|
689
|
+
toolbarInputRef.current?.focus();
|
|
690
|
+
}
|
|
691
|
+
}, [toolbarCreating]);
|
|
692
|
+
|
|
693
|
+
const handleEditorMount: OnMount = useCallback((editor) => {
|
|
694
|
+
editorRef.current = editor;
|
|
695
|
+
}, []);
|
|
696
|
+
|
|
697
|
+
useEffect(() => {
|
|
698
|
+
async function load() {
|
|
699
|
+
const plugin = await getPlugin(editId);
|
|
700
|
+
if (!plugin) {
|
|
701
|
+
toast('插件不存在', 'error');
|
|
702
|
+
if (canGoBack()) {
|
|
703
|
+
back();
|
|
704
|
+
} else {
|
|
705
|
+
navigate('/extensions');
|
|
706
|
+
}
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
setName(plugin.name);
|
|
710
|
+
setPluginId(plugin.id);
|
|
711
|
+
setVersion(plugin.version);
|
|
712
|
+
setAuthor(plugin.author);
|
|
713
|
+
setIcon(plugin.icon || '');
|
|
714
|
+
setType(plugin.type);
|
|
715
|
+
setDescription(plugin.description);
|
|
716
|
+
setCode(plugin.code);
|
|
717
|
+
setConfigSchema(plugin.configSchema || []);
|
|
718
|
+
setCommonPermissions(plugin.commonPermissions || []);
|
|
719
|
+
setExclusivePermissions(plugin.exclusivePermissions || []);
|
|
720
|
+
setRequiredPermissions(plugin.requiredPermissions || []);
|
|
721
|
+
setDependencies(Array.isArray(plugin.dependencies) ? plugin.dependencies : []);
|
|
722
|
+
|
|
723
|
+
// 检测是否为 .xye 格式插件
|
|
724
|
+
try {
|
|
725
|
+
const res = await fetch(`/api/plugins/files-list?pluginId=${encodeURIComponent(plugin.id)}`);
|
|
726
|
+
if (res.ok) {
|
|
727
|
+
const data = await res.json();
|
|
728
|
+
if (data.isXye) {
|
|
729
|
+
setIsXye(true);
|
|
730
|
+
setXyeFiles(data.files || []);
|
|
731
|
+
// 从 codePath 提取入口文件名(如 data/plugins/x.y/index.js → index.js)
|
|
732
|
+
const entry = (plugin as unknown as Record<string, string>).codePath
|
|
733
|
+
? (plugin as unknown as Record<string, string>).codePath.split('/').pop() || 'plugin.js'
|
|
734
|
+
: 'plugin.js';
|
|
735
|
+
setEntryFileName(entry);
|
|
736
|
+
setActiveFile(entry);
|
|
737
|
+
const codeRes = await fetch(`/api/plugins/files-list?pluginId=${encodeURIComponent(plugin.id)}&path=${encodeURIComponent(entry)}`);
|
|
738
|
+
if (codeRes.ok) {
|
|
739
|
+
const codeData = await codeRes.json();
|
|
740
|
+
setCode(codeData.content);
|
|
741
|
+
setFileContents(prev => ({ ...prev, [entry]: codeData.content }));
|
|
742
|
+
}
|
|
743
|
+
// 加载 manifest.json
|
|
744
|
+
const manifestRes = await fetch(`/api/plugins/files-list?pluginId=${encodeURIComponent(plugin.id)}&path=manifest.json`);
|
|
745
|
+
if (manifestRes.ok) {
|
|
746
|
+
const manifestData = await manifestRes.json();
|
|
747
|
+
setFileContents(prev => ({ ...prev, 'manifest.json': manifestData.content }));
|
|
748
|
+
// 从 manifest.json 解析元数据填充表单
|
|
749
|
+
try {
|
|
750
|
+
const manifest = JSON.parse(manifestData.content);
|
|
751
|
+
if (manifest.name) setName(manifest.name);
|
|
752
|
+
if (manifest.version) setVersion(manifest.version);
|
|
753
|
+
if (manifest.author) setAuthor(manifest.author);
|
|
754
|
+
if (manifest.icon) setIcon(manifest.icon);
|
|
755
|
+
if (manifest.type) setType(manifest.type);
|
|
756
|
+
if (manifest.description) setDescription(manifest.description);
|
|
757
|
+
if (manifest.configSchema) setConfigSchema(manifest.configSchema);
|
|
758
|
+
if (manifest.commonPermissions) setCommonPermissions(manifest.commonPermissions);
|
|
759
|
+
if (manifest.exclusivePermissions) setExclusivePermissions(manifest.exclusivePermissions);
|
|
760
|
+
if (manifest.requiredPermissions) setRequiredPermissions(manifest.requiredPermissions);
|
|
761
|
+
if (Array.isArray(manifest.dependencies)) setDependencies(manifest.dependencies);
|
|
762
|
+
// 从 manifest.json 的 pluginEntry 字段获取入口文件名
|
|
763
|
+
if (manifest.pluginEntry) {
|
|
764
|
+
const entryName = manifest.pluginEntry.startsWith('/')
|
|
765
|
+
? manifest.pluginEntry.slice(1)
|
|
766
|
+
: manifest.pluginEntry;
|
|
767
|
+
setEntryFileName(entryName);
|
|
768
|
+
// 如果当前激活的文件是旧的 plugin.js,切换到正确的入口文件
|
|
769
|
+
if (activeFile === 'plugin.js' && entryName !== 'plugin.js') {
|
|
770
|
+
setActiveFile(entryName);
|
|
771
|
+
const entryCodeRes = await fetch(`/api/plugins/files-list?pluginId=${encodeURIComponent(plugin.id)}&path=${encodeURIComponent(entryName)}`);
|
|
772
|
+
if (entryCodeRes.ok) {
|
|
773
|
+
const entryCodeData = await entryCodeRes.json();
|
|
774
|
+
setCode(entryCodeData.content);
|
|
775
|
+
setFileContents(prev => ({ ...prev, [entryName]: entryCodeData.content }));
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
} catch { /* ignore */ }
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
} catch { /* ignore: 非 .xye 插件 */ }
|
|
784
|
+
|
|
785
|
+
setLoading(false);
|
|
786
|
+
}
|
|
787
|
+
load();
|
|
788
|
+
}, [editId, router]);
|
|
789
|
+
|
|
790
|
+
const typeOptions = Object.entries(PLUGIN_TYPE_LABELS).map(([key, val]) => ({
|
|
791
|
+
label: `${val.icon} ${val.label}`,
|
|
792
|
+
value: key,
|
|
793
|
+
}));
|
|
794
|
+
|
|
795
|
+
const handleResizeMid = useCallback((deltaX: number) => {
|
|
796
|
+
setMidWidth((prev) => Math.max(280, Math.min(600, prev + deltaX)));
|
|
797
|
+
}, []);
|
|
798
|
+
|
|
799
|
+
const handleResizeFileTree = useCallback((deltaX: number) => {
|
|
800
|
+
setFileTreeWidth((prev) => Math.max(120, Math.min(400, prev + deltaX)));
|
|
801
|
+
}, []);
|
|
802
|
+
|
|
803
|
+
const handleAddConfigField = () => {
|
|
804
|
+
setConfigSchema((prev) => [
|
|
805
|
+
...prev,
|
|
806
|
+
{ key: `field_${Date.now()}`, label: '', type: 'text', defaultValue: '' },
|
|
807
|
+
]);
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
const handleRemoveConfigField = (index: number) => {
|
|
811
|
+
setConfigSchema((prev) => prev.filter((_, i) => i !== index));
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
const handleUpdateConfigField = (index: number, field: Partial<PluginConfigField>) => {
|
|
815
|
+
setConfigSchema((prev) => prev.map((f, i) => (i === index ? { ...f, ...field } : f)));
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
// ==================== 依赖管理 ====================
|
|
819
|
+
|
|
820
|
+
const checkDependencyStatuses = useCallback(async (deps: PluginDependency[]) => {
|
|
821
|
+
const statuses: Record<string, 'satisfied' | 'missing' | 'version_mismatch'> = {};
|
|
822
|
+
for (const dep of deps) {
|
|
823
|
+
try {
|
|
824
|
+
const res = await fetch(`/api/plugins?id=${dep.pluginId}`);
|
|
825
|
+
if (!res.ok) {
|
|
826
|
+
statuses[dep.pluginId] = 'missing';
|
|
827
|
+
continue;
|
|
828
|
+
}
|
|
829
|
+
const plugin = await res.json();
|
|
830
|
+
if (dep.versionRange && plugin.version) {
|
|
831
|
+
const installed = plugin.version.replace(/^\^|~/, '').split('.').map(Number);
|
|
832
|
+
const required = dep.versionRange.replace(/^\^|~/, '').split('.').map(Number);
|
|
833
|
+
const majorOk = installed[0] === required[0];
|
|
834
|
+
const minorOk = installed[0] === required[0] ? installed[1] >= required[1] : false;
|
|
835
|
+
statuses[dep.pluginId] = (majorOk && minorOk) ? 'satisfied' : 'version_mismatch';
|
|
836
|
+
} else {
|
|
837
|
+
statuses[dep.pluginId] = 'satisfied';
|
|
838
|
+
}
|
|
839
|
+
} catch {
|
|
840
|
+
statuses[dep.pluginId] = 'missing';
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
setDepStatuses(statuses);
|
|
844
|
+
}, []);
|
|
845
|
+
|
|
846
|
+
// 加载时检查依赖状态
|
|
847
|
+
useEffect(() => {
|
|
848
|
+
if (dependencies.length > 0) {
|
|
849
|
+
checkDependencyStatuses(dependencies);
|
|
850
|
+
}
|
|
851
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
852
|
+
|
|
853
|
+
// 打开添加依赖面板时加载已安装插件列表
|
|
854
|
+
useEffect(() => {
|
|
855
|
+
if (showAddDep) {
|
|
856
|
+
getPlugins().then(setInstalledPlugins);
|
|
857
|
+
}
|
|
858
|
+
}, [showAddDep]);
|
|
859
|
+
|
|
860
|
+
const scanDependencies = useCallback(() => {
|
|
861
|
+
const regex = /(?:loadDependency|callPlugin|isPluginAvailable|getPluginExports)\s*\(\s*['"]([^'"]+)['"]/g;
|
|
862
|
+
const matches = new Set<string>();
|
|
863
|
+
let match;
|
|
864
|
+
while ((match = regex.exec(code)) !== null) {
|
|
865
|
+
matches.add(match[1]);
|
|
866
|
+
}
|
|
867
|
+
if (matches.size === 0) {
|
|
868
|
+
toast('未在代码中发现依赖调用', 'info');
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
setDependencies(prev => {
|
|
872
|
+
const existing = new Map(prev.map(d => [d.pluginId, d]));
|
|
873
|
+
for (const pluginId of Array.from(matches)) {
|
|
874
|
+
if (!existing.has(pluginId)) {
|
|
875
|
+
existing.set(pluginId, { pluginId });
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
const updated = Array.from(existing.values());
|
|
879
|
+
checkDependencyStatuses(updated);
|
|
880
|
+
return updated;
|
|
881
|
+
});
|
|
882
|
+
toast(`扫描到 ${matches.size} 个依赖`, 'success');
|
|
883
|
+
}, [code, toast, checkDependencyStatuses]);
|
|
884
|
+
|
|
885
|
+
const handleAddDependency = () => {
|
|
886
|
+
if (!newDepId.trim()) {
|
|
887
|
+
toast('请填写插件 ID', 'warning');
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
if (dependencies.some(d => d.pluginId === newDepId.trim())) {
|
|
891
|
+
toast('该依赖已存在', 'warning');
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
const newDep: PluginDependency = {
|
|
895
|
+
pluginId: newDepId.trim(),
|
|
896
|
+
...(newDepVersion.trim() ? { versionRange: newDepVersion.trim() } : {}),
|
|
897
|
+
optional: newDepOptional,
|
|
898
|
+
};
|
|
899
|
+
const updated = [...dependencies, newDep];
|
|
900
|
+
setDependencies(updated);
|
|
901
|
+
checkDependencyStatuses(updated);
|
|
902
|
+
setNewDepId('');
|
|
903
|
+
setNewDepVersion('');
|
|
904
|
+
setNewDepOptional(false);
|
|
905
|
+
setShowAddDep(false);
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
const handleRemoveDependency = (pluginId: string) => {
|
|
909
|
+
const updated = dependencies.filter(d => d.pluginId !== pluginId);
|
|
910
|
+
setDependencies(updated);
|
|
911
|
+
setDepStatuses(prev => {
|
|
912
|
+
const next = { ...prev };
|
|
913
|
+
delete next[pluginId];
|
|
914
|
+
return next;
|
|
915
|
+
});
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
const depStatusIcon = (status: string) => {
|
|
919
|
+
switch (status) {
|
|
920
|
+
case 'satisfied': return <span title="已安装" style={{ color: '#22c55e' }}>✔</span>;
|
|
921
|
+
case 'missing': return <span title="未安装" style={{ color: '#ef4444' }}>✘</span>;
|
|
922
|
+
case 'version_mismatch': return <span title="版本不匹配" style={{ color: '#f59e0b' }}>⚠</span>;
|
|
923
|
+
default: return null;
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
const depStatusLabel = (status: string) => {
|
|
928
|
+
switch (status) {
|
|
929
|
+
case 'satisfied': return '已安装';
|
|
930
|
+
case 'missing': return '未安装';
|
|
931
|
+
case 'version_mismatch': return '版本不匹配';
|
|
932
|
+
default: return '检查中...';
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
/** 切换 .xye 文件树中的活动文件 */
|
|
937
|
+
const handleFileSelect = useCallback(async (filePath: string, editable: boolean) => {
|
|
938
|
+
if (!editable) {
|
|
939
|
+
toast('该文件不可编辑(资源文件)', 'warning');
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
setActiveFile(filePath);
|
|
943
|
+
// 如果已缓存则直接使用
|
|
944
|
+
if (fileContents[filePath] !== undefined) {
|
|
945
|
+
setCode(fileContents[filePath]);
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
// 否则从服务端加载
|
|
949
|
+
try {
|
|
950
|
+
const res = await fetch(`/api/plugins/files-list?pluginId=${encodeURIComponent(pluginId)}&path=${encodeURIComponent(filePath)}`);
|
|
951
|
+
if (res.ok) {
|
|
952
|
+
const data = await res.json();
|
|
953
|
+
setCode(data.content);
|
|
954
|
+
setFileContents(prev => ({ ...prev, [filePath]: data.content }));
|
|
955
|
+
} else {
|
|
956
|
+
toast('加载文件失败', 'error');
|
|
957
|
+
}
|
|
958
|
+
} catch {
|
|
959
|
+
toast('加载文件失败', 'error');
|
|
960
|
+
}
|
|
961
|
+
}, [pluginId, fileContents]);
|
|
962
|
+
|
|
963
|
+
/** 刷新文件树 */
|
|
964
|
+
const refreshFileTree = useCallback(async () => {
|
|
965
|
+
try {
|
|
966
|
+
const res = await fetch(`/api/plugins/files-list?pluginId=${encodeURIComponent(pluginId)}`);
|
|
967
|
+
if (res.ok) {
|
|
968
|
+
const data = await res.json();
|
|
969
|
+
setXyeFiles(data.files || []);
|
|
970
|
+
}
|
|
971
|
+
} catch { /* ignore */ }
|
|
972
|
+
}, [pluginId]);
|
|
973
|
+
|
|
974
|
+
/** 新建文件 */
|
|
975
|
+
const handleCreateFile = useCallback(async (filePath: string, isDir: boolean) => {
|
|
976
|
+
try {
|
|
977
|
+
const res = await fetch(`/api/plugins/files-write?pluginId=${encodeURIComponent(pluginId)}`, {
|
|
978
|
+
method: 'POST',
|
|
979
|
+
headers: { 'Content-Type': 'application/json' },
|
|
980
|
+
body: JSON.stringify({ path: filePath, type: isDir ? 'dir' : 'file', content: '' }),
|
|
981
|
+
});
|
|
982
|
+
if (res.ok) {
|
|
983
|
+
await refreshFileTree();
|
|
984
|
+
if (!isDir) {
|
|
985
|
+
setActiveFile(filePath);
|
|
986
|
+
setCode('');
|
|
987
|
+
setFileContents(prev => ({ ...prev, [filePath]: '' }));
|
|
988
|
+
}
|
|
989
|
+
toast(isDir ? '文件夹已创建' : '文件已创建', 'success');
|
|
990
|
+
} else {
|
|
991
|
+
const err = await res.json().catch(() => ({}));
|
|
992
|
+
toast(`创建失败: ${err.error || '未知错误'}`, 'error');
|
|
993
|
+
}
|
|
994
|
+
} catch {
|
|
995
|
+
toast('创建失败', 'error');
|
|
996
|
+
}
|
|
997
|
+
}, [pluginId, refreshFileTree]);
|
|
998
|
+
|
|
999
|
+
/** 删除文件 */
|
|
1000
|
+
const handleDeleteFile = useCallback(async (filePath: string) => {
|
|
1001
|
+
try {
|
|
1002
|
+
const res = await fetch(`/api/plugins/files-write?pluginId=${encodeURIComponent(pluginId)}&path=${encodeURIComponent(filePath)}`, {
|
|
1003
|
+
method: 'DELETE',
|
|
1004
|
+
});
|
|
1005
|
+
if (res.ok) {
|
|
1006
|
+
await refreshFileTree();
|
|
1007
|
+
if (activeFile === filePath) {
|
|
1008
|
+
// 回退到入口文件
|
|
1009
|
+
const fallback = xyeFiles.find((f: XyeFileItem) => f.type === 'file' && f.editable && f.path !== filePath);
|
|
1010
|
+
if (fallback) {
|
|
1011
|
+
setActiveFile(fallback.path);
|
|
1012
|
+
setCode(fileContents[fallback.path] || '');
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
setFileContents(prev => {
|
|
1016
|
+
const next = { ...prev };
|
|
1017
|
+
delete next[filePath];
|
|
1018
|
+
return next;
|
|
1019
|
+
});
|
|
1020
|
+
toast('已删除', 'success');
|
|
1021
|
+
} else {
|
|
1022
|
+
const err = await res.json().catch(() => ({}));
|
|
1023
|
+
toast(`删除失败: ${err.error || '未知错误'}`, 'error');
|
|
1024
|
+
}
|
|
1025
|
+
} catch {
|
|
1026
|
+
toast('删除失败', 'error');
|
|
1027
|
+
}
|
|
1028
|
+
}, [pluginId, activeFile, fileContents, refreshFileTree]);
|
|
1029
|
+
|
|
1030
|
+
/** 重命名文件 */
|
|
1031
|
+
const handleRenameFile = useCallback(async (oldPath: string, newPath: string) => {
|
|
1032
|
+
try {
|
|
1033
|
+
const res = await fetch(`/api/plugins/files-write?pluginId=${encodeURIComponent(pluginId)}&path=${encodeURIComponent(oldPath)}`, {
|
|
1034
|
+
method: 'PATCH',
|
|
1035
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1036
|
+
body: JSON.stringify({ newPath }),
|
|
1037
|
+
});
|
|
1038
|
+
if (res.ok) {
|
|
1039
|
+
await refreshFileTree();
|
|
1040
|
+
if (activeFile === oldPath) {
|
|
1041
|
+
setActiveFile(newPath);
|
|
1042
|
+
const oldContent = fileContents[oldPath];
|
|
1043
|
+
if (oldContent !== undefined) {
|
|
1044
|
+
setFileContents(prev => {
|
|
1045
|
+
const next = { ...prev };
|
|
1046
|
+
delete next[oldPath];
|
|
1047
|
+
next[newPath] = oldContent;
|
|
1048
|
+
return next;
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
toast('已重命名', 'success');
|
|
1053
|
+
} else {
|
|
1054
|
+
const err = await res.json().catch(() => ({}));
|
|
1055
|
+
toast(`重命名失败: ${err.error || '未知错误'}`, 'error');
|
|
1056
|
+
}
|
|
1057
|
+
} catch {
|
|
1058
|
+
toast('重命名失败', 'error');
|
|
1059
|
+
}
|
|
1060
|
+
}, [pluginId, activeFile, fileContents, refreshFileTree]);
|
|
1061
|
+
|
|
1062
|
+
/** 上传资源文件 */
|
|
1063
|
+
const handleUploadFiles = useCallback(async (files: FileList) => {
|
|
1064
|
+
if (!files || files.length === 0) return;
|
|
1065
|
+
try {
|
|
1066
|
+
const formData = new FormData();
|
|
1067
|
+
for (let i = 0; i < files.length; i++) {
|
|
1068
|
+
formData.append('files', files[i]);
|
|
1069
|
+
}
|
|
1070
|
+
const res = await fetch(`/api/plugins/files-upload?pluginId=${encodeURIComponent(pluginId)}`, {
|
|
1071
|
+
method: 'POST',
|
|
1072
|
+
body: formData,
|
|
1073
|
+
});
|
|
1074
|
+
if (res.ok) {
|
|
1075
|
+
const data = await res.json();
|
|
1076
|
+
await refreshFileTree();
|
|
1077
|
+
toast(`已上传 ${data.count} 个文件`, 'success');
|
|
1078
|
+
} else {
|
|
1079
|
+
const err = await res.json().catch(() => ({}));
|
|
1080
|
+
toast(`上传失败: ${err.error || '未知错误'}`, 'error');
|
|
1081
|
+
}
|
|
1082
|
+
} catch {
|
|
1083
|
+
toast('上传失败', 'error');
|
|
1084
|
+
}
|
|
1085
|
+
}, [pluginId, refreshFileTree]);
|
|
1086
|
+
|
|
1087
|
+
/** 从代码注释解析 manifest 信息并填充表单(静默模式不弹 toast) */
|
|
1088
|
+
/** 解析插件信息:.xye 从 manifest.json 解析,单 JS 从代码注释解析 */
|
|
1089
|
+
const applyParsedManifest = async (silent = false) => {
|
|
1090
|
+
let count = 0;
|
|
1091
|
+
|
|
1092
|
+
if (isXye) {
|
|
1093
|
+
// .xye 插件:从 manifest.json 解析
|
|
1094
|
+
try {
|
|
1095
|
+
let manifestContent = fileContents['manifest.json'];
|
|
1096
|
+
if (!manifestContent) {
|
|
1097
|
+
const res = await fetch(`/api/plugins/files-list?pluginId=${encodeURIComponent(pluginId)}&path=manifest.json`);
|
|
1098
|
+
if (res.ok) {
|
|
1099
|
+
const data = await res.json();
|
|
1100
|
+
manifestContent = data.content;
|
|
1101
|
+
setFileContents(prev => ({ ...prev, 'manifest.json': manifestContent }));
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
if (!manifestContent) {
|
|
1105
|
+
if (!silent) toast('未找到 manifest.json', 'warning');
|
|
1106
|
+
return 0;
|
|
1107
|
+
}
|
|
1108
|
+
const manifest = JSON.parse(manifestContent);
|
|
1109
|
+
if (manifest.id && manifest.id !== pluginId) {
|
|
1110
|
+
const existing = await getPlugin(manifest.id);
|
|
1111
|
+
if (existing) {
|
|
1112
|
+
if (!silent) toast(`插件 ID「${manifest.id}」已存在,解析跳过`, 'warning');
|
|
1113
|
+
} else {
|
|
1114
|
+
setPluginId(manifest.id);
|
|
1115
|
+
count++;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
if (manifest.name) { setName(manifest.name); count++; }
|
|
1119
|
+
if (manifest.version) { setVersion(manifest.version); count++; }
|
|
1120
|
+
if (manifest.author) { setAuthor(manifest.author); count++; }
|
|
1121
|
+
if (manifest.icon) { setIcon(manifest.icon); count++; }
|
|
1122
|
+
if (manifest.type) { setType(manifest.type); count++; }
|
|
1123
|
+
if (manifest.description) { setDescription(manifest.description); count++; }
|
|
1124
|
+
if (Array.isArray(manifest.configSchema) && manifest.configSchema.length > 0) { setConfigSchema(manifest.configSchema); count++; }
|
|
1125
|
+
if (Array.isArray(manifest.commonPermissions)) { setCommonPermissions(manifest.commonPermissions); count++; }
|
|
1126
|
+
if (Array.isArray(manifest.exclusivePermissions)) { setExclusivePermissions(manifest.exclusivePermissions); count++; }
|
|
1127
|
+
if (Array.isArray(manifest.requiredPermissions)) { setRequiredPermissions(manifest.requiredPermissions); count++; }
|
|
1128
|
+
if (Array.isArray(manifest.dependencies)) { setDependencies(manifest.dependencies); count++; }
|
|
1129
|
+
} catch {
|
|
1130
|
+
if (!silent) toast('manifest.json 解析失败', 'error');
|
|
1131
|
+
return 0;
|
|
1132
|
+
}
|
|
1133
|
+
if (!silent) {
|
|
1134
|
+
toast(count > 0 ? `已从 manifest.json 解析 ${count} 项信息` : 'manifest.json 中无额外信息', count > 0 ? 'success' : 'warning');
|
|
1135
|
+
}
|
|
1136
|
+
} else {
|
|
1137
|
+
// 单 JS 插件:从代码注释解析
|
|
1138
|
+
const parsed = parseManifestFromCode(code);
|
|
1139
|
+
if (parsed.id) {
|
|
1140
|
+
if (parsed.id !== pluginId) {
|
|
1141
|
+
const existing = await getPlugin(parsed.id);
|
|
1142
|
+
if (existing) {
|
|
1143
|
+
toast(`插件 ID「${parsed.id}」已存在,解析失败`, 'error');
|
|
1144
|
+
return 0;
|
|
1145
|
+
}
|
|
1146
|
+
setPluginId(parsed.id);
|
|
1147
|
+
count++;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
if (parsed.name) { setName(parsed.name); count++; }
|
|
1151
|
+
if (parsed.version) { setVersion(parsed.version); count++; }
|
|
1152
|
+
if (parsed.author) { setAuthor(parsed.author); count++; }
|
|
1153
|
+
if (parsed.icon) { setIcon(parsed.icon); count++; }
|
|
1154
|
+
if (parsed.type) { setType(parsed.type); count++; }
|
|
1155
|
+
if (parsed.description) { setDescription(parsed.description); count++; }
|
|
1156
|
+
if (parsed.permissions?.length) { setCommonPermissions(parsed.permissions); count++; }
|
|
1157
|
+
if (parsed.exclusivePermissions?.length) { setExclusivePermissions(parsed.exclusivePermissions); count++; }
|
|
1158
|
+
if (parsed.requiredPermissions?.length) { setRequiredPermissions(parsed.requiredPermissions); count++; }
|
|
1159
|
+
if (parsed.configSchema && parsed.configSchema.length > 0) {
|
|
1160
|
+
setConfigSchema(parsed.configSchema);
|
|
1161
|
+
count += parsed.configSchema.length;
|
|
1162
|
+
}
|
|
1163
|
+
if (!silent) {
|
|
1164
|
+
if (count > 0) {
|
|
1165
|
+
toast(`已从代码注释解析 ${count} 项信息`, 'success');
|
|
1166
|
+
} else {
|
|
1167
|
+
toast('未在代码中发现 manifest 注释', 'warning');
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
return count;
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1174
|
+
const handleSave = async ({recordRouter = true, goBack = true} = {}) => {
|
|
1175
|
+
if (!name.trim() || !pluginId.trim() || !code.trim()) {
|
|
1176
|
+
toast('请填写名称、ID 和代码', 'warning');
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
// 保存前自动从代码解析 manifest 信息,直接使用解析结果构建数据
|
|
1180
|
+
const parsed = parseManifestFromCode(code);
|
|
1181
|
+
|
|
1182
|
+
// 处理 @plugin-id:代码注释中的 ID 优先,但需检查重复(排除自身)
|
|
1183
|
+
let finalId = pluginId;
|
|
1184
|
+
if (parsed.id?.trim() && parsed.id.trim() !== pluginId) {
|
|
1185
|
+
const codeId = parsed.id.trim();
|
|
1186
|
+
const existing = await getPlugin(codeId);
|
|
1187
|
+
if (existing) {
|
|
1188
|
+
toast(`插件 ID「${codeId}」已存在,请修改 @plugin-id`, 'error');
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
finalId = codeId;
|
|
1192
|
+
setPluginId(codeId);
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
const finalName = parsed.name?.trim() || name.trim();
|
|
1196
|
+
const finalVersion = parsed.version?.trim() || version.trim() || '1.0.0';
|
|
1197
|
+
const finalAuthor = parsed.author?.trim() || author.trim() || '匿名';
|
|
1198
|
+
const finalIcon = parsed.icon?.trim() || icon.trim() || undefined;
|
|
1199
|
+
const finalType = parsed.type || type;
|
|
1200
|
+
const finalDescription = parsed.description?.trim() || description.trim();
|
|
1201
|
+
const finalCommonPermissions = parsed.permissions?.length ? parsed.permissions : (commonPermissions.length > 0 ? commonPermissions : undefined);
|
|
1202
|
+
const finalExclusivePermissions = parsed.exclusivePermissions?.length ? parsed.exclusivePermissions : (exclusivePermissions.length > 0 ? exclusivePermissions : undefined);
|
|
1203
|
+
const finalRequiredPermissions = parsed.requiredPermissions?.length ? parsed.requiredPermissions : (requiredPermissions.length > 0 ? requiredPermissions : undefined);
|
|
1204
|
+
const finalConfigSchema = parsed.configSchema?.length ? parsed.configSchema : (configSchema.length > 0 ? configSchema : undefined);
|
|
1205
|
+
|
|
1206
|
+
// 同步更新表单状态(用户可见)
|
|
1207
|
+
if (parsed.name) setName(parsed.name);
|
|
1208
|
+
if (parsed.version) setVersion(parsed.version);
|
|
1209
|
+
if (parsed.author) setAuthor(parsed.author);
|
|
1210
|
+
if (parsed.icon) setIcon(parsed.icon);
|
|
1211
|
+
if (parsed.type) setType(parsed.type);
|
|
1212
|
+
if (parsed.description) setDescription(parsed.description);
|
|
1213
|
+
if (parsed.permissions?.length) setCommonPermissions(parsed.permissions);
|
|
1214
|
+
if (parsed.configSchema?.length) setConfigSchema(parsed.configSchema);
|
|
1215
|
+
|
|
1216
|
+
setSaving(true);
|
|
1217
|
+
try {
|
|
1218
|
+
// .xye 插件:保存前先从 manifest.json 自动解析最新 ID
|
|
1219
|
+
if (isXye) {
|
|
1220
|
+
const manifestContent = activeFile === 'manifest.json'
|
|
1221
|
+
? code.trim()
|
|
1222
|
+
: fileContents['manifest.json'];
|
|
1223
|
+
if (manifestContent) {
|
|
1224
|
+
try {
|
|
1225
|
+
const manifest = JSON.parse(manifestContent);
|
|
1226
|
+
if (manifest.id && manifest.id !== pluginId) {
|
|
1227
|
+
const existing = await getPlugin(manifest.id);
|
|
1228
|
+
if (existing) {
|
|
1229
|
+
toast(`插件 ID「${manifest.id}」已存在,请修改 manifest.json 中的 id`, 'error');
|
|
1230
|
+
setSaving(false);
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
finalId = manifest.id;
|
|
1234
|
+
setPluginId(manifest.id);
|
|
1235
|
+
}
|
|
1236
|
+
} catch { /* manifest 解析失败时忽略 */ }
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
// .xye 插件:保存当前活动文件到服务端
|
|
1241
|
+
if (isXye && activeFile) {
|
|
1242
|
+
const saveRes = await fetch(`/api/plugins/files-write?pluginId=${encodeURIComponent(editId)}&path=${encodeURIComponent(activeFile)}`, {
|
|
1243
|
+
method: 'PUT',
|
|
1244
|
+
headers: { 'Content-Type': 'application/json' },
|
|
1245
|
+
body: JSON.stringify({ content: code.trim() }),
|
|
1246
|
+
});
|
|
1247
|
+
if (!saveRes.ok) {
|
|
1248
|
+
toast('保存文件失败', 'error');
|
|
1249
|
+
setSaving(false);
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
// 更新缓存
|
|
1253
|
+
setFileContents(prev => ({ ...prev, [activeFile]: code.trim() }));
|
|
1254
|
+
// files-write API 在写入 manifest.json 时会自动同步数据库元数据
|
|
1255
|
+
// 对于入口文件,仍需更新数据库中的 code 字段
|
|
1256
|
+
if (activeFile === entryFileName) {
|
|
1257
|
+
const updateFields: Record<string, unknown> = { code: code.trim() };
|
|
1258
|
+
if (finalId !== editId) updateFields.newId = finalId;
|
|
1259
|
+
await updatePlugin(editId, updateFields);
|
|
1260
|
+
}
|
|
1261
|
+
} else {
|
|
1262
|
+
// 非 .xye 插件:原有逻辑
|
|
1263
|
+
const updateFields: Record<string, unknown> = {
|
|
1264
|
+
name: finalName,
|
|
1265
|
+
version: finalVersion,
|
|
1266
|
+
author: finalAuthor,
|
|
1267
|
+
type: finalType,
|
|
1268
|
+
icon: finalIcon,
|
|
1269
|
+
description: finalDescription,
|
|
1270
|
+
code: code.trim(),
|
|
1271
|
+
configSchema: finalConfigSchema,
|
|
1272
|
+
commonPermissions: finalCommonPermissions,
|
|
1273
|
+
exclusivePermissions: finalExclusivePermissions,
|
|
1274
|
+
requiredPermissions: finalRequiredPermissions,
|
|
1275
|
+
dependencies: dependencies.length > 0 ? dependencies : undefined,
|
|
1276
|
+
};
|
|
1277
|
+
// 如果 ID 发生变更,传递 newId 让后端同时更新 extensions 和 extension_bindings
|
|
1278
|
+
if (finalId !== editId) {
|
|
1279
|
+
updateFields.newId = finalId;
|
|
1280
|
+
}
|
|
1281
|
+
const ok = await updatePlugin(editId, updateFields);
|
|
1282
|
+
if (!ok) {
|
|
1283
|
+
toast('保存失败,请重试', 'error');
|
|
1284
|
+
setSaving(false);
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
toast('插件已更新', 'success');
|
|
1289
|
+
if (!goBack) return;
|
|
1290
|
+
if (canGoBack()) {
|
|
1291
|
+
back();
|
|
1292
|
+
} else {
|
|
1293
|
+
navigate('/extensions', {record: recordRouter});
|
|
1294
|
+
}
|
|
1295
|
+
router.refresh();
|
|
1296
|
+
} catch {
|
|
1297
|
+
toast('保存失败', 'error');
|
|
1298
|
+
} finally {
|
|
1299
|
+
setSaving(false);
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
const handleScan = async () => {
|
|
1304
|
+
if (!code.trim()) {
|
|
1305
|
+
toast('请先编写插件代码', 'warning');
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
setScanning(true);
|
|
1309
|
+
setScanResult(null);
|
|
1310
|
+
try {
|
|
1311
|
+
const result = await scanPluginSecurity(code, { id: pluginId, name, type, author });
|
|
1312
|
+
setScanResult(result);
|
|
1313
|
+
} catch {
|
|
1314
|
+
toast('安全检测失败', 'error');
|
|
1315
|
+
} finally {
|
|
1316
|
+
setScanning(false);
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
|
|
1320
|
+
const riskColors: Record<string, string> = { low: '#22c55e', medium: '#f59e0b', high: '#ef4444', critical: '#dc2626' };
|
|
1321
|
+
const riskLabels: Record<string, string> = { low: '低风险', medium: '中风险', high: '高风险', critical: '严重风险' };
|
|
1322
|
+
|
|
1323
|
+
if (loading) {
|
|
1324
|
+
return <FullPageLoader />;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
const codeLines = code.split('\n');
|
|
1328
|
+
|
|
1329
|
+
return (
|
|
1330
|
+
<div className="h-screen flex flex-col" style={{ backgroundColor: s.bgPrimary }}>
|
|
1331
|
+
{/* ===== 顶部导航栏 ===== */}
|
|
1332
|
+
<PageHeader
|
|
1333
|
+
title="星语 · 编辑插件"
|
|
1334
|
+
showBack={true}
|
|
1335
|
+
actions={
|
|
1336
|
+
<div className="flex items-center gap-2">
|
|
1337
|
+
<button
|
|
1338
|
+
onClick={() => navigate('/extensions/tutorial')}
|
|
1339
|
+
className="px-3 py-1.5 rounded-lg text-xs border flex items-center gap-1.5 transition-colors"
|
|
1340
|
+
style={{
|
|
1341
|
+
borderColor: s.border,
|
|
1342
|
+
color: s.textSecondary,
|
|
1343
|
+
backgroundColor: 'transparent',
|
|
1344
|
+
}}
|
|
1345
|
+
title="插件开发教程"
|
|
1346
|
+
>
|
|
1347
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
1348
|
+
<path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" />
|
|
1349
|
+
<path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" />
|
|
1350
|
+
</svg>
|
|
1351
|
+
开发教程
|
|
1352
|
+
</button>
|
|
1353
|
+
<button
|
|
1354
|
+
onClick={async () => {
|
|
1355
|
+
try {
|
|
1356
|
+
const res = await fetch(`/api/plugins/export-xye?id=${encodeURIComponent(pluginId)}`);
|
|
1357
|
+
if (!res.ok) { toast('导出失败', 'error'); return; }
|
|
1358
|
+
const blob = await res.blob();
|
|
1359
|
+
const url = URL.createObjectURL(blob);
|
|
1360
|
+
const a = document.createElement('a');
|
|
1361
|
+
a.href = url;
|
|
1362
|
+
a.download = `${pluginId}.xye`;
|
|
1363
|
+
a.click();
|
|
1364
|
+
URL.revokeObjectURL(url);
|
|
1365
|
+
toast('已导出为 .xye', 'success');
|
|
1366
|
+
} catch { toast('导出失败', 'error'); }
|
|
1367
|
+
}}
|
|
1368
|
+
className="px-3 py-1.5 rounded-lg text-xs border flex items-center gap-1.5 transition-colors"
|
|
1369
|
+
style={{
|
|
1370
|
+
borderColor: s.border,
|
|
1371
|
+
color: s.textSecondary,
|
|
1372
|
+
backgroundColor: 'transparent',
|
|
1373
|
+
}}
|
|
1374
|
+
title="导出插件为 .xye 包"
|
|
1375
|
+
>
|
|
1376
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
1377
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
1378
|
+
<polyline points="17 8 12 3 7 8" />
|
|
1379
|
+
<line x1="12" y1="3" x2="12" y2="15" />
|
|
1380
|
+
</svg>
|
|
1381
|
+
导出 .xye
|
|
1382
|
+
</button>
|
|
1383
|
+
{!isXye && (
|
|
1384
|
+
<button
|
|
1385
|
+
onClick={async () => {
|
|
1386
|
+
try {
|
|
1387
|
+
const res = await fetch(`/api/plugins/export?id=${encodeURIComponent(pluginId)}`);
|
|
1388
|
+
if (!res.ok) { toast('导出失败', 'error'); return; }
|
|
1389
|
+
const data = await res.text();
|
|
1390
|
+
const blob = new Blob([data], { type: 'application/json' });
|
|
1391
|
+
const url = URL.createObjectURL(blob);
|
|
1392
|
+
const a = document.createElement('a');
|
|
1393
|
+
a.href = url;
|
|
1394
|
+
a.download = `${pluginId}.json`;
|
|
1395
|
+
a.click();
|
|
1396
|
+
URL.revokeObjectURL(url);
|
|
1397
|
+
toast('已导出为 .json', 'success');
|
|
1398
|
+
} catch { toast('导出失败', 'error'); }
|
|
1399
|
+
}}
|
|
1400
|
+
className="px-3 py-1.5 rounded-lg text-xs border flex items-center gap-1.5 transition-colors"
|
|
1401
|
+
style={{
|
|
1402
|
+
borderColor: s.border,
|
|
1403
|
+
color: s.textMuted,
|
|
1404
|
+
backgroundColor: 'transparent',
|
|
1405
|
+
}}
|
|
1406
|
+
title="导出为 .json 文件(仅单 JS 插件可用)"
|
|
1407
|
+
>
|
|
1408
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
1409
|
+
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
|
|
1410
|
+
<polyline points="17 8 12 3 7 8" />
|
|
1411
|
+
<line x1="12" y1="3" x2="12" y2="15" />
|
|
1412
|
+
</svg>
|
|
1413
|
+
导出 .json
|
|
1414
|
+
</button>
|
|
1415
|
+
)}
|
|
1416
|
+
<button
|
|
1417
|
+
onClick={() => {
|
|
1418
|
+
const fileName = pluginId.replace(/-([a-z])/g, (_, c) => c.toUpperCase()) + '.js';
|
|
1419
|
+
const blob = new Blob([code], { type: 'text/javascript' });
|
|
1420
|
+
const url = URL.createObjectURL(blob);
|
|
1421
|
+
const a = document.createElement('a');
|
|
1422
|
+
a.href = url;
|
|
1423
|
+
a.download = fileName;
|
|
1424
|
+
a.click();
|
|
1425
|
+
URL.revokeObjectURL(url);
|
|
1426
|
+
}}
|
|
1427
|
+
className="px-3 py-1.5 rounded-lg text-xs border flex items-center gap-1.5 transition-colors"
|
|
1428
|
+
style={{
|
|
1429
|
+
borderColor: s.border,
|
|
1430
|
+
color: s.textSecondary,
|
|
1431
|
+
backgroundColor: 'transparent',
|
|
1432
|
+
}}
|
|
1433
|
+
title="仅导出插件代码为 .js 文件"
|
|
1434
|
+
>
|
|
1435
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
1436
|
+
<polyline points="16 18 22 12 16 6" />
|
|
1437
|
+
<polyline points="8 6 2 12 8 18" />
|
|
1438
|
+
</svg>
|
|
1439
|
+
导出代码
|
|
1440
|
+
</button>
|
|
1441
|
+
<button
|
|
1442
|
+
onClick={() => {
|
|
1443
|
+
navigate('/extensions', {record: false, pop: true});
|
|
1444
|
+
}}
|
|
1445
|
+
className="px-4 py-1.5 rounded-lg text-xs border transition-colors"
|
|
1446
|
+
style={{
|
|
1447
|
+
borderColor: s.border,
|
|
1448
|
+
color: s.textSecondary,
|
|
1449
|
+
backgroundColor: 'transparent',
|
|
1450
|
+
}}
|
|
1451
|
+
>
|
|
1452
|
+
取消保存
|
|
1453
|
+
</button>
|
|
1454
|
+
<button
|
|
1455
|
+
onClick={() => handleSave({recordRouter: false, goBack: false})}
|
|
1456
|
+
disabled={saving}
|
|
1457
|
+
className="px-4 py-1.5 rounded-lg text-xs border transition-colors"
|
|
1458
|
+
style={{
|
|
1459
|
+
borderColor: s.border,
|
|
1460
|
+
color: s.textSecondary,
|
|
1461
|
+
backgroundColor: 'transparent',
|
|
1462
|
+
}}
|
|
1463
|
+
>
|
|
1464
|
+
{saving ? '保存中...' : '保存插件'}
|
|
1465
|
+
</button>
|
|
1466
|
+
<button
|
|
1467
|
+
onClick={() => handleSave({recordRouter: false})}
|
|
1468
|
+
disabled={saving}
|
|
1469
|
+
className="px-5 py-1.5 rounded-lg text-xs font-bold transition-opacity"
|
|
1470
|
+
style={{
|
|
1471
|
+
backgroundColor: s.accent,
|
|
1472
|
+
color: s.bgPrimary,
|
|
1473
|
+
opacity: saving ? 0.6 : 1,
|
|
1474
|
+
}}
|
|
1475
|
+
>
|
|
1476
|
+
{saving ? '保存中...' : '完成编辑'}
|
|
1477
|
+
</button>
|
|
1478
|
+
</div>
|
|
1479
|
+
}
|
|
1480
|
+
/>
|
|
1481
|
+
|
|
1482
|
+
{/* ===== 主体:两列布局 ===== */}
|
|
1483
|
+
<div ref={containerRef} className="flex-1 flex overflow-hidden">
|
|
1484
|
+
{/* 左侧:基础信息 + 配置项 + 安全检测 */}
|
|
1485
|
+
<div
|
|
1486
|
+
className="shrink-0 overflow-y-auto"
|
|
1487
|
+
style={{
|
|
1488
|
+
width: midWidth,
|
|
1489
|
+
backgroundColor: s.bgPrimary,
|
|
1490
|
+
}}
|
|
1491
|
+
>
|
|
1492
|
+
<div className="p-5 space-y-5">
|
|
1493
|
+
{/* 基础信息 */}
|
|
1494
|
+
<div>
|
|
1495
|
+
<div className="flex items-center justify-between mb-3">
|
|
1496
|
+
<h3 className="text-sm font-bold" style={{ color: s.textPrimary }}>基础信息</h3>
|
|
1497
|
+
<button
|
|
1498
|
+
onClick={() => applyParsedManifest()}
|
|
1499
|
+
className="px-2 py-1 rounded text-xs border transition-colors"
|
|
1500
|
+
style={{ borderColor: s.border, color: s.textMuted, backgroundColor: 'transparent' }}
|
|
1501
|
+
title={isXye ? '从 manifest.json 解析插件信息' : '从代码注释中解析 @name、@version、@author、@config 等信息'}
|
|
1502
|
+
>
|
|
1503
|
+
<i className="fa-solid fa-wand-magic-sparkles" style={{ fontSize: '10px', marginRight: '4px' }} />
|
|
1504
|
+
解析插件信息
|
|
1505
|
+
</button>
|
|
1506
|
+
</div>
|
|
1507
|
+
<div className="space-y-3">
|
|
1508
|
+
<div>
|
|
1509
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>名称 *</label>
|
|
1510
|
+
<TextField value={name} onChange={setName} placeholder="插件名称" />
|
|
1511
|
+
</div>
|
|
1512
|
+
<div>
|
|
1513
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>ID *</label>
|
|
1514
|
+
<TextField value={pluginId} onChange={setPluginId} placeholder="author.plugin-name" mono readOnly className="opacity-60 cursor-not-allowed" />
|
|
1515
|
+
</div>
|
|
1516
|
+
<div className="grid grid-cols-2 gap-3">
|
|
1517
|
+
<div>
|
|
1518
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>版本</label>
|
|
1519
|
+
<TextField value={version} onChange={setVersion} placeholder="1.0.0" />
|
|
1520
|
+
</div>
|
|
1521
|
+
<div>
|
|
1522
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>作者</label>
|
|
1523
|
+
<TextField value={author} onChange={setAuthor} placeholder="作者名" />
|
|
1524
|
+
</div>
|
|
1525
|
+
</div>
|
|
1526
|
+
<div className="grid grid-cols-2 gap-3">
|
|
1527
|
+
<div>
|
|
1528
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>图标</label>
|
|
1529
|
+
<div className="flex items-center gap-2">
|
|
1530
|
+
<div
|
|
1531
|
+
className="shrink-0 w-8 h-8 rounded flex items-center justify-center"
|
|
1532
|
+
style={{ backgroundColor: s.bgTertiary }}
|
|
1533
|
+
>
|
|
1534
|
+
<PluginIcon icon={icon} pluginId={pluginId} fallback="🧩" size={20} />
|
|
1535
|
+
</div>
|
|
1536
|
+
<TextField value={icon} onChange={setIcon} placeholder="Emoji 或资源文件路径(如 icon.png)" />
|
|
1537
|
+
{isXye && (
|
|
1538
|
+
<button
|
|
1539
|
+
type="button"
|
|
1540
|
+
onClick={async () => {
|
|
1541
|
+
// 获取插件目录中的图片文件列表
|
|
1542
|
+
try {
|
|
1543
|
+
const res = await fetch(`/api/plugins/files-list?pluginId=${encodeURIComponent(pluginId)}`);
|
|
1544
|
+
if (res.ok) {
|
|
1545
|
+
const data = await res.json();
|
|
1546
|
+
const imageFiles: string[] = [];
|
|
1547
|
+
const collectImages = (files: typeof data.files) => {
|
|
1548
|
+
for (const f of files) {
|
|
1549
|
+
if (f.type === 'file' && /\.(png|jpg|jpeg|gif|svg|webp|ico)$/i.test(f.path)) {
|
|
1550
|
+
imageFiles.push(f.path);
|
|
1551
|
+
}
|
|
1552
|
+
if (f.type === 'dir' && f.children) collectImages(f.children);
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
collectImages(data.files || []);
|
|
1556
|
+
if (imageFiles.length === 0) {
|
|
1557
|
+
toast('插件目录中没有图片文件', 'warning');
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1560
|
+
const selected = prompt(`选择图标文件(输入路径):\n${imageFiles.join('\n')}`, imageFiles[0]);
|
|
1561
|
+
if (selected && imageFiles.includes(selected)) {
|
|
1562
|
+
setIcon(selected);
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
} catch { /* ignore */ }
|
|
1566
|
+
}}
|
|
1567
|
+
className="shrink-0 p-1.5 rounded text-xs border transition-colors"
|
|
1568
|
+
style={{ borderColor: s.border, color: s.textMuted, backgroundColor: 'transparent' }}
|
|
1569
|
+
title="从资源文件中选择图标"
|
|
1570
|
+
>
|
|
1571
|
+
<i className="fa-solid fa-image" style={{ fontSize: '11px' }} />
|
|
1572
|
+
</button>
|
|
1573
|
+
)}
|
|
1574
|
+
</div>
|
|
1575
|
+
</div>
|
|
1576
|
+
<div>
|
|
1577
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>类型</label>
|
|
1578
|
+
<SelectField value={type} onChange={(v) => setType(v as PluginType)} options={typeOptions} />
|
|
1579
|
+
</div>
|
|
1580
|
+
</div>
|
|
1581
|
+
<div>
|
|
1582
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>描述</label>
|
|
1583
|
+
<TextAreaField value={description} onChange={setDescription} placeholder="插件功能描述..." rows={5} />
|
|
1584
|
+
</div>
|
|
1585
|
+
</div>
|
|
1586
|
+
</div>
|
|
1587
|
+
|
|
1588
|
+
{/* 配置项定义 */}
|
|
1589
|
+
<div>
|
|
1590
|
+
<div className="flex items-center justify-between mb-2">
|
|
1591
|
+
<div className="flex items-center gap-2 cursor-pointer select-none" onClick={() => setConfigSectionCollapsed(v => !v)}>
|
|
1592
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"
|
|
1593
|
+
style={{ color: s.textMuted, transform: configSectionCollapsed ? 'rotate(-90deg)' : 'rotate(0deg)', transition: 'transform 0.15s ease' }}>
|
|
1594
|
+
<polyline points="6 9 12 15 18 9" />
|
|
1595
|
+
</svg>
|
|
1596
|
+
<h3 className="text-sm font-bold" style={{ color: s.textPrimary }}>配置项定义(可选)</h3>
|
|
1597
|
+
{configSchema.length > 0 && (
|
|
1598
|
+
<span className="text-xs px-1.5 py-0.5 rounded" style={{ backgroundColor: s.bgTertiary, color: s.textMuted }}>{configSchema.length}</span>
|
|
1599
|
+
)}
|
|
1600
|
+
</div>
|
|
1601
|
+
{!configSectionCollapsed && (
|
|
1602
|
+
<button
|
|
1603
|
+
onClick={handleAddConfigField}
|
|
1604
|
+
className="px-3 py-1 rounded-lg text-xs border"
|
|
1605
|
+
style={{ borderColor: s.accent, color: s.accent, backgroundColor: 'transparent' }}
|
|
1606
|
+
>
|
|
1607
|
+
+ 添加
|
|
1608
|
+
</button>
|
|
1609
|
+
)}
|
|
1610
|
+
</div>
|
|
1611
|
+
{!configSectionCollapsed && (
|
|
1612
|
+
configSchema.length === 0 ? (
|
|
1613
|
+
<p className="text-xs" style={{ color: s.textMuted }}>暂无配置项</p>
|
|
1614
|
+
) : (
|
|
1615
|
+
<div className="space-y-3">
|
|
1616
|
+
{configSchema.map((field, idx) => (
|
|
1617
|
+
<div key={idx} className="rounded-lg border" style={{ backgroundColor: s.bgTertiary, borderColor: s.border }}>
|
|
1618
|
+
{/* 卡片头部 */}
|
|
1619
|
+
<div className="flex items-center justify-between px-3 py-2 cursor-pointer select-none"
|
|
1620
|
+
onClick={() => setCollapsedConfigItems(prev => { const next = new Set(prev); if (next.has(idx)) { next.delete(idx); } else { next.add(idx); } return next; })}>
|
|
1621
|
+
<div className="flex items-center gap-2">
|
|
1622
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"
|
|
1623
|
+
style={{ color: s.textMuted, transform: collapsedConfigItems.has(idx) ? 'rotate(-90deg)' : 'rotate(0deg)', transition: 'transform 0.15s ease' }}>
|
|
1624
|
+
<polyline points="6 9 12 15 18 9" />
|
|
1625
|
+
</svg>
|
|
1626
|
+
<span className="text-xs font-bold" style={{ color: s.textPrimary }}>{field.label || field.key || `配置项 #${idx + 1}`}</span>
|
|
1627
|
+
<span className="text-xs" style={{ color: s.textMuted }}>{field.type}</span>
|
|
1628
|
+
</div>
|
|
1629
|
+
<button onClick={(e) => { e.stopPropagation(); handleRemoveConfigField(idx); }} className="text-xs px-2 py-0.5 rounded" style={{ color: '#ef4444' }}>删除</button>
|
|
1630
|
+
</div>
|
|
1631
|
+
{/* 卡片内容 */}
|
|
1632
|
+
{!collapsedConfigItems.has(idx) && (
|
|
1633
|
+
<div className="px-3 pb-3 space-y-2">
|
|
1634
|
+
<div className="grid grid-cols-2 gap-2">
|
|
1635
|
+
<div>
|
|
1636
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>键名</label>
|
|
1637
|
+
<TextField value={field.key} onChange={(v) => handleUpdateConfigField(idx, { key: v })} placeholder="key" mono />
|
|
1638
|
+
</div>
|
|
1639
|
+
<div>
|
|
1640
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>标签</label>
|
|
1641
|
+
<TextField value={field.label} onChange={(v) => handleUpdateConfigField(idx, { label: v })} placeholder="显示名称" />
|
|
1642
|
+
</div>
|
|
1643
|
+
</div>
|
|
1644
|
+
<div className="grid grid-cols-2 gap-2">
|
|
1645
|
+
<div>
|
|
1646
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>类型</label>
|
|
1647
|
+
<SelectField
|
|
1648
|
+
value={field.type}
|
|
1649
|
+
onChange={(v) => handleUpdateConfigField(idx, { type: v as PluginConfigField['type'] })}
|
|
1650
|
+
options={CONFIG_FIELD_TYPES.map((t) => ({ label: CONFIG_FIELD_TYPE_LABELS[t], value: t }))}
|
|
1651
|
+
/>
|
|
1652
|
+
</div>
|
|
1653
|
+
<div>
|
|
1654
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>默认值</label>
|
|
1655
|
+
{field.type === 'select' ? (
|
|
1656
|
+
<SelectField
|
|
1657
|
+
value={String(field.defaultValue ?? '')}
|
|
1658
|
+
onChange={(v) => handleUpdateConfigField(idx, { defaultValue: v })}
|
|
1659
|
+
options={[{ label: '无', value: '' }, ...(field.options || []).map(opt => ({ label: opt.label, value: opt.value }))]}
|
|
1660
|
+
/>
|
|
1661
|
+
) : field.type === 'boolean' ? (
|
|
1662
|
+
<button
|
|
1663
|
+
type="button"
|
|
1664
|
+
onClick={() => handleUpdateConfigField(idx, { defaultValue: !field.defaultValue })}
|
|
1665
|
+
className="relative w-9 h-5 rounded-full transition-colors shrink-0"
|
|
1666
|
+
style={{
|
|
1667
|
+
backgroundColor: !!field.defaultValue ? 'var(--color-accent)' : 'var(--color-bg-primary)',
|
|
1668
|
+
border: `1px solid ${!!field.defaultValue ? 'var(--color-accent)' : 'var(--color-border)'}`,
|
|
1669
|
+
}}
|
|
1670
|
+
>
|
|
1671
|
+
<div
|
|
1672
|
+
className="absolute top-0.5 w-3.5 h-3.5 rounded-full transition-all"
|
|
1673
|
+
style={{
|
|
1674
|
+
backgroundColor: !!field.defaultValue ? '#fff' : 'var(--color-text-muted)',
|
|
1675
|
+
left: !!field.defaultValue ? '18px' : '2px',
|
|
1676
|
+
}}
|
|
1677
|
+
/>
|
|
1678
|
+
</button>
|
|
1679
|
+
) : (
|
|
1680
|
+
<TextField value={String(field.defaultValue)} onChange={(v) => handleUpdateConfigField(idx, { defaultValue: v })} placeholder="默认值" />
|
|
1681
|
+
)}
|
|
1682
|
+
</div>
|
|
1683
|
+
</div>
|
|
1684
|
+
<div>
|
|
1685
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>描述</label>
|
|
1686
|
+
<TextField value={field.description ?? ''} onChange={(v) => handleUpdateConfigField(idx, { description: v })} placeholder="配置项说明" />
|
|
1687
|
+
</div>
|
|
1688
|
+
{field.type === 'select' && (
|
|
1689
|
+
<div>
|
|
1690
|
+
<div className="flex items-center justify-between mb-1.5">
|
|
1691
|
+
<label className="text-xs" style={{ color: s.textMuted }}>选项列表</label>
|
|
1692
|
+
<button
|
|
1693
|
+
type="button"
|
|
1694
|
+
onClick={() => handleUpdateConfigField(idx, {
|
|
1695
|
+
options: [...(field.options || []), { label: '', value: '' }],
|
|
1696
|
+
})}
|
|
1697
|
+
className="text-xs px-2 py-0.5 rounded transition-colors"
|
|
1698
|
+
style={{ color: s.accent, backgroundColor: 'transparent' }}
|
|
1699
|
+
>
|
|
1700
|
+
+ 添加选项
|
|
1701
|
+
</button>
|
|
1702
|
+
</div>
|
|
1703
|
+
<div className="flex flex-col gap-1.5">
|
|
1704
|
+
{(field.options || []).map((opt, oi) => (
|
|
1705
|
+
<div key={oi} className="flex items-center gap-1.5 min-w-0">
|
|
1706
|
+
<input
|
|
1707
|
+
type="text"
|
|
1708
|
+
value={opt.label}
|
|
1709
|
+
onChange={(e) => {
|
|
1710
|
+
const newOpts = [...(field.options || [])];
|
|
1711
|
+
newOpts[oi] = { ...newOpts[oi], label: e.target.value, value: e.target.value };
|
|
1712
|
+
handleUpdateConfigField(idx, { options: newOpts });
|
|
1713
|
+
}}
|
|
1714
|
+
placeholder="标签"
|
|
1715
|
+
className="flex-1 min-w-0 px-2 py-1 rounded text-xs border outline-none"
|
|
1716
|
+
style={{
|
|
1717
|
+
borderColor: s.border,
|
|
1718
|
+
backgroundColor: s.bgPrimary,
|
|
1719
|
+
color: s.textPrimary,
|
|
1720
|
+
}}
|
|
1721
|
+
/>
|
|
1722
|
+
<input
|
|
1723
|
+
type="text"
|
|
1724
|
+
value={opt.value}
|
|
1725
|
+
onChange={(e) => {
|
|
1726
|
+
const newOpts = [...(field.options || [])];
|
|
1727
|
+
newOpts[oi] = { ...newOpts[oi], value: e.target.value };
|
|
1728
|
+
handleUpdateConfigField(idx, { options: newOpts });
|
|
1729
|
+
}}
|
|
1730
|
+
placeholder="值"
|
|
1731
|
+
className="flex-1 min-w-0 px-2 py-1 rounded text-xs border outline-none"
|
|
1732
|
+
style={{
|
|
1733
|
+
borderColor: s.border,
|
|
1734
|
+
backgroundColor: s.bgPrimary,
|
|
1735
|
+
color: s.textPrimary,
|
|
1736
|
+
}}
|
|
1737
|
+
/>
|
|
1738
|
+
<button
|
|
1739
|
+
type="button"
|
|
1740
|
+
onClick={() => {
|
|
1741
|
+
const newOpts = (field.options || []).filter((_, i) => i !== oi);
|
|
1742
|
+
handleUpdateConfigField(idx, { options: newOpts });
|
|
1743
|
+
}}
|
|
1744
|
+
className="p-1 rounded transition-colors shrink-0"
|
|
1745
|
+
style={{ color: s.textMuted }}
|
|
1746
|
+
title="删除选项"
|
|
1747
|
+
>
|
|
1748
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
1749
|
+
<path d="M18 6L6 18M6 6l12 12" />
|
|
1750
|
+
</svg>
|
|
1751
|
+
</button>
|
|
1752
|
+
</div>
|
|
1753
|
+
))}
|
|
1754
|
+
{(field.options || []).length === 0 && (
|
|
1755
|
+
<p className="text-xs" style={{ color: s.textMuted }}>暂无选项,点击上方按钮添加</p>
|
|
1756
|
+
)}
|
|
1757
|
+
</div>
|
|
1758
|
+
</div>
|
|
1759
|
+
)}
|
|
1760
|
+
</div>
|
|
1761
|
+
)}
|
|
1762
|
+
</div>
|
|
1763
|
+
))}
|
|
1764
|
+
</div>
|
|
1765
|
+
)
|
|
1766
|
+
)}
|
|
1767
|
+
</div>
|
|
1768
|
+
|
|
1769
|
+
{/* UI 权限声明 */}
|
|
1770
|
+
<div>
|
|
1771
|
+
<div className="flex items-center justify-between mb-2">
|
|
1772
|
+
<h3
|
|
1773
|
+
className="text-sm font-bold flex items-center gap-1.5 cursor-pointer select-none"
|
|
1774
|
+
style={{ color: s.textPrimary }}
|
|
1775
|
+
onClick={() => setPermSectionCollapsed(!permSectionCollapsed)}
|
|
1776
|
+
>
|
|
1777
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"
|
|
1778
|
+
style={{ color: s.textMuted, transform: permSectionCollapsed ? 'rotate(-90deg)' : 'rotate(0deg)', transition: 'transform 0.15s ease' }}>
|
|
1779
|
+
<polyline points="6 9 12 15 18 9" />
|
|
1780
|
+
</svg>
|
|
1781
|
+
UI 权限声明(可选)
|
|
1782
|
+
{(commonPermissions.length + exclusivePermissions.length + requiredPermissions.length) > 0 && (
|
|
1783
|
+
<span className="text-xs px-1.5 py-0.5 rounded" style={{ backgroundColor: s.bgTertiary, color: s.textMuted }}>
|
|
1784
|
+
{commonPermissions.length + exclusivePermissions.length + requiredPermissions.length}
|
|
1785
|
+
</span>
|
|
1786
|
+
)}
|
|
1787
|
+
</h3>
|
|
1788
|
+
</div>
|
|
1789
|
+
{!permSectionCollapsed && (<>
|
|
1790
|
+
<p className="text-xs mb-3" style={{ color: s.textMuted }}>
|
|
1791
|
+
声明插件需要使用的 UI 能力。未声明时使用默认权限。支持在代码中编写 <code style={{ background: s.bgTertiary, padding: '1px 4px', borderRadius: '3px' }}>{'// @permission xxxx:......'}</code> 注释自动解析。
|
|
1792
|
+
</p>
|
|
1793
|
+
|
|
1794
|
+
{/* 共享权限 */}
|
|
1795
|
+
<div className="border rounded-lg p-3 mt-2" style={{ borderColor: '#3f3f3f' }}>
|
|
1796
|
+
<div className="flex items-center justify-between mb-2">
|
|
1797
|
+
<span className="text-xs font-medium" style={{ color: s.textPrimary }}>共享权限</span>
|
|
1798
|
+
<span className="text-xs" style={{ color: s.textMuted }}>可被多个插件同时声明</span>
|
|
1799
|
+
</div>
|
|
1800
|
+
<PermSelector
|
|
1801
|
+
allPerms={Object.entries(UI_PERMISSION_LABELS) as [UIPermission, string][]}
|
|
1802
|
+
selected={commonPermissions}
|
|
1803
|
+
onChange={setCommonPermissions}
|
|
1804
|
+
accentColor={s.accent}
|
|
1805
|
+
theme={s}
|
|
1806
|
+
/>
|
|
1807
|
+
</div>
|
|
1808
|
+
|
|
1809
|
+
{/* 排他权限 */}
|
|
1810
|
+
<div className="border rounded-lg p-3 mt-2" style={{ borderColor: '#f97316' }}>
|
|
1811
|
+
<div className="flex items-center justify-between mb-2">
|
|
1812
|
+
<span className="text-xs font-medium" style={{ color: '#f97316' }}>排他权限</span>
|
|
1813
|
+
<span className="text-xs" style={{ color: s.textMuted }}>同时只能被一个插件声明</span>
|
|
1814
|
+
</div>
|
|
1815
|
+
<PermSelector
|
|
1816
|
+
allPerms={Object.entries(UI_PERMISSION_LABELS) as [UIPermission, string][]}
|
|
1817
|
+
selected={exclusivePermissions}
|
|
1818
|
+
onChange={setExclusivePermissions}
|
|
1819
|
+
accentColor="#f97316"
|
|
1820
|
+
theme={s}
|
|
1821
|
+
/>
|
|
1822
|
+
</div>
|
|
1823
|
+
|
|
1824
|
+
{/* 必要权限 */}
|
|
1825
|
+
<div className="border rounded-lg p-3 mt-2" style={{ borderColor: '#3b82f6' }}>
|
|
1826
|
+
<div className="flex items-center justify-between mb-2">
|
|
1827
|
+
<span className="text-xs font-medium" style={{ color: '#3b82f6' }}>必要权限</span>
|
|
1828
|
+
<span className="text-xs" style={{ color: s.textMuted }}>没有此权限则插件不允许启动</span>
|
|
1829
|
+
</div>
|
|
1830
|
+
<PermSelector
|
|
1831
|
+
allPerms={Object.entries(UI_PERMISSION_LABELS) as [UIPermission, string][]}
|
|
1832
|
+
selected={requiredPermissions}
|
|
1833
|
+
onChange={setRequiredPermissions}
|
|
1834
|
+
accentColor="#3b82f6"
|
|
1835
|
+
theme={s}
|
|
1836
|
+
/>
|
|
1837
|
+
<p className="text-xs mt-2" style={{ color: s.textMuted }}>⚠️ 必要权限必须在共享权限或排他权限中声明</p>
|
|
1838
|
+
</div>
|
|
1839
|
+
</>)}
|
|
1840
|
+
</div>
|
|
1841
|
+
|
|
1842
|
+
{/* 依赖管理 */}
|
|
1843
|
+
<div>
|
|
1844
|
+
<div className="flex items-center justify-between mb-2">
|
|
1845
|
+
<h3
|
|
1846
|
+
className="text-sm font-bold flex items-center gap-1.5 cursor-pointer select-none"
|
|
1847
|
+
style={{ color: s.textPrimary }}
|
|
1848
|
+
onClick={() => setDepSectionCollapsed(!depSectionCollapsed)}
|
|
1849
|
+
>
|
|
1850
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round"
|
|
1851
|
+
style={{ color: s.textMuted, transform: depSectionCollapsed ? 'rotate(-90deg)' : 'rotate(0deg)', transition: 'transform 0.15s ease' }}>
|
|
1852
|
+
<polyline points="6 9 12 15 18 9" />
|
|
1853
|
+
</svg>
|
|
1854
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
1855
|
+
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z" />
|
|
1856
|
+
<polyline points="3.27 6.96 12 12.01 20.73 6.96" />
|
|
1857
|
+
<line x1="12" y1="22.08" x2="12" y2="12" />
|
|
1858
|
+
</svg>
|
|
1859
|
+
依赖管理
|
|
1860
|
+
{dependencies.length > 0 && (
|
|
1861
|
+
<span className="text-xs px-1.5 py-0.5 rounded" style={{ backgroundColor: s.bgTertiary, color: s.textMuted }}>
|
|
1862
|
+
{dependencies.length}
|
|
1863
|
+
</span>
|
|
1864
|
+
)}
|
|
1865
|
+
</h3>
|
|
1866
|
+
{!depSectionCollapsed && (
|
|
1867
|
+
<div className="flex items-center gap-1.5">
|
|
1868
|
+
<button
|
|
1869
|
+
onClick={() => setShowAddDep(!showAddDep)}
|
|
1870
|
+
className="px-3 py-1 rounded-lg text-xs border"
|
|
1871
|
+
style={{ borderColor: s.accent, color: s.accent, backgroundColor: 'transparent' }}
|
|
1872
|
+
>
|
|
1873
|
+
手动添加
|
|
1874
|
+
</button>
|
|
1875
|
+
</div>
|
|
1876
|
+
)}
|
|
1877
|
+
</div>
|
|
1878
|
+
|
|
1879
|
+
{!depSectionCollapsed && (<>
|
|
1880
|
+
{/* 手动添加内联表单 */}
|
|
1881
|
+
{showAddDep && (
|
|
1882
|
+
<div className="rounded-lg p-3 border mb-3 space-y-2" style={{ backgroundColor: s.bgTertiary, borderColor: s.border }}>
|
|
1883
|
+
<div>
|
|
1884
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>插件 ID *</label>
|
|
1885
|
+
<TextField value={newDepId} onChange={setNewDepId} placeholder="例如:builtin.dice" mono />
|
|
1886
|
+
</div>
|
|
1887
|
+
<div>
|
|
1888
|
+
<label className="block text-xs mb-1" style={{ color: s.textMuted }}>版本范围(可选)</label>
|
|
1889
|
+
<TextField value={newDepVersion} onChange={setNewDepVersion} placeholder="例如:^1.0.0" mono />
|
|
1890
|
+
</div>
|
|
1891
|
+
<div className="flex items-center gap-2">
|
|
1892
|
+
<label className="flex items-center gap-1.5 text-xs cursor-pointer" style={{ color: s.textSecondary }}>
|
|
1893
|
+
<input
|
|
1894
|
+
type="checkbox"
|
|
1895
|
+
checked={newDepOptional}
|
|
1896
|
+
onChange={(e) => setNewDepOptional(e.target.checked)}
|
|
1897
|
+
className="rounded"
|
|
1898
|
+
/>
|
|
1899
|
+
可选依赖
|
|
1900
|
+
</label>
|
|
1901
|
+
</div>
|
|
1902
|
+
|
|
1903
|
+
{/* 从已安装插件选择 */}
|
|
1904
|
+
{installedPlugins.length > 0 && (
|
|
1905
|
+
<div className="pt-1 border-t" style={{ borderColor: s.border }}>
|
|
1906
|
+
<p className="text-xs mb-1.5" style={{ color: s.textMuted }}>从已安装插件中选择:</p>
|
|
1907
|
+
<input
|
|
1908
|
+
type="text"
|
|
1909
|
+
value={pluginPickerSearch}
|
|
1910
|
+
onChange={(e) => setPluginPickerSearch(e.target.value)}
|
|
1911
|
+
placeholder="搜索插件..."
|
|
1912
|
+
className="w-full px-2 py-1 rounded text-xs border outline-none mb-1.5"
|
|
1913
|
+
style={{
|
|
1914
|
+
backgroundColor: s.bgSecondary, borderColor: s.border,
|
|
1915
|
+
color: s.textPrimary,
|
|
1916
|
+
}}
|
|
1917
|
+
/>
|
|
1918
|
+
<div className="max-h-40 overflow-y-auto space-y-0.5">
|
|
1919
|
+
{installedPlugins
|
|
1920
|
+
.filter(p => p.id !== editId && !dependencies.some(d => d.pluginId === p.id))
|
|
1921
|
+
.filter(p =>
|
|
1922
|
+
!pluginPickerSearch ||
|
|
1923
|
+
p.id.toLowerCase().includes(pluginPickerSearch.toLowerCase()) ||
|
|
1924
|
+
p.name.toLowerCase().includes(pluginPickerSearch.toLowerCase())
|
|
1925
|
+
)
|
|
1926
|
+
.map(p => (
|
|
1927
|
+
<button
|
|
1928
|
+
key={p.id}
|
|
1929
|
+
onClick={() => {
|
|
1930
|
+
setNewDepId(p.id);
|
|
1931
|
+
setNewDepVersion(p.version ? `^${p.version}` : '');
|
|
1932
|
+
setPluginPickerSearch('');
|
|
1933
|
+
}}
|
|
1934
|
+
className="w-full flex items-center gap-2 px-2 py-1.5 rounded text-xs text-left transition-colors"
|
|
1935
|
+
style={{
|
|
1936
|
+
backgroundColor: newDepId === p.id ? 'var(--color-bg-secondary)' : 'transparent',
|
|
1937
|
+
color: s.textPrimary,
|
|
1938
|
+
}}
|
|
1939
|
+
onMouseEnter={(e) => { e.currentTarget.style.backgroundColor = 'var(--color-bg-secondary)'; }}
|
|
1940
|
+
onMouseLeave={(e) => { e.currentTarget.style.backgroundColor = newDepId === p.id ? 'var(--color-bg-secondary)' : 'transparent'; }}
|
|
1941
|
+
>
|
|
1942
|
+
<PluginIcon icon={p.icon} pluginId={p.id} />
|
|
1943
|
+
<span className="flex-1 min-w-0">
|
|
1944
|
+
<span className="font-medium">{p.name}</span>
|
|
1945
|
+
<span className="ml-1 font-mono" style={{ color: s.textMuted, fontSize: '9px' }}>{p.id}</span>
|
|
1946
|
+
</span>
|
|
1947
|
+
<span className="font-mono" style={{ color: s.textMuted, fontSize: '9px' }}>v{p.version}</span>
|
|
1948
|
+
</button>
|
|
1949
|
+
))}
|
|
1950
|
+
{installedPlugins.filter(p => p.id !== editId && !dependencies.some(d => d.pluginId === p.id))
|
|
1951
|
+
.filter(p =>
|
|
1952
|
+
!pluginPickerSearch ||
|
|
1953
|
+
p.id.toLowerCase().includes(pluginPickerSearch.toLowerCase()) ||
|
|
1954
|
+
p.name.toLowerCase().includes(pluginPickerSearch.toLowerCase())
|
|
1955
|
+
).length === 0 && (
|
|
1956
|
+
<p className="text-xs py-2 text-center" style={{ color: s.textMuted }}>无匹配的插件</p>
|
|
1957
|
+
)}
|
|
1958
|
+
</div>
|
|
1959
|
+
</div>
|
|
1960
|
+
)}
|
|
1961
|
+
|
|
1962
|
+
<div className="flex items-center gap-2 pt-1">
|
|
1963
|
+
<button
|
|
1964
|
+
onClick={handleAddDependency}
|
|
1965
|
+
className="px-3 py-1 rounded-lg text-xs font-bold"
|
|
1966
|
+
style={{ backgroundColor: s.accent, color: s.bgPrimary }}
|
|
1967
|
+
>
|
|
1968
|
+
确认添加
|
|
1969
|
+
</button>
|
|
1970
|
+
<button
|
|
1971
|
+
onClick={() => { setShowAddDep(false); setNewDepId(''); setNewDepVersion(''); setNewDepOptional(false); setPluginPickerSearch(''); }}
|
|
1972
|
+
className="px-3 py-1 rounded-lg text-xs border"
|
|
1973
|
+
style={{ borderColor: s.border, color: s.textSecondary, backgroundColor: 'transparent' }}
|
|
1974
|
+
>
|
|
1975
|
+
取消
|
|
1976
|
+
</button>
|
|
1977
|
+
</div>
|
|
1978
|
+
</div>
|
|
1979
|
+
)}
|
|
1980
|
+
|
|
1981
|
+
{/* 依赖列表 */}
|
|
1982
|
+
{dependencies.length === 0 ? (
|
|
1983
|
+
<p className="text-xs" style={{ color: s.textMuted }}>暂无依赖。点击“从代码扫描”自动检测,或“手动添加”。</p>
|
|
1984
|
+
) : (
|
|
1985
|
+
<div className="rounded-lg border overflow-hidden" style={{ borderColor: s.border }}>
|
|
1986
|
+
{/* 表头 */}
|
|
1987
|
+
<div className="grid grid-cols-[1fr_80px_80px_40px] gap-2 px-3 py-2 text-xs font-bold" style={{ backgroundColor: s.bgTertiary, color: s.textMuted }}>
|
|
1988
|
+
<span>插件 ID</span>
|
|
1989
|
+
<span>版本范围</span>
|
|
1990
|
+
<span>状态</span>
|
|
1991
|
+
<span>操作</span>
|
|
1992
|
+
</div>
|
|
1993
|
+
{/* 依赖项 */}
|
|
1994
|
+
{dependencies.map((dep) => (
|
|
1995
|
+
<div
|
|
1996
|
+
key={dep.pluginId}
|
|
1997
|
+
className="grid grid-cols-[1fr_80px_80px_40px] gap-2 px-3 py-2 text-xs items-center"
|
|
1998
|
+
style={{ borderTop: `1px solid ${s.border}`, color: s.textPrimary }}
|
|
1999
|
+
>
|
|
2000
|
+
<span className="font-mono truncate" title={dep.pluginId}>
|
|
2001
|
+
{dep.pluginId}
|
|
2002
|
+
{dep.optional && (
|
|
2003
|
+
<span className="ml-1 px-1.5 py-0.5 rounded text-[10px]" style={{ backgroundColor: s.bgTertiary, color: s.textMuted }}>可选</span>
|
|
2004
|
+
)}
|
|
2005
|
+
</span>
|
|
2006
|
+
<span className="font-mono" style={{ color: s.textSecondary }}>
|
|
2007
|
+
{dep.versionRange || '\u2014'}
|
|
2008
|
+
</span>
|
|
2009
|
+
<span className="flex items-center gap-1">
|
|
2010
|
+
{depStatusIcon(depStatuses[dep.pluginId])}
|
|
2011
|
+
<span style={{ color: depStatuses[dep.pluginId] === 'satisfied' ? '#22c55e' : depStatuses[dep.pluginId] === 'missing' ? '#ef4444' : '#f59e0b' }}>
|
|
2012
|
+
{depStatusLabel(depStatuses[dep.pluginId])}
|
|
2013
|
+
</span>
|
|
2014
|
+
</span>
|
|
2015
|
+
<button
|
|
2016
|
+
onClick={() => handleRemoveDependency(dep.pluginId)}
|
|
2017
|
+
className="text-xs px-1 py-0.5 rounded transition-colors hover:opacity-80"
|
|
2018
|
+
style={{ color: '#ef4444' }}
|
|
2019
|
+
title="删除依赖"
|
|
2020
|
+
>
|
|
2021
|
+
🗑
|
|
2022
|
+
</button>
|
|
2023
|
+
</div>
|
|
2024
|
+
))}
|
|
2025
|
+
</div>
|
|
2026
|
+
)}
|
|
2027
|
+
|
|
2028
|
+
{/* 提示 */}
|
|
2029
|
+
{dependencies.length > 0 && (
|
|
2030
|
+
<p className="text-xs mt-2" style={{ color: s.textMuted }}>
|
|
2031
|
+
💡 使用 <code className="font-mono px-1 py-0.5 rounded" style={{ backgroundColor: s.bgTertiary }}>xinyu.plugin.loadDependency()</code> 在代码中加载依赖
|
|
2032
|
+
</p>
|
|
2033
|
+
)}
|
|
2034
|
+
</>)}
|
|
2035
|
+
</div>
|
|
2036
|
+
|
|
2037
|
+
{/* AI 安全检测 */}
|
|
2038
|
+
<div>
|
|
2039
|
+
<div className="flex items-center justify-between mb-2">
|
|
2040
|
+
<h3 className="text-sm font-bold" style={{ color: s.textPrimary }}>安全检测</h3>
|
|
2041
|
+
<button
|
|
2042
|
+
onClick={handleScan}
|
|
2043
|
+
disabled={scanning}
|
|
2044
|
+
className="px-3 py-1 rounded-lg text-xs border"
|
|
2045
|
+
style={{ borderColor: s.accent, color: s.accent, backgroundColor: 'transparent' }}
|
|
2046
|
+
>
|
|
2047
|
+
{scanning ? '检测中...' : 'AI 安全检测'}
|
|
2048
|
+
</button>
|
|
2049
|
+
</div>
|
|
2050
|
+
{scanResult && (
|
|
2051
|
+
<div className="rounded-lg p-4 border" style={{ backgroundColor: s.bgTertiary, borderColor: riskColors[scanResult.riskLevel] }}>
|
|
2052
|
+
<div className="flex items-center gap-3 mb-3">
|
|
2053
|
+
<span className="px-2 py-0.5 rounded text-xs font-bold" style={{ backgroundColor: riskColors[scanResult.riskLevel], color: '#fff' }}>
|
|
2054
|
+
{riskLabels[scanResult.riskLevel]} ({scanResult.score}/100)
|
|
2055
|
+
</span>
|
|
2056
|
+
<span className="text-sm" style={{ color: s.textPrimary }}>{scanResult.summary}</span>
|
|
2057
|
+
</div>
|
|
2058
|
+
{scanResult.findings.length > 0 && (
|
|
2059
|
+
<div className="space-y-2">
|
|
2060
|
+
{scanResult.findings.map((finding, i) => (
|
|
2061
|
+
<div key={i} className="text-xs" style={{ color: s.textSecondary }}>
|
|
2062
|
+
<span className="font-bold" style={{ color: riskColors[finding.level] }}>[{finding.category}]</span>{' '}
|
|
2063
|
+
{finding.description}
|
|
2064
|
+
{finding.recommendation && <span style={{ color: s.textMuted }}> - 建议: {finding.recommendation}</span>}
|
|
2065
|
+
</div>
|
|
2066
|
+
))}
|
|
2067
|
+
</div>
|
|
2068
|
+
)}
|
|
2069
|
+
{scanResult.recommendation && (
|
|
2070
|
+
<p className="text-xs mt-2" style={{ color: s.textMuted }}>建议: {scanResult.recommendation}</p>
|
|
2071
|
+
)}
|
|
2072
|
+
</div>
|
|
2073
|
+
)}
|
|
2074
|
+
</div>
|
|
2075
|
+
|
|
2076
|
+
{/* 底部留白 */}
|
|
2077
|
+
<div className="h-8" />
|
|
2078
|
+
</div>
|
|
2079
|
+
</div>
|
|
2080
|
+
|
|
2081
|
+
{/* 拖拽分隔条 2 */}
|
|
2082
|
+
<ResizableDivider onResize={handleResizeMid} />
|
|
2083
|
+
|
|
2084
|
+
{/* 右侧:代码编辑器 */}
|
|
2085
|
+
<div className="flex-1 flex flex-col overflow-hidden">
|
|
2086
|
+
<div
|
|
2087
|
+
className="shrink-0 px-4 py-2 text-xs flex items-center justify-between"
|
|
2088
|
+
style={{ backgroundColor: s.bgTertiary, color: s.textMuted, borderBottom: `1px solid ${s.border}` }}
|
|
2089
|
+
>
|
|
2090
|
+
<div className="flex items-center gap-3">
|
|
2091
|
+
<span className="font-mono">{isXye ? activeFile : 'plugin.js'}</span>
|
|
2092
|
+
{isXye && (
|
|
2093
|
+
<button
|
|
2094
|
+
onClick={() => setFileTreeOpen(!fileTreeOpen)}
|
|
2095
|
+
className="flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors"
|
|
2096
|
+
style={{
|
|
2097
|
+
backgroundColor: s.bgPrimary,
|
|
2098
|
+
color: s.textSecondary,
|
|
2099
|
+
border: `1px solid ${s.border}`,
|
|
2100
|
+
}}
|
|
2101
|
+
title={fileTreeOpen ? '隐藏文件树' : '显示文件树'}
|
|
2102
|
+
>
|
|
2103
|
+
<i className="fa-solid fa-folder-tree" style={{ fontSize: '10px' }} />
|
|
2104
|
+
</button>
|
|
2105
|
+
)}
|
|
2106
|
+
{isXye && (
|
|
2107
|
+
<span className="px-1.5 py-0.5 rounded text-[10px] font-medium" style={{ backgroundColor: 'var(--color-accent)', color: '#fff' }}>
|
|
2108
|
+
XYE
|
|
2109
|
+
</span>
|
|
2110
|
+
)}
|
|
2111
|
+
<div className="relative">
|
|
2112
|
+
<button
|
|
2113
|
+
onClick={() => setThemeMenuOpen(!themeMenuOpen)}
|
|
2114
|
+
className="flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors"
|
|
2115
|
+
style={{
|
|
2116
|
+
backgroundColor: s.bgPrimary,
|
|
2117
|
+
color: s.textSecondary,
|
|
2118
|
+
border: `1px solid ${s.border}`,
|
|
2119
|
+
}}
|
|
2120
|
+
title="切换编辑器主题"
|
|
2121
|
+
>
|
|
2122
|
+
<i className="fa-solid fa-palette" style={{ fontSize: '10px' }} />
|
|
2123
|
+
<span>{EDITOR_THEMES.find(t => t.id === editorTheme)?.label}</span>
|
|
2124
|
+
<i className="fa-solid fa-chevron-down" style={{ fontSize: '8px' }} />
|
|
2125
|
+
</button>
|
|
2126
|
+
{themeMenuOpen && (
|
|
2127
|
+
<>
|
|
2128
|
+
<div className="fixed inset-0 z-10" onClick={() => setThemeMenuOpen(false)} />
|
|
2129
|
+
<div
|
|
2130
|
+
className="absolute left-0 top-full mt-1 py-1 rounded-lg shadow-lg z-20 min-w-[140px]"
|
|
2131
|
+
style={{
|
|
2132
|
+
backgroundColor: s.bgSecondary,
|
|
2133
|
+
border: `1px solid ${s.border}`,
|
|
2134
|
+
}}
|
|
2135
|
+
>
|
|
2136
|
+
{EDITOR_THEMES.map((t) => (
|
|
2137
|
+
<button
|
|
2138
|
+
key={t.id}
|
|
2139
|
+
onClick={() => { setEditorTheme(t.id); setThemeMenuOpen(false); }}
|
|
2140
|
+
className="w-full text-left px-3 py-1.5 text-xs flex items-center gap-2 transition-colors"
|
|
2141
|
+
style={{
|
|
2142
|
+
backgroundColor: editorTheme === t.id ? s.bgTertiary : 'transparent',
|
|
2143
|
+
color: editorTheme === t.id ? s.accent : s.textSecondary,
|
|
2144
|
+
}}
|
|
2145
|
+
>
|
|
2146
|
+
<span
|
|
2147
|
+
className="w-3 h-3 rounded-sm shrink-0"
|
|
2148
|
+
style={{ backgroundColor: t.color }}
|
|
2149
|
+
/>
|
|
2150
|
+
{t.label}
|
|
2151
|
+
</button>
|
|
2152
|
+
))}
|
|
2153
|
+
</div>
|
|
2154
|
+
</>
|
|
2155
|
+
)}
|
|
2156
|
+
</div>
|
|
2157
|
+
</div>
|
|
2158
|
+
<span>{codeLines.length} 行</span>
|
|
2159
|
+
</div>
|
|
2160
|
+
<div className="flex-1 flex overflow-hidden">
|
|
2161
|
+
{/* .xye 文件树面板 */}
|
|
2162
|
+
{isXye && fileTreeOpen && (
|
|
2163
|
+
<>
|
|
2164
|
+
<div
|
|
2165
|
+
className="shrink-0 overflow-y-auto py-2"
|
|
2166
|
+
style={{
|
|
2167
|
+
width: fileTreeWidth,
|
|
2168
|
+
backgroundColor: s.bgSecondary,
|
|
2169
|
+
}}
|
|
2170
|
+
>
|
|
2171
|
+
<div className="px-3 py-1 text-[10px] font-bold uppercase tracking-wider flex items-center justify-between" style={{ color: s.textMuted }}>
|
|
2172
|
+
<span className="flex items-center gap-1.5">
|
|
2173
|
+
<i className="fa-solid fa-folder-tree" style={{ fontSize: '10px' }} />
|
|
2174
|
+
文件树
|
|
2175
|
+
</span>
|
|
2176
|
+
<span className="flex items-center gap-0.5">
|
|
2177
|
+
<button
|
|
2178
|
+
onClick={() => { setToolbarCreating('file'); setToolbarNewItemName(''); }}
|
|
2179
|
+
className="p-0.5 rounded transition-colors hover:opacity-70"
|
|
2180
|
+
title="新建文件"
|
|
2181
|
+
>
|
|
2182
|
+
<i className="fa-solid fa-file-circle-plus" style={{ fontSize: '10px' }} />
|
|
2183
|
+
</button>
|
|
2184
|
+
<button
|
|
2185
|
+
onClick={() => { setToolbarCreating('dir'); setToolbarNewItemName(''); }}
|
|
2186
|
+
className="p-0.5 rounded transition-colors hover:opacity-70"
|
|
2187
|
+
title="新建文件夹"
|
|
2188
|
+
>
|
|
2189
|
+
<i className="fa-solid fa-folder-plus" style={{ fontSize: '10px' }} />
|
|
2190
|
+
</button>
|
|
2191
|
+
<button
|
|
2192
|
+
onClick={() => refreshFileTree()}
|
|
2193
|
+
className="p-0.5 rounded transition-colors hover:opacity-70"
|
|
2194
|
+
title="刷新文件树"
|
|
2195
|
+
>
|
|
2196
|
+
<i className="fa-solid fa-arrows-rotate" style={{ fontSize: '10px' }} />
|
|
2197
|
+
</button>
|
|
2198
|
+
<button
|
|
2199
|
+
onClick={() => {
|
|
2200
|
+
const input = document.createElement('input');
|
|
2201
|
+
input.type = 'file';
|
|
2202
|
+
input.multiple = true;
|
|
2203
|
+
input.onchange = (e) => {
|
|
2204
|
+
const target = e.target as HTMLInputElement;
|
|
2205
|
+
if (target.files && target.files.length > 0) {
|
|
2206
|
+
handleUploadFiles(target.files);
|
|
2207
|
+
}
|
|
2208
|
+
};
|
|
2209
|
+
input.click();
|
|
2210
|
+
}}
|
|
2211
|
+
className="p-0.5 rounded transition-colors hover:opacity-70"
|
|
2212
|
+
title="上传文件"
|
|
2213
|
+
>
|
|
2214
|
+
<i className="fa-solid fa-upload" style={{ fontSize: '10px' }} />
|
|
2215
|
+
</button>
|
|
2216
|
+
</span>
|
|
2217
|
+
</div>
|
|
2218
|
+
{/* 工具栏新建输入框 */}
|
|
2219
|
+
{toolbarCreating && (
|
|
2220
|
+
<div className="px-3 py-1.5">
|
|
2221
|
+
<div className="text-[10px] mb-1" style={{ color: s.textMuted }}>
|
|
2222
|
+
{toolbarCreating === 'file' ? '新建文件(在根目录下)' : '新建文件夹(在根目录下)'}
|
|
2223
|
+
</div>
|
|
2224
|
+
<input
|
|
2225
|
+
ref={toolbarInputRef}
|
|
2226
|
+
value={toolbarNewItemName}
|
|
2227
|
+
onChange={(e) => setToolbarNewItemName(e.target.value)}
|
|
2228
|
+
onKeyDown={(e) => {
|
|
2229
|
+
if (e.key === 'Enter' && toolbarNewItemName.trim()) {
|
|
2230
|
+
handleCreateFile(toolbarNewItemName.trim(), toolbarCreating === 'dir');
|
|
2231
|
+
setToolbarCreating(null);
|
|
2232
|
+
setToolbarNewItemName('');
|
|
2233
|
+
}
|
|
2234
|
+
if (e.key === 'Escape') {
|
|
2235
|
+
setToolbarCreating(null);
|
|
2236
|
+
setToolbarNewItemName('');
|
|
2237
|
+
}
|
|
2238
|
+
}}
|
|
2239
|
+
onBlur={() => {
|
|
2240
|
+
// 失焦时如果内容为空则关闭
|
|
2241
|
+
if (!toolbarNewItemName.trim()) {
|
|
2242
|
+
setToolbarCreating(null);
|
|
2243
|
+
}
|
|
2244
|
+
}}
|
|
2245
|
+
placeholder={toolbarCreating === 'file' ? '文件名.js' : '文件夹名'}
|
|
2246
|
+
className="w-full px-2 py-1 rounded text-xs outline-none"
|
|
2247
|
+
style={{ backgroundColor: s.bgTertiary, color: s.textPrimary, border: `1px solid ${s.border}` }}
|
|
2248
|
+
/>
|
|
2249
|
+
</div>
|
|
2250
|
+
)}
|
|
2251
|
+
<FileTree
|
|
2252
|
+
files={xyeFiles}
|
|
2253
|
+
activeFile={activeFile}
|
|
2254
|
+
depth={0}
|
|
2255
|
+
onSelect={handleFileSelect}
|
|
2256
|
+
onContextMenu={(e, file) => {
|
|
2257
|
+
e.preventDefault();
|
|
2258
|
+
setContextMenu({ x: e.clientX, y: e.clientY, file });
|
|
2259
|
+
}}
|
|
2260
|
+
theme={s}
|
|
2261
|
+
/>
|
|
2262
|
+
</div>
|
|
2263
|
+
<ResizableDivider onResize={handleResizeFileTree} />
|
|
2264
|
+
</>
|
|
2265
|
+
)}
|
|
2266
|
+
{/* 右键菜单 */}
|
|
2267
|
+
{contextMenu && (
|
|
2268
|
+
<FileContextMenu
|
|
2269
|
+
x={contextMenu.x}
|
|
2270
|
+
y={contextMenu.y}
|
|
2271
|
+
file={contextMenu.file}
|
|
2272
|
+
activeFile={activeFile}
|
|
2273
|
+
onClose={() => setContextMenu(null)}
|
|
2274
|
+
onNewFile={(dirPath) => handleCreateFile(dirPath, false)}
|
|
2275
|
+
onNewFolder={(dirPath) => handleCreateFile(dirPath, true)}
|
|
2276
|
+
onDelete={(path) => handleDeleteFile(path)}
|
|
2277
|
+
onRename={(oldPath, newPath) => handleRenameFile(oldPath, newPath)}
|
|
2278
|
+
theme={s}
|
|
2279
|
+
/>
|
|
2280
|
+
)}
|
|
2281
|
+
<div className="flex-1 overflow-hidden">
|
|
2282
|
+
<Editor
|
|
2283
|
+
height="100%"
|
|
2284
|
+
language={activeFile.endsWith('.json') ? 'json' : activeFile.endsWith('.css') ? 'css' : activeFile.endsWith('.html') ? 'html' : 'javascript'}
|
|
2285
|
+
theme={editorTheme}
|
|
2286
|
+
value={code}
|
|
2287
|
+
onChange={(value) => {
|
|
2288
|
+
const newCode = value ?? '';
|
|
2289
|
+
setCode(newCode);
|
|
2290
|
+
// .xye 模式下同步更新文件缓存
|
|
2291
|
+
if (isXye && activeFile) {
|
|
2292
|
+
setFileContents(prev => ({ ...prev, [activeFile]: newCode }));
|
|
2293
|
+
}
|
|
2294
|
+
}}
|
|
2295
|
+
onMount={handleEditorMount}
|
|
2296
|
+
options={{
|
|
2297
|
+
fontSize: 12,
|
|
2298
|
+
fontFamily: 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',
|
|
2299
|
+
lineHeight: 18,
|
|
2300
|
+
minimap: { enabled: false },
|
|
2301
|
+
scrollBeyondLastLine: false,
|
|
2302
|
+
wordWrap: 'on',
|
|
2303
|
+
tabSize: 2,
|
|
2304
|
+
padding: { top: 8, bottom: 8 },
|
|
2305
|
+
overviewRulerBorder: false,
|
|
2306
|
+
scrollbar: {
|
|
2307
|
+
verticalScrollbarSize: 8,
|
|
2308
|
+
horizontalScrollbarSize: 8,
|
|
2309
|
+
},
|
|
2310
|
+
}}
|
|
2311
|
+
/>
|
|
2312
|
+
</div>
|
|
2313
|
+
</div>
|
|
2314
|
+
</div>
|
|
2315
|
+
</div>
|
|
2316
|
+
</div>
|
|
2317
|
+
);
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
/** 权限选择器组件:下拉选择 + 标签列表 */
|
|
2321
|
+
function PermSelector({
|
|
2322
|
+
allPerms,
|
|
2323
|
+
selected,
|
|
2324
|
+
onChange,
|
|
2325
|
+
accentColor,
|
|
2326
|
+
theme: s,
|
|
2327
|
+
}: {
|
|
2328
|
+
allPerms: [string, string][];
|
|
2329
|
+
selected: string[];
|
|
2330
|
+
onChange: (perms: UIPermission[]) => void;
|
|
2331
|
+
accentColor: string;
|
|
2332
|
+
theme: Record<string, string>;
|
|
2333
|
+
}) {
|
|
2334
|
+
const available = allPerms.filter(([perm]) => !selected.includes(perm));
|
|
2335
|
+
const [selectVal, setSelectVal] = useState('');
|
|
2336
|
+
|
|
2337
|
+
const handleAdd = () => {
|
|
2338
|
+
if (selectVal && !selected.includes(selectVal)) {
|
|
2339
|
+
onChange([...selected as UIPermission[], selectVal as UIPermission]);
|
|
2340
|
+
}
|
|
2341
|
+
setSelectVal('');
|
|
2342
|
+
};
|
|
2343
|
+
|
|
2344
|
+
const handleRemove = (perm: string) => {
|
|
2345
|
+
onChange(selected.filter(p => p !== perm) as UIPermission[]);
|
|
2346
|
+
};
|
|
2347
|
+
|
|
2348
|
+
return (
|
|
2349
|
+
<div>
|
|
2350
|
+
{selected.length > 0 && (
|
|
2351
|
+
<div className="flex flex-wrap gap-1.5 mb-2">
|
|
2352
|
+
{selected.map(perm => {
|
|
2353
|
+
const label = allPerms.find(([p]) => p === perm)?.[1] || perm;
|
|
2354
|
+
return (
|
|
2355
|
+
<span key={perm} className="inline-flex items-center gap-1 text-xs px-2 py-1 rounded-md transition-colors"
|
|
2356
|
+
style={{ backgroundColor: `${accentColor}15`, border: `1px solid ${accentColor}40`, color: accentColor }}>
|
|
2357
|
+
{label}
|
|
2358
|
+
<button onClick={() => handleRemove(perm)} className="hover:opacity-70 transition-opacity ml-0.5" style={{ color: accentColor }}>✕</button>
|
|
2359
|
+
</span>
|
|
2360
|
+
);
|
|
2361
|
+
})}
|
|
2362
|
+
</div>
|
|
2363
|
+
)}
|
|
2364
|
+
|
|
2365
|
+
<div className="flex gap-1.5 min-w-0">
|
|
2366
|
+
<div className="flex-1 min-w-0 flex items-center rounded-md border overflow-hidden"
|
|
2367
|
+
style={{ borderColor: s.border }}>
|
|
2368
|
+
<select
|
|
2369
|
+
value={selectVal}
|
|
2370
|
+
onChange={(e) => setSelectVal(e.target.value)}
|
|
2371
|
+
className="flex-1 min-w-0 text-xs px-2 py-1.5 outline-none bg-transparent appearance-none cursor-pointer"
|
|
2372
|
+
style={{ color: s.textPrimary }}
|
|
2373
|
+
>
|
|
2374
|
+
<option value="">选择权限...</option>
|
|
2375
|
+
{available.map(([perm, label]) => (
|
|
2376
|
+
<option key={perm} value={perm}>{label} ({perm})</option>
|
|
2377
|
+
))}
|
|
2378
|
+
</select>
|
|
2379
|
+
<button
|
|
2380
|
+
onClick={handleAdd}
|
|
2381
|
+
disabled={!selectVal}
|
|
2382
|
+
className="shrink-0 text-xs px-2.5 py-1.5 transition-colors disabled:opacity-40 disabled:cursor-not-allowed border-l"
|
|
2383
|
+
style={{
|
|
2384
|
+
backgroundColor: selectVal ? `${accentColor}20` : 'transparent',
|
|
2385
|
+
borderColor: s.border,
|
|
2386
|
+
color: selectVal ? accentColor : s.textMuted,
|
|
2387
|
+
}}
|
|
2388
|
+
>
|
|
2389
|
+
+ 添加
|
|
2390
|
+
</button>
|
|
2391
|
+
</div>
|
|
2392
|
+
</div>
|
|
2393
|
+
</div>
|
|
2394
|
+
);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
function PageLoader() {
|
|
2398
|
+
return (
|
|
2399
|
+
<div className="flex flex-col items-center justify-center gap-4" style={{ minHeight: '100vh', backgroundColor: 'var(--color-bg-primary)' }}>
|
|
2400
|
+
<MathCurveLoader size={80} strokeWidthScale={0.8} />
|
|
2401
|
+
<p className="text-sm" style={{ color: 'var(--color-text-muted)' }}>加载中...</p>
|
|
2402
|
+
</div>
|
|
2403
|
+
);
|
|
2404
|
+
}
|
|
2405
|
+
|
|
2406
|
+
export default function EditPluginPage() {
|
|
2407
|
+
return (
|
|
2408
|
+
<React.Suspense fallback={<PageLoader />}>
|
|
2409
|
+
<EditPluginPageContent />
|
|
2410
|
+
</React.Suspense>
|
|
2411
|
+
);
|
|
2412
|
+
}
|