ReferenceLibrary.vue
148 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
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
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
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
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
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
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
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
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
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
<template>
<div class="reference-library">
<!-- 子 Tab 切换器:全部文献 / 文献集 -->
<div class="library-tabs">
<div
class="library-tab"
:class="{ active: librarySubTab === 'all' }"
@click="librarySubTab = 'all'; activeCollection = null"
>
{{ t('referenceLibrary.allReferences') || '全部文献' }}
</div>
<div
class="library-tab"
:class="{ active: librarySubTab === 'collections' }"
@click="librarySubTab = 'collections'; activeCollection = null"
>
{{ t('referenceLibrary.collections') || '文献集' }}
</div>
</div>
<!-- 搜索与操作栏:全部文献 / 文献集 两种模式 -->
<div class="library-toolbar">
<!-- 全部文献模式 -->
<template v-if="librarySubTab === 'all'">
<button
class="toolbar-btn upload-btn"
:title="t('reference.addReference') || '上传'"
@click="handleUploadClick"
:disabled="!canAddReference"
>
<i class="fas fa-upload"></i>
</button>
<div class="search-wrapper">
<i class="fas fa-search search-icon"></i>
<input
v-model="searchKeyword"
type="text"
class="search-input"
:placeholder="t('referenceLibrary.searchPlaceholder') || '搜索文献'"
/>
</div>
<el-dropdown trigger="click" placement="right-start" class="filter-dropdown">
<button
class="toolbar-btn filter-btn"
:title="t('referenceLibrary.filter') || '筛选'"
>
<i class="fas fa-bars"></i>
</button>
<template #dropdown>
<div class="filter-panel" @click.stop>
<div class="filter-panel-title">{{ t('referenceLibrary.filterTitle') || '文献筛选' }}</div>
<div class="filter-section">
<div class="filter-section-label">{{ t('referenceLibrary.pdfStatus') || 'PDF文件状态' }}</div>
<div class="filter-options">
<button
v-for="opt in pdfStatusOptions"
:key="opt.value"
class="filter-opt-btn"
:class="{ active: filterState.pdfStatus === opt.value }"
@click="filterState.pdfStatus = opt.value"
>
{{ opt.label }}
</button>
</div>
</div>
<div class="filter-section">
<div class="filter-section-label">{{ t('referenceLibrary.pubYear') || '出版年份' }}</div>
<div class="filter-options">
<button
v-for="opt in pubYearOptions"
:key="opt.value"
class="filter-opt-btn"
:class="{ active: filterState.pubYear === opt.value }"
@click="filterState.pubYear = opt.value"
>
{{ opt.label }}
</button>
</div>
</div>
<div class="filter-section">
<div class="filter-section-label">{{ t('referenceLibrary.impactFactor') || '影响因子' }}</div>
<div class="filter-options">
<button
v-for="opt in impactFactorOptions"
:key="opt.value"
class="filter-opt-btn"
:class="{ active: filterState.impactFactor === opt.value }"
@click="filterState.impactFactor = opt.value"
>
{{ opt.label }}
</button>
</div>
</div>
<div class="filter-section">
<div class="filter-section-label">{{ t('referenceLibrary.openAccess') || '开放访问' }}</div>
<div class="filter-options">
<button
v-for="opt in openAccessOptions"
:key="opt.value"
class="filter-opt-btn"
:class="{ active: filterState.openAccess === opt.value }"
@click="filterState.openAccess = opt.value"
>
{{ opt.label }}
</button>
</div>
</div>
<div class="filter-section">
<div class="filter-section-header">
<div class="filter-section-label">
{{ t('referenceLibrary.litType') || '文献类型' }}
</div>
<label class="filter-checkbox all-checkbox">
<input
v-model="filterState.litTypes"
type="checkbox"
value="all"
/>
<span>{{ t('referenceLibrary.all') || '所有' }}</span>
</label>
</div>
<div class="filter-options filter-options-grid">
<label
v-for="opt in litTypeOptions"
:key="opt.value"
class="filter-checkbox"
>
<input
v-model="filterState.litTypes"
type="checkbox"
:value="opt.value"
/>
<span>{{ opt.label }}</span>
</label>
</div>
</div>
<div class="filter-section">
<div class="filter-section-label">{{ t('referenceLibrary.personalTags') || '个性化标签' }}</div>
<div class="filter-options">
<button
v-for="opt in tagOptions"
:key="opt.value"
class="filter-opt-btn"
:class="{ active: filterState.tag === opt.value }"
@click="filterState.tag = opt.value"
>
{{ opt.label }}
</button>
</div>
</div>
<div class="filter-tag-input-row">
<input
v-model="tagInput"
type="text"
class="filter-tag-input"
:placeholder="t('referenceLibrary.addTagPlaceholder') || '添加标签...'"
/>
<button class="filter-add-btn" @click="handleAddTag">
{{ t('referenceLibrary.add') || '添加' }}
</button>
</div>
</div>
</template>
</el-dropdown>
</template>
<!-- 文献集模式 -->
<template v-else>
<div class="search-wrapper search-wrapper-full">
<i class="fas fa-search search-icon"></i>
<input
v-model="collectionSearchKeyword"
type="text"
class="search-input"
:placeholder="t('referenceLibrary.searchCollections') || '搜索文献集....'"
/>
</div>
<button
class="toolbar-btn new-collection-btn"
:title="t('referenceLibrary.newCollection') || '新建文献集'"
@click="handleCreateCollection"
:disabled="collectionsCreateBusy"
>
<i class="fas fa-folder-plus"></i>
</button>
</template>
</div>
<!-- 内容区域 -->
<div class="library-content">
<!-- 文献集:当前文献集下的文献列表(样式与全部文献一致) -->
<template v-if="librarySubTab === 'collections' && activeCollection">
<div class="collection-detail-header">
<button
class="collection-back-btn"
:title="t('common.back') || '返回'"
@click="activeCollection = null"
>
<i class="fas fa-arrow-left"></i>
</button>
<span class="collection-detail-title">{{ activeCollection.title }}</span>
</div>
<div v-if="collectionDocsBusy" class="library-loading">
<i class="fas fa-spinner fa-spin"></i>
<span>{{ t('reference.loading') || '加载中...' }}</span>
</div>
<div
v-else-if="collectionDisplayReferences.length === 0"
class="library-empty"
>
<i class="fas fa-book-open empty-icon"></i>
<span>该文献集中暂无文献</span>
</div>
<div v-else class="library-cards">
<div
v-for="ref in collectionDisplayReferences"
:key="ref.workId"
class="reference-card"
>
<!-- 添加到文献集下拉菜单 -->
<el-dropdown
:ref="(el) => setAddToCollectionDropdownRef(ref.workId, el)"
trigger="click"
placement="right-start"
:disabled="!!(ref as any).isMock"
@visible-change="handleAddToCollectionDropdownVisibleChange"
>
<button
class="card-add-btn"
:title="'添加到文献集'"
@click="handleAddRef(ref)"
>
<i class="fas fa-plus"></i>
</button>
<template #dropdown>
<div
v-if="addToCollectionTargetWorkId === ref.workId"
class="add-collection-panel"
>
<div class="add-collection-title">
{{ t('referenceLibrary.collections') || '文献集' }}
</div>
<div class="add-collection-search" @click.stop>
<i class="fas fa-search search-icon"></i>
<input
v-model="addToCollectionSearchKeyword"
type="text"
class="search-input"
:placeholder="t('referenceLibrary.searchCollections') || '搜索文献集...'"
/>
</div>
<div v-if="collectionsBusy" class="library-loading">
<i class="fas fa-spinner fa-spin"></i>
<span>{{ t('reference.loading') || '加载中...' }}</span>
</div>
<div
v-else-if="addToCollectionFilteredCollections.length === 0"
class="add-collection-empty"
>
暂无文献集
</div>
<div v-else class="add-collection-list">
<div
v-for="coll in addToCollectionFilteredCollections"
:key="coll.id"
class="add-collection-item"
:class="{ selected: addToCollectionSelectedCollectionId === coll.id }"
@click.stop="addToCollectionSelectedCollectionId = coll.id"
>
<div class="add-collection-item-title">{{ coll.title }}</div>
<div class="add-collection-item-meta">
{{ coll.count }} {{ t('referenceLibrary.referencesCount') || '篇' }}
</div>
</div>
</div>
<!-- 创建文献集入口 -->
<div class="add-collection-create">
<div
v-if="!addToCollectionShowCreateInput"
class="add-collection-create-entry"
:class="{ disabled: addToCollectionCreateBusy }"
@click.stop="!addToCollectionCreateBusy && handleAddToCollectionCreateCollection()"
>
<i class="fas fa-plus"></i>
创建文献集
</div>
<div
v-else
class="add-collection-create-input-wrap"
@click.stop
>
<i class="fas fa-plus add-collection-create-input-plus"></i>
<input
ref="addToCollectionNewCollectionInputRef"
v-model="addToCollectionNewCollectionName"
class="collection-create-input"
type="text"
:disabled="addToCollectionCreateBusy"
placeholder="输入文献集名称,回车创建"
@keydown.enter.prevent="submitAddToCollectionCreateCollection"
@blur="submitAddToCollectionCreateCollectionOnBlur"
@keydown.esc.prevent="closeAddToCollectionCreateCollectionInput"
/>
<div
class="add-collection-create-submit"
:class="{ disabled: addToCollectionCreateBusy }"
@mousedown.prevent
@click.stop="!addToCollectionCreateBusy && submitAddToCollectionCreateCollection()"
>
创建
</div>
</div>
</div>
<div class="add-collection-actions">
<button class="add-collection-cancel" @click="cancelAddToCollection">
{{ t('common.cancel') || '取消' }}
</button>
<button
class="add-collection-confirm"
:disabled="addToCollectionBusy || !addToCollectionSelectedCollectionId"
@click="confirmAddToCollection"
>
{{ t('common.save') || '确认' }}
</button>
</div>
</div>
</template>
</el-dropdown>
<div class="card-title">{{ ref.title }}</div>
<div class="card-author">
{{ formatAuthorsDisplayForCard(ref.authorsText) || '—' }}
</div>
<div class="card-journal">{{ ref.venueName || ref.journalAbbr || getJournal(ref) }}</div>
<div class="card-meta">
<span v-if="ref.impactFactor">IF {{ ref.impactFactor }}</span>
<span v-if="ref.publicationYear" class="meta-sep">·</span>
<span v-if="ref.publicationYear">{{ ref.publicationYear }}</span>
<span v-if="ref.citations" class="meta-sep">·</span>
<span v-if="ref.citations">{{ ref.citations }} citations</span>
<span v-if="ref.doi" class="meta-sep">·</span>
<a
v-if="ref.doi"
:href="`https://doi.org/${ref.doi}`"
target="_blank"
rel="noopener noreferrer"
class="doi-link"
@click.stop
>
DOI
</a>
</div>
<div class="card-actions">
<div
class="action-btn"
@click="openDetail(ref)"
>
<i class="fas fa-info-circle"></i>
<span>{{ t('referenceLibrary.detail') || '详情' }}</span>
</div>
<div
class="action-btn"
@click="openOriginal(ref)"
>
<i class="fas fa-external-link-alt"></i>
<span>{{ t('reference.viewOriginal') || '打开原文' }}</span>
</div>
<div
class="action-btn"
@click="copyCitation(ref)"
>
<i class="fas fa-quote-right"></i>
<span>{{ t('referenceLibrary.citation') || '引用' }}</span>
</div>
<label
v-if="getWorkIdForCollectionDocSelect(ref) > 0"
class="card-delete-checkbox"
:title="
t('referenceLibrary.selectCollectionDocHint') ||
'选择以从文献库删除或移出文献集'
"
@click.stop
>
<input
type="checkbox"
:checked="
isCollectionDocWorkIdSelected(getWorkIdForCollectionDocSelect(ref))
"
@change="
toggleCollectionDocWorkIdSelection(getWorkIdForCollectionDocSelect(ref))
"
/>
</label>
</div>
</div>
</div>
</template>
<!-- 文献集:集合卡片列表 -->
<div
v-else-if="
librarySubTab === 'collections' &&
!collectionsBusy &&
(collections.length > 0 || showCreateCollectionInput)
"
class="library-collections"
>
<div
v-if="showCreateCollectionInput"
class="collection-card collection-create-card"
@click.stop
>
<input
ref="newCollectionInputRef"
v-model="newCollectionName"
class="collection-create-input"
type="text"
:disabled="collectionsCreateBusy"
placeholder="输入文献集名称,回车创建"
@keydown.enter.prevent="submitCreateCollection"
@blur="submitCreateCollectionOnBlur"
@keydown.esc.prevent="closeCreateCollectionInput"
/>
</div>
<div
v-for="coll in displayCollections"
:key="coll.id"
class="collection-card"
@click="openCollection(coll)"
>
<label
class="collection-delete-checkbox"
:title="t('referenceLibrary.selectCollectionToDelete') || '选择以删除文献集'"
@click.stop
>
<input
type="checkbox"
:checked="isCollectionIdSelected(coll.id)"
@change="toggleCollectionIdSelection(coll.id)"
/>
</label>
<div class="collection-title-row">
<input
v-if="editingCollectionId === coll.id"
ref="editCollectionInputRef"
v-model="editingCollectionName"
class="collection-title-input"
type="text"
:disabled="collectionsRenameBusy"
:placeholder="'重命名文献集名称'"
@click.stop
@keydown.enter.prevent="submitRenameCollection('enter')"
@blur="submitRenameCollection('blur')"
/>
<div v-else class="collection-title">{{ coll.title }}</div>
<button
v-if="editingCollectionId !== coll.id"
type="button"
class="collection-edit-btn"
:disabled="collectionsRenameBusy"
:title="'编辑'"
@click.stop="startRenameCollection(coll)"
>
<i class="fas fa-pen"></i>
</button>
</div>
<div class="collection-meta">
{{ coll.count }} {{ t('referenceLibrary.referencesCount') || '篇' }}
<span class="meta-sep">·</span>
{{ t('referenceLibrary.created') || '创建:' }} {{ coll.createdAt }}
</div>
</div>
</div>
<!-- 文献集:无数据提示 -->
<div
v-else-if="
librarySubTab === 'collections' &&
!collectionsBusy &&
collections.length === 0 &&
!!collectionSearchKeyword.trim() &&
!showCreateCollectionInput
"
class="library-empty collections-empty"
>
<i class="fas fa-box-open collections-empty-icon"></i>
<div class="collections-empty-text">
{{ t('referenceLibrary.emptyCollectionsSearchHint') || '未找到匹配的文献集' }}
</div>
</div>
<!-- 文献集:无数据提示 -->
<div
v-else-if="
librarySubTab === 'collections' &&
!collectionsBusy &&
collections.length === 0 &&
!collectionSearchKeyword.trim() &&
!showCreateCollectionInput
"
class="library-empty collections-empty"
>
<i class="fas fa-box-open collections-empty-icon"></i>
<div class="collections-empty-text">
创建您的第一个文献集以开始使用。
</div>
<el-button
type="primary"
class="import-btn collections-empty-btn"
@click="handleCreateCollection"
:disabled="collectionsCreateBusy"
>
<i class="fas fa-plus"></i>添加文献集
</el-button>
</div>
<!-- 文献集:加载中 -->
<div
v-else-if="librarySubTab === 'collections' && collectionsBusy"
class="library-loading"
>
<i class="fas fa-spinner fa-spin"></i>
<span>{{ t('reference.loading') || '加载中...' }}</span>
</div>
<!-- 全部文献:加载中 -->
<div
v-else-if="isLoading"
class="library-loading"
>
<i class="fas fa-spinner fa-spin"></i>
<span>{{ t('reference.loading') || '加载中...' }}</span>
</div>
<!-- 全部文献:库中无任何文献 — 引导添加来源 -->
<div
v-else-if="
librarySubTab === 'all' &&
references.length === 0 &&
!searchKeyword.trim()
"
class="library-empty library-empty-cta"
>
<div class="library-empty-cta-visual" aria-hidden="true">
<div class="cta-source-stack">
<span class="cta-mini-card cta-mini-card--n">Nature</span>
<span class="cta-mini-card cta-mini-card--s">Springer</span>
<span class="cta-mini-card cta-mini-card--a">arXiv</span>
</div>
</div>
<h3 class="library-empty-cta-title">
{{ t('referenceLibrary.emptyCtaTitle') }}
</h3>
<p class="library-empty-cta-subtitle">
{{ t('referenceLibrary.emptyCtaSubtitle') }}
</p>
<div class="library-empty-cta-section-label">
{{ t('referenceLibrary.emptyCtaPopular') }}
</div>
<div class="library-empty-cta-actions">
<button
type="button"
class="library-empty-cta-btn"
@click="openImportDialog('pdf')"
>
<i class="fas fa-upload library-empty-cta-btn-icon"></i>
<span>{{ t('referenceLibrary.emptyCtaUploadPdf') }}</span>
</button>
<button
type="button"
class="library-empty-cta-btn"
@click="openImportDialog('zotero')"
>
<i class="tab-icon-z library-empty-cta-btn-zm" aria-hidden="true">Z</i>
<span>{{ t('referenceLibrary.emptyCtaZotero') }}</span>
</button>
<button
type="button"
class="library-empty-cta-btn"
@click="openImportDialog('mendeley')"
>
<i class="tab-icon-m library-empty-cta-btn-zm" aria-hidden="true">M</i>
<span>{{ t('referenceLibrary.emptyCtaMendeley') }}</span>
</button>
</div>
<div class="library-empty-cta-section-label library-empty-cta-section-label--other">
{{ t('referenceLibrary.emptyCtaOther') }}
</div>
<div class="library-empty-cta-actions">
<button
type="button"
class="library-empty-cta-btn"
@click="openImportDialog('pasteId')"
>
<i class="fas fa-link library-empty-cta-btn-icon"></i>
<span>{{ t('referenceLibrary.emptyCtaDoiPmid') }}</span>
</button>
<button
type="button"
class="library-empty-cta-btn"
@click="openImportDialog('bibris')"
>
<i class="fas fa-file-alt library-empty-cta-btn-icon"></i>
<span>{{ t('referenceLibrary.emptyCtaBibRis') }}</span>
</button>
</div>
</div>
<!-- 全部文献:有文献但当前筛选/搜索无匹配 -->
<div
v-else-if="librarySubTab === 'all' && displayReferences.length === 0"
class="library-empty"
>
<i class="fas fa-book-open empty-icon"></i>
<span>{{ t('referenceLibrary.emptySearchHint') }}</span>
</div>
<!-- 全部文献:文献卡片列表 -->
<div v-else class="library-cards">
<div
v-for="ref in displayReferences"
:key="ref.workId"
class="reference-card"
>
<!-- 添加到文献集下拉菜单 -->
<el-dropdown
:ref="(el) => setAddToCollectionDropdownRef(ref.workId, el)"
trigger="click"
placement="right-start"
:disabled="!!(ref as any).isMock"
@visible-change="handleAddToCollectionDropdownVisibleChange"
>
<button
class="card-add-btn"
:title="'添加到文献集'"
@click="handleAddRef(ref)"
>
<i class="fas fa-plus"></i>
</button>
<template #dropdown>
<div
v-if="addToCollectionTargetWorkId === ref.workId"
class="add-collection-panel"
>
<div class="add-collection-search" @click.stop>
<i class="fas fa-search search-icon"></i>
<input
v-model="addToCollectionSearchKeyword"
type="text"
class="search-input"
:placeholder="t('referenceLibrary.searchCollections') || '搜索文献集...'"
/>
</div>
<div v-if="collectionsBusy" class="library-loading">
<i class="fas fa-spinner fa-spin"></i>
<span>{{ t('reference.loading') || '加载中...' }}</span>
</div>
<div
v-else-if="addToCollectionFilteredCollections.length === 0"
class="add-collection-empty"
>
暂无文献集
</div>
<div v-else class="add-collection-list">
<div
v-for="coll in addToCollectionFilteredCollections"
:key="coll.id"
class="add-collection-item"
:class="{ selected: addToCollectionSelectedCollectionId === coll.id }"
@click.stop="addToCollectionSelectedCollectionId = coll.id"
>
<div class="add-collection-item-title">{{ coll.title }}</div>
<div class="add-collection-item-meta">
{{ coll.count }} {{ t('referenceLibrary.referencesCount') || '篇' }}
</div>
</div>
</div>
<!-- 创建文献集入口 -->
<div class="add-collection-create">
<div
v-if="!addToCollectionShowCreateInput"
class="add-collection-create-entry"
:class="{ disabled: addToCollectionCreateBusy }"
@click.stop="!addToCollectionCreateBusy && handleAddToCollectionCreateCollection()"
>
<i class="fas fa-plus"></i>
创建文献集
</div>
<div
v-else
class="add-collection-create-input-wrap"
@click.stop
>
<i class="fas fa-plus add-collection-create-input-plus"></i>
<input
ref="addToCollectionNewCollectionInputRef"
v-model="addToCollectionNewCollectionName"
class="collection-create-input"
type="text"
:disabled="addToCollectionCreateBusy"
placeholder="输入文献集名称"
@keydown.enter.prevent="submitAddToCollectionCreateCollection"
@blur="submitAddToCollectionCreateCollectionOnBlur"
@keydown.esc.prevent="closeAddToCollectionCreateCollectionInput"
/>
<div
class="add-collection-create-submit"
:class="{ disabled: addToCollectionCreateBusy }"
@mousedown.prevent
@click.stop="!addToCollectionCreateBusy && submitAddToCollectionCreateCollection()"
>
创建
</div>
</div>
</div>
<div class="add-collection-actions">
<button class="add-collection-cancel" @click="cancelAddToCollection">
{{ t('common.cancel') || '取消' }}
</button>
<button
class="add-collection-confirm"
:disabled="addToCollectionBusy || !addToCollectionSelectedCollectionId"
@click="confirmAddToCollection"
>
{{ t('common.save') || '确认' }}
</button>
</div>
</div>
</template>
</el-dropdown>
<div class="card-title">{{ ref.title }}</div>
<div class="card-author">
{{ formatAuthorsDisplayForCard(ref.authorsText) || '—' }}
</div>
<div class="card-journal">{{ ref.venueName || ref.journalAbbr || getJournal(ref) }}</div>
<div class="card-meta">
<span v-if="ref.impactFactor">IF {{ ref.impactFactor }}</span>
<span v-if="ref.publicationYear" class="meta-sep">·</span>
<span v-if="ref.publicationYear">{{ ref.publicationYear }}</span>
<span v-if="ref.citations" class="meta-sep">·</span>
<span v-if="ref.citations">{{ ref.citations }} citations</span>
<span v-if="ref.doi" class="meta-sep">·</span>
<a
v-if="ref.doi"
:href="`https://doi.org/${ref.doi}`"
target="_blank"
rel="noopener noreferrer"
class="doi-link"
@click.stop
>
DOI
</a>
</div>
<div class="card-actions">
<div
class="action-btn"
@click="openDetail(ref)"
>
<i class="fas fa-info-circle"></i>
<span>{{ t('referenceLibrary.detail') || '详情' }}</span>
</div>
<div
class="action-btn"
@click="openOriginal(ref)"
>
<i class="fas fa-external-link-alt"></i>
<span>{{ t('reference.viewOriginal') || '打开原文' }}</span>
</div>
<div
class="action-btn"
@click="copyCitation(ref)"
>
<i class="fas fa-quote-right"></i>
<span>{{ t('referenceLibrary.citation') || '引用' }}</span>
</div>
<label
v-if="getLibraryItemIdForDelete(ref) > 0"
class="card-delete-checkbox"
:title="t('referenceLibrary.selectToDelete') || '选择以从文献库删除'"
@click.stop
>
<input
type="checkbox"
:checked="isLibraryItemIdSelected(getLibraryItemIdForDelete(ref))"
@change="toggleLibraryItemIdSelection(getLibraryItemIdForDelete(ref))"
/>
</label>
</div>
</div>
</div>
</div>
<div
v-if="canShowLibraryBatchDeleteBar"
class="library-batch-delete-bar"
>
<span class="library-batch-delete-hint">
{{
t('referenceLibrary.selectedCount', {
count: batchDeleteBarSelectedCount,
}) || `已选 ${batchDeleteBarSelectedCount} 项`
}}
</span>
<div class="library-batch-delete-actions">
<el-button
size="small"
@click="clearBatchDeleteBarSelection"
>
{{ t('common.cancel') || '取消' }}
</el-button>
<el-button
v-if="isBatchDeleteBarCollectionDocsMode"
size="small"
:loading="removeFromCollectionBusy"
@click="handleRemoveFromCollection"
>
{{ t('referenceLibrary.removeFromCollection') || '移出文献集' }}
</el-button>
<el-button
type="danger"
size="small"
:loading="batchDeleteBarBusy"
@click="handleBatchDeleteBarConfirm"
>
{{ t('common.delete') || '删除' }}
</el-button>
</div>
</div>
<!-- 详情抽屉/弹窗 -->
<el-drawer
v-model="detailVisible"
size="400px"
direction="rtl"
>
<template #header>
<div class="detail-drawer-header">
<div class="detail-drawer-title">
{{ t('referenceLibrary.detail') || '文献详情' }}
</div>
<div class="detail-drawer-actions">
<el-button
v-if="!isEditingDetail"
type="primary"
link
:disabled="!currentDetail || isLoadingDetail"
:title="t('common.edit') || '编辑'"
@click="startEditDetail"
>
{{ t('common.edit') || '编辑' }}
</el-button>
<template v-else>
<el-button
link
:disabled="isLoadingDetail"
:title="t('common.cancel') || '取消'"
@click="cancelDetailEdit"
>
{{ t('common.cancel') || '取消' }}
</el-button>
<el-button
type="primary"
link
:disabled="isLoadingDetail"
:title="t('common.save') || '保存'"
@click="saveDetailEdit"
>
{{ t('common.save') || '保存' }}
</el-button>
</template>
</div>
</div>
</template>
<div v-if="currentDetail" class="detail-content">
<div v-if="isLoadingDetail" class="detail-loading">
<i class="fas fa-spinner fa-spin"></i>
<span>{{ t('reference.loading') || '加载中...' }}</span>
</div>
<template v-else>
<el-form
v-if="isEditingDetail"
class="detail-edit-form"
label-position="top"
>
<el-form-item :label="t('reference.detailLabels.title')">
<el-input v-model="editableDetail.title" />
</el-form-item>
<el-form-item :label="t('reference.detailLabels.authors')">
<el-input v-model="editableDetail.authorsText" />
</el-form-item>
<el-form-item :label="t('reference.detailLabels.venueName')">
<el-input v-model="editableDetail.venueName" />
</el-form-item>
<el-form-item :label="t('reference.detailLabels.publicationYear')">
<el-input-number
v-model="editableDetail.publicationYear"
:min="0"
:max="2100"
controls-position="right"
style="width: 100%;"
/>
</el-form-item>
<el-form-item :label="t('reference.detailLabels.abstract')">
<el-input
v-model="editableDetail.abstractText"
type="textarea"
:rows="6"
resize="none"
/>
</el-form-item>
<el-form-item :label="t('reference.detailLabels.doi')">
<el-input v-model="editableDetail.doi" />
</el-form-item>
</el-form>
<template v-else>
<div class="detail-row">
<div class="detail-label">{{ t('reference.detailLabels.title') }}</div>
<div class="detail-value">{{ currentDetail.title }}</div>
</div>
<div class="detail-row" v-if="currentDetail.authorsText">
<div class="detail-label">{{ t('reference.detailLabels.authors') }}</div>
<div class="detail-value">{{ currentDetail.authorsText }}</div>
</div>
<div class="detail-row" v-if="currentDetail.venueName">
<div class="detail-label">{{ t('reference.detailLabels.venueName') }}</div>
<div class="detail-value">{{ currentDetail.venueName }}</div>
</div>
<div class="detail-row" v-if="currentDetail.publicationYear">
<div class="detail-label">{{ t('reference.detailLabels.publicationYear') }}</div>
<div class="detail-value">{{ currentDetail.publicationYear }}</div>
</div>
<div class="detail-row" v-if="currentDetail.abstractText">
<div class="detail-label">{{ t('reference.detailLabels.abstract') }}</div>
<div class="detail-value abstract">{{ currentDetail.abstractText }}</div>
</div>
<div class="detail-row" v-if="currentDetail.doi">
<div class="detail-label">{{ t('reference.detailLabels.doi') }}</div>
<div class="detail-value">
<a
:href="`https://doi.org/${currentDetail.doi}`"
target="_blank"
rel="noopener noreferrer"
>
{{ currentDetail.doi }}
</a>
</div>
</div>
</template>
</template>
</div>
</el-drawer>
<!-- 上传到文献库弹窗 -->
<el-dialog
v-model="importVisible"
:title="t('reference.uploadToLibrary')"
width="570px"
>
<div class="import-dialog-content">
<el-tabs v-model="importTab" class="import-tabs">
<el-tab-pane name="pdf">
<template #label>
<span class="tab-label">
<i class="fas fa-upload"></i>
{{ t('reference.uploadPdf') }}
</span>
</template>
<div class="upload-pdf-panel">
<el-upload
ref="pdfUploadRef"
class="pdf-upload-area"
drag
multiple
:limit="100"
accept=".pdf"
:auto-upload="false"
:file-list="pdfFileList"
:before-upload="beforePdfUpload"
:on-change="handlePdfFileChange"
:on-exceed="handlePdfExceed"
>
<div class="upload-inner">
<i class="fas fa-cloud-upload-alt upload-icon"></i>
<div class="upload-text">{{ t('reference.maxPdfCount') }}</div>
<div class="upload-hint">
{{ t('reference.dragOrSelect') }}
<span class="select-link" @click.stop="triggerPdfSelect">{{ t('reference.selectFile') }}</span>
</div>
<div class="upload-limit">{{ t('reference.pdfLimit') }}</div>
</div>
</el-upload>
<input
ref="pdfInputRef"
type="file"
accept=".pdf"
multiple
class="hidden-file-input"
@change="handlePdfInputChange"
/>
<el-button
type="primary"
class="pdf-import-btn"
:disabled="pdfFileList.length === 0"
@click="handlePdfImport"
>
{{ t('reference.importToLibrary') }}
</el-button>
</div>
</el-tab-pane>
<el-tab-pane name="zotero">
<template #label>
<span class="tab-label">
<i class="tab-icon-z">Z</i>
{{ t('reference.zotero') }}
</span>
</template>
<div class="zotero-connect-panel">
<div class="zotero-logo" aria-hidden="true">
<span class="zotero-logo-z">Z</span>
</div>
<div class="zotero-title">
{{ t('reference.zoteroConnectTitle') || '连接Zotero账户' }}
</div>
<div class="zotero-desc">
{{ t('reference.zoteroConnectDesc') || '从Zotero导入PDF和元数据以在LinkMed中使用。' }}
</div>
<el-button type="primary" class="zotero-connect-btn" @click="openZoteroLogin">
{{ t('reference.zoteroConnectBtn') || '连接Zotero' }}
</el-button>
</div>
</el-tab-pane>
<el-tab-pane name="mendeley">
<template #label>
<span class="tab-label">
<i class="tab-icon-m">M</i>
{{ t('reference.mendeley') }}
</span>
</template>
<div class="mendeley-connect-panel">
<div class="mendeley-logo" aria-hidden="true">
<span class="mendeley-logo-m">M</span>
</div>
<div class="mendeley-title">
{{ t('reference.mendeleyConnectTitle') || '连接Mendeley账户' }}
</div>
<div class="mendeley-desc">
{{ t('reference.mendeleyConnectDesc') || '从Mendeley导入PDF和元数据以在LinkMed中使用。' }}
</div>
<el-button type="primary" class="mendeley-connect-btn" @click="openMendeley">
{{ t('reference.mendeleyConnectBtn') || '连接Mendeley' }}
</el-button>
</div>
</el-tab-pane>
<el-tab-pane name="bibris">
<template #label>
<span class="tab-label">
<i class="fas fa-file-alt"></i>
{{ t('reference.importBibRis') }}
</span>
</template>
<div class="bibris-panel">
<textarea
v-model="bibrisContent"
class="bibris-textarea"
:placeholder="t('reference.bibrisPlaceholder')"
rows="14"
spellcheck="false"
@input="bibrisOnInput"
/>
<div v-if="bibrisHint" class="bibris-hint" :class="`kind-${bibrisHintKind}`">
<i
v-if="bibrisHintKind === 'success'"
class="fas fa-check-circle"
aria-hidden="true"
></i>
<i
v-else-if="bibrisHintKind === 'warning'"
class="fas fa-exclamation-circle"
aria-hidden="true"
></i>
<i
v-else-if="bibrisHintKind === 'error'"
class="fas fa-times-circle"
aria-hidden="true"
></i>
<i v-else class="fas fa-info-circle" aria-hidden="true"></i>
<span class="bibris-hint-text">{{ bibrisHint }}</span>
</div>
<div class="bibris-file-hint">
{{ t('reference.bibrisPreferFile') }}
<span class="select-link" @click="triggerBibRisFileSelect">{{ t('reference.selectFile') }}</span>
</div>
<input
ref="bibrisFileInputRef"
type="file"
accept=".bib,.ris"
multiple
class="hidden-file-input"
@change="handleBibRisFileChange"
/>
<el-button
type="primary"
class="bibris-search-btn"
:disabled="
bibrisBusy ||
(bibrisInputType === 'text' ? !bibrisContent.trim() : !bibrisSelectedFile)
"
@click="handleBibRisSearch"
>
<i class="fas fa-search"></i>
检索并导入
</el-button>
</div>
</el-tab-pane>
<el-tab-pane name="pasteId">
<template #label>
<span class="tab-label">
<i class="fas fa-hashtag"></i>
{{ t('reference.pasteId') }}
</span>
</template>
<div class="pasteid-panel">
<div class="pasteid-tip">
{{
te('reference.pasteIdTip')
? t('reference.pasteIdTip')
: '通过 DOI、PMID、arXiv URL 或 ISBN 获取元数据'
}}
</div>
<div class="pasteid-input-row">
<input
v-model="pasteIdValue"
class="pasteid-input"
type="text"
ref="pasteIdInputRef"
:placeholder="
te('reference.pasteIdPlaceholder')
? t('reference.pasteIdPlaceholder')
: '请输入 DOI / PMID / arXiv URL / ISBN'
"
/>
<button
class="pasteid-search-btn"
type="button"
:disabled="pasteIdBusy || !pasteIdValue.trim()"
@click="handlePasteIdSearch"
>
<i class="fas fa-search"></i>
</button>
</div>
<div v-if="pasteIdHint" class="pasteid-hint" :class="`kind-${pasteIdHintKind}`">
<i
v-if="pasteIdHintKind === 'success'"
class="fas fa-check-circle"
aria-hidden="true"
></i>
<i
v-else-if="pasteIdHintKind === 'warning'"
class="fas fa-exclamation-circle"
aria-hidden="true"
></i>
<i
v-else-if="pasteIdHintKind === 'error'"
class="fas fa-times-circle"
aria-hidden="true"
></i>
<i v-else class="fas fa-info-circle" aria-hidden="true"></i>
<span class="pasteid-hint-text">{{ pasteIdHint }}</span>
</div>
<div v-if="pasteIdBusy" class="pasteid-results-header">
<i class="fas fa-spinner fa-spin"></i>
{{ '正在获取元数据...' }}
</div>
<template v-else-if="pasteIdImportItems.length">
<div class="pasteid-results-list">
<div
v-for="item in pasteIdImportItems"
:key="item.workId ?? item.doi ?? item.title"
class="pasteid-result-item"
>
<div class="pasteid-result-title">{{ item.title }}</div>
<div class="pasteid-result-authors" v-if="item.authorsText">
{{ item.authorsText }}
</div>
<div class="pasteid-result-venue" v-if="item.venueName || item.journalAbbr">
{{ item.venueName || item.journalAbbr }}
<span v-if="item.publicationYear"> {{ item.publicationYear }}</span>
</div>
</div>
</div>
</template>
<template v-else>
<div class="pasteid-examples-title">
{{
te('reference.pasteIdExamples')
? t('reference.pasteIdExamples')
: '尝试以下示例之一:'
}}
</div>
<div class="pasteid-examples">
<div class="example-card" role="button" tabindex="0" @click="setPasteIdExample('10.1056/NEJMoa2034577')">
<div class="example-title">DOI</div>
<div class="example-subtitle">
{{
te('reference.pasteIdExampleDoi')
? t('reference.pasteIdExampleDoi')
: '数字对象标识符'
}}
</div>
<div class="example-value">10.1056/NEJMoa2034577</div>
</div>
<div class="example-card" role="button" tabindex="0" @click="setPasteIdExample('34407336')">
<div class="example-title">PMID</div>
<div class="example-subtitle">
{{
te('reference.pasteIdExamplePmid')
? t('reference.pasteIdExamplePmid')
: 'PubMed 标识符'
}}
</div>
<div class="example-value">39549757</div>
</div>
<div class="example-card" role="button" tabindex="0" @click="setPasteIdExample('https://arxiv.org/abs/1706.03762')">
<div class="example-title">arXiv</div>
<div class="example-subtitle">
{{
te('reference.pasteIdExampleArxiv')
? t('reference.pasteIdExampleArxiv')
: 'arXiv 预印本 URL'
}}
</div>
<div class="example-value">https://arxiv.org/abs/1706.03762</div>
</div>
<div class="example-card" role="button" tabindex="0" @click="setPasteIdExample('9780262033848')">
<div class="example-title">ISBN</div>
<div class="example-subtitle">
{{
te('reference.pasteIdExampleIsbn')
? t('reference.pasteIdExampleIsbn')
: '国际标准书号'
}}
</div>
<div class="example-value">9780262033848</div>
</div>
</div>
</template>
<el-button
type="primary"
class="pasteid-import-btn"
:disabled="pasteIdBusy || pasteIdImportItems.length === 0"
@click="handlePasteIdImport"
>
{{ t('reference.importToLibrary') }}
</el-button>
</div>
</el-tab-pane>
</el-tabs>
</div>
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, computed, watch, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import { ElMessage, ElMessageBox } from 'element-plus';
import type { UploadFile, UploadFiles } from 'element-plus';
import * as pdfjsLib from 'pdfjs-dist';
import {
getReferenceDetail,
getFormatCitation,
type ReferenceItem,
type ReferenceDetail,
} from '@/api/references';
import {
importReferenceByArxiv,
importReferenceByBibtex,
importReferenceByBibtexFile,
importReferenceByRis,
importReferenceByRisFile,
importReferenceByDoi,
importReferenceByIsbn,
importReferenceByPmid,
getUserLibraryItems,
getUserLibraryCollections,
getUserLibraryCollectionDocuments,
createUserLibraryCollection,
createUserLibraryCollectionDocument,
updateUserLibraryCollection,
upsertUserLibraryItem,
deleteUserLibraryItem,
batchDeleteUserLibraryItems,
deleteUserLibraryCollection,
batchDeleteUserLibraryCollections,
deleteUserLibraryCollectionDocument,
batchDeleteUserLibraryCollectionDocuments,
type ReferenceImportItem,
type UserLibraryItem,
type UserLibraryCollectionItem,
type UserLibraryCollectionDocumentItem,
} from '@/api/referenceLibrary';
const MAX_PDF_SIZE = 1024 * 1024 * 1024; // 1GB
const MAX_PDF_PAGES = 1000;
const props = defineProps<{
fileId?: string | number | null;
isChatAnswer?: boolean;
}>();
const { t, te } = useI18n();
const librarySubTab = ref<'all' | 'collections'>('all');
/** 当前打开的文献集(进入文献集内文献列表时设置,返回时清空) */
const activeCollection = ref<ReferenceCollection | null>(null);
const collectionsBusy = ref(false);
const collections = ref<ReferenceCollection[]>([]);
const collectionsCreateBusy = ref(false);
const collectionsRenameBusy = ref(false);
const collectionDocsBusy = ref(false);
const collectionDocuments = ref<any[]>([]);
const showCreateCollectionInput = ref(false);
const newCollectionName = ref('');
const newCollectionInputRef = ref<HTMLInputElement | null>(null);
// 文献集重命名:仅在 collections 列表页生效
const editingCollectionId = ref<number | null>(null);
const editingCollectionName = ref('');
const editingCollectionOriginalName = ref('');
const editCollectionInputRef = ref<HTMLInputElement | null>(null);
const searchKeyword = ref('');
const collectionSearchKeyword = ref('');
// 添加到文献集:下拉选择状态
const addToCollectionSearchKeyword = ref('');
const addToCollectionSelectedCollectionId = ref<number | null>(null);
const addToCollectionTargetWorkId = ref<number | null>(null);
const addToCollectionBusy = ref(false);
// 下拉内创建文献集
const addToCollectionShowCreateInput = ref(false);
const addToCollectionNewCollectionName = ref('');
const addToCollectionNewCollectionInputRef = ref<HTMLInputElement | null>(null);
const addToCollectionCreateBusy = ref(false);
/** 按 workId 保存「添加到文献集」的 el-dropdown 实例,确认后调用 handleClose */
const addToCollectionDropdownByWorkId = new Map<number, { handleClose?: () => void }>();
function setAddToCollectionDropdownRef(workId: number, el: unknown) {
if (el && typeof el === 'object' && 'handleClose' in el) {
addToCollectionDropdownByWorkId.set(workId, el as { handleClose?: () => void });
} else {
addToCollectionDropdownByWorkId.delete(workId);
}
}
function closeAddToCollectionDropdownForWorkId(workId: number) {
addToCollectionDropdownByWorkId.get(workId)?.handleClose?.();
}
const filterState = reactive({
pdfStatus: 'all' as string,
pubYear: '1y' as string,
impactFactor: 'all' as string,
openAccess: 'any' as string,
// 默认文献类型为“所有”
litTypes: ['all'] as string[],
tag: 'any' as string,
});
const tagInput = ref('');
const pdfStatusOptions = [
{ value: 'all', label: '所有' },
{ value: 'has', label: '有PDF文件' },
{ value: 'no', label: '没有PDF文件' },
];
const pubYearOptions = [
{ value: 'all', label: '所有' },
{ value: '1y', label: '最近1年' },
{ value: '3y', label: '最近3年' },
{ value: 'custom', label: '自定义时间' },
];
const impactFactorOptions = [
{ value: 'all', label: 'All' },
{ value: '0.25', label: '>0.25' },
{ value: '3', label: '>3' },
{ value: '10', label: '>10' },
];
const openAccessOptions = [
{ value: 'any', label: 'Any' },
{ value: 'open', label: '开放访问' },
{ value: 'closed', label: '不是开放访问' },
];
const litTypeOptions = [
{ value: 'literature', label: '文献' },
{ value: 'online', label: '网络文献' },
{ value: 'book', label: '书籍' },
{ value: 'document', label: '文档' },
];
const tagOptions = [
{ value: 'any', label: 'Any' },
{ value: 'guide', label: '指南' },
{ value: 'evidence', label: '循证' },
{ value: 'case', label: '病例' },
];
const isLoading = ref(false);
const references = ref<ReferenceItem[]>([]);
const referencesDetailCache = ref<Record<number, ReferenceDetail>>({});
const detailVisible = ref(false);
const currentDetailRef = ref<ReferenceItem | null>(null);
const currentDetail = ref<ReferenceDetail | null>(null);
const isLoadingDetail = ref(false);
const isEditingDetail = ref(false);
const editableDetail = reactive({
title: '',
authorsText: '',
venueName: '',
publicationYear: 0,
abstractText: '',
doi: '',
});
const importVisible = ref(false);
const importTab = ref<'pdf' | 'zotero' | 'mendeley' | 'bibris' | 'pasteId'>('pdf');
const pdfFileList = ref<UploadFile[]>([]);
const pdfUploadRef = ref();
void pdfUploadRef.value;
const pdfInputRef = ref<HTMLInputElement>();
const bibrisContent = ref('');
const bibrisFileInputRef = ref<HTMLInputElement>();
/** BibTeX 文本输入 或 选择的 .bib 文件 */
const bibrisInputType = ref<'text' | 'file'>('text');
/** 选择的 .bib 文件(用于文件导入) */
const bibrisSelectedFile = ref<File | null>(null);
/** 标记 textarea 的程序性更新,避免误触发 @input 把文件模式清掉 */
const bibrisProgrammaticChange = ref(false);
const bibrisSearched = ref(false);
const bibrisImportItems = ref<BibrisParsedItem[]>([]);
const bibrisBusy = ref(false);
const bibrisHint = ref('');
const bibrisHintKind = ref<'success' | 'warning' | 'error' | 'info'>('info');
interface BibrisParsedItem {
workId?: number;
title?: string;
authorsText?: string;
publicationYear?: number;
doi?: string;
}
const pasteIdValue = ref('');
const pasteIdInputRef = ref<HTMLInputElement>();
const pasteIdImportItems = ref<ReferenceImportItem[]>([]);
const pasteIdBusy = ref(false);
const pasteIdLastQuery = ref('');
const pasteIdHint = ref('');
const pasteIdHintKind = ref<'success' | 'warning' | 'error' | 'info'>('info');
type PasteIdType = 'doi' | 'pmid' | 'arxiv' | 'isbn';
function isValidIsbn13(isbn13: string) {
const digits = isbn13.replace(/[^0-9]/g, '');
if (digits.length !== 13) return false;
const sum = digits
.slice(0, 12)
.split('')
.reduce((acc, d, idx) => acc + Number(d) * (idx % 2 === 0 ? 1 : 3), 0);
const checkDigit = (10 - (sum % 10)) % 10;
return checkDigit === Number(digits[12]);
}
function isValidIsbn10(isbn10: string) {
const s = isbn10.replace(/[^0-9Xx]/g, '').toUpperCase();
if (!/^[0-9]{9}[0-9X]$/.test(s)) return false;
let sum = 0;
for (let i = 0; i < 10; i++) {
const c = s[i];
const digit = c === 'X' ? 10 : Number(c);
sum += digit * (10 - i);
}
return sum % 11 === 0;
}
function detectPasteIdType(input: string): { type: PasteIdType; value: string } | null {
const trimmed = input.trim();
if (!trimmed) return null;
// 允许用户输入形如:`PMID: 123` / `DOI: 10.xxxx/xxxx` 之类的前缀
const cleaned = trimmed.replace(/^(doi|pmid|arxiv|isbn)\s*[::]\s*/i, '');
// 1) arXiv
// 支持:arXiv URL、arXiv ID(新/旧格式)
if (/arxiv\.org/i.test(cleaned) || /^arxiv[::]/i.test(trimmed)) {
const arxivId = cleaned
.replace(/^https?:\/\/(www\.)?arxiv\.org\/(abs|pdf)\//i, '')
.replace(/\.pdf$/i, '')
.trim();
const modern = /^\d{4}\.\d{4,5}(v\d+)?$/i;
const old = /^[a-z-]+\/\d{7}(v\d+)?$/i;
if (modern.test(arxivId) || old.test(arxivId)) return { type: 'arxiv', value: arxivId };
// 后端通常可兜底解析完整 URL;这里仍按 arXiv 路由
if (arxivId) return { type: 'arxiv', value: cleaned };
}
// 2) DOI
const doiNormalized = cleaned
.replace(/^https?:\/\/(dx\.)?doi\.org\//i, '')
.replace(/^\s*doi\.org\//i, '')
.trim()
.replace(/\s+/g, '');
const doiRegex = /^10\.\d{4,9}\/[-._;()/:A-Z0-9]+$/i;
if (doiRegex.test(doiNormalized)) return { type: 'doi', value: doiNormalized };
// 3) ISBN(10 位/13 位,做校验后再当作 ISBN)
const isbnCandidate = cleaned.replace(/[\s-]/g, '').toUpperCase();
if (/^[0-9]{13}$/.test(isbnCandidate) && isValidIsbn13(isbnCandidate)) return { type: 'isbn', value: isbnCandidate };
if (/^[0-9]{9}[0-9X]$/.test(isbnCandidate) && isValidIsbn10(isbnCandidate)) return { type: 'isbn', value: isbnCandidate };
// 4) PMID(纯数字)
if (/^\d{1,20}$/.test(cleaned)) return { type: 'pmid', value: cleaned };
return null;
}
// 上传文献应独立于当前工作台是否打开文件
const canAddReference = computed(() => true);
// PDF.js 获取页数
function getPdfjs() {
const lib = pdfjsLib as any;
if (lib.getDocument) return lib;
if (lib.default?.getDocument) return lib.default;
return lib;
}
let pdfWorkerInited = false;
function initPdfWorker() {
if (pdfWorkerInited) return;
try {
const pdfjs = getPdfjs();
if (pdfjs.GlobalWorkerOptions?.workerSrc) return;
pdfjs.GlobalWorkerOptions = pdfjs.GlobalWorkerOptions || {};
pdfjs.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version || '2.16.105'}/pdf.worker.min.js`;
pdfWorkerInited = true;
} catch (e) {
console.error('Failed to init PDF worker:', e);
}
}
async function getPdfPageCount(file: File): Promise<number> {
initPdfWorker();
const url = URL.createObjectURL(file);
try {
const pdfjs = getPdfjs();
const doc = await pdfjs.getDocument({ url }).promise;
const n = doc.numPages;
doc.destroy();
return n;
} finally {
URL.revokeObjectURL(url);
}
}
async function beforePdfUpload(file: File): Promise<boolean> {
if (file.size > MAX_PDF_SIZE) {
ElMessage.warning(t('reference.pdfExceedSize', { name: file.name }));
return false;
}
try {
const pages = await getPdfPageCount(file);
if (pages > MAX_PDF_PAGES) {
ElMessage.warning(t('reference.pdfExceedPages', { name: file.name }));
return false;
}
} catch (e) {
console.error('PDF 页数检测失败:', e);
ElMessage.warning(`「${file.name}」无法读取,暂不上传`);
return false;
}
return true;
}
function handlePdfFileChange(_file: UploadFile, files: UploadFiles) {
pdfFileList.value = [...files];
}
function handlePdfExceed() {
ElMessage.warning(t('reference.maxPdfCount'));
}
function triggerPdfSelect() {
pdfInputRef.value?.click();
}
async function handlePdfInputChange(e: Event) {
const input = e.target as HTMLInputElement;
const files = input.files;
if (!files?.length) return;
for (let i = 0; i < files.length; i++) {
const file = files[i];
if (!file) continue;
if (pdfFileList.value.length >= 100) {
ElMessage.warning(t('reference.maxPdfCount'));
break;
}
const ok = await beforePdfUpload(file);
if (ok) {
pdfFileList.value = [
...pdfFileList.value,
{
name: file.name,
size: file.size,
raw: file,
uid: Date.now() + Math.random(),
status: 'ready',
} as UploadFile,
];
}
}
input.value = '';
}
function triggerBibRisFileSelect() {
bibrisFileInputRef.value?.click();
}
function bibrisOnInput() {
if (bibrisProgrammaticChange.value) return;
// 用户在文本框修改时,隐藏之前的导入报错/警告提示
if (bibrisHintKind.value === 'error' || bibrisHintKind.value === 'warning') {
bibrisHint.value = '';
bibrisHintKind.value = 'info';
}
if (bibrisSelectedFile.value) {
bibrisInputType.value = 'text';
bibrisSelectedFile.value = null;
}
}
function handlePdfImport() {
if (pdfFileList.value.length === 0) {
ElMessage.warning(t('reference.selectFile') || '请先选择文件');
return;
}
// 暂未接入接口:先补齐与其它 tab 一致的“导入到库”入口
ElMessage.info(t('reference.bibrisComingSoon') || '导入功能即将推出');
}
async function handleBibRisFileChange(e: Event) {
const input = e.target as HTMLInputElement;
const files = input.files;
if (!files?.length) return;
const file = files[0];
if (!file) return;
const isBib = /\.bib$/i.test(file.name);
const isRis = /\.ris$/i.test(file.name);
if (!isBib && !isRis) {
ElMessage.warning(t('reference.selectFile') || '请先选择 BibTeX .bib 或 RIS .ris 文件');
bibrisSelectedFile.value = null;
bibrisInputType.value = 'text';
bibrisContent.value = '';
bibrisHint.value = '';
bibrisHintKind.value = 'info';
bibrisImportItems.value = [];
bibrisSearched.value = false;
input.value = '';
return;
}
if (bibrisBusy.value) return;
try {
// 清理旧状态,避免之前“文件模式”残留影响按钮可用性
bibrisInputType.value = 'text';
bibrisSelectedFile.value = null;
bibrisImportItems.value = [];
bibrisSearched.value = false;
bibrisBusy.value = true;
bibrisHint.value = isRis ? '正在导入 RIS 到文献库...' : '正在导入 BibTeX 到文献库...';
bibrisHintKind.value = 'info';
const resp = isRis
? await importReferenceByRisFile({
file,
addToUserLibrary: true,
})
: await importReferenceByBibtexFile({
file,
addToUserLibrary: true,
});
const successCount = resp?.data?.success ?? 0;
const failedCount = resp?.data?.failed ?? 0;
const items = resp?.data?.items ?? [];
const nullWorkIdItems = items.filter((it) => it?.workId == null);
const hasNullWorkId = nullWorkIdItems.length > 0;
if (hasNullWorkId) {
bibrisHint.value = '导入失败';
bibrisHintKind.value = 'error';
} else if (successCount <= 0) {
ElMessage.warning(resp?.data?.message || '导入完成,但未检测到成功导入的条目');
bibrisHint.value = '';
bibrisHintKind.value = 'info';
} else if (failedCount > 0) {
bibrisHint.value = `已导入 ${successCount} 条文献(失败 ${failedCount} 条)`;
bibrisHintKind.value = 'warning';
} else {
bibrisHint.value = `已成功导入 ${successCount} 条文献`;
bibrisHintKind.value = 'success';
}
// 如果存在 workId: null,直接判定为失败并保持弹窗不关闭
if (hasNullWorkId) return;
// 刷新列表,让用户能立即看到新增结果
await loadReferences(searchKeyword.value);
bibrisProgrammaticChange.value = true;
bibrisInputType.value = 'text';
bibrisSelectedFile.value = null;
bibrisContent.value = '';
bibrisImportItems.value = [];
bibrisSearched.value = false;
nextTick(() => {
bibrisProgrammaticChange.value = false;
});
setTimeout(() => {
importVisible.value = false;
bibrisHint.value = '';
bibrisHintKind.value = 'info';
}, 700);
} catch (err) {
console.error('读取 .bib/.ris 文件失败:', err);
// 上传失败只展示统一提示
bibrisHint.value = '导入失败';
bibrisHintKind.value = 'error';
} finally {
bibrisBusy.value = false;
input.value = '';
}
}
/** 检测内容是否为 RIS 格式(基于 TY/ER 行的粗校验,用于路由判断) */
function isRisFormat(content: string): boolean {
const t = content.trim();
return /^\s*TY\s*-\s*/im.test(t) || /^\s*ER\s*-\s*/im.test(t);
}
/** 校验 RIS 内容是否足够“完整”,否则不直接发给后端避免失败体验差 */
function isValidRis(content: string): boolean {
const t = content.trim();
if (!isRisFormat(t)) return false;
// 典型 RIS 必须包含 TY 和 ER
if (!/^\s*TY\s*-\s*/im.test(t)) return false;
if (!/^\s*ER\s*-\s*/im.test(t)) return false;
// 至少要有一个字段行(如 AU/TI/JO...)
const hasFieldLine = /^(?:[A-Z0-9]{2})\s*-\s*.+/im.test(t);
return hasFieldLine;
}
/** 解析 BibTeX 为预览项,用于校验和展示(支持常见格式) */
function parseBibtexToItems(content: string): BibrisParsedItem[] {
const items: BibrisParsedItem[] = [];
const trimmed = content.trim();
if (!trimmed) return items;
const entryRegex = /@(\w+)\s*\{\s*([^,\n]+)\s*,\s*([\s\S]*?)(?=\s*@\w|$)/g;
let m: RegExpExecArray | null;
while ((m = entryRegex.exec(trimmed)) !== null) {
const rest = m[3] || '';
const fields: Record<string, string> = {};
const fieldRegex = /(\w+)\s*=\s*(\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}|"([^"]*)"|(\d+))/g;
let fm: RegExpExecArray | null;
while ((fm = fieldRegex.exec(rest)) !== null) {
const key = fm[1]?.toLowerCase();
if (!key) continue;
const braced = fm[3];
const quoted = fm[4];
const num = fm[5];
fields[key] = (braced ?? quoted ?? num ?? '').trim();
}
items.push({
title: fields.title,
authorsText: fields.author,
publicationYear: fields.year ? parseInt(fields.year, 10) : undefined,
doi: fields.doi,
});
}
return items;
}
/** 检测内容是否为有效 BibTeX */
function isValidBibtex(content: string): boolean {
const t = content.trim();
if (!/@\s*\w+\s*\{/.test(t)) return false;
// 粗校验:花括号需配对,避免明显残缺文本
let depth = 0;
for (const ch of t) {
if (ch === '{') depth += 1;
if (ch === '}') depth -= 1;
if (depth < 0) return false;
}
if (depth !== 0) return false;
// 至少可解析出一条 entry
return parseBibtexToItems(t).length > 0;
}
async function handleBibRisSearch() {
if (bibrisBusy.value) return;
let importScheduledClose = false;
bibrisBusy.value = true;
bibrisHint.value = '正在检索并导入到文献库...';
bibrisHintKind.value = 'info';
try {
// 1) 文件模式:根据文件扩展名路由到 RIS 或 BibTeX
if (bibrisInputType.value === 'file') {
const file = bibrisSelectedFile.value;
if (!file) {
ElMessage.warning(t('reference.selectFile') || '请先选择文件');
return;
}
const isRisFile = /\.ris$/i.test(file.name);
const isBibFile = /\.bib$/i.test(file.name);
if (!isRisFile && !isBibFile) {
ElMessage.warning('仅支持 .bib / .ris 文件');
return;
}
if (isRisFile) {
// 读取并校验 RIS 内容(避免后端解析失败体验差)
const risText = await file.text();
if (!isValidRis(risText)) {
bibrisHint.value = 'RIS 格式不完整,请检查 TY/ER 行及字段内容';
bibrisHintKind.value = 'error';
return;
}
const resp = await importReferenceByRisFile({
file,
addToUserLibrary: true,
});
const successCount = resp?.data?.success ?? 0;
const failedCount = resp?.data?.failed ?? 0;
const items = resp?.data?.items ?? [];
const nullWorkIdItems = items.filter((it) => it?.workId == null);
const hasNullWorkId = nullWorkIdItems.length > 0;
if (hasNullWorkId) {
bibrisHint.value = '导入失败';
bibrisHintKind.value = 'error';
return;
}
if (successCount <= 0) {
ElMessage.warning(resp?.data?.message || '导入完成,但未检测到成功导入的条目');
bibrisHint.value = '';
bibrisHintKind.value = 'info';
bibrisSelectedFile.value = null;
bibrisImportItems.value = [];
bibrisSearched.value = false;
return;
}
if (failedCount > 0) {
bibrisHint.value = `已导入 ${successCount} 条文献(失败 ${failedCount} 条)`;
bibrisHintKind.value = 'warning';
} else {
bibrisHint.value = `已成功导入 ${successCount} 条文献`;
bibrisHintKind.value = 'success';
}
} else {
// BibTeX .bib 文件导入(保持与原逻辑一致:由后端解析后返回 success/failed)
const resp = await importReferenceByBibtexFile({
file,
addToUserLibrary: true,
});
const successCount = resp?.data?.success ?? 0;
const failedCount = resp?.data?.failed ?? 0;
const items = resp?.data?.items ?? [];
const nullWorkIdItems = items.filter((it) => it?.workId == null);
const hasNullWorkId = nullWorkIdItems.length > 0;
if (hasNullWorkId) {
bibrisHint.value = '导入失败';
bibrisHintKind.value = 'error';
return;
}
if (successCount <= 0) {
ElMessage.warning(resp?.data?.message || '导入完成,但未检测到成功导入的条目');
bibrisHint.value = '';
bibrisHintKind.value = 'info';
bibrisSelectedFile.value = null;
bibrisImportItems.value = [];
bibrisSearched.value = false;
return;
}
if (failedCount > 0) {
bibrisHint.value = `已导入 ${successCount} 条文献(失败 ${failedCount} 条)`;
bibrisHintKind.value = 'warning';
} else {
bibrisHint.value = `已成功导入 ${successCount} 条文献`;
bibrisHintKind.value = 'success';
}
}
// 刷新列表,让用户能立即看到新增结果
await loadReferences(searchKeyword.value);
bibrisSelectedFile.value = null;
bibrisInputType.value = 'text';
bibrisContent.value = '';
bibrisImportItems.value = [];
bibrisSearched.value = false;
importScheduledClose = true;
setTimeout(() => {
importVisible.value = false;
bibrisHint.value = '';
bibrisHintKind.value = 'info';
}, 700);
return;
}
// 2) 文本模式:根据内容路由到 RIS 或 BibTeX
const content = bibrisContent.value.trim();
if (!content) {
bibrisHint.value = t('reference.bibrisEmptyHint');
bibrisHintKind.value = 'warning';
bibrisSearched.value = false;
return;
}
if (isRisFormat(content)) {
if (!isValidRis(content)) {
bibrisHint.value = 'RIS 格式不完整,请检查 TY/ER 行及字段内容';
bibrisHintKind.value = 'error';
bibrisImportItems.value = [];
bibrisSearched.value = false;
return;
}
const resp = await importReferenceByRis({
ris: content,
addToUserLibrary: true,
});
const successCount =
resp?.data?.success ?? resp?.data?.items?.filter((it) => it.addedToUserLibrary)?.length ?? 0;
const failedCount = resp?.data?.failed ?? 0;
const items = resp?.data?.items ?? [];
const nullWorkIdItems = items.filter((it) => it?.workId == null);
if (nullWorkIdItems.length > 0) {
bibrisHint.value = '导入失败';
bibrisHintKind.value = 'error';
return;
}
if (!successCount) {
bibrisHint.value = resp?.data?.message || '导入完成,但未检测到可导入条目';
bibrisHintKind.value = 'warning';
return;
}
if (failedCount > 0) {
bibrisHint.value = `已导入 ${successCount} 条文献(失败 ${failedCount} 条)`;
bibrisHintKind.value = 'warning';
} else {
bibrisHint.value = `已成功导入 ${successCount} 条文献`;
bibrisHintKind.value = 'success';
}
} else {
if (!isValidBibtex(content)) {
bibrisHint.value = '无效的 BibTeX 格式,请输入正确的 BibTeX 内容';
bibrisHintKind.value = 'error';
bibrisImportItems.value = [];
bibrisSearched.value = false;
return;
}
const resp = await importReferenceByBibtex({
bibtex: content,
addToUserLibrary: true,
});
const successCount =
resp?.data?.success ?? resp?.data?.items?.filter((it) => it.addedToUserLibrary)?.length ?? 0;
const failedCount = resp?.data?.failed ?? 0;
const items = resp?.data?.items ?? [];
const nullWorkIdItems = items.filter((it) => it?.workId == null);
if (nullWorkIdItems.length > 0) {
bibrisHint.value = '导入失败';
bibrisHintKind.value = 'error';
return;
}
if (!successCount) {
bibrisHint.value = resp?.data?.message || '导入完成,但未检测到可导入条目';
bibrisHintKind.value = 'warning';
return;
}
if (failedCount > 0) {
bibrisHint.value = `已导入 ${successCount} 条文献(失败 ${failedCount} 条)`;
bibrisHintKind.value = 'warning';
} else {
bibrisHint.value = `已成功导入 ${successCount} 条文献`;
bibrisHintKind.value = 'success';
}
}
// 刷新列表,让用户能立即看到新增结果
await loadReferences(searchKeyword.value);
bibrisContent.value = '';
bibrisSelectedFile.value = null;
bibrisInputType.value = 'text';
bibrisImportItems.value = [];
bibrisSearched.value = false;
importScheduledClose = true;
setTimeout(() => {
importVisible.value = false;
bibrisHint.value = '';
bibrisHintKind.value = 'info';
}, 700);
} catch (e) {
bibrisHint.value = '导入失败';
bibrisHintKind.value = 'error';
} finally {
if (!importScheduledClose) {
bibrisBusy.value = false;
}
}
}
// 文献集数据结构(与图中示例一致)
interface ReferenceCollection {
id: number;
title: string;
count: number;
createdAt: string;
}
const displayCollections = computed(() => collections.value);
const addToCollectionFilteredCollections = computed(() => {
const list = collections.value || [];
const kw = addToCollectionSearchKeyword.value.trim().toLowerCase();
if (!kw) return list;
return list.filter((c) => (c.title || '').toLowerCase().includes(kw));
});
async function loadCollections(keyword?: string) {
try {
collectionsBusy.value = true;
const res = await getUserLibraryCollections({
page: 0,
size: 50,
keyword: keyword?.trim() || undefined,
});
const items = (res?.data || []) as UserLibraryCollectionItem[];
collections.value = items
.filter((it): it is UserLibraryCollectionItem & { id: number } => typeof it.id === 'number')
.map((it) => ({
id: it.id,
title: it.name || '',
count: it.documentCount ?? 0,
createdAt: it.createdAt || it.updatedAt || '',
}));
} catch (e) {
ElMessage.error((e as Error).message || '获取文献集列表失败');
collections.value = [];
} finally {
collectionsBusy.value = false;
}
}
watch(
() => librarySubTab.value,
(val) => {
if (val === 'collections') {
// 切换到“文献集”时立即拉取一次真实列表
loadCollections(collectionSearchKeyword.value);
return;
}
if (val === 'all') {
// 切换到“全部文献”时,按当前关键词拉取服务端搜索结果
loadReferences(searchKeyword.value);
}
}
);
watch(
() => activeCollection.value,
(v) => {
if (!v) {
collectionDocuments.value = [];
collectionDocsBusy.value = false;
}
}
);
// 文献集搜索:对输入做防抖,减少请求次数
let collectionsSearchTimer: ReturnType<typeof setTimeout> | null = null;
watch(
() => collectionSearchKeyword.value,
(kw) => {
if (librarySubTab.value !== 'collections') return;
if (collectionsSearchTimer) clearTimeout(collectionsSearchTimer);
collectionsSearchTimer = setTimeout(() => loadCollections(kw), 300);
}
);
// 全部文献搜索:走 /library/items 的 keyword 参数
let referencesSearchTimer: ReturnType<typeof setTimeout> | null = null;
watch(
() => searchKeyword.value,
(kw) => {
if (librarySubTab.value !== 'all') return;
if (referencesSearchTimer) clearTimeout(referencesSearchTimer);
referencesSearchTimer = setTimeout(() => loadReferences(kw), 300);
}
);
function handleCreateCollection() {
if (collectionsCreateBusy.value) return;
activeCollection.value = null;
showCreateCollectionInput.value = true;
newCollectionName.value = '';
nextTick(() => {
newCollectionInputRef.value?.focus();
newCollectionInputRef.value?.select?.();
});
}
function closeCreateCollectionInput() {
showCreateCollectionInput.value = false;
newCollectionName.value = '';
}
async function submitCreateCollection() {
if (collectionsCreateBusy.value) return;
const name = newCollectionName.value.trim();
if (!name) {
ElMessage.warning('请输入文献集名称');
return;
}
collectionsCreateBusy.value = true;
try {
await createUserLibraryCollection({ name });
ElMessage.success('文献集已创建');
// 创建后刷新列表,保证用户能立即看到新增结果
collectionSearchKeyword.value = '';
closeCreateCollectionInput();
await loadCollections('');
} catch (e) {
ElMessage.error((e as Error).message || '创建文献集失败');
} finally {
collectionsCreateBusy.value = false;
}
}
function submitCreateCollectionOnBlur() {
// ESC 取消时可能会触发 blur,避免误提交
if (!showCreateCollectionInput.value) return;
const name = newCollectionName.value.trim();
if (!name) {
// 失焦但未输入内容:直接关闭输入框(不弹 warning)
closeCreateCollectionInput();
return;
}
submitCreateCollection();
}
function startRenameCollection(coll: ReferenceCollection) {
if (collectionsRenameBusy.value) return;
editingCollectionId.value = coll.id;
editingCollectionOriginalName.value = coll.title;
editingCollectionName.value = coll.title;
nextTick(() => {
editCollectionInputRef.value?.focus();
editCollectionInputRef.value?.select?.();
});
}
function cancelRenameCollection() {
editingCollectionId.value = null;
editingCollectionName.value = editingCollectionOriginalName.value;
}
async function submitRenameCollection(trigger: 'enter' | 'blur') {
const id = editingCollectionId.value;
if (!id) return;
if (collectionsRenameBusy.value) return;
const name = editingCollectionName.value.trim();
if (!name) {
if (trigger === 'blur') {
cancelRenameCollection();
} else {
ElMessage.warning('请输入文献集名称');
}
return;
}
const original = editingCollectionOriginalName.value;
if (name === original) {
editingCollectionId.value = null;
return;
}
collectionsRenameBusy.value = true;
try {
await updateUserLibraryCollection(id, { name });
ElMessage.success('文献集已重命名');
// 同步列表展示(不强制刷新,避免影响当前筛选/搜索状态)
collections.value = collections.value.map((c) => (c.id === id ? { ...c, title: name } : c));
// 如果恰好打开的是同一个文献集,也一并同步
if (activeCollection.value && activeCollection.value.id === id) {
activeCollection.value = { ...activeCollection.value, title: name };
}
editingCollectionId.value = null;
} catch (e) {
editingCollectionName.value = original;
ElMessage.error((e as Error).message || '重命名文献集失败');
} finally {
collectionsRenameBusy.value = false;
}
}
async function openCollection(coll: ReferenceCollection) {
// 正在重命名时不切换文献集,避免交互打断
if (editingCollectionId.value !== null) return;
activeCollection.value = coll;
const requestedCollectionId = coll.id;
collectionDocsBusy.value = true;
collectionDocuments.value = [];
try {
const res = await getUserLibraryCollectionDocuments(requestedCollectionId, {
page: 0,
size: 50,
});
const items = (res?.data || []) as UserLibraryCollectionDocumentItem[];
const safeItems = items.filter(
(it): it is UserLibraryCollectionDocumentItem & { workId: number } =>
typeof it.workId === 'number',
);
// 如果请求过程中用户切换了文献集,则丢弃旧结果
if (activeCollection.value?.id !== requestedCollectionId) return;
collectionDocuments.value = safeItems.map((doc) => {
const rawDoi = (doc.workDoi || '').trim();
const doi = rawDoi
.replace(/^https?:\/\/(dx\.)?doi\.org\//i, '')
.replace(/^doi\.org\//i, '')
.trim();
const lib = references.value.find((r) => r.workId === doc.workId);
const libraryItemId = lib && lib.id > 0 ? lib.id : 0;
return {
id: libraryItemId,
fileId: 0,
workId: doc.workId,
title: doc.workTitle || '',
publicationYear: doc.publicationYear ?? 0,
authorsText: doc.workAuthors || '',
doi,
landingUrl: doi ? `https://doi.org/${doi}` : '',
pdfUrl: '',
note: '',
updatedAt: doc.createdAt || '',
venueName: doc.venueName || '',
journalAbbr: doc.journalAbbr || '',
} as ExtendedRef;
});
} catch (e) {
if (activeCollection.value?.id !== requestedCollectionId) return;
ElMessage.error((e as Error).message || '获取文献集文献列表失败');
collectionDocuments.value = [];
} finally {
if (activeCollection.value?.id !== requestedCollectionId) return;
collectionDocsBusy.value = false;
}
}
function handleAddTag() {
const tag = tagInput.value.trim();
if (!tag) return;
if (!filterState.litTypes.includes(tag)) {
filterState.litTypes = [...filterState.litTypes, tag];
}
tagInput.value = '';
}
// 扩展 ReferenceItem 以支持 venueName、impactFactor、citations
interface ExtendedRef extends ReferenceItem {
isMock?: boolean;
venueName?: string;
journalAbbr?: string;
impactFactor?: string;
citations?: string;
}
// 当前文献集文献列表由接口返回数据渲染
const displayReferences = computed(() => {
return references.value as ExtendedRef[];
});
/** 当前文献集下的文献列表(由接口返回) */
const collectionDisplayReferences = computed((): ExtendedRef[] => {
if (!activeCollection.value) return [];
return collectionDocuments.value as ExtendedRef[];
});
/** 勾选后批量删除用户文献库项(/library/items) */
const selectedLibraryItemIds = ref<number[]>([]);
const batchDeleteLibraryBusy = ref(false);
/** 文献集列表页:勾选后批量删除文献集(/library/collections) */
const selectedCollectionIds = ref<number[]>([]);
const batchDeleteCollectionsBusy = ref(false);
/** 文献集详情页:按 workId 勾选(支持移出文献集;删除文献库仍按 library item id 解析) */
const selectedCollectionDocWorkIds = ref<number[]>([]);
const removeFromCollectionBusy = ref(false);
const isBatchDeleteBarCollectionsMode = computed(
() =>
librarySubTab.value === 'collections' &&
!activeCollection.value &&
selectedCollectionIds.value.length > 0,
);
const isBatchDeleteBarCollectionDocsMode = computed(
() =>
librarySubTab.value === 'collections' &&
!!activeCollection.value &&
selectedCollectionDocWorkIds.value.length > 0,
);
const batchDeleteBarSelectedCount = computed(() => {
if (isBatchDeleteBarCollectionsMode.value) {
return selectedCollectionIds.value.length;
}
if (isBatchDeleteBarCollectionDocsMode.value) {
return selectedCollectionDocWorkIds.value.length;
}
return selectedLibraryItemIds.value.length;
});
const batchDeleteBarBusy = computed(() =>
isBatchDeleteBarCollectionsMode.value
? batchDeleteCollectionsBusy.value
: batchDeleteLibraryBusy.value,
);
function clearCollectionSelection() {
selectedCollectionIds.value = [];
}
function isCollectionIdSelected(id: number): boolean {
return id > 0 && selectedCollectionIds.value.includes(id);
}
function toggleCollectionIdSelection(id: number) {
if (id <= 0) return;
const cur = selectedCollectionIds.value;
const idx = cur.indexOf(id);
if (idx >= 0) {
selectedCollectionIds.value = cur.filter((x) => x !== id);
} else {
selectedCollectionIds.value = [...cur, id];
}
}
function clearBatchDeleteBarSelection() {
if (isBatchDeleteBarCollectionsMode.value) {
clearCollectionSelection();
} else if (isBatchDeleteBarCollectionDocsMode.value) {
clearCollectionDocWorkIdSelection();
} else {
clearLibraryItemSelection();
}
}
async function handleBatchDeleteBarConfirm() {
if (isBatchDeleteBarCollectionsMode.value) {
await handleBatchDeleteCollections();
} else {
await handleBatchDeleteLibraryItems();
}
}
function getWorkIdForCollectionDocSelect(ref: ExtendedRef): number {
if ((ref as any).isMock) return 0;
const w = (ref as ReferenceItem).workId;
return typeof w === 'number' && w > 0 ? w : 0;
}
function getLibraryItemIdForDelete(ref: ExtendedRef): number {
if ((ref as any).isMock) return 0;
const id = (ref as ReferenceItem).id;
return typeof id === 'number' && id > 0 ? id : 0;
}
function isCollectionDocWorkIdSelected(workId: number): boolean {
return workId > 0 && selectedCollectionDocWorkIds.value.includes(workId);
}
function toggleCollectionDocWorkIdSelection(workId: number) {
if (workId <= 0) return;
const cur = selectedCollectionDocWorkIds.value;
const idx = cur.indexOf(workId);
if (idx >= 0) {
selectedCollectionDocWorkIds.value = cur.filter((x) => x !== workId);
} else {
selectedCollectionDocWorkIds.value = [...cur, workId];
}
}
function clearCollectionDocWorkIdSelection() {
selectedCollectionDocWorkIds.value = [];
}
function isLibraryItemIdSelected(id: number): boolean {
return id > 0 && selectedLibraryItemIds.value.includes(id);
}
function toggleLibraryItemIdSelection(id: number) {
if (id <= 0) return;
const cur = selectedLibraryItemIds.value;
const idx = cur.indexOf(id);
if (idx >= 0) {
selectedLibraryItemIds.value = cur.filter((x) => x !== id);
} else {
selectedLibraryItemIds.value = [...cur, id];
}
}
function clearLibraryItemSelection() {
selectedLibraryItemIds.value = [];
}
const canShowLibraryBatchDeleteBar = computed(() => {
const onCollectionsRoot =
librarySubTab.value === 'collections' && !activeCollection.value;
if (onCollectionsRoot && selectedCollectionIds.value.length > 0) {
return !collectionsBusy.value;
}
if (librarySubTab.value === 'collections' && activeCollection.value) {
if (selectedCollectionDocWorkIds.value.length > 0) {
return !collectionDocsBusy.value;
}
return false;
}
if (selectedLibraryItemIds.value.length === 0) return false;
if (librarySubTab.value === 'all') {
return !isLoading.value;
}
return false;
});
watch(
() => [librarySubTab.value, activeCollection.value?.id ?? null] as const,
() => {
clearLibraryItemSelection();
clearCollectionSelection();
clearCollectionDocWorkIdSelection();
},
);
watch(
() => [
displayReferences.value,
collectionDisplayReferences.value,
librarySubTab.value,
activeCollection.value?.id,
],
() => {
if (librarySubTab.value === 'collections' && activeCollection.value) {
const validW = new Set(
collectionDisplayReferences.value
.map((r) => getWorkIdForCollectionDocSelect(r as ExtendedRef))
.filter((w) => w > 0),
);
selectedCollectionDocWorkIds.value = selectedCollectionDocWorkIds.value.filter(
(w) => validW.has(w),
);
return;
}
const list = displayReferences.value;
const valid = new Set(
list
.map((r) => getLibraryItemIdForDelete(r as ExtendedRef))
.filter((id) => id > 0),
);
selectedLibraryItemIds.value = selectedLibraryItemIds.value.filter((id) =>
valid.has(id),
);
},
{ deep: true },
);
watch(
() => collections.value.map((c) => c.id),
() => {
const valid = new Set(collections.value.map((c) => c.id));
selectedCollectionIds.value = selectedCollectionIds.value.filter((id) =>
valid.has(id),
);
},
);
watch(
references,
() => {
if (!activeCollection.value || collectionDocsBusy.value) return;
const next = collectionDocuments.value.map((row) => {
const ext = row as ExtendedRef;
const lib = references.value.find((r) => r.workId === ext.workId);
const nid = lib && lib.id > 0 ? lib.id : 0;
return { ...ext, id: nid };
});
const changed = next.some(
(row, i) => row.id !== (collectionDocuments.value[i] as ExtendedRef | undefined)?.id,
);
if (changed) collectionDocuments.value = next;
},
{ deep: true },
);
async function handleBatchDeleteLibraryItems() {
let ids: number[];
if (
librarySubTab.value === 'collections' &&
activeCollection.value &&
selectedCollectionDocWorkIds.value.length > 0
) {
ids = selectedCollectionDocWorkIds.value
.map((wid) => {
const r = collectionDisplayReferences.value.find((x) => x.workId === wid);
return r ? getLibraryItemIdForDelete(r as ExtendedRef) : 0;
})
.filter((id) => id > 0);
if (ids.length === 0) {
ElMessage.warning(
t('referenceLibrary.noLibraryItemForBatchDelete') ||
'所选文献不在个人文献库中,无法从文献库删除',
);
return;
}
} else {
ids = selectedLibraryItemIds.value.filter((id) => id > 0);
}
if (ids.length === 0) return;
try {
await ElMessageBox.confirm(
t('referenceLibrary.batchDeleteConfirm', { count: ids.length }) ||
`确定从文献库删除已选中的 ${ids.length} 条文献吗?`,
t('common.warning') || '提示',
{
type: 'warning',
confirmButtonText: t('common.delete') || '删除',
cancelButtonText: t('common.cancel') || '取消',
},
);
} catch {
return;
}
batchDeleteLibraryBusy.value = true;
try {
if (ids.length === 1) {
const onlyId = ids[0]!;
await deleteUserLibraryItem(onlyId);
} else {
await batchDeleteUserLibraryItems(ids);
}
ElMessage.success(t('common.success') || '操作成功');
clearLibraryItemSelection();
clearCollectionDocWorkIdSelection();
await loadReferences(searchKeyword.value);
await loadCollections(collectionSearchKeyword.value);
if (activeCollection.value) {
await openCollection(activeCollection.value);
}
} catch (e) {
ElMessage.error((e as Error).message || '删除失败');
} finally {
batchDeleteLibraryBusy.value = false;
}
}
async function handleRemoveFromCollection() {
const coll = activeCollection.value;
if (!coll) return;
const workIds = selectedCollectionDocWorkIds.value.filter((w) => w > 0);
if (workIds.length === 0) return;
try {
await ElMessageBox.confirm(
t('referenceLibrary.removeFromCollectionConfirm', { count: workIds.length }) ||
`确定将已选中的 ${workIds.length} 篇文献移出当前文献集吗?`,
t('common.warning') || '提示',
{
type: 'warning',
confirmButtonText: t('referenceLibrary.removeFromCollection') || '移出文献集',
cancelButtonText: t('common.cancel') || '取消',
},
);
} catch {
return;
}
removeFromCollectionBusy.value = true;
try {
const collectionId = coll.id;
if (workIds.length === 1) {
await deleteUserLibraryCollectionDocument(collectionId, workIds[0]!);
} else {
await batchDeleteUserLibraryCollectionDocuments(collectionId, workIds);
}
ElMessage.success(t('common.success') || '操作成功');
clearCollectionDocWorkIdSelection();
await loadCollections(collectionSearchKeyword.value);
await openCollection(coll);
} catch (e) {
ElMessage.error((e as Error).message || '移出失败');
} finally {
removeFromCollectionBusy.value = false;
}
}
async function handleBatchDeleteCollections() {
const ids = selectedCollectionIds.value.filter((id) => id > 0);
if (ids.length === 0) return;
try {
await ElMessageBox.confirm(
t('referenceLibrary.batchDeleteCollectionsConfirm', { count: ids.length }) ||
`确定删除已选中的 ${ids.length} 个文献集吗?`,
t('common.warning') || '提示',
{
type: 'warning',
confirmButtonText: t('common.delete') || '删除',
cancelButtonText: t('common.cancel') || '取消',
},
);
} catch {
return;
}
batchDeleteCollectionsBusy.value = true;
try {
if (ids.length === 1) {
await deleteUserLibraryCollection(ids[0]!);
} else {
await batchDeleteUserLibraryCollections(ids);
}
ElMessage.success(t('common.success') || '操作成功');
clearCollectionSelection();
await loadCollections(collectionSearchKeyword.value);
await loadReferences(searchKeyword.value);
} catch (e) {
ElMessage.error((e as Error).message || '删除失败');
} finally {
batchDeleteCollectionsBusy.value = false;
}
}
// 文献类型筛选逻辑:
// - 默认选中“所有”
// - 若在只选中“所有”时勾选其他类型,则取消“所有”,只保留其他类型
// - 若在已有其他类型时再勾选“所有”,则只保留“所有”
// - 若全部取消,则恢复为“所有”
watch(
() => filterState.litTypes.slice(),
(val, prev) => {
const hasAll = val.includes('all');
const prevHasAll = prev.includes('all');
// 全部取消 -> 恢复为“所有”
if (val.length === 0) {
filterState.litTypes = ['all'];
return;
}
// 之前只有“所有”,现在勾选了其他类型 -> 取消“所有”,只保留其他类型
if (prevHasAll && prev.length === 1 && hasAll && val.length > 1) {
filterState.litTypes = val.filter((v) => v !== 'all');
return;
}
// 之前是其他类型,现在又勾选了“所有” -> 只保留“所有”
if (!prevHasAll && hasAll) {
filterState.litTypes = ['all'];
return;
}
}
);
function getJournal(ref: ReferenceItem): string {
const ext = ref as ExtendedRef;
return ext.venueName || ext.journalAbbr || '—';
}
/** 列表卡片作者展示:workAuthors 多为分号分隔,仅显示前 max 位,其余用拉丁语缩写 et al. */
function formatAuthorsDisplayForCard(raw: string | undefined | null, max = 3): string {
const s = (raw || '').trim();
if (!s) return '';
const parts = s
.split(';')
.map((p) => p.trim())
.filter(Boolean);
if (parts.length === 0) return '';
if (parts.length <= max) return parts.join('; ');
return `${parts.slice(0, max).join('; ')} et al.`;
}
async function handleAddRef(ref: ExtendedRef) {
if (!ref || typeof ref.workId !== 'number') return;
// 模拟数据不允许落库
if ((ref as any).isMock) {
ElMessage.info(t('referenceLibrary.openDocToView') || '该文献无法添加');
return;
}
addToCollectionTargetWorkId.value = ref.workId;
addToCollectionSearchKeyword.value = '';
addToCollectionSelectedCollectionId.value = null;
addToCollectionBusy.value = false;
addToCollectionShowCreateInput.value = false;
addToCollectionNewCollectionName.value = '';
addToCollectionCreateBusy.value = false;
// 在“全部文献”视图下按需补齐文献集列表
if (!collections.value.length && !collectionsBusy.value) {
await loadCollections('');
}
}
function cancelAddToCollection() {
addToCollectionSearchKeyword.value = '';
addToCollectionSelectedCollectionId.value = null;
addToCollectionTargetWorkId.value = null;
addToCollectionBusy.value = false;
addToCollectionShowCreateInput.value = false;
addToCollectionNewCollectionName.value = '';
addToCollectionCreateBusy.value = false;
}
function handleAddToCollectionDropdownVisibleChange(visible: boolean) {
if (visible) return;
addToCollectionSearchKeyword.value = '';
addToCollectionSelectedCollectionId.value = null;
addToCollectionTargetWorkId.value = null;
addToCollectionBusy.value = false;
addToCollectionShowCreateInput.value = false;
addToCollectionNewCollectionName.value = '';
addToCollectionCreateBusy.value = false;
}
function handleAddToCollectionCreateCollection() {
if (addToCollectionCreateBusy.value) return;
addToCollectionShowCreateInput.value = true;
addToCollectionNewCollectionName.value = '';
nextTick(() => {
addToCollectionNewCollectionInputRef.value?.focus();
addToCollectionNewCollectionInputRef.value?.select?.();
});
}
function closeAddToCollectionCreateCollectionInput() {
addToCollectionShowCreateInput.value = false;
addToCollectionNewCollectionName.value = '';
}
async function submitAddToCollectionCreateCollection() {
if (addToCollectionCreateBusy.value) return;
const name = addToCollectionNewCollectionName.value.trim();
if (!name) {
ElMessage.warning('请输入文献集名称');
return;
}
addToCollectionCreateBusy.value = true;
try {
await createUserLibraryCollection({ name });
ElMessage.success('文献集已创建');
// 刷新文献集列表,确保新数据可立即选择/查看
addToCollectionSearchKeyword.value = '';
closeAddToCollectionCreateCollectionInput();
await loadCollections('');
} catch (e) {
ElMessage.error((e as Error).message || '创建文献集失败');
} finally {
addToCollectionCreateBusy.value = false;
}
}
async function submitAddToCollectionCreateCollectionOnBlur(e: FocusEvent) {
if (!addToCollectionShowCreateInput.value) return;
// 如果是点击“创建”按钮导致的 blur,则由按钮 click 负责提交,避免重复提交
const relatedTarget = e.relatedTarget as HTMLElement | null;
if (relatedTarget?.closest?.('.add-collection-create-submit')) return;
const name = addToCollectionNewCollectionName.value.trim();
if (!name) {
closeAddToCollectionCreateCollectionInput();
return;
}
await submitAddToCollectionCreateCollection();
}
async function confirmAddToCollection() {
const targetWorkId = addToCollectionTargetWorkId.value;
const collectionId = addToCollectionSelectedCollectionId.value;
if (!targetWorkId || !collectionId) {
ElMessage.warning(t('referenceLibrary.selectCollection') || '请选择文献集');
return;
}
if (addToCollectionBusy.value) return;
addToCollectionBusy.value = true;
try {
await createUserLibraryCollectionDocument(collectionId, { workId: targetWorkId });
ElMessage.success(t('common.saveSuccess') || '已添加到文献集');
closeAddToCollectionDropdownForWorkId(targetWorkId);
// 刷新文献集数量(以及可能的列表更新)
await loadCollections('');
// 如果当前正在查看该文献集内文献,则刷新列表
if (activeCollection.value?.id === collectionId) {
await openCollection(activeCollection.value);
}
} catch (e) {
ElMessage.error((e as Error).message || '添加失败');
} finally {
addToCollectionBusy.value = false;
}
}
async function loadReferences(keyword?: string) {
isLoading.value = true;
try {
references.value = [];
// 由于 getUserLibraryItems 仅返回列表,这里通过“返回数量不足 pageSize”来判断结束。
const pageSize = 50;
let page = 0;
const all: UserLibraryItem[] = [];
const kw = keyword?.trim() || undefined;
while (true) {
const res = await getUserLibraryItems({ page, size: pageSize, keyword: kw });
const items = (res?.data || []) as UserLibraryItem[];
all.push(...items);
if (items.length === 0 || items.length < pageSize) break;
page += 1;
// 防御性:避免极端情况下死循环
if (page > 10000) break;
}
references.value = all.map((item) => {
const rawDoi = (item.workDoi || '').trim();
const doi = rawDoi
.replace(/^https?:\/\/(dx\.)?doi\.org\//i, '')
.replace(/^doi\.org\//i, '')
.trim();
const landingUrl = doi ? `https://doi.org/${doi}` : '';
const impactFactorRaw = (item as any).impactFactor;
const citationsRaw = (item as any).citations;
return {
id: item.id ?? 0,
fileId: 0,
workId: item.workId ?? 0,
title: item.workTitle || '',
publicationYear: item.publicationYear ?? 0,
authorsText: item.workAuthors || '',
doi,
landingUrl,
pdfUrl: '',
note: item.note || '',
updatedAt: item.updatedAt || item.createdAt || '',
venueName: item.venueName || '',
journalAbbr: item.journalAbbr || '',
impactFactor:
impactFactorRaw !== undefined && impactFactorRaw !== null
? String(impactFactorRaw)
: undefined,
citations:
citationsRaw !== undefined && citationsRaw !== null ? String(citationsRaw) : undefined,
} as ExtendedRef;
});
} catch (e) {
console.error('加载文献库失败:', e);
references.value = [];
} finally {
isLoading.value = false;
}
}
watch(
() => [props.fileId, props.isChatAnswer],
() => loadReferences(searchKeyword.value),
{ immediate: true }
);
// 输入变化时清空旧结果(避免展示与输入不一致的文献)
watch(
() => pasteIdValue.value.trim(),
(v) => {
if (pasteIdImportItems.value.length && v !== pasteIdLastQuery.value) {
pasteIdImportItems.value = [];
}
pasteIdHint.value = '';
pasteIdHintKind.value = 'info';
}
);
type ImportTabName = 'pdf' | 'zotero' | 'mendeley' | 'bibris' | 'pasteId';
function openImportDialog(tab: ImportTabName) {
importTab.value = tab;
importVisible.value = true;
pdfFileList.value = [];
bibrisContent.value = '';
bibrisInputType.value = 'text';
bibrisSelectedFile.value = null;
bibrisSearched.value = false;
bibrisImportItems.value = [];
bibrisBusy.value = false;
bibrisHint.value = '';
bibrisHintKind.value = 'info';
pasteIdValue.value = '';
pasteIdImportItems.value = [];
pasteIdLastQuery.value = '';
pasteIdHint.value = '';
pasteIdHintKind.value = 'info';
}
function handleUploadClick() {
openImportDialog('pdf');
}
async function handlePasteIdSearch() {
const input = pasteIdValue.value.trim();
if (!input) return;
if (pasteIdBusy.value) return;
pasteIdLastQuery.value = input;
const detected = detectPasteIdType(input);
if (!detected) {
pasteIdImportItems.value = [];
pasteIdHint.value = '无法识别输入,请确认是 DOI / PMID / arXiv URL / ISBN';
pasteIdHintKind.value = 'warning';
return;
}
pasteIdBusy.value = true;
pasteIdImportItems.value = [];
pasteIdHint.value = '';
pasteIdHintKind.value = 'info';
try {
const res =
detected.type === 'doi'
? await importReferenceByDoi(detected.value)
: detected.type === 'arxiv'
? await importReferenceByArxiv(detected.value)
: detected.type === 'pmid'
? await importReferenceByPmid(detected.value)
: await importReferenceByIsbn(detected.value);
const items = (res?.data?.items || []) as ReferenceImportItem[];
pasteIdImportItems.value = items;
if (!items.length) {
pasteIdHint.value = '未获取到可用的元数据结果';
pasteIdHintKind.value = 'warning';
return;
}
pasteIdHint.value = `已找到 ${items.length} 条结果,点击“导入到库”完成添加`;
pasteIdHintKind.value = 'success';
} catch (e) {
pasteIdHint.value = (e as Error).message || '获取元数据失败,请稍后重试';
pasteIdHintKind.value = 'error';
} finally {
pasteIdBusy.value = false;
}
}
async function handlePasteIdImport() {
const input = pasteIdValue.value.trim();
if (!input) return;
if (pasteIdBusy.value) return;
// 如果还没搜索获取过,则先获取一次结果
if (!pasteIdImportItems.value.length) {
await handlePasteIdSearch();
if (!pasteIdImportItems.value.length) return;
}
const items = pasteIdImportItems.value || [];
const workIds = items.map((i) => i.workId).filter((id): id is number => typeof id === 'number');
if (!workIds.length) {
pasteIdHint.value = '未获取到可添加的文献 ID';
pasteIdHintKind.value = 'warning';
return;
}
let scheduledClose = false;
try {
pasteIdBusy.value = true;
pasteIdHint.value = '正在导入到文献库...';
pasteIdHintKind.value = 'info';
// 1) 先“落库”(确保点击按钮必定调用 /library/items)
await Promise.all(workIds.map((workId) => upsertUserLibraryItem({ workId })));
// 2) 导入成功后刷新“全部文献”列表
await loadReferences(searchKeyword.value);
// 注意:此按钮仅负责“落库”(/library/items),不额外触发其它接口
pasteIdHint.value = '已导入到文献库';
pasteIdHintKind.value = 'success';
pasteIdImportItems.value = [];
pasteIdLastQuery.value = '';
scheduledClose = true;
setTimeout(() => {
importVisible.value = false;
pasteIdHint.value = '';
pasteIdHintKind.value = 'info';
pasteIdBusy.value = false;
}, 700);
} catch (e) {
pasteIdHint.value = (e as Error).message || '导入失败,请稍后重试';
pasteIdHintKind.value = 'error';
} finally {
if (!scheduledClose) {
pasteIdBusy.value = false;
}
}
}
function setPasteIdExample(v: string) {
pasteIdValue.value = v;
try {
pasteIdInputRef.value?.focus();
} catch {
// ignore
}
}
function openZoteroLogin() {
window.open('https://www.zotero.org/user/login', '_blank', 'noopener,noreferrer');
}
function openMendeley() {
window.open(
'https://id.elsevier.com/as/authorization.oauth2?state=396037cfb1894cc18f05027aedafd2ab&prompt=login&scope=openid%20email%20profile%20els_auth_info%20els_analytics_info%20urn%3Acom%3Aelsevier%3Aidp%3Apolicy%3Aproduct%3Aindv_identity&authType=SINGLE_SIGN_IN&response_type=code&platSite=MDY%2Fmendeley&redirect_uri=https%3A%2F%2Fwww.mendeley.com%2Fcallback%2F&client_id=MENDELEY&additionalPlatSites=SC%2Fscopus%2CSD%2Fscience',
'_blank',
'noopener,noreferrer',
);
}
async function openDetail(ref: ReferenceItem) {
currentDetailRef.value = ref;
detailVisible.value = true;
isEditingDetail.value = false;
const cached = referencesDetailCache.value[ref.workId];
if (cached) {
currentDetail.value = cached;
return;
}
// 模拟数据:直接使用 ref 构建详情,不请求 API
const ext = ref as ExtendedRef;
if (ext.isMock) {
currentDetail.value = {
workId: ref.workId,
doi: ref.doi,
title: ref.title,
publicationYear: ref.publicationYear || 0,
publicationDate: '',
itemType: '',
authorsText: ref.authorsText || '',
abstractText: '',
venueName: ext.venueName || '',
journalAbbr: ext.journalAbbr || '',
issn: '',
volume: '',
issue: '',
pages: '',
language: '',
landingUrl: ref.landingUrl,
pdfUrl: ref.pdfUrl,
source: '',
identifiersJson: '',
createdAt: '',
updatedAt: '',
note: ref.note,
};
return;
}
isLoadingDetail.value = true;
currentDetail.value = null;
try {
const res = await getReferenceDetail(ref.workId);
if (res?.data) {
const detail = res.data;
currentDetail.value = detail;
referencesDetailCache.value[ref.workId] = detail;
}
} catch (e) {
console.error('获取详情失败:', e);
ElMessage.error('获取详情失败');
} finally {
isLoadingDetail.value = false;
}
}
watch(
() => detailVisible.value,
(v) => {
if (!v) {
isEditingDetail.value = false;
currentDetailRef.value = null;
currentDetail.value = null;
isLoadingDetail.value = false;
}
}
);
function startEditDetail() {
if (!currentDetail.value) return;
isEditingDetail.value = true;
editableDetail.title = currentDetail.value.title || '';
editableDetail.authorsText = currentDetail.value.authorsText || '';
editableDetail.venueName = currentDetail.value.venueName || '';
editableDetail.publicationYear = currentDetail.value.publicationYear || 0;
editableDetail.abstractText = currentDetail.value.abstractText || '';
editableDetail.doi = currentDetail.value.doi || '';
}
function cancelDetailEdit() {
isEditingDetail.value = false;
}
function saveDetailEdit() {
if (!currentDetail.value) return;
currentDetail.value.title = editableDetail.title?.trim() || '';
currentDetail.value.authorsText = editableDetail.authorsText?.trim() || '';
currentDetail.value.venueName = editableDetail.venueName?.trim() || '';
currentDetail.value.publicationYear = Number(editableDetail.publicationYear || 0);
currentDetail.value.abstractText = editableDetail.abstractText || '';
currentDetail.value.doi = editableDetail.doi?.trim() || '';
referencesDetailCache.value[currentDetail.value.workId] = { ...currentDetail.value };
const refInList = references.value.find((r) => r.workId === currentDetail.value!.workId) as any;
if (refInList) {
refInList.title = currentDetail.value.title;
refInList.authorsText = currentDetail.value.authorsText;
refInList.publicationYear = currentDetail.value.publicationYear;
refInList.doi = currentDetail.value.doi;
refInList.venueName = currentDetail.value.venueName;
}
if (currentDetailRef.value && currentDetailRef.value.workId === currentDetail.value.workId) {
(currentDetailRef.value as any).title = currentDetail.value.title;
(currentDetailRef.value as any).authorsText = currentDetail.value.authorsText;
(currentDetailRef.value as any).publicationYear = currentDetail.value.publicationYear;
(currentDetailRef.value as any).doi = currentDetail.value.doi;
(currentDetailRef.value as any).venueName = currentDetail.value.venueName;
}
isEditingDetail.value = false;
ElMessage.success(t('common.saveSuccess') || '保存成功');
}
function openOriginal(ref: ReferenceItem) {
const url = ref.landingUrl || (ref.doi ? `https://doi.org/${ref.doi}` : '');
if (url) window.open(url, '_blank');
else ElMessage.warning('暂无原文链接');
}
async function copyCitation(ref: ReferenceItem) {
if (!props.fileId) return;
try {
const res = await getFormatCitation(
Number(props.fileId),
[[ref.workId]],
'apa',
'text'
);
const text = res?.data?.entries?.[0];
if (text) {
await navigator.clipboard.writeText(text);
ElMessage.success('已复制引用');
}
} catch (e) {
ElMessage.error('复制失败');
}
}
</script>
<style lang="scss" scoped>
/* 全部文献:详情/原文/添加按钮与勾选框;文献集勾选框 — 共用同一圆角数值 */
$ref-lib-card-action-radius: 4px;
.reference-library {
display: flex;
flex-direction: column;
height: 100%;
overflow: hidden;
/* 与左侧知识库区域统一的浅灰底色 */
background: var(--color-card, #f5f5f5);
}
.library-tabs {
display: flex;
gap: 0;
padding: 0 12px;
border-bottom: 1px solid var(--color-border, #e0e0e0);
flex-shrink: 0;
.library-tab {
padding: 10px 16px;
font-size: 14px;
color: var(--outline-text, #666);
cursor: pointer;
position: relative;
transition: color 0.2s;
&:hover {
color: var(--color-text, #333);
}
&.active {
color: var(--color-primary, #409eff);
font-weight: 500;
&::after {
content: '';
position: absolute;
left: 16px;
right: 16px;
bottom: -1px;
height: 2px;
background: var(--color-primary, #409eff);
}
}
}
}
.library-toolbar {
display: flex;
align-items: center;
gap: 6px;
padding: 10px 12px;
border-bottom: 1px solid var(--color-border, #e0e0e0);
flex-shrink: 0;
margin-bottom: 8px;
.toolbar-btn {
width: 26px;
height: 26px;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 4px;
background: var(--color-bg, #fff);
color: var(--outline-text, #666);
cursor: pointer;
transition: all 0.2s;
&:hover:not(:disabled) {
border-color: var(--color-primary, #409eff);
color: var(--color-primary, #409eff);
}
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
}
.search-wrapper {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
height: 32px;
padding: 0 12px;
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 4px;
background: var(--color-bg, #fff);
.search-icon {
margin-right: 8px;
color: var(--outline-text, #999);
font-size: 12px;
}
.search-input {
flex: 1;
min-width: 0;
width: 100%;
border: none;
outline: none;
font-size: 13px;
color: var(--color-text, #333);
background: transparent;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&::placeholder {
color: var(--outline-text, #999);
text-overflow: ellipsis;
}
}
&.search-wrapper-full {
flex: 1;
}
}
.new-collection-btn {
flex-shrink: 0;
}
}
.filter-panel {
width: 280px;
max-height: 80vh;
overflow-y: auto;
padding: 16px;
background: var(--color-bg, #fff);
border-radius: 8px;
.filter-panel-title {
font-size: 16px;
font-weight: 600;
color: var(--color-text, #333);
text-align: center;
margin-bottom: 16px;
}
.filter-section {
margin-bottom: 14px;
position: relative;
.filter-section-label {
font-size: 12px;
color: var(--outline-text, #666);
font-weight: 600;
margin-bottom: 4px;
}
.filter-section-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.filter-options {
display: flex;
flex-wrap: wrap;
gap: 6px;
&.filter-options-grid {
display: flex;
flex-wrap: wrap;
column-gap: 8px;
row-gap: 4px;
justify-content: flex-start;
}
}
.filter-opt-btn {
padding: 6px 12px;
font-size: 12px;
color: var(--color-text, #333);
background: var(--color-bg, #fff);
border: 1px solid var(--color-border, #ddd);
border-radius: 4px;
cursor: pointer;
transition: all 0.2s;
outline: none;
user-select: none;
white-space: nowrap;
&:hover {
border-color: #1890ff;
color: #1890ff;
background: rgba(24, 144, 255, 0.05);
}
&.active {
border-color: #1890ff;
color: #1890ff;
background: rgba(24, 144, 255, 0.05);
}
}
.filter-checkbox {
display: flex;
align-items: center;
gap: 4px;
font-size: 12px;
color: var(--color-text, #333);
cursor: pointer;
span {
white-space: nowrap;
}
input {
width: 14px;
height: 14px;
}
&.all-checkbox {
flex-shrink: 0;
}
}
.filter-all-text {
position: absolute;
right: 0;
top: 0;
font-size: 12px;
color: var(--outline-text, #999);
cursor: pointer;
&.active {
color: #1890ff;
font-weight: 500;
}
}
}
/* 个性化标签输入行(移出 filter-section 后的独立样式) */
.filter-tag-input-row {
display: flex;
gap: 8px;
margin-top: 6px;
}
.filter-tag-input {
flex: 1;
height: 32px;
padding: 0 10px;
font-size: 12px;
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 6px;
outline: none;
&:focus {
border-color: var(--color-primary, #409eff);
}
&::placeholder {
color: var(--outline-text, #999);
}
}
.filter-add-btn {
padding: 0 14px;
font-size: 12px;
color: #fff;
background: var(--color-primary, #409eff);
border: none;
border-radius: 6px;
cursor: pointer;
transition: opacity 0.2s;
&:hover {
opacity: 0.9;
}
}
}
.filter-panel-enter-active,
.filter-panel-leave-active {
transition: opacity 0.2s, transform 0.2s;
}
.filter-panel-enter-from,
.filter-panel-leave-to {
opacity: 0;
transform: translateX(-8px);
}
.collection-detail-header {
position: sticky;
top: 0;
z-index: 1;
display: flex;
align-items: center;
gap: 8px;
padding-bottom: 8px;
margin-bottom: 0;
border-bottom: 1px solid var(--color-border, #e0e0e0);
background: var(--color-card, #f5f5f5);
margin-bottom: 8px;
}
.collection-back-btn {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
padding: 0;
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 6px;
background: var(--color-bg, #fff);
color: var(--outline-text, #666);
cursor: pointer;
transition: all 0.2s;
&:hover {
border-color: var(--color-primary, #409eff);
color: var(--color-primary, #409eff);
}
}
.collection-detail-title {
font-size: 15px;
font-weight: 600;
color: var(--color-text, #333);
}
.library-collections {
display: flex;
flex-direction: column;
gap: 8px;
}
.collection-card {
position: relative;
padding: 10px 36px 10px 12px;
background: var(--color-bg, #fff);
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
cursor: pointer;
transition: box-shadow 0.2s;
&:hover {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.collection-delete-checkbox {
position: absolute;
top: 8px;
right: 8px;
display: flex;
align-items: center;
justify-content: center;
padding: 4px;
cursor: pointer;
input[type='checkbox'] {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
box-sizing: border-box;
width: 16px;
height: 16px;
margin: 0;
cursor: pointer;
flex-shrink: 0;
border: 1px solid var(--color-border, #dcdfe6);
border-radius: $ref-lib-card-action-radius;
background: var(--color-bg, #fff);
position: relative;
transition: border-color 0.2s, background 0.2s;
}
input[type='checkbox']:checked {
background: var(--color-primary, #409eff);
border-color: var(--color-primary, #409eff);
}
input[type='checkbox']:checked::after {
content: '';
position: absolute;
left: 4px;
top: 0;
width: 6px;
height: 11px;
box-sizing: border-box;
border: solid #fff;
border-width: 0 2.5px 2.5px 0;
transform: rotate(45deg);
}
&:hover input[type='checkbox']:not(:checked) {
border-color: var(--color-primary, #409eff);
}
}
.collection-title {
font-size: 14px;
font-weight: 600;
color: var(--color-text, #333);
line-height: 1.4;
margin: 0;
}
.collection-title-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.collection-edit-btn {
position: absolute;
top: 6px;
right: 38px;
width: 28px;
height: 28px;
border: 1px solid transparent;
border-radius: 6px;
background: transparent;
color: var(--outline-text, #666);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.2s;
flex-shrink: 0;
&:hover:not(:disabled) {
color: var(--color-primary, #409eff);
background: var(--color-bg, #fff);
}
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
i {
font-size: 13px;
}
}
.collection-title-input {
flex: 1;
min-width: 0;
font-size: 14px;
font-weight: 600;
color: var(--color-text, #333);
line-height: 1.4;
padding: 6px 8px;
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 6px;
background: var(--color-bg, #fff);
outline: none;
&:focus {
border-color: var(--color-primary, #409eff);
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.15);
}
}
.collection-meta {
font-size: 12px;
color: var(--outline-text, #666);
.meta-sep {
margin: 0 4px;
}
}
}
.collection-create-card {
cursor: default;
}
.collection-create-input {
width: 100%;
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 6px;
padding: 8px 10px;
font-size: 13px;
color: var(--color-text, #333);
outline: none;
background: var(--color-bg, #fff);
}
.collection-create-input:focus {
border-color: var(--color-primary, #409eff);
}
/* 下拉内创建输入框:不显示边框,聚焦也不显示描边 */
.add-collection-create-input-wrap .collection-create-input {
border: none !important;
box-shadow: none !important;
outline: none !important;
border-radius: 6px;
height: 32px;
padding: 0;
margin: 0;
line-height: 32px;
flex: 1;
min-width: 0;
background: transparent;
}
.add-collection-create-input-wrap .collection-create-input:focus {
border: none !important;
box-shadow: none !important;
outline: none !important;
}
.library-batch-delete-bar {
flex-shrink: 0;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: space-between;
gap: 8px;
padding: 8px 12px 6px 12px;
border-top: 1px solid var(--color-border, #e0e0e0);
.library-batch-delete-hint {
flex: 0 1 auto;
min-width: 0;
font-size: 13px;
color: var(--color-text, #333);
white-space: nowrap;
}
.library-batch-delete-actions {
display: flex;
flex: 0 0 auto;
flex-wrap: nowrap;
align-items: center;
}
}
.library-content {
flex: 1;
min-height: 0;
overflow-y: auto;
padding: 0 12px 12px;
display: flex;
flex-direction: column;
}
.library-loading,
.library-empty {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
color: var(--outline-text, #999);
font-size: 14px;
.empty-icon {
font-size: 40px;
opacity: 0.5;
}
.import-btn {
margin-top: 8px;
}
}
.library-empty.library-empty-cta {
justify-content: flex-start;
align-items: stretch;
align-self: center;
width: 100%;
max-width: 400px;
margin: 0 auto;
padding: 20px 8px 24px;
gap: 0;
color: var(--color-text, #333);
}
.library-empty-cta-visual {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.cta-source-stack {
position: relative;
width: 200px;
height: 100px;
}
.cta-mini-card {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
width: 88px;
height: 52px;
border-radius: 8px;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.02em;
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
border: 1px solid rgba(0, 0, 0, 0.06);
}
.cta-mini-card--n {
left: 8px;
top: 28px;
transform: rotate(-12deg);
background: linear-gradient(145deg, #fff 0%, #e8f5e9 100%);
color: #1b5e20;
}
.cta-mini-card--s {
left: 56px;
top: 4px;
transform: rotate(4deg);
z-index: 2;
background: linear-gradient(145deg, #fff8e1 0%, #ffecb3 100%);
color: #e65100;
}
.cta-mini-card--a {
right: 4px;
top: 22px;
transform: rotate(14deg);
background: linear-gradient(145deg, #fff 0%, #ffebee 100%);
color: #b71c1c;
font-size: 10px;
}
.library-empty-cta-title {
margin: 0 0 8px;
font-size: 20px;
font-weight: 700;
line-height: 1.3;
text-align: center;
color: var(--color-text, #111);
}
.library-empty-cta-subtitle {
margin: 0 0 22px;
font-size: 13px;
line-height: 1.5;
text-align: center;
color: var(--outline-text, #888);
}
.library-empty-cta-section-label {
font-size: 12px;
font-weight: 600;
color: var(--outline-text, #666);
margin-bottom: 10px;
&--other {
margin-top: 20px;
}
}
.library-empty-cta-actions {
display: flex;
flex-direction: column;
gap: 10px;
}
.library-empty-cta-btn {
display: flex;
flex-direction: row;
align-items: center;
gap: 12px;
width: 100%;
padding: 12px 14px;
text-align: left;
font-size: 14px;
font-weight: 500;
color: var(--color-text, #333);
background: var(--color-bg, #fff);
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 10px;
cursor: pointer;
transition: border-color 0.15s, box-shadow 0.15s;
&:hover {
border-color: var(--color-primary, #409eff);
box-shadow: 0 2px 8px rgba(64, 158, 255, 0.12);
}
}
.library-empty-cta-btn-icon {
font-size: 16px;
color: var(--outline-text, #666);
width: 22px;
text-align: center;
}
.library-empty-cta-btn-zm {
display: inline-flex;
align-items: center;
justify-content: center;
width: 22px;
font-style: normal;
font-weight: 700;
font-size: 14px;
}
.library-empty-cta-btn .tab-icon-z {
color: #c5522b;
}
.library-empty-cta-btn .tab-icon-m {
color: #9d1625;
}
.collections-empty-icon {
width: 48px;
height: 48px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.04);
color: var(--color-text, #111);
opacity: 0.85;
font-size: 22px;
}
.collections-empty-text {
max-width: 520px;
text-align: center;
line-height: 1.6;
padding: 0 10px;
}
.collections-empty-btn {
width: 100%;
max-width: 520px;
}
.library-cards {
display: flex;
flex-direction: column;
gap: 8px;
}
.reference-card {
position: relative;
padding: 14px 16px;
/* 卡片保持白底,在浅灰背景上形成对比,风格与知识库列表一致 */
background: var(--color-bg, #fff);
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 8px;
transition: box-shadow 0.2s;
/* el-dropdown 触发层可能会成为定位参照,导致绝对定位按钮偏移 */
:deep(.el-dropdown) {
position: static !important;
}
&:hover {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.card-title {
font-size: 14px;
font-weight: 600;
color: var(--color-text, #333);
line-height: 1.4;
margin-bottom: 6px;
padding-right: 44px; /* 为右上角 + 按钮留出空间,避免重叠 */
}
.card-author {
font-size: 12px;
color: var(--outline-text, #666);
margin-bottom: 4px;
}
.card-journal {
font-size: 12px;
color: var(--color-primary, #409eff);
font-weight: 500;
margin-bottom: 8px;
}
.card-meta {
font-size: 12px;
color: var(--outline-text, #999);
margin-bottom: 10px;
.meta-sep {
margin: 0 4px;
}
.doi-link {
color: var(--color-primary, #409eff);
text-decoration: underline;
}
}
.card-actions {
display: flex;
align-items: center;
gap: 4px;
flex-wrap: nowrap;
padding-top: 12px;
border-top: 1px solid var(--color-border, #eee);
.action-btn {
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
padding: 4px 6px;
font-size: 11px;
color: var(--color-text, #333);
background: var(--color-bg, #fff);
border: 1px solid var(--color-border, #dcdfe6);
border-radius: $ref-lib-card-action-radius;
cursor: pointer;
transition: all 0.2s;
i {
font-size: 11px;
color: var(--outline-text, #666);
}
&:hover {
border-color: var(--color-primary, #409eff);
color: var(--color-primary, #409eff);
i {
color: var(--color-primary, #409eff);
}
}
}
.card-delete-checkbox {
margin-left: auto;
display: flex;
align-items: center;
justify-content: center;
padding: 4px 6px;
cursor: pointer;
input[type='checkbox'] {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
box-sizing: border-box;
width: 16px;
height: 16px;
margin: 0;
cursor: pointer;
flex-shrink: 0;
border: 1px solid var(--color-border, #dcdfe6);
border-radius: $ref-lib-card-action-radius;
background: var(--color-bg, #fff);
position: relative;
transition: border-color 0.2s, background 0.2s;
}
input[type='checkbox']:checked {
background: var(--color-primary, #409eff);
border-color: var(--color-primary, #409eff);
}
input[type='checkbox']:checked::after {
content: '';
position: absolute;
left: 4px;
top: 0;
width: 6px;
height: 11px;
box-sizing: border-box;
border: solid #fff;
border-width: 0 2.5px 2.5px 0;
transform: rotate(45deg);
}
&:hover input[type='checkbox']:not(:checked) {
border-color: var(--color-primary, #409eff);
}
}
}
.card-add-btn {
position: absolute;
top: 12px;
right: 12px;
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid var(--color-border, #dcdfe6);
border-radius: $ref-lib-card-action-radius;
background: var(--color-bg, #fff);
color: var(--color-text, #333);
cursor: pointer;
transition: all 0.2s;
font-size: 14px;
&:hover {
border-color: var(--color-primary, #409eff);
color: var(--color-primary, #409eff);
background: rgba(64, 158, 255, 0.06);
}
}
}
.add-collection-panel {
width: 246px;
max-height: 80vh;
overflow: hidden;
padding: 12px;
}
.add-collection-title {
font-size: 14px;
font-weight: 600;
color: var(--color-text, #333);
text-align: center;
margin-bottom: 10px;
}
.add-collection-search {
display: flex;
align-items: center;
gap: 8px;
padding: 6px 10px;
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 8px;
background: var(--color-bg, #fff);
margin-bottom: 6px;
.search-icon {
color: var(--outline-text, #999);
font-size: 12px;
}
.search-input {
flex: 1;
border: none;
outline: none;
font-size: 13px;
color: var(--color-text, #333);
background: transparent;
&::placeholder {
color: var(--outline-text, #999);
}
}
}
.add-collection-empty {
padding: 20px 10px;
text-align: center;
color: var(--outline-text, #999);
font-size: 13px;
}
.add-collection-list {
/* 视觉上最多展示 3 条;多余通过滚动 */
max-height: 136px;
overflow-y: auto;
padding-right: 2px;
padding-bottom: 4px;
margin-bottom: 6px;
/* 隐藏滚动条(仍可滚动) */
-ms-overflow-style: none; /* IE/Edge */
scrollbar-width: none; /* Firefox */
&::-webkit-scrollbar {
width: 0;
height: 0;
}
}
.add-collection-item {
padding: 6px 10px;
border-radius: 8px;
border: 1px solid transparent;
cursor: pointer;
transition: all 0.2s;
user-select: none;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
&:hover {
background: rgba(64, 158, 255, 0.06);
border-color: rgba(64, 158, 255, 0.25);
}
&.selected {
background: rgba(64, 158, 255, 0.08);
border-color: var(--color-primary, #409eff);
}
}
.add-collection-item-title {
font-size: 13px;
color: var(--color-text, #333);
font-weight: 600;
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.add-collection-item-meta {
flex-shrink: 0;
font-size: 12px;
color: var(--outline-text, #999);
}
.add-collection-actions {
display: flex;
justify-content: flex-end;
gap: 8px;
.add-collection-cancel,
.add-collection-confirm {
height: 26px;
line-height: 26px;
padding: 0 10px;
font-size: 11px;
border-radius: 6px;
border: 1px solid var(--color-border, #dcdfe6);
background: var(--color-bg, #fff);
color: var(--color-text, #333);
cursor: pointer;
transition: all 0.2s;
min-width: 0;
}
.add-collection-confirm {
background: var(--color-primary, #409eff);
border-color: var(--color-primary, #409eff);
color: #fff;
&:disabled {
opacity: 0.6;
cursor: not-allowed;
}
}
.add-collection-cancel {
&:hover {
border-color: var(--color-primary, #409eff);
color: var(--color-primary, #409eff);
background: rgba(64, 158, 255, 0.06);
}
}
}
.add-collection-create {
border-top: 1px solid var(--color-border, #f0f0f0);
}
.add-collection-create-entry {
width: 100%;
height: 32px;
display: flex;
align-items: center;
gap: 8px;
padding: 0 10px;
border-radius: 8px;
color: var(--color-primary, #409eff);
cursor: pointer;
transition: all 0.2s;
font-size: 12px;
font-weight: 600;
/* 用于 <i> 图标对齐 */
i {
font-size: 13px;
line-height: 1;
}
}
.add-collection-create-entry.disabled {
opacity: 0.6;
cursor: not-allowed;
}
.add-collection-create-input-wrap {
width: 100%;
height: 32px;
display: flex;
align-items: center;
gap: 8px;
padding: 0 10px;
border-radius: 8px;
}
.add-collection-create-input-plus {
color: var(--color-primary, #409eff);
font-size: 13px;
line-height: 1;
flex-shrink: 0;
}
.add-collection-create-submit {
height: 26px;
line-height: 26px;
padding: 0 12px;
border-radius: 6px;
border: 1px solid var(--color-border, #dcdfe6);
background: transparent;
color: var(--outline-text, #909399);
font-size: 11px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
flex-shrink: 0;
}
.add-collection-create-submit.disabled {
opacity: 0.6;
cursor: not-allowed;
}
.add-collection-create-submit:not(.disabled):hover {
background: rgba(0, 0, 0, 0.04);
}
.detail-content {
padding: 12px 0;
.detail-loading {
display: flex;
align-items: center;
gap: 8px;
color: var(--outline-text, #999);
}
.detail-row {
margin-bottom: 16px;
.detail-label {
font-size: 12px;
color: var(--outline-text, #999);
margin-bottom: 4px;
}
.detail-value {
font-size: 14px;
color: var(--color-text, #333);
line-height: 1.5;
&.abstract {
max-height: 120px;
overflow-y: auto;
}
a {
color: var(--color-primary, #409eff);
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
}
}
}
.detail-drawer-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
width: 100%;
/* 预留右侧关闭按钮位置,避免操作按钮挤在一起 */
padding-right: 16px;
.detail-drawer-title {
font-size: 16px;
font-weight: 600;
color: var(--color-text, #333);
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.detail-drawer-actions {
flex-shrink: 0;
display: inline-flex;
align-items: center;
gap: 8px;
}
}
.detail-edit-form {
padding-top: 2px;
}
.import-dialog-content {
display: flex;
flex-direction: column;
gap: 16px;
:deep(.import-tabs) {
.el-tabs__header {
margin-bottom: 16px;
}
.el-tabs__nav-wrap::after {
display: none;
}
.el-tabs__item {
font-size: 13px;
}
.el-tabs__item.is-active .tab-label {
color: var(--color-primary, #409eff);
}
.tab-label {
display: inline-flex;
align-items: center;
gap: 6px;
i, .tab-icon-z, .tab-icon-m {
font-size: 14px;
}
.tab-icon-z, .tab-icon-m {
font-weight: 700;
font-style: normal;
}
.tab-icon-z { color: #c5522b; }
.tab-icon-m { color: #9d1625; }
}
.tab-placeholder {
padding: 24px;
text-align: center;
color: var(--outline-text, #999);
font-size: 14px;
}
}
.upload-pdf-panel {
position: relative;
display: flex;
flex-direction: column;
gap: 12px;
.pdf-upload-area {
:deep(.el-upload-dragger) {
padding: 32px 20px;
}
}
.upload-inner {
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
.upload-icon {
font-size: 32px;
color: var(--outline-text, #999);
}
.upload-text {
font-size: 14px;
color: var(--color-text, #333);
}
.upload-hint {
font-size: 13px;
color: var(--outline-text, #666);
.select-link {
color: var(--color-primary, #409eff);
cursor: pointer;
&:hover { text-decoration: underline; }
}
}
.upload-limit {
font-size: 12px;
color: var(--outline-text, #999);
}
}
.hidden-file-input {
position: absolute;
width: 0;
height: 0;
opacity: 0;
overflow: hidden;
}
.pdf-import-btn {
align-self: flex-end;
margin-top: 4px;
}
/* Element Plus: primary + disabled 仍可能保留主题色,这里强制置灰 */
:deep(.pdf-import-btn.is-disabled),
:deep(.pdf-import-btn.is-disabled:hover),
:deep(.pdf-import-btn.is-disabled:focus),
:deep(.pdf-import-btn.is-disabled:active) {
background-color: #cfd3dc !important;
border-color: #cfd3dc !important;
color: #ffffff !important;
cursor: not-allowed !important;
}
}
.bibris-panel {
display: flex;
flex-direction: column;
gap: 12px;
position: relative;
.bibris-textarea {
min-height: 200px;
width: 100%;
padding: 12px;
font-size: 13px;
font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
line-height: 1.5;
color: var(--color-text, #333);
background: var(--color-bg-secondary, #fafafa);
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 8px;
resize: none;
outline: none;
transition: border-color 0.2s, box-shadow 0.2s;
&::placeholder {
color: var(--outline-text, #999);
}
&:focus {
border-color: var(--color-primary, #409eff);
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.15);
}
}
.bibris-file-hint {
font-size: 13px;
color: var(--outline-text, #666);
.select-link {
color: var(--color-primary, #409eff);
cursor: pointer;
&:hover { text-decoration: underline; }
}
}
.bibris-search-btn {
align-self: flex-end;
margin-top: 4px;
}
.bibris-hint {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
border-radius: 10px;
font-size: 13px;
border: 1px solid var(--color-border, #e0e0e0);
background: #fff;
color: var(--outline-text, #666);
}
.bibris-hint.kind-success {
border-color: rgba(64, 158, 255, 0.35);
background: rgba(64, 158, 255, 0.08);
color: var(--color-primary, #409eff);
}
.bibris-hint.kind-warning {
border-color: rgba(230, 162, 60, 0.45);
background: rgba(230, 162, 60, 0.12);
color: #e6a23c;
}
.bibris-hint.kind-error {
border-color: rgba(245, 108, 108, 0.45);
background: rgba(245, 108, 108, 0.12);
color: #f56c6c;
}
.bibris-hint-text {
word-break: break-word;
line-height: 1.4;
}
.bibris-results-list {
display: flex;
flex-direction: column;
gap: 10px;
max-height: 240px;
overflow-y: auto;
}
.bibris-result-item {
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 10px;
padding: 12px 14px;
}
.bibris-result-title {
font-size: 14px;
font-weight: 700;
color: var(--color-text, #333);
}
.bibris-result-authors {
font-size: 12px;
color: var(--outline-text, #666);
margin-top: 4px;
}
.bibris-result-venue {
font-size: 12px;
color: #8a8f98;
margin-top: 2px;
}
.bibris-actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 8px;
}
.bibris-back-btn {
margin-left: 0;
}
.bibris-import-btn {
align-self: flex-end;
margin-top: 4px;
}
/* 强制“导入到库”禁用态置灰 */
:deep(.bibris-import-btn.is-disabled),
:deep(.bibris-import-btn.is-disabled:hover),
:deep(.bibris-import-btn.is-disabled:focus),
:deep(.bibris-import-btn.is-disabled:active) {
background-color: #cfd3dc !important;
border-color: #cfd3dc !important;
color: #ffffff !important;
cursor: not-allowed !important;
}
.hidden-file-input {
position: absolute;
width: 0;
height: 0;
opacity: 0;
overflow: hidden;
}
}
.pasteid-panel {
display: flex;
flex-direction: column;
gap: 14px;
position: relative;
.pasteid-tip {
font-size: 13px;
color: var(--outline-text, #666);
}
.pasteid-input-row {
display: flex;
align-items: center;
gap: 10px;
}
.pasteid-input {
flex: 1;
height: 40px;
padding: 0 12px;
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 10px;
font-size: 12px;
outline: none;
background: #fff;
transition: border-color 0.2s, box-shadow 0.2s;
}
.pasteid-input:focus {
border-color: var(--color-primary, #409eff);
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.15);
}
.pasteid-search-btn {
width: 44px;
height: 40px;
border-radius: 10px;
border: none;
background: var(--color-primary, #409eff);
color: #fff;
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
transition: opacity 0.2s, background-color 0.2s;
}
.pasteid-search-btn:hover {
opacity: 0.92;
}
.pasteid-search-btn:disabled {
background: #cfd3dc;
cursor: not-allowed;
opacity: 1;
}
.pasteid-results-header {
display: flex;
align-items: center;
gap: 8px;
font-size: 13px;
color: var(--color-text, #333);
font-weight: 600;
}
.pasteid-hint {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
border-radius: 10px;
border: 1px solid var(--color-border, #e0e0e0);
background: #fff;
font-size: 13px;
color: var(--outline-text, #666);
}
.pasteid-hint.kind-success {
border-color: rgba(64, 158, 255, 0.35);
background: rgba(64, 158, 255, 0.08);
color: var(--color-primary, #409eff);
}
.pasteid-hint.kind-warning {
border-color: rgba(230, 162, 60, 0.45);
background: rgba(230, 162, 60, 0.12);
color: #e6a23c;
}
.pasteid-hint.kind-error {
border-color: rgba(245, 108, 108, 0.45);
background: rgba(245, 108, 108, 0.12);
color: #f56c6c;
}
.pasteid-hint-text {
word-break: break-word;
line-height: 1.4;
}
.pasteid-results-list {
display: flex;
flex-direction: column;
gap: 10px;
}
.pasteid-result-item {
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 10px;
background: #fff;
padding: 12px;
}
.pasteid-result-title {
font-size: 14px;
font-weight: 700;
color: var(--color-text, #333);
margin-bottom: 6px;
line-height: 1.35;
word-break: break-word;
}
.pasteid-result-authors {
font-size: 12px;
color: var(--outline-text, #666);
margin-bottom: 2px;
}
.pasteid-result-venue {
font-size: 12px;
color: #8a8f98;
font-style: italic;
}
.pasteid-examples-title {
font-size: 13px;
color: var(--color-text, #333);
}
.pasteid-examples {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
}
.example-card {
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 10px;
background: #fff;
padding: 12px 12px 10px;
cursor: pointer;
transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
outline: none;
}
.example-card:hover {
border-color: var(--color-primary, #409eff);
box-shadow: 0 6px 18px rgba(16, 24, 40, 0.08);
transform: translateY(-1px);
}
.example-card:active {
transform: translateY(0);
}
.example-card:focus-visible {
border-color: var(--color-primary, #409eff);
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.18);
}
.example-title {
font-size: 14px;
font-weight: 700;
color: var(--color-text, #333);
margin-bottom: 2px;
}
.example-subtitle {
font-size: 12px;
color: var(--outline-text, #666);
margin-bottom: 10px;
}
.example-value {
height: 34px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 8px;
background: #f3f4f6;
color: #8a8f98;
font-size: 13px;
user-select: none;
}
.pasteid-import-btn {
align-self: flex-end;
margin-top: 4px;
}
/* 强制“导入到库”禁用态置灰 */
:deep(.pasteid-import-btn.is-disabled),
:deep(.pasteid-import-btn.is-disabled:hover),
:deep(.pasteid-import-btn.is-disabled:focus),
:deep(.pasteid-import-btn.is-disabled:active) {
background-color: #cfd3dc !important;
border-color: #cfd3dc !important;
color: #ffffff !important;
cursor: not-allowed !important;
}
}
.zotero-connect-panel {
min-height: 330px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 10px;
padding: 24px 16px;
text-align: center;
}
.zotero-logo {
width: 56px;
height: 56px;
border-radius: 14px;
background: #ffffff;
box-shadow: 0 8px 22px rgba(16, 24, 40, 0.1);
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow: hidden;
}
.zotero-logo::before {
content: '';
position: absolute;
inset: -20px;
background: conic-gradient(from 180deg, #ff6b6b, #845ef7, #74c0fc, #ffd43b, #ff6b6b);
opacity: 0.22;
filter: blur(6px);
}
.zotero-logo-z {
position: relative;
font-weight: 800;
font-size: 22px;
color: #d6336c;
line-height: 1;
}
.zotero-title {
margin-top: 6px;
font-size: 18px;
font-weight: 700;
color: var(--color-text, #333);
}
.zotero-desc {
max-width: 420px;
font-size: 13px;
color: var(--outline-text, #666);
line-height: 1.5;
}
.zotero-connect-btn {
margin-top: 10px;
padding: 10px 18px;
border-radius: 10px;
font-weight: 600;
}
.mendeley-connect-panel {
min-height: 330px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 10px;
padding: 24px 16px;
text-align: center;
}
.mendeley-logo {
width: 56px;
height: 56px;
border-radius: 14px;
background: #b31217;
box-shadow: 0 8px 22px rgba(16, 24, 40, 0.12);
display: flex;
align-items: center;
justify-content: center;
}
.mendeley-logo-m {
font-weight: 800;
font-size: 22px;
color: #ffffff;
line-height: 1;
}
.mendeley-title {
margin-top: 6px;
font-size: 18px;
font-weight: 700;
color: var(--color-text, #333);
}
.mendeley-desc {
max-width: 420px;
font-size: 13px;
color: var(--outline-text, #666);
line-height: 1.5;
}
.mendeley-connect-btn {
margin-top: 10px;
padding: 10px 18px;
border-radius: 10px;
font-weight: 600;
}
.import-method-group {
display: flex;
gap: 16px;
}
.import-results {
max-height: 300px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 8px;
}
.import-result-item {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 12px;
border: 1px solid var(--color-border, #e0e0e0);
border-radius: 6px;
.result-title {
flex: 1;
font-size: 13px;
font-weight: 500;
}
.result-meta {
flex: 1;
font-size: 12px;
color: var(--outline-text, #666);
}
.el-button {
flex-shrink: 0;
}
}
}
</style>