-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoloMini_pro.html
More file actions
1697 lines (1540 loc) · 110 KB
/
FoloMini_pro.html
File metadata and controls
1697 lines (1540 loc) · 110 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
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
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Folo Mini - 本地版</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
zinc: {
850: '#1f1f22',
950: '#09090b',
}
},
animation: {
'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite',
}
}
}
}
</script>
<!-- React & ReactDOM -->
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<!-- Babel for JSX -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<!-- Google Fonts & Styles -->
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;700&display=swap');
body { font-family: 'Inter', 'Noto Sans SC', sans-serif; }
/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(156, 163, 175, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(156, 163, 175, 0.5); }
/* Typography adjustments */
.prose h1 { font-size: 1.5em; font-weight: 700; margin: 1em 0 0.5em; line-height: 1.3; }
.prose h2 { font-size: 1.25em; font-weight: 600; margin: 1em 0 0.5em; line-height: 1.3; }
.prose h3 { font-size: 1.1em; font-weight: 600; margin: 1em 0 0.5em; }
.prose p { margin-bottom: 1em; line-height: 1.7; font-size: 1.05rem; }
.prose ul { list-style-type: disc; padding-left: 1.25em; margin-bottom: 1em; }
.prose ol { list-style-type: decimal; padding-left: 1.25em; margin-bottom: 1em; }
.prose img { max-width: 100%; height: auto; border-radius: 0.5rem; margin: 1em 0; display: block; }
.prose blockquote { border-left: 4px solid #e5e7eb; padding-left: 1em; color: #6b7280; font-style: italic; margin: 1em 0; background: rgba(0,0,0,0.02); border-radius: 0 4px 4px 0; }
.prose pre { background: #f3f4f6; padding: 1em; border-radius: 0.5rem; overflow-x: auto; font-size: 0.9em; }
.dark .prose pre { background: #27272a; }
.dark .prose blockquote { border-color: #3f3f46; color: #a1a1aa; background: rgba(255,255,255,0.02); }
/* Details Summary Customization */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.animate-fade-in { animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { pointer-events: auto; padding: 10px 16px; border-radius: 8px; color: white; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: fadeIn 0.3s ease; max-width: 300px; }
.toast.error { background-color: #ef4444; }
.toast.success { background-color: #22c55e; }
</style>
<!-- DATA SEED BLOCK: This is where data lives in the downloaded file -->
<script id="app-data" type="application/json">null</script>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
const { useState, useEffect, useMemo, useRef } = React;
// --- Constants & Config ---
const INITIAL_FEEDS = [
{ id: '1', title: '少数派', url: 'https://sspai.com/feed' },
{ id: '2', title: '36氪', url: 'https://36kr.com/feed' },
{ id: '3', title: 'V2EX', url: 'https://www.v2ex.com/index.xml' },
];
const DEFAULT_RSSHUB_NODES = [
'https://eren.zeabur.app',
'https://rsshub.app',
'https://rsshub.feedlib.xyz'
];
const DEFAULT_PROFILES = [
{
id: 'default-deepseek',
name: 'DeepSeek (默认)',
provider: 'openai',
baseUrl: 'https://api.deepseek.com',
apiKey: '',
model: 'deepseek-chat'
},
{
id: 'default-google',
name: 'Google Gemini',
provider: 'google',
baseUrl: 'https://generativelanguage.googleapis.com',
apiKey: '',
model: 'gemini-1.5-flash'
}
];
// --- Icons ---
const Icon = ({ path, className, ...props }) => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className={className} {...props}>{path}</svg>
);
const Icons = {
Plus: (p) => <Icon path={<><path d="M5 12h14"/><path d="M12 5v14"/></>} {...p} />,
Trash: (p) => <Icon path={<><path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></>} {...p} />,
Menu: (p) => <Icon path={<><line x1="4" x2="20" y1="12" y2="12"/><line x1="4" x2="20" y1="6" y2="6"/><line x1="4" x2="20" y1="18" y2="18"/></>} {...p} />,
X: (p) => <Icon path={<><path d="M18 6 6 18"/><path d="m6 6 12 12"/></>} {...p} />,
Rss: (p) => <Icon path={<><path d="M4 11a9 9 0 0 1 9 9"/><path d="M4 4a16 16 0 0 1 16 16"/><circle cx="5" cy="19" r="1"/></>} {...p} />,
Sparkles: (p) => <Icon path={<path d="m12 3-1.912 5.813a2 2 0 0 1-1.275 1.275L3 12l5.813 1.912a2 2 0 0 1 1.275 1.275L12 21l1.912-5.813a2 2 0 0 1-1.275-1.275L21 12l-5.813-1.912a2 2 0 0 1-1.275-1.275L12 3Z"/>} {...p} />,
ExternalLink: (p) => <Icon path={<><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" x2="21" y1="14" y2="3"/></>} {...p} />,
Left: (p) => <Icon path={<path d="m15 18-6-6 6-6"/>} {...p} />,
Settings: (p) => <Icon path={<><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.47a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></>} {...p} />,
Moon: (p) => <Icon path={<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>} {...p} />,
Sun: (p) => <Icon path={<><circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/></>} {...p} />,
Loader: (p) => <Icon path={<path d="M21 12a9 9 0 1 1-6.219-8.56"/>} className={cn("animate-spin", p.className)} {...p} />,
Refresh: (p) => <Icon path={<><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/></>} {...p} />,
Save: (p) => <Icon path={<><path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"/><path d="M17 21v-8H7v8"/><path d="M7 3v5h8"/></>} {...p} />,
Layers: (p) => <Icon path={<><polygon points="12 2 2 7 12 12 22 7 12 2"/><polyline points="2 17 12 22 22 17"/><polyline points="2 12 12 17 22 12"/></>} {...p} />,
Star: (p) => <Icon path={<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/>} {...p} />,
Download: (p) => <Icon path={<><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></>} {...p} />,
Link: (p) => <Icon path={<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>} {...p} />,
Activity: (p) => <Icon path={<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/>} {...p} />,
CheckCircle: (p) => <Icon path={<><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></>} {...p} />,
Edit: (p) => <Icon path={<><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></>} {...p} />,
Brain: (p) => <Icon path={<><path d="M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z"/><path d="M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z"/></>} {...p} />,
ChevronDown: (p) => <Icon path={<path d="m6 9 6 6 6-6"/>} {...p} />,
Database: (p) => <Icon path={<><ellipse cx="12" cy="5" rx="9" ry="3"/><path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"/><path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"/></>} {...p} />,
Key: (p) => <Icon path={<><path d="m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"/></>} {...p} />,
Tv: (p) => <Icon path={<><rect width="20" height="15" x="2" y="7" rx="2" ry="2"/><polyline points="17 2 12 7 7 2"/></>} {...p} />,
Youtube: (p) => <Icon path={<><path d="M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17"/><path d="m10 15 5-3-5-3z"/></>} {...p} />,
Eye: (p) => <Icon path={<><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></>} {...p} />,
Mic: (p) => <Icon path={<><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/></>} {...p} />,
Video: (p) => <Icon path={<><path d="m22 8-6 4 6 4V8Z"/><rect width="14" height="12" x="2" y="6" rx="2" ry="2"/></>} {...p} />,
MessageSquare: (p) => <Icon path={<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>} {...p} />,
ScrollText: (p) => <Icon path={<><path d="M8 21h12a2 2 0 0 0 2-2v-2H10v2a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v3h4"/><path d="M19 17V5a2 2 0 0 0-2-2H4"/></>} {...p} />,
Search: (p) => <Icon path={<><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></>} {...p} />,
Hash: (p) => <Icon path={<><line x1="4" x2="20" y1="9" y2="9"/><line x1="4" x2="20" y1="15" y2="15"/><line x1="10" x2="8" y1="3" y2="21"/><line x1="16" x2="14" y1="3" y2="21"/></>} {...p} />,
Copy: (p) => <Icon path={<><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></>} {...p} />,
Check: (p) => <Icon path={<polyline points="20 6 9 17 4 12"/>} {...p} />,
AlertTriangle: (p) => <Icon path={<><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" x2="12" y1="9" y2="13"/><line x1="12" x2="12.01" y1="17" y2="17"/></>} {...p} />,
Wand: (p) => <Icon path={<><path d="M15 4V2"/><path d="M15 16v-2"/><path d="M8 9h2"/><path d="M20 9h2"/><path d="M17.8 11.8 19 13"/><path d="M15 9h0"/><path d="M17.8 6.2 19 5"/><path d="m3 21 9-9"/><path d="M12.2 6.2 11 5"/></>} {...p} />,
Server: (p) => <Icon path={<><rect width="20" height="8" x="2" y="2" rx="2" ry="2"/><rect width="20" height="8" x="2" y="14" rx="2" ry="2"/><line x1="6" x2="6.01" y1="6" y2="6"/><line x1="6" x2="6.01" y1="18" y2="18"/></>} {...p} />,
PlayCircle: (p) => <Icon path={<><circle cx="12" cy="12" r="10"/><polygon points="10 8 16 12 10 16 10 8"/></>} {...p} />,
Film: (p) => <Icon path={<><rect width="20" height="20" x="2" y="2" rx="2.18" ry="2.18"/><line x1="7" x2="7" y1="2" y2="22"/><line x1="17" x2="17" y1="2" y2="22"/><line x1="2" x2="22" y1="12" y2="12"/><line x1="2" x2="7" y1="7" y2="7"/><line x1="2" x2="7" y1="17" y2="17"/><line x1="17" x2="22" y1="17" y2="17"/><line x1="17" x2="22" y1="7" y2="7"/></>} {...p} />,
Upload: (p) => <Icon path={<><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></>} {...p} />
};
const GENERATOR_PLATFORMS = {
bilibili: { id: 'bilibili', name: 'Bilibili', icon: 'Tv', placeholder: '例如: 401742377 或 space.bilibili.com/...', colors: { main: 'orange-500', bgLight: 'bg-orange-50', text: 'text-orange-600', ring: 'ring-orange-500' }, requiresAuth: true, options: [
{ id: 'video', label: '用户投稿', path: '/bilibili/user/video/', desc: 'UP 主发布的视频', icon: 'Tv' },
{ id: 'dynamic', label: '用户动态', path: '/bilibili/user/dynamic/', desc: '转发与图文动态', icon: 'Activity' },
{ id: 'fav', label: '收藏夹', path: '/bilibili/user/fav/', desc: '默认收藏夹内容', icon: 'Star' },
{ id: 'coin', label: '投币视频', path: '/bilibili/user/coin/', desc: '最近投币的视频', icon: 'Database' },
]},
youtube: { id: 'youtube', name: 'YouTube', icon: 'Youtube', placeholder: '例如: @LofiGirl 或 youtube.com/@...', colors: { main: 'red-600', bgLight: 'bg-red-50', text: 'text-red-600', ring: 'ring-red-500' }, requiresAuth: true, options: [
{ id: 'video', label: '频道视频', desc: '频道最新发布的视频', icon: 'Video' },
{ id: 'community', label: '社区动态', desc: '社区帖子 (Community Tab)', icon: 'MessageSquare' }
]},
weibo: { id: 'weibo', name: '微博', icon: 'Eye', placeholder: '例如: weibo.com/u/123456', colors: { main: 'rose-500', bgLight: 'bg-rose-50', text: 'text-rose-600', ring: 'ring-rose-500' }, requiresAuth: true, options: [
{ id: 'timeline', label: '博主动态', path: '/weibo/user/', desc: '用户的全部微博动态', icon: 'ScrollText' },
{ id: 'keyword', label: '关键词搜索', path: '/weibo/keyword/', desc: '实时热搜关键词', icon: 'Search' }
]},
xiaoyuzhou: { id: 'xiaoyuzhou', name: '小宇宙', icon: 'Mic', placeholder: '例如: xiaoyuzhoufm.com/podcast/...', colors: { main: 'indigo-500', bgLight: 'bg-indigo-50', text: 'text-indigo-600', ring: 'ring-indigo-500' }, requiresAuth: false, options: [
{ id: 'podcast', label: '播客更新', path: '/xiaoyuzhou/podcast/', desc: '订阅该播客的最新单集', icon: 'Mic' }
]},
jike: { id: 'jike', name: '即刻', icon: 'Activity', placeholder: '例如: okjike.com/users/...', colors: { main: 'yellow-400', bgLight: 'bg-yellow-50', text: 'text-yellow-600', ring: 'ring-yellow-400' }, requiresAuth: false, options: [
{ id: 'user', label: '用户动态', path: '/jike/user/', desc: '指定用户的即刻动态', icon: 'Activity' },
{ id: 'topic', label: '圈子/话题', path: '/jike/topic/', desc: '指定圈子的精选/全部动态', icon: 'Hash' }
]}
};
// --- Helpers ---
const cn = (...classes) => classes.filter(Boolean).join(' ');
// --- RSS Parsers ---
const parseXMLRSS = (xmlText) => {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlText, "text/xml");
const isAtom = xmlDoc.querySelector("feed");
const feedTitle = xmlDoc.querySelector(isAtom ? "feed > title" : "channel > title")?.textContent || "";
const items = Array.from(xmlDoc.querySelectorAll(isAtom ? "entry" : "item"));
return items.map(item => {
const title = item.querySelector("title")?.textContent || "";
let link = "";
if (isAtom) {
link = item.querySelector("link[rel='alternate']")?.getAttribute("href") || item.querySelector("link")?.getAttribute("href");
} else {
link = item.querySelector("link")?.textContent;
}
const pubDate = item.querySelector("pubDate, published, updated")?.textContent || new Date().toISOString();
let description = "";
const contentEncoded = item.getElementsByTagNameNS("http://purl.org/rss/1.0/modules/content/", "encoded")[0];
if (contentEncoded) {
description = contentEncoded.textContent;
} else {
description = item.querySelector("encoded")?.textContent || item.querySelector("description, summary, content")?.textContent || "";
}
const guid = item.querySelector("guid, id")?.textContent || link;
// Enclosure parsing
const enclosure = item.querySelector("enclosure");
let mediaUrl = enclosure?.getAttribute("url");
let mediaType = enclosure?.getAttribute("type");
return { title, link, feedTitle, id: guid, isoDate: pubDate, description, content: description, mediaUrl, mediaType };
});
}
const fetchRSS = async (url) => {
// Strategy 1: RSS2JSON
try {
const res = await fetch(`https://api.rss2json.com/v1/api.json?rss_url=${encodeURIComponent(url)}`);
const data = await res.json();
if (data.status === 'ok') {
return data.items.map(item => ({
...item,
feedTitle: data.feed.title,
id: item.guid || item.link,
isoDate: item.pubDate,
description: item.description || item.content || '',
mediaUrl: item.enclosure?.link,
mediaType: item.enclosure?.type
}));
}
} catch (e) {}
// Strategy 2: AllOrigins
try {
const proxyUrl = `https://api.allorigins.win/get?url=${encodeURIComponent(url)}`;
const res = await fetch(proxyUrl);
const data = await res.json();
if (data.contents) {
const items = parseXMLRSS(data.contents);
if (items.length > 0) return items;
}
} catch(e) {}
// Strategy 3: CorsProxy
try {
const res = await fetch(`https://corsproxy.io/?${encodeURIComponent(url)}`);
if (res.ok) {
const text = await res.text();
const items = parseXMLRSS(text);
if (items.length > 0) return items;
}
} catch(e) {}
return [];
};
const parseOPML = (text) => {
try {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(text, "text/xml");
const outlines = xmlDoc.querySelectorAll("outline[xmlUrl]");
const newFeeds = [];
outlines.forEach(outline => {
const url = outline.getAttribute("xmlUrl");
const title = outline.getAttribute("text") || outline.getAttribute("title") || "New Feed";
if (url) newFeeds.push({
id: Date.now().toString() + Math.random().toString(36).substr(2, 9),
url,
title,
createdAt: new Date().toISOString()
});
});
return newFeeds;
} catch (e) {
console.error("OPML Parse Error", e);
return [];
}
};
const generateOPML = (feeds) => {
const header = `<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Folo Mini Feeds Export</title>
</head>
<body>`;
const footer = `
</body>
</opml>`;
const body = feeds.map(f => ` <outline text="${(f.title || '').replace(/"/g, '"')}" title="${(f.title || '').replace(/"/g, '"')}" type="rss" xmlUrl="${(f.url || '').replace(/"/g, '"')}" />`).join('\n');
return header + '\n' + body + footer;
};
// --- AI API Logic (Streaming) ---
// Streaming Function
const streamSummary = async (text, config, onReasoning, onUpdate, onComplete, onError) => {
if (!config.apiKey) {
onError("配置中缺失 API Key,请在设置中添加。");
return;
}
const cleanText = text.replace(/<[^>]+>/g, '').substring(0, 8000);
const contextPrompt = `请用通俗易懂的中文,为用户总结这篇文章的核心观点。\n\n文章内容:\n${cleanText}`;
try {
let url, body, headers, parseChunk;
// Remove trailing slash safely
let baseUrl = (config.baseUrl || '').replace(/\/+$/, '');
if (config.provider === 'google') {
baseUrl = baseUrl || 'https://generativelanguage.googleapis.com';
const model = config.model || 'gemini-1.5-flash';
// Use alt=sse for easier parsing
url = `${baseUrl}/v1beta/models/${model}:streamGenerateContent?key=${config.apiKey}&alt=sse`;
headers = { 'Content-Type': 'application/json' };
body = JSON.stringify({ contents: [{ parts: [{ text: contextPrompt }] }] });
parseChunk = (line) => {
if (line.startsWith('data: ')) {
try {
const json = JSON.parse(line.substring(6));
const content = json.candidates?.[0]?.content?.parts?.[0]?.text;
if (content) onUpdate(content);
} catch (e) { }
}
};
} else {
// OpenAI Compatible
baseUrl = baseUrl || 'https://api.deepseek.com';
const aiModel = config.model || "deepseek-chat";
url = `${baseUrl}/chat/completions`;
headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${config.apiKey}`
};
body = JSON.stringify({
model: aiModel,
messages: [
{ role: "system", content: "你是一个专业的文章摘要助手。请用通俗易懂的中文,为用户总结这篇文章的核心观点。使用无序列表列出3-5个重点。保持客观,不要使用第一人称。" },
{ role: "user", content: contextPrompt }
],
stream: true
});
parseChunk = (line) => {
if (line.startsWith('data: ') && line !== 'data: [DONE]') {
try {
const json = JSON.parse(line.substring(6));
const delta = json.choices?.[0]?.delta;
if (delta) {
// Handle Reasoning
if (delta.reasoning_content) {
onReasoning(delta.reasoning_content);
}
// Handle Content
else if (delta.content) {
onUpdate(delta.content);
}
}
} catch (e) { }
}
};
}
// 404 AUTO-FIX LOGIC (Same as checkConnection)
let response = await fetch(url, { method: 'POST', headers, body });
if (response.status === 404 && config.provider !== 'google' && !url.includes('/v1/')) {
// Try inserting /v1
const v1Url = `${baseUrl}/v1/chat/completions`;
const resV1 = await fetch(v1Url, { method: 'POST', headers, body });
if (resV1.status !== 404) {
response = resV1; // Use the successful v1 response
}
}
if (!response.ok) {
let errMsg = `HTTP ${response.status}`;
if (response.status === 401) errMsg = "401 无效 Key";
if (response.status === 403) errMsg = "403 余额不足/无权限";
if (response.status === 404) errMsg = "404 找不到模型 (请检查Base URL或模型ID)";
if (response.status === 429) errMsg = "429 请求过快";
throw new Error(errMsg);
}
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value, { stream: true });
buffer += chunk;
const lines = buffer.split('\n');
buffer = lines.pop();
for (const line of lines) {
const trimmed = line.trim();
if (trimmed) parseChunk(trimmed);
}
}
onComplete();
} catch (e) {
console.error(e);
onError(`流式生成失败: ${e.message}`);
}
};
const callGoogle = async (apiKey, baseUrl, model, text) => {
const url = `${baseUrl}/v1beta/models/${model}:generateContent?key=${apiKey}`;
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ contents: [{ parts: [{ text }] }] })
});
if (!res.ok) throw new Error(`Google API Error: ${res.status}`);
const data = await res.json();
return data.candidates?.[0]?.content?.parts?.[0]?.text;
};
const callOpenAI = async (apiKey, baseUrl, model, text) => {
// URL Normalization for Testing
let cleanBase = (baseUrl || '').replace(/\/+$/, '');
let url = `${cleanBase}/chat/completions`;
const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}` };
const body = JSON.stringify({
model: model,
messages: [{ role: "user", content: text }],
stream: false,
max_tokens: 50
});
let res = await fetch(url, { method: 'POST', headers, body });
// Retry logic
if (res.status === 404 && !url.includes('/v1/')) {
url = `${cleanBase}/v1/chat/completions`;
res = await fetch(url, { method: 'POST', headers, body });
}
if (!res.ok) {
try {
const err = await res.json();
if (err.error && err.error.message) throw new Error(`${res.status} ${err.error.message}`);
} catch(e) { if(e.message.includes(res.status)) throw e; }
throw new Error(`API Error: ${res.status}`);
}
const data = await res.json();
return data.choices?.[0]?.message?.content;
};
// --- UI Components ---
const Toast = ({ toasts, removeToast }) => (
<div className="toast-container">
{toasts.map(t => (
<div key={t.id} className={`toast ${t.type === 'error' ? 'error' : 'success'}`} onClick={() => removeToast(t.id)}>
{t.msg}
</div>
))}
</div>
);
const BackupModal = ({ open, onClose, onConfirm, stats, darkMode }) => {
const [options, setOptions] = useState({ feeds: true, favorites: true, settings: true, nodes: true });
if (!open) return null;
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4 animate-fade-in">
<div className={cn("w-full max-w-sm rounded-xl shadow-2xl p-6 transition-all scale-100", darkMode ? "bg-zinc-900 border border-zinc-800 text-zinc-100" : "bg-white text-zinc-900")}>
<div className="flex justify-between items-center mb-4">
<h3 className="text-lg font-bold flex items-center gap-2"><Icons.Download className="w-5 h-5" /> 备份与导出</h3>
<button onClick={onClose}><Icons.X className="w-5 h-5" /></button>
</div>
<p className="text-sm text-zinc-500 mb-4">
此操作将生成一个包含当前数据的独立 HTML 文件。您可以勾选需要保存的内容:
</p>
<div className="space-y-3 mb-6">
<label className="flex items-center justify-between p-3 rounded border cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800 transition-colors border-zinc-200 dark:border-zinc-800">
<div className="flex items-center gap-3">
<Icons.Rss className="w-4 h-4 text-orange-500" />
<div className="text-sm font-medium">订阅源</div>
</div>
<div className="flex items-center gap-2">
<span className="text-xs text-zinc-400">{stats.feedsCount} 个</span>
<input type="checkbox" checked={options.feeds} onChange={e => setOptions({...options, feeds: e.target.checked})} className="w-4 h-4 accent-purple-600" />
</div>
</label>
<label className="flex items-center justify-between p-3 rounded border cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800 transition-colors border-zinc-200 dark:border-zinc-800">
<div className="flex items-center gap-3">
<Icons.Star className="w-4 h-4 text-yellow-500" />
<div className="text-sm font-medium">收藏文章</div>
</div>
<div className="flex items-center gap-2">
<span className="text-xs text-zinc-400">{stats.favoritesCount} 篇</span>
<input type="checkbox" checked={options.favorites} onChange={e => setOptions({...options, favorites: e.target.checked})} className="w-4 h-4 accent-purple-600" />
</div>
</label>
<label className="flex items-center justify-between p-3 rounded border cursor-pointer hover:bg-zinc-50 dark:hover:bg-zinc-800 transition-colors border-zinc-200 dark:border-zinc-800">
<div className="flex items-center gap-3">
<Icons.Server className="w-4 h-4 text-blue-500" />
<div className="text-sm font-medium">RSSHub 节点</div>
</div>
<div className="flex items-center gap-2">
<span className="text-xs text-zinc-400">{stats.nodesCount} 个</span>
<input type="checkbox" checked={options.nodes} onChange={e => setOptions({...options, nodes: e.target.checked})} className="w-4 h-4 accent-blue-600" />
</div>
</label>
<label className={cn("flex items-center justify-between p-3 rounded border cursor-pointer transition-colors border-zinc-200 dark:border-zinc-800", options.settings ? "bg-red-50/50 dark:bg-red-900/10" : "hover:bg-zinc-50 dark:hover:bg-zinc-800")}>
<div className="flex items-center gap-3">
<Icons.Key className="w-4 h-4 text-red-500" />
<div className="flex flex-col">
<div className="text-sm font-medium">AI 配置与密钥</div>
{options.settings && <span className="text-[10px] text-red-500">包含敏感 API Key,请谨慎分享</span>}
</div>
</div>
<div className="flex items-center gap-2">
<span className="text-xs text-zinc-400">{stats.profilesCount} 组</span>
<input type="checkbox" checked={options.settings} onChange={e => setOptions({...options, settings: e.target.checked})} className="w-4 h-4 accent-red-600" />
</div>
</label>
</div>
<div className="flex justify-end gap-2">
<button onClick={onClose} className="px-4 py-2 text-sm text-zinc-500 hover:text-zinc-700">取消</button>
<button onClick={() => onConfirm(options)} className="px-4 py-2 text-sm bg-purple-600 hover:bg-purple-700 text-white rounded-lg flex items-center gap-2 shadow-lg shadow-purple-500/20">
<Icons.Download className="w-4 h-4" /> 确认下载
</button>
</div>
</div>
</div>
);
};
const OPMLModal = ({ open, onClose, onImport, onExport, darkMode }) => {
const fileInputRef = useRef(null);
if (!open) return null;
const handleFileChange = (e) => {
const file = e.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = (event) => {
const text = event.target.result;
const feeds = parseOPML(text);
if (feeds.length > 0) {
onImport(feeds);
onClose();
} else {
alert("OPML 解析失败或文件为空");
}
};
reader.readAsText(file);
};
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4 animate-fade-in">
<div className={cn("w-full max-w-sm rounded-xl shadow-2xl p-6 transition-all scale-100", darkMode ? "bg-zinc-900 border border-zinc-800 text-zinc-100" : "bg-white text-zinc-900")}>
<div className="flex justify-between items-center mb-4">
<h3 className="text-lg font-bold flex items-center gap-2"><Icons.Rss className="w-5 h-5" /> 导入/导出 OPML</h3>
<button onClick={onClose}><Icons.X className="w-5 h-5" /></button>
</div>
<p className="text-sm text-zinc-500 mb-6">
管理您的订阅列表。支持标准的 OPML 格式,兼容 Feedly、Inoreader 等。
</p>
<div className="space-y-3">
<button onClick={() => fileInputRef.current.click()} className="w-full p-3 rounded-lg border border-dashed border-zinc-300 dark:border-zinc-700 hover:border-purple-500 dark:hover:border-purple-500 hover:bg-purple-50 dark:hover:bg-purple-900/10 flex items-center justify-center gap-2 transition-all group">
<Icons.Upload className="w-5 h-5 text-zinc-400 group-hover:text-purple-600" />
<span className="text-sm font-medium text-zinc-600 dark:text-zinc-400 group-hover:text-purple-700 dark:group-hover:text-purple-400">导入 OPML 文件</span>
</button>
<input type="file" ref={fileInputRef} onChange={handleFileChange} accept=".opml,.xml" className="hidden" />
<button onClick={onExport} className="w-full p-3 rounded-lg border border-zinc-200 dark:border-zinc-800 hover:bg-zinc-50 dark:hover:bg-zinc-800 flex items-center justify-center gap-2 transition-all">
<Icons.Download className="w-5 h-5 text-zinc-400" />
<span className="text-sm font-medium text-zinc-600 dark:text-zinc-400">导出当前订阅</span>
</button>
</div>
</div>
</div>
);
};
const SettingsModal = ({ open, onClose, profiles, activeProfileId, onSaveProfiles, onSetActiveProfile, darkMode, addToast }) => {
const activeProfile = profiles.find(p => p.id === activeProfileId) || profiles[0];
const [localActiveProfile, setLocalActiveProfile] = useState(activeProfile);
const [availableModels, setAvailableModels] = useState([]);
const [isChecking, setIsChecking] = useState(false);
const [isTestingModel, setIsTestingModel] = useState(false);
const [isRenaming, setIsRenaming] = useState(false);
const [renameValue, setRenameValue] = useState("");
useEffect(() => {
if (open) {
const current = profiles.find(p => p.id === activeProfileId) || profiles[0];
setLocalActiveProfile(current);
setAvailableModels([]);
setIsRenaming(false);
}
}, [open, profiles, activeProfileId]);
if (!open) return null;
const updateField = (field, value) => {
setLocalActiveProfile(prev => {
const updated = { ...prev, [field]: value };
if (field === 'provider') {
updated.baseUrl = value === 'google'
? 'https://generativelanguage.googleapis.com'
: 'https://api.deepseek.com';
updated.model = '';
setAvailableModels([]);
}
return updated;
});
};
const handleProfileSwitch = (e) => {
const newId = e.target.value;
// Save current changes to the old profile before switching?
// Simple approach: Trigger parent save for current, then switch.
onSaveProfiles(profiles.map(p => p.id === localActiveProfile.id ? localActiveProfile : p));
onSetActiveProfile(newId);
};
const handleAddProfile = () => {
const newId = `custom-${Date.now()}`;
const newProfile = {
id: newId,
name: '新配置 ' + (profiles.length + 1),
provider: 'openai',
baseUrl: 'https://api.deepseek.com',
apiKey: '',
model: 'deepseek-chat'
};
// Save current work then add new
const updatedList = profiles.map(p => p.id === localActiveProfile.id ? localActiveProfile : p);
onSaveProfiles([...updatedList, newProfile]);
onSetActiveProfile(newId);
};
const handleDeleteProfile = () => {
if (profiles.length <= 1) {
addToast("至少保留一个配置", "error");
return;
}
if (confirm(`确定删除配置 "${localActiveProfile.name}" 吗?`)) {
const newList = profiles.filter(p => p.id !== localActiveProfile.id);
onSaveProfiles(newList);
onSetActiveProfile(newList[0].id);
}
};
const startRename = () => {
setRenameValue(localActiveProfile.name);
setIsRenaming(true);
};
const finishRename = () => {
if (renameValue.trim()) {
updateField('name', renameValue.trim());
}
setIsRenaming(false);
};
const saveAll = () => {
// Update the current profile in the main list
const updatedList = profiles.map(p => p.id === localActiveProfile.id ? localActiveProfile : p);
onSaveProfiles(updatedList);
addToast("设置已保存");
onClose();
};
const checkConnection = async () => {
if (!localActiveProfile.apiKey) {
addToast("请先填写 API Key", "error");
return;
}
setIsChecking(true);
try {
if (localActiveProfile.provider === 'google') {
const baseUrl = (localActiveProfile.baseUrl || 'https://generativelanguage.googleapis.com').replace(/\/$/, '');
const res = await fetch(`${baseUrl}/v1beta/models?key=${localActiveProfile.apiKey}`);
if (res.ok) {
const data = await res.json();
if (data.models) {
const ids = data.models
.filter(m => m.supportedGenerationMethods && m.supportedGenerationMethods.includes("generateContent"))
.map(m => m.name.replace('models/', ''))
.sort();
setAvailableModels(ids);
addToast(`成功!筛选出 ${ids.length} 个对话模型。`);
if (!localActiveProfile.model) updateField('model', ids[0]);
}
} else {
throw new Error(`HTTP ${res.status}`);
}
} else {
// FIX: Ensure no double slashes and handle /v1 logic robustly
let baseUrl = (localActiveProfile.baseUrl || 'https://api.deepseek.com').replace(/\/+$/, '');
// Try 1: Direct path
let res = await fetch(`${baseUrl}/models`, { headers: { 'Authorization': `Bearer ${localActiveProfile.apiKey}` } });
// Try 2: Add /v1 if failed
if (res.status === 404 && !baseUrl.includes('/v1')) {
const v1Url = `${baseUrl}/v1/models`;
const resV1 = await fetch(v1Url, { headers: { 'Authorization': `Bearer ${localActiveProfile.apiKey}` } });
if (resV1.ok || resV1.status !== 404) res = resV1;
}
if (res.ok) {
const data = await res.json();
if (data.data && Array.isArray(data.data)) {
const ids = data.data
.map(m => m.id)
.filter(id => !id.includes('embedding') && !id.includes('tts') && !id.includes('audio') && !id.includes('whisper'))
.sort();
setAvailableModels(ids);
addToast(`成功!发现 ${ids.length} 个模型。`);
if (!localActiveProfile.model && ids.length > 0) updateField('model', ids[0]);
} else {
addToast("连接成功,但未找到模型列表", "error");
}
} else {
throw new Error(`HTTP ${res.status}`);
}
}
} catch (e) {
addToast(`连接失败: ${e.message}`, "error");
} finally {
setIsChecking(false);
}
};
const testCurrentModel = async () => {
if (!localActiveProfile.apiKey || !localActiveProfile.model) {
addToast("请先填写 Key 并选择模型", "error");
return;
}
setIsTestingModel(true);
const baseUrl = (localActiveProfile.baseUrl || (localActiveProfile.provider === 'google' ? 'https://generativelanguage.googleapis.com' : 'https://api.deepseek.com')).replace(/\/$/, '');
try {
const testPrompt = "Hi";
let res;
if (localActiveProfile.provider === 'google') {
res = await callGoogle(localActiveProfile.apiKey, baseUrl, localActiveProfile.model, testPrompt);
} else {
res = await callOpenAI(localActiveProfile.apiKey, baseUrl, localActiveProfile.model, testPrompt);
}
if (res) addToast(`测试通过!模型回复正常。`);
else throw new Error("无回复");
} catch (e) {
addToast(`测试失败: ${e.message}`, "error");
} finally {
setIsTestingModel(false);
}
};
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4 animate-fade-in">
<div className={cn("w-full max-w-md rounded-xl shadow-2xl p-6 transition-all scale-100 flex flex-col max-h-[90vh]", darkMode ? "bg-zinc-900 border border-zinc-800 text-zinc-100" : "bg-white text-zinc-900")}>
<div className="flex justify-between items-center mb-4 shrink-0">
<h3 className="text-lg font-bold flex items-center gap-2"><Icons.Settings className="w-5 h-5" /> AI 配置</h3>
<button onClick={onClose}><Icons.X className="w-5 h-5" /></button>
</div>
<div className="space-y-4 overflow-y-auto flex-1 custom-scrollbar pr-1">
{/* Profile Selector */}
<div className={cn("p-3 rounded-lg border space-y-2", darkMode ? "bg-zinc-950 border-zinc-800" : "bg-zinc-50 border-zinc-200")}>
<div className="flex justify-between items-center">
<label className="text-xs font-bold text-zinc-500 uppercase tracking-wider">配置方案</label>
<div className="flex gap-1">
{isRenaming ? (
<div className="flex items-center gap-1">
<input
value={renameValue}
onChange={e => setRenameValue(e.target.value)}
onBlur={finishRename}
onKeyDown={e => e.key === 'Enter' && finishRename()}
autoFocus
className={cn("w-24 text-xs px-1 py-0.5 rounded border outline-none", darkMode ? "bg-zinc-900 border-zinc-700" : "bg-white border-zinc-300")}
/>
<button onClick={finishRename} className="text-green-500"><Icons.CheckCircle className="w-3 h-3"/></button>
</div>
) : (
<button onClick={startRename} title="重命名当前方案" className="text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300 p-1"><Icons.Edit className="w-3 h-3"/></button>
)}
<button onClick={handleDeleteProfile} title="删除当前方案" className="text-zinc-400 hover:text-red-500 p-1"><Icons.Trash className="w-3 h-3"/></button>
</div>
</div>
<div className="flex gap-2">
<select
value={activeProfileId}
onChange={handleProfileSwitch}
className={cn("flex-1 px-3 py-2 rounded text-sm border outline-none cursor-pointer font-medium", darkMode ? "bg-zinc-900 border-zinc-700" : "bg-white border-zinc-300")}
>
{profiles.map(p => <option key={p.id} value={p.id}>{p.name}</option>)}
</select>
<button onClick={handleAddProfile} className="px-3 py-2 bg-zinc-200 dark:bg-zinc-800 hover:bg-zinc-300 dark:hover:bg-zinc-700 rounded text-zinc-600 dark:text-zinc-300"><Icons.Plus className="w-4 h-4" /></button>
</div>
</div>
<hr className={cn("border-t", darkMode ? "border-zinc-800" : "border-zinc-200")} />
<div>
<label className="block text-xs font-medium text-zinc-500 mb-1">服务商类型</label>
<select
value={localActiveProfile.provider}
onChange={e => updateField('provider', e.target.value)}
className={cn("w-full px-3 py-2 rounded-lg text-sm border outline-none cursor-pointer", darkMode ? "bg-zinc-950 border-zinc-800 focus:border-purple-500" : "bg-zinc-50 border-zinc-200 focus:border-purple-500")}
>
<option value="openai">OpenAI 兼容 (DeepSeek/ChatGPT/自定义)</option>
<option value="google">Google Gemini (官方)</option>
</select>
</div>
<div>
<label className="block text-xs font-medium text-zinc-500 mb-1">API Base URL</label>
<input type="text" value={localActiveProfile.baseUrl} onChange={e => updateField('baseUrl', e.target.value)} className={cn("w-full px-3 py-2 rounded-lg text-sm border outline-none", darkMode ? "bg-zinc-950 border-zinc-800 focus:border-purple-500" : "bg-zinc-50 border-zinc-200 focus:border-purple-500")} />
</div>
<div>
<label className="block text-xs font-medium text-zinc-500 mb-1">API Key</label>
<input type="password" value={localActiveProfile.apiKey} onChange={e => updateField('apiKey', e.target.value)} className={cn("w-full px-3 py-2 rounded-lg text-sm border outline-none", darkMode ? "bg-zinc-950 border-zinc-800 focus:border-purple-500" : "bg-zinc-50 border-zinc-200 focus:border-purple-500")} placeholder="sk-..." />
</div>
<div className="flex justify-end">
<button
onClick={checkConnection}
disabled={isChecking}
className={cn("flex items-center gap-1 text-xs px-2 py-1 rounded transition-colors",
isChecking ? "opacity-50 cursor-wait" : "hover:bg-zinc-100 dark:hover:bg-zinc-800 text-purple-600 dark:text-purple-400"
)}
>
{isChecking ? <Icons.Loader className="w-3 h-3" /> : <Icons.Activity className="w-3 h-3" />}
{isChecking ? "正在筛选..." : "检测连接 & 获取模型"}
</button>
</div>
<div>
<label className="block text-xs font-medium text-zinc-500 mb-1">模型名称 (Model ID)</label>
<div className="space-y-2">
{availableModels.length > 0 ? (
<div className="flex gap-2">
<select
onChange={e => updateField('model', e.target.value)}
className={cn("flex-1 px-2 py-2 rounded text-sm border outline-none cursor-pointer", darkMode ? "bg-zinc-950 border-zinc-700" : "bg-white border-zinc-300")}
value={availableModels.includes(localActiveProfile.model) ? localActiveProfile.model : ""}
>
<option value="" disabled>-- 请选择模型 --</option>
{availableModels.map(m => (
<option key={m} value={m}>{m}</option>
))}
</select>
<button
onClick={testCurrentModel}
disabled={isTestingModel || !localActiveProfile.model}
className={cn("px-3 py-1.5 rounded text-xs border transition-all flex items-center gap-1",
isTestingModel ? "opacity-50" : "hover:border-green-500 hover:text-green-600 dark:hover:text-green-400",
darkMode ? "border-zinc-700 bg-zinc-900" : "border-zinc-300 bg-white"
)}
>
{isTestingModel ? <Icons.Loader className="w-3 h-3"/> : <Icons.CheckCircle className="w-3 h-3"/>}
测试
</button>
</div>
) : (
<input
type="text"
value={localActiveProfile.model || ''}
onChange={e => updateField('model', e.target.value)}
className={cn("w-full px-3 py-2 rounded-lg text-sm border outline-none", darkMode ? "bg-zinc-950 border-zinc-800 focus:border-purple-500" : "bg-zinc-50 border-zinc-200 focus:border-purple-500")}
placeholder="如 deepseek-chat"
/>
)}
</div>
</div>
</div>
<div className="mt-6 flex justify-end gap-2 shrink-0">
<button onClick={onClose} className="px-4 py-2 text-sm text-zinc-500 hover:text-zinc-700">取消</button>
<button onClick={saveAll} className="px-4 py-2 text-sm bg-purple-600 text-white rounded-lg flex items-center gap-2 hover:bg-purple-700 shadow-lg shadow-purple-500/20"><Icons.Save className="w-4 h-4" /> 保存当前配置</button>
</div>
</div>
</div>
);
};
// --- RSS Generator Modal Component ---
const RSSGeneratorModal = ({ open, onClose, onAddFeed, darkMode, addToast, savedNodes, setSavedNodes }) => {
const [platform, setPlatform] = useState('bilibili');
const [uid, setUid] = useState('');
const [selectedType, setSelectedType] = useState('video');
const [baseUrl, setBaseUrl] = useState('https://eren.zeabur.app');
const [dropdownOpen, setDropdownOpen] = useState(false);
useEffect(() => {
if(GENERATOR_PLATFORMS[platform]) {
setSelectedType(GENERATOR_PLATFORMS[platform].options[0].id);
setUid('');
}
}, [platform]);
if (!open) return null;
const handleInputChange = (e) => {
const value = e.target.value;
setUid(value);
};
const getSmartUid = () => {
let cleanUid = uid;
if (platform === 'bilibili') {
const match = uid.match(/(?:space\.bilibili\.com|bilibili\.com\/space)\/(\d+)/);
if (match) cleanUid = match[1];
} else if (platform === 'youtube') {
const handleMatch = uid.match(/@([\w.-]+)/);
if (handleMatch) cleanUid = `@${handleMatch[1]}`;
} else if (platform === 'weibo') {
const match = uid.match(/weibo\.com\/u\/(\d+)/);
if (match) cleanUid = match[1];
}
return cleanUid;
}
const getResultUrl = () => {
if (!uid) return '';
const p = GENERATOR_PLATFORMS[platform];
const cleanBase = baseUrl.replace(/\/$/, '');
let path = '';
const cleanUid = getSmartUid();
if (platform === 'youtube') {
if (selectedType === 'community') path = `/youtube/community/${cleanUid}`;
else path = cleanUid.startsWith('UC') ? `/youtube/channel/${cleanUid}` : `/youtube/user/${cleanUid}`;
} else if (platform === 'weibo' && selectedType === 'keyword') {
path = `/weibo/keyword/${encodeURIComponent(cleanUid)}`;
} else {
const opt = p.options.find(o => o.id === selectedType);
if (opt && opt.path) path = `${opt.path}${cleanUid}`;
}
return path ? `${cleanBase}${path}` : '';
};
const resultUrl = getResultUrl();
const currentPlatform = GENERATOR_PLATFORMS[platform];
const PlatformIcon = Icons[currentPlatform.icon];
const showAuthWarning = ['bilibili', 'youtube', 'weibo'].includes(platform);
const handleAddNode = () => {
if (baseUrl && !savedNodes.includes(baseUrl)) {
setSavedNodes([...savedNodes, baseUrl]);
addToast("节点已保存");
}
};
const handleAddToFolo = () => {
if (resultUrl) {
onAddFeed(resultUrl);
onClose();
}
};
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4 animate-fade-in">
<div className={cn("w-full max-w-2xl rounded-xl shadow-2xl overflow-hidden flex flex-col max-h-[90vh]", darkMode ? "bg-zinc-900 border border-zinc-800 text-zinc-100" : "bg-white text-zinc-900")}>
<div className="p-4 border-b border-gray-200 dark:border-zinc-800 flex justify-between items-center bg-gray-50 dark:bg-zinc-950">
<div className="flex items-center gap-3">
<div className={cn("p-2 rounded-full text-white shadow-sm", `bg-${currentPlatform.colors.main.split('-')[0]}-${currentPlatform.colors.main.split('-')[1]}`)}>
<PlatformIcon className="w-5 h-5" />
</div>
<h2 className="text-lg font-bold">RSS 订阅源生成器</h2>
</div>
<button onClick={onClose}><Icons.X className="w-5 h-5" /></button>