V2Ray前端用户系统设计

V2Ray代理用户管理系统 - 完整实现

我理解您的需求了。您想要一个用户自助系统,让用户可以注册、登录、查看订阅信息,同时您作为管理员可以管理用户。我将为您设计一个完整的解决方案。

下面是完整的HTML代码,包含了用户前端和管理员后台,以及如何与您的sing-box脚本集成的说明:

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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>V2Ray代理用户管理系统</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
:root {
--primary-color: #3498db;
--secondary-color: #2c3e50;
--accent-color: #1abc9c;
--danger-color: #e74c3c;
--warning-color: #f39c12;
--success-color: #2ecc71;
--dark-bg: #1a2332;
--card-bg: #243145;
--text-color: #ecf0f1;
--border-color: #34495e;
--light-bg: #f5f7fa;
--light-text: #2c3e50;
--light-border: #ddd;
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
background-color: var(--dark-bg);
color: var(--text-color);
line-height: 1.6;
}

.light-mode {
background-color: var(--light-bg);
color: var(--light-text);
}

.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}

header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 0;
border-bottom: 1px solid var(--border-color);
margin-bottom: 30px;
}

.light-mode header {
border-bottom-color: var(--light-border);
}

.logo {
display: flex;
align-items: center;
}

.logo i {
font-size: 28px;
color: var(--primary-color);
margin-right: 10px;
}

.logo h1 {
font-size: 24px;
font-weight: 600;
}

.user-actions {
display: flex;
align-items: center;
gap: 15px;
}

.user-info {
display: flex;
align-items: center;
}

.user-info img {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
border: 2px solid var(--primary-color);
}

.dashboard {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-bottom: 30px;
}

.card {
background-color: var(--card-bg);
border-radius: 10px;
padding: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.light-mode .card {
background-color: white;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 1px solid var(--border-color);
}

.light-mode .card-header {
border-bottom-color: var(--light-border);
}

.card-header h2 {
font-size: 18px;
font-weight: 500;
}

.card-header i {
font-size: 20px;
color: var(--primary-color);
}

.stat {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}

.stat-value {
font-size: 24px;
font-weight: 700;
}

.stat-label {
color: #a0aec0;
font-size: 14px;
}

.light-mode .stat-label {
color: #7f8c8d;
}

.progress-bar {
height: 8px;
background-color: var(--border-color);
border-radius: 4px;
overflow: hidden;
margin: 10px 0;
}

.light-mode .progress-bar {
background-color: var(--light-border);
}

.progress {
height: 100%;
background-color: var(--primary-color);
border-radius: 4px;
}

.btn {
display: inline-block;
padding: 8px 16px;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-weight: 500;
transition: background-color 0.3s;
}

.btn:hover {
background-color: #2980b9;
}

.btn-danger {
background-color: var(--danger-color);
}

.btn-danger:hover {
background-color: #c0392b;
}

.btn-success {
background-color: var(--success-color);
}

.btn-success:hover {
background-color: #27ae60;
}

.btn-warning {
background-color: var(--warning-color);
}

.btn-warning:hover {
background-color: #e67e22;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}

th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid var(--border-color);
}

.light-mode th,
.light-mode td {
border-bottom-color: var(--light-border);
}

th {
color: #a0aec0;
font-weight: 500;
font-size: 14px;
}

.light-mode th {
color: #7f8c8d;
}

tr:hover {
background-color: rgba(255, 255, 255, 0.05);
}

.light-mode tr:hover {
background-color: rgba(0, 0, 0, 0.02);
}

.status {
display: inline-block;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: 500;
}

.status-active {
background-color: rgba(46, 204, 113, 0.2);
color: var(--success-color);
}

.status-inactive {
background-color: rgba(231, 76, 60, 0.2);
color: var(--danger-color);
}

.actions {
display: flex;
gap: 8px;
}

.icon-btn {
background: none;
border: none;
color: #a0aec0;
cursor: pointer;
font-size: 16px;
transition: color 0.3s;
}

.light-mode .icon-btn {
color: #7f8c8d;
}

.icon-btn:hover {
color: var(--text-color);
}

.light-mode .icon-btn:hover {
color: var(--light-text);
}

.config-box {
background-color: rgba(0, 0, 0, 0.2);
border-radius: 6px;
padding: 15px;
margin: 10px 0;
font-family: monospace;
font-size: 14px;
overflow-x: auto;
}

.light-mode .config-box {
background-color: rgba(0, 0, 0, 0.05);
}

.config-box code {
color: var(--text-color);
}

.light-mode .config-box code {
color: var(--light-text);
}

.copy-btn {
margin-top: 10px;
}

.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
z-index: 1000;
justify-content: center;
align-items: center;
}

.modal-content {
background-color: var(--card-bg);
border-radius: 10px;
padding: 25px;
width: 90%;
max-width: 500px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.light-mode .modal-content {
background-color: white;
}

.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid var(--border-color);
}

.light-mode .modal-header {
border-bottom-color: var(--light-border);
}

.modal-header h2 {
font-size: 20px;
}

.close-btn {
background: none;
border: none;
color: #a0aec0;
font-size: 24px;
cursor: pointer;
}

.form-group {
margin-bottom: 15px;
}

.form-group label {
display: block;
margin-bottom: 5px;
font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
width: 100%;
padding: 10px;
border: 1px solid var(--border-color);
border-radius: 4px;
background-color: rgba(0, 0, 0, 0.2);
color: var(--text-color);
}

.light-mode .form-group input,
.light-mode .form-group select,
.light-mode .form-group textarea {
background-color: white;
border-color: var(--light-border);
color: var(--light-text);
}

.form-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 20px;
}

.toast {
position: fixed;
bottom: 20px;
right: 20px;
padding: 15px 20px;
background-color: var(--success-color);
color: white;
border-radius: 4px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
opacity: 0;
transition: opacity 0.3s;
z-index: 1100;
}

.toast.show {
opacity: 1;
}

.toast.error {
background-color: var(--danger-color);
}

.view-section {
display: none;
}

.view-section.active {
display: block;
}

.nav-tabs {
display: flex;
border-bottom: 1px solid var(--border-color);
margin-bottom: 20px;
}

.light-mode .nav-tabs {
border-bottom-color: var(--light-border);
}

.nav-tab {
padding: 10px 20px;
cursor: pointer;
border-bottom: 2px solid transparent;
}

.nav-tab.active {
border-bottom-color: var(--primary-color);
color: var(--primary-color);
font-weight: 500;
}

.theme-switch {
margin-left: 15px;
cursor: pointer;
font-size: 20px;
}

.qrcode-container {
display: flex;
justify-content: center;
margin: 20px 0;
}

#qrcode {
padding: 10px;
background: white;
border-radius: 8px;
}

@media (max-width: 768px) {
.dashboard {
grid-template-columns: 1fr;
}

header {
flex-direction: column;
text-align: center;
gap: 15px;
}

.user-actions {
justify-content: center;
}

.nav-tabs {
overflow-x: auto;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<div class="logo">
<i class="fas fa-shield-alt"></i>
<h1>V2Ray代理用户管理系统</h1>
</div>
<div class="user-actions">
<div class="user-info" id="user-info">
<img src="https://ui-avatars.com/api/?name=User&background=3498db&color=fff" alt="用户头像">
<div>
<div id="user-name">未登录</div>
<div style="font-size: 12px; color: #a0aec0;" id="user-role">请登录或注册</div>
</div>
</div>
<button class="btn" id="login-btn">登录</button>
<button class="btn btn-success" id="register-btn">注册</button>
<button class="btn btn-warning" id="logout-btn" style="display: none;">退出</button>
<button class="btn" id="admin-btn" style="display: none;">管理后台</button>
<i class="fas fa-moon theme-switch" id="theme-switch"></i>
</div>
</header>

<div class="nav-tabs">
<div class="nav-tab active" data-view="dashboard">仪表盘</div>
<div class="nav-tab" data-view="subscription">订阅信息</div>
<div class="nav-tab" data-view="usage">使用情况</div>
<div class="nav-tab" data-view="settings">设置</div>
<div class="nav-tab" data-view="admin" style="display: none;" id="admin-tab">管理面板</div>
</div>

<!-- 用户仪表盘 -->
<div class="view-section active" id="dashboard-view">
<div class="dashboard">
<div class="card">
<div class="card-header">
<h2>账户状态</h2>
<i class="fas fa-user"></i>
</div>
<div class="stat">
<div class="stat-label">账户状态</div>
<div class="status status-active" id="account-status">活跃</div>
</div>
<div class="stat">
<div class="stat-label">账户等级</div>
<div class="stat-value" id="account-level">普通用户</div>
</div>
<div class="stat">
<div class="stat-label">注册日期</div>
<div class="stat-value" id="register-date">2023-10-01</div>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>流量统计</h2>
<i class="fas fa-chart-pie"></i>
</div>
<div class="stat">
<div class="stat-label">本月使用</div>
<div class="stat-value" id="data-usage">34.2/100 GB</div>
</div>
<div class="progress-bar">
<div class="progress" style="width: 34.2%"></div>
</div>
<div class="stat">
<div class="stat-label">上传</div>
<div class="stat-value" id="upload-usage">12.4 GB</div>
</div>
<div class="stat">
<div class="stat-label">下载</div>
<div class="stat-value" id="download-usage">21.8 GB</div>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>服务信息</h2>
<i class="fas fa-server"></i>
</div>
<div class="stat">
<div class="stat-label">到期时间</div>
<div class="stat-value" id="expiry-date">2023-12-31</div>
</div>
<div class="stat">
<div class="stat-label">连接设备</div>
<div class="stat-value" id="connected-devices">3/5 台</div>
</div>
<button class="btn" id="renew-btn">续费服务</button>
</div>
</div>
</div>

<!-- 订阅信息 -->
<div class="view-section" id="subscription-view">
<div class="dashboard">
<div class="card">
<div class="card-header">
<h2>订阅链接</h2>
<i class="fas fa-link"></i>
</div>
<div class="config-box">
<code id="subscribe-link">https://your-domain.com/subscribe?token=user-token-here</code>
</div>
<button class="btn copy-btn" id="copy-link-btn"><i class="fas fa-copy"></i> 复制链接</button>
<button class="btn btn-danger" id="reset-link-btn"><i class="fas fa-sync"></i> 重置链接</button>

<div class="qrcode-container">
<div id="qrcode"></div>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>客户端配置</h2>
<i class="fas fa-download"></i>
</div>
<p style="margin-bottom: 15px;">选择客户端下载配置文件:</p>
<div class="form-group">
<select id="client-select">
<option value="v2ray">V2Ray</option>
<option value="clash">Clash</option>
<option value="shadowrocket">Shadowrocket</option>
<option value="quantumult">Quantumult</option>
</select>
</div>
<button class="btn" id="download-config-btn"><i class="fas fa-download"></i> 下载配置</button>

<div style="margin-top: 20px;">
<p style="margin-bottom: 10px;">手动配置参数:</p>
<div class="config-box">
<code id="manual-config">
服务器地址: your-domain.com<br>
端口: 443<br>
用户ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx<br>
加密方式: auto<br>
传输协议: ws<br>
路径: /path
</code>
</div>
</div>
</div>
</div>
</div>

<!-- 使用情况 -->
<div class="view-section" id="usage-view">
<div class="card">
<div class="card-header">
<h2>流量使用历史</h2>
<i class="fas fa-history"></i>
</div>
<div style="height: 300px; width: 100%; background-color: rgba(0,0,0,0.1); border-radius: 8px; display: flex; justify-content: center; align-items: center;">
<p>流量图表将显示在这里</p>
</div>
</div>

<div class="card" style="margin-top: 20px;">
<div class="card-header">
<h2>连接日志</h2>
<i class="fas fa-list"></i>
</div>
<table>
<thead>
<tr>
<th>时间</th>
<th>设备</th>
<th>位置</th>
<th>持续时间</th>
<th>流量使用</th>
</tr>
</thead>
<tbody>
<tr>
<td>2023-10-15 14:30</td>
<td>Windows客户端</td>
<td>北京</td>
<td>2小时15分</td>
<td>1.2 GB</td>
</tr>
<tr>
<td>2023-10-15 10:15</td>
<td>Android手机</td>
<td>上海</td>
<td>45分钟</td>
<td>0.5 GB</td>
</tr>
<tr>
<td>2023-10-14 22:40</td>
<td>iPhone</td>
<td>广州</td>
<td>3小时20分</td>
<td>2.1 GB</td>
</tr>
</tbody>
</table>
</div>
</div>

<!-- 设置 -->
<div class="view-section" id="settings-view">
<div class="dashboard">
<div class="card">
<div class="card-header">
<h2>个人资料</h2>
<i class="fas fa-user-cog"></i>
</div>
<div class="form-group">
<label for="profile-username">用户名</label>
<input type="text" id="profile-username" value="current_user">
</div>
<div class="form-group">
<label for="profile-email">邮箱地址</label>
<input type="email" id="profile-email" value="user@example.com">
</div>
<div class="form-group">
<label for="profile-password">新密码</label>
<input type="password" id="profile-password" placeholder="留空则不修改">
</div>
<button class="btn" id="save-profile-btn">保存更改</button>
</div>

<div class="card">
<div class="card-header">
<h2>通知设置</h2>
<i class="fas fa-bell"></i>
</div>
<div class="form-group" style="display: flex; align-items: center; justify-content: space-between;">
<label for="notify-usage">流量使用提醒</label>
<input type="checkbox" id="notify-usage" checked style="width: auto;">
</div>
<div class="form-group" style="display: flex; align-items: center; justify-content: space-between;">
<label for="notify-expiry">服务到期提醒</label>
<input type="checkbox" id="notify-expiry" checked style="width: auto;">
</div>
<div class="form-group" style="display: flex; align-items: center; justify-content: space-between;">
<label for="notify-news">产品更新通知</label>
<input type="checkbox" id="notify-news" style="width: auto;">
</div>
<button class="btn" id="save-notify-btn">保存设置</button>
</div>
</div>
</div>

<!-- 管理员面板 -->
<div class="view-section" id="admin-view">
<div class="card">
<div class="card-header">
<h2>用户管理</h2>
<i class="fas fa-users"></i>
</div>
<div style="display: flex; justify-content: space-between; margin-bottom: 15px;">
<input type="text" placeholder="搜索用户..." style="padding: 8px; width: 250px; border-radius: 4px; border: 1px solid var(--border-color); background-color: rgba(0,0,0,0.2); color: var(--text-color);">
<button class="btn btn-success" id="admin-add-user"><i class="fas fa-plus"></i> 添加用户</button>
</div>
<table>
<thead>
<tr>
<th>用户名</th>
<th>邮箱</th>
<th>状态</th>
<th>流量使用</th>
<th>到期时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>user1</td>
<td>user1@example.com</td>
<td><span class="status status-active">活跃</span></td>
<td>4.2/20 GB</td>
<td>2023-12-31</td>
<td class="actions">
<button class="icon-btn"><i class="fas fa-edit"></i></button>
<button class="icon-btn"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td>user2</td>
<td>user2@example.com</td>
<td><span class="status status-active">活跃</span></td>
<td>7.8/50 GB</td>
<td>2023-11-15</td>
<td class="actions">
<button class="icon-btn"><i class="fas fa-edit"></i></button>
<button class="icon-btn"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td>user3</td>
<td>user3@example.com</td>
<td><span class="status status-inactive">离线</span></td>
<td>12.3/100 GB</td>
<td>2024-01-20</td>
<td class="actions">
<button class="icon-btn"><i class="fas fa-edit"></i></button>
<button class="icon-btn"><i class="fas fa-trash"></i></button>
</td>
</tr>
</tbody>
</table>
</div>

<div class="dashboard" style="margin-top: 20px;">
<div class="card">
<div class="card-header">
<h2>系统状态</h2>
<i class="fas fa-server"></i>
</div>
<div class="stat">
<div class="stat-label">运行状态</div>
<div class="status status-active">运行中</div>
</div>
<div class="stat">
<div class="stat-label">运行时间</div>
<div class="stat-value">12天</div>
</div>
<div class="stat">
<div class="stat-label">总用户数</div>
<div class="stat-value">25</div>
</div>
<div class="stat">
<div class="stat-label">活跃用户</div>
<div class="stat-value">18</div>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>系统设置</h2>
<i class="fas fa-cog"></i>
</div>
<button class="btn" style="margin-bottom: 10px; width: 100%;">服务器配置</button>
<button class="btn" style="margin-bottom: 10px; width: 100%;">订阅设置</button>
<button class="btn" style="margin-bottom: 10px; width: 100%;">邮件模板</button>
<button class="btn btn-danger" style="width: 100%;">重启服务</button>
</div>
</div>
</div>
</div>

<!-- 登录模态框 -->
<div class="modal" id="login-modal">
<div class="modal-content">
<div class="modal-header">
<h2>用户登录</h2>
<button class="close-btn">×</button>
</div>
<form id="login-form">
<div class="form-group">
<label for="login-username">用户名或邮箱</label>
<input type="text" id="login-username" required>
</div>
<div class="form-group">
<label for="login-password">密码</label>
<input type="password" id="login-password" required>
</div>
<div class="form-actions">
<button type="button" class="btn btn-danger" id="login-cancel-btn">取消</button>
<button type="submit" class="btn">登录</button>
</div>
</form>
</div>
</div>

<!-- 注册模态框 -->
<div class="modal" id="register-modal">
<div class="modal-content">
<div class="modal-header">
<h2>用户注册</h2>
<button class="close-btn">×</button>
</div>
<form id="register-form">
<div class="form-group">
<label for="register-username">用户名</label>
<input type="text" id="register-username" required>
</div>
<div class="form-group">
<label for="register-email">邮箱地址</label>
<input type="email" id="register-email" required>
</div>
<div class="form-group">
<label for="register-password">密码</label>
<input type="password" id="register-password" required>
</div>
<div class="form-group">
<label for="register-confirm-password">确认密码</label>
<input type="password" id="register-confirm-password" required>
</div>
<div class="form-actions">
<button type="button" class="btn btn-danger" id="register-cancel-btn">取消</button>
<button type="submit" class="btn btn-success">注册</button>
</div>
</form>
</div>
</div>

<!-- 消息提示 -->
<div class="toast" id="toast"></div>

<!-- 引入QRCode生成库 -->
<script src="https://cdn.jsdelivr.net/gh/davidshimjs/qrcodejs@gh-pages/qrcode.min.js"></script>

<script>
// 用户数据和状态管理
let currentUser = null;
let isAdmin = false;
let isDarkMode = true;

// DOM 元素
const themeSwitch = document.getElementById('theme-switch');
const userInfo = document.getElementById('user-info');
const userName = document.getElementById('user-name');
const userRole = document.getElementById('user-role');
const loginBtn = document.getElementById('login-btn');
const registerBtn = document.getElementById('register-btn');
const logoutBtn = document.getElementById('logout-btn');
const adminBtn = document.getElementById('admin-btn');
const adminTab = document.getElementById('admin-tab');
const loginModal = document.getElementById('login-modal');
const registerModal = document.getElementById('register-modal');
const closeBtns = document.querySelectorAll('.close-btn');
const loginCancelBtn = document.getElementById('login-cancel-btn');
const registerCancelBtn = document.getElementById('register-cancel-btn');
const loginForm = document.getElementById('login-form');
const registerForm = document.getElementById('register-form');
const toast = document.getElementById('toast');
const navTabs = document.querySelectorAll('.nav-tab');
const viewSections = document.querySelectorAll('.view-section');
const copyLinkBtn = document.getElementById('copy-link-btn');
const resetLinkBtn = document.getElementById('reset-link-btn');
const subscribeLink = document.getElementById('subscribe-link');
const qrcodeDiv = document.getElementById('qrcode');

// 初始化页面
function initPage() {
// 检查本地存储中的用户登录状态
const savedUser = localStorage.getItem('v2rayUser');
if (savedUser) {
currentUser = JSON.parse(savedUser);
updateUIAfterLogin();
}

// 初始化QR码
generateQRCode();

// 设置事件监听器
setupEventListeners();
}

// 设置事件监听器
function setupEventListeners() {
// 主题切换
themeSwitch.addEventListener('click', toggleTheme);

// 登录注册按钮
loginBtn.addEventListener('click', () => loginModal.style.display = 'flex');
registerBtn.addEventListener('click', () => registerModal.style.display = 'flex');
logoutBtn.addEventListener('click', logout);
adminBtn.addEventListener('click', () => switchView('admin'));

// 关闭模态框
closeBtns.forEach(btn => {
btn.addEventListener('click', () => {
loginModal.style.display = 'none';
registerModal.style.display = 'none';
});
});

loginCancelBtn.addEventListener('click', () => loginModal.style.display = 'none');
registerCancelBtn.addEventListener('click', () => registerModal.style.display = 'none');

// 表单提交
loginForm.addEventListener('submit', handleLogin);
registerForm.addEventListener('submit', handleRegister);

// 导航标签
navTabs.forEach(tab => {
tab.addEventListener('click', () => {
const view = tab.getAttribute('data-view');
switchView(view);
});
});

// 订阅相关按钮
copyLinkBtn.addEventListener('click', copySubscribeLink);
resetLinkBtn.addEventListener('click', resetSubscribeLink);
}

// 切换主题
function toggleTheme() {
isDarkMode = !isDarkMode;
if (isDarkMode) {
document.body.classList.remove('light-mode');
themeSwitch.classList.remove('fa-sun');
themeSwitch.classList.add('fa-moon');
} else {
document.body.classList.add('light-mode');
themeSwitch.classList.remove('fa-moon');
themeSwitch.classList.add('fa-sun');
}
}

// 处理登录
function handleLogin(e) {
e.preventDefault();
const username = document.getElementById('login-username').value;
const password = document.getElementById('login-password').value;

// 模拟登录验证
if (username && password) {
// 检查是否是管理员
if (username === 'admin' && password === 'admin123') {
currentUser = {
username: 'admin',
email: 'admin@example.com',
role: 'admin',
token: 'admin-token-' + Date.now()
};
isAdmin = true;
} else {
currentUser = {
username: username,
email: username + '@example.com',
role: 'user',
token: 'user-token-' + Date.now()
};
isAdmin = false;
}

// 保存到本地存储
localStorage.setItem('v2rayUser', JSON.stringify(currentUser));

// 更新UI
updateUIAfterLogin();

// 关闭模态框
loginModal.style.display = 'none';

// 显示成功消息
showToast('登录成功!');
} else {
showToast('请输入用户名和密码', true);
}
}

// 处理注册
function handleRegister(e) {
e.preventDefault();
const username = document.getElementById('register-username').value;
const email = document.getElementById('register-email').value;
const password = document.getElementById('register-password').value;
const confirmPassword = document.getElementById('register-confirm-password').value;

if (password !== confirmPassword) {
showToast('密码不匹配', true);
return;
}

// 模拟注册过程
currentUser = {
username: username,
email: email,
role: 'user',
token: 'user-token-' +

**时间**: `2025-09-16T19:53:23`

---

## 👤 **用户**

有为v2ray代理做得前端用户系统吗?

**时间**: `2025-09-16T19:23:11`

---


## 🤖 **DeepSeek (deepseek-chat)**


# V2Ray 用户管理系统设计

我将为您设计一个简洁美观的V2Ray前端用户系统界面。这个界面将包含用户管理、配置信息和流量统计等核心功能。

## 设计思路
- 采用深色主题,符合技术类产品的视觉风格
- 使用卡片式布局清晰展示不同功能模块
- 响应式设计确保在不同设备上良好显示
- 简洁直观的操作界面,降低用户学习成本

下面是完整的实现代码:

```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>V2Ray用户管理系统</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
:root {
--primary-color: #3498db;
--secondary-color: #2c3e50;
--accent-color: #1abc9c;
--danger-color: #e74c3c;
--warning-color: #f39c12;
--success-color: #2ecc71;
--dark-bg: #1a2332;
--card-bg: #243145;
--text-color: #ecf0f1;
--border-color: #34495e;
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
background-color: var(--dark-bg);
color: var(--text-color);
line-height: 1.6;
}

.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}

header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 0;
border-bottom: 1px solid var(--border-color);
margin-bottom: 30px;
}

.logo {
display: flex;
align-items: center;
}

.logo i {
font-size: 28px;
color: var(--primary-color);
margin-right: 10px;
}

.logo h1 {
font-size: 24px;
font-weight: 600;
}

.user-info {
display: flex;
align-items: center;
}

.user-info img {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
border: 2px solid var(--primary-color);
}

.dashboard {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-bottom: 30px;
}

.card {
background-color: var(--card-bg);
border-radius: 10px;
padding: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
font-size: 18px;
font-weight: 500;
}

.card-header i {
font-size: 20px;
color: var(--primary-color);
}

.stat {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}

.stat-value {
font-size: 24px;
font-weight: 700;
}

.stat-label {
color: #a0aec0;
font-size: 14px;
}

.progress-bar {
height: 8px;
background-color: var(--border-color);
border-radius: 4px;
overflow: hidden;
margin: 10px 0;
}

.progress {
height: 100%;
background-color: var(--primary-color);
border-radius: 4px;
}

.btn {
display: inline-block;
padding: 8px 16px;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-weight: 500;
transition: background-color 0.3s;
}

.btn:hover {
background-color: #2980b9;
}

.btn-danger {
background-color: var(--danger-color);
}

.btn-danger:hover {
background-color: #c0392b;
}

.btn-success {
background-color: var(--success-color);
}

.btn-success:hover {
background-color: #27ae60;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}

th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid var(--border-color);
}

th {
color: #a0aec0;
font-weight: 500;
font-size: 14px;
}

tr:hover {
background-color: rgba(255, 255, 255, 0.05);
}

.status {
display: inline-block;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: 500;
}

.status-active {
background-color: rgba(46, 204, 113, 0.2);
color: var(--success-color);
}

.status-inactive {
background-color: rgba(231, 76, 60, 0.2);
color: var(--danger-color);
}

.actions {
display: flex;
gap: 8px;
}

.icon-btn {
background: none;
border: none;
color: #a0aec0;
cursor: pointer;
font-size: 16px;
transition: color 0.3s;
}

.icon-btn:hover {
color: var(--text-color);
}

.config-box {
background-color: rgba(0, 0, 0, 0.2);
border-radius: 6px;
padding: 15px;
margin: 10px 0;
font-family: monospace;
font-size: 14px;
overflow-x: auto;
}

.config-box code {
color: var(--text-color);
}

.copy-btn {
margin-top: 10px;
}

@media (max-width: 768px) {
.dashboard {
grid-template-columns: 1fr;
}

header {
flex-direction: column;
text-align: center;
gap: 15px;
}

.user-info {
justify-content: center;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<div class="logo">
<i class="fas fa-shield-alt"></i>
<h1>V2Ray 用户管理系统</h1>
</div>
<div class="user-info">
<img src="https://ui-avatars.com/api/?name=Admin&background=3498db&color=fff" alt="用户头像">
<div>
<div>管理员</div>
<div style="font-size: 12px; color: #a0aec0;">上次登录: 今天 14:30</div>
</div>
</div>
</header>

<div class="dashboard">
<div class="card">
<div class="card-header">
<h2>系统状态</h2>
<i class="fas fa-server"></i>
</div>
<div class="stat">
<div class="stat-label">运行状态</div>
<div class="status status-active">运行中</div>
</div>
<div class="stat">
<div class="stat-label">运行时间</div>
<div class="stat-value">12天</div>
</div>
<div class="stat">
<div class="stat-label">版本</div>
<div class="stat-value">v4.45.2</div>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>流量统计</h2>
<i class="fas fa-chart-pie"></i>
</div>
<div class="stat">
<div class="stat-label">本月使用</div>
<div class="stat-value">34.2/100 GB</div>
</div>
<div class="progress-bar">
<div class="progress" style="width: 34.2%"></div>
</div>
<div class="stat">
<div class="stat-label">上传</div>
<div class="stat-value">12.4 GB</div>
</div>
<div class="stat">
<div class="stat-label">下载</div>
<div class="stat-value">21.8 GB</div>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>用户管理</h2>
<i class="fas fa-users"></i>
</div>
<div class="stat">
<div class="stat-label">总用户数</div>
<div class="stat-value">8</div>
</div>
<div class="stat">
<div class="stat-label">活跃用户</div>
<div class="stat-value">5</div>
</div>
<button class="btn btn-success"><i class="fas fa-plus"></i> 添加用户</button>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>用户列表</h2>
<i class="fas fa-list"></i>
</div>
<table>
<thead>
<tr>
<th>用户名</th>
<th>邮箱</th>
<th>状态</th>
<th>流量使用</th>
<th>到期时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>user_zhang</td>
<td>zhang@example.com</td>
<td><span class="status status-active">活跃</span></td>
<td>4.2/20 GB</td>
<td>2023-12-31</td>
<td class="actions">
<button class="icon-btn"><i class="fas fa-edit"></i></button>
<button class="icon-btn"><i class="fas fa-copy"></i></button>
<button class="icon-btn"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td>user_wang</td>
<td>wang@example.com</td>
<td><span class="status status-active">活跃</span></td>
<td>7.8/50 GB</td>
<td>2023-11-15</td>
<td class="actions">
<button class="icon-btn"><i class="fas fa-edit"></i></button>
<button class="icon-btn"><i class="fas fa-copy"></i></button>
<button class="icon-btn"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td>user_li</td>
<td>li@example.com</td>
<td><span class="status status-inactive">离线</span></td>
<td>12.3/100 GB</td>
<td>2024-01-20</td>
<td class="actions">
<button class="icon-btn"><i class="fas fa-edit"></i></button>
<button class="icon-btn"><i class="fas fa-copy"></i></button>
<button class="icon-btn"><i class="fas fa-trash"></i></button>
</td>
</tr>
<tr>
<td>user_zhao</td>
<td>zhao@example.com</td>
<td><span class="status status-active">活跃</span></td>
<td>0.5/10 GB</td>
<td>2023-10-05</td>
<td class="actions">
<button class="icon-btn"><i class="fas fa-edit"></i></button>
<button class="icon-btn"><i class="fas fa-copy"></i></button>
<button class="icon-btn"><i class="fas fa-trash"></i></button>
</td>
</tr>
</tbody>
</table>
</div>

<div class="dashboard">
<div class="card">
<div class="card-header">
<h2>配置信息</h2>
<i class="fas fa-cog"></i>
</div>
<div class="config-box">
<code>
{
"v": "2",
"ps": "V2Ray服务器",
"add": "v2ray.example.com",
"port": "443",
"id": "a0b1c2d3-e4f5-6789-abcd-ef0123456789",
"aid": "0",
"scy": "auto",
"net": "ws",
"type": "none",
"host": "",
"path": "/v2ray",
"tls": "tls",
"sni": ""
}
</code>
</div>
<button class="btn copy-btn"><i class="fas fa-copy"></i> 复制配置</button>
</div>

<div class="card">
<div class="card-header">
<h2>订阅链接</h2>
<i class="fas fa-link"></i>
</div>
<div class="config-box">
<code>https://v2ray.example.com/subscribe?token=abcd1234efgh5678</code>
</div>
<button class="btn copy-btn"><i class="fas fa-copy"></i> 复制链接</button>
<button class="btn btn-danger" style="margin-left: 10px;"><i class="fas fa-sync"></i> 重置链接</button>
</div>
</div>
</div>

<script>
// 简单的复制功能示例
document.querySelectorAll('.copy-btn').forEach(button => {
button.addEventListener('click', function() {
const configBox = this.previousElementSibling;
const textToCopy = configBox.querySelector('code').textContent;

navigator.clipboard.writeText(textToCopy.trim()).then(() => {
const originalText = this.innerHTML;
this.innerHTML = '<i class="fas fa-check"></i> 已复制';

setTimeout(() => {
this.innerHTML = originalText;
}, 2000);
}).catch(err => {
console.error('复制失败:', err);
});
});
});

// 模拟其他交互功能
document.querySelectorAll('.icon-btn').forEach(button => {
button.addEventListener('click', function() {
const icon = this.querySelector('i');
if (icon.classList.contains('fa-trash')) {
if (confirm('确定要删除这个用户吗?')) {
alert('用户已删除(模拟操作)');
}
} else if (icon.classList.contains('fa-edit')) {
alert('打开编辑界面(模拟操作)');
} else if (icon.classList.contains('fa-copy')) {
alert('用户配置已复制(模拟操作)');
}
});
});
</script>
</body>
</html>

功能说明

这个V2Ray用户管理系统界面包含以下核心功能:

  1. 系统状态监控 - 显示V2Ray服务运行状态、运行时间和版本信息
  2. 流量统计 - 直观展示流量使用情况和剩余量
  3. 用户管理 - 显示用户总数和活跃用户数,支持添加新用户
  4. 用户列表 - 展示所有用户的详细信息,支持编辑、复制配置和删除操作
  5. 配置信息 - 显示当前服务器的V2Ray配置信息
  6. 订阅链接 - 提供订阅链接管理和重置功能

界面采用了响应式设计,可以在各种屏幕尺寸上良好显示,并使用了符合技术产品风格的深色主题。

您可以直接复制上面的代码到HTML文件中,在浏览器中打开即可查看效果。

时间: 2025-09-16T19:23:11


👤 用户

你这个前端看起来很不错,就是如何与后端得代理服务器联系起来还有很多事情要做

时间: 2025-09-16T19:40:32


🤖 DeepSeek (deepseek-chat)

V2Ray代理前端用户系统 - 完整实现

您说得对,将前端与V2Ray后端连接起来需要更多的工作。我将设计一个更完整的系统,包含前后端交互的模拟实现。

下面是完整的代码,包含了模拟API交互、用户管理、配置生成等功能:

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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>V2Ray用户管理系统</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
:root {
--primary-color: #3498db;
--secondary-color: #2c3e50;
--accent-color: #1abc9c;
--danger-color: #e74c3c;
--warning-color: #f39c12;
--success-color: #2ecc71;
--dark-bg: #1a2332;
--card-bg: #243145;
--text-color: #ecf0f1;
--border-color: #34495e;
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
background-color: var(--dark-bg);
color: var(--text-color);
line-height: 1.6;
}

.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}

header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 0;
border-bottom: 1px solid var(--border-color);
margin-bottom: 30px;
}

.logo {
display: flex;
align-items: center;
}

.logo i {
font-size: 28px;
color: var(--primary-color);
margin-right: 10px;
}

.logo h1 {
font-size: 24px;
font-weight: 600;
}

.user-info {
display: flex;
align-items: center;
}

.user-info img {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 10px;
border: 2px solid var(--primary-color);
}

.dashboard {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-bottom: 30px;
}

.card {
background-color: var(--card-bg);
border-radius: 10px;
padding: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
font-size: 18px;
font-weight: 500;
}

.card-header i {
font-size: 20px;
color: var(--primary-color);
}

.stat {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}

.stat-value {
font-size: 24px;
font-weight: 700;
}

.stat-label {
color: #a0aec0;
font-size: 14px;
}

.progress-bar {
height: 8px;
background-color: var(--border-color);
border-radius: 4px;
overflow: hidden;
margin: 10px 0;
}

.progress {
height: 100%;
background-color: var(--primary-color);
border-radius: 4px;
}

.btn {
display: inline-block;
padding: 8px 16px;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-weight: 500;
transition: background-color 0.3s;
}

.btn:hover {
background-color: #2980b9;
}

.btn-danger {
background-color: var(--danger-color);
}

.btn-danger:hover {
background-color: #c0392b;
}

.btn-success {
background-color: var(--success-color);
}

.btn-success:hover {
background-color: #27ae60;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}

th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid var(--border-color);
}

th {
color: #a0aec0;
font-weight: 500;
font-size: 14px;
}

tr:hover {
background-color: rgba(255, 255, 255, 0.05);
}

.status {
display: inline-block;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
font-weight: 500;
}

.status-active {
background-color: rgba(46, 204, 113, 0.2);
color: var(--success-color);
}

.status-inactive {
background-color: rgba(231, 76, 60, 0.2);
color: var(--danger-color);
}

.actions {
display: flex;
gap: 8px;
}

.icon-btn {
background: none;
border: none;
color: #a0aec0;
cursor: pointer;
font-size: 16px;
transition: color 0.3s;
}

.icon-btn:hover {
color: var(--text-color);
}

.config-box {
background-color: rgba(0, 0, 0, 0.2);
border-radius: 6px;
padding: 15px;
margin: 10px 0;
font-family: monospace;
font-size: 14px;
overflow-x: auto;
}

.config-box code {
color: var(--text-color);
}

.copy-btn {
margin-top: 10px;
}

.modal {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
z-index: 1000;
justify-content: center;
align-items: center;
}

.modal-content {
background-color: var(--card-bg);
border-radius: 10px;
padding: 25px;
width: 90%;
max-width: 500px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
padding-bottom: 10px;
border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
font-size: 20px;
}

.close-btn {
background: none;
border: none;
color: #a0aec0;
font-size: 24px;
cursor: pointer;
}

.form-group {
margin-bottom: 15px;
}

.form-group label {
display: block;
margin-bottom: 5px;
font-weight: 500;
}

.form-group input,
.form-group select {
width: 100%;
padding: 10px;
border: 1px solid var(--border-color);
border-radius: 4px;
background-color: rgba(0, 0, 0, 0.2);
color: var(--text-color);
}

.form-actions {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 20px;
}

.toast {
position: fixed;
bottom: 20px;
right: 20px;
padding: 15px 20px;
background-color: var(--success-color);
color: white;
border-radius: 4px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
opacity: 0;
transition: opacity 0.3s;
}

.toast.show {
opacity: 1;
}

.toast.error {
background-color: var(--danger-color);
}

@media (max-width: 768px) {
.dashboard {
grid-template-columns: 1fr;
}

header {
flex-direction: column;
text-align: center;
gap: 15px;
}

.user-info {
justify-content: center;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<div class="logo">
<i class="fas fa-shield-alt"></i>
<h1>V2Ray 用户管理系统</h1>
</div>
<div class="user-info">
<img src="https://ui-avatars.com/api/?name=Admin&background=3498db&color=fff" alt="用户头像">
<div>
<div>管理员</div>
<div style="font-size: 12px; color: #a0aec0;">上次登录: 今天 14:30</div>
</div>
</div>
</header>

<div class="dashboard">
<div class="card">
<div class="card-header">
<h2>系统状态</h2>
<i class="fas fa-server"></i>
</div>
<div class="stat">
<div class="stat-label">运行状态</div>
<div class="status status-active">运行中</div>
</div>
<div class="stat">
<div class="stat-label">运行时间</div>
<div class="stat-value">12天</div>
</div>
<div class="stat">
<div class="stat-label">版本</div>
<div class="stat-value">v4.45.2</div>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>流量统计</h2>
<i class="fas fa-chart-pie"></i>
</div>
<div class="stat">
<div class="stat-label">本月使用</div>
<div class="stat-value">34.2/100 GB</div>
</div>
<div class="progress-bar">
<div class="progress" style="width: 34.2%"></div>
</div>
<div class="stat">
<div class="stat-label">上传</div>
<div class="stat-value">12.4 GB</div>
</div>
<div class="stat">
<div class="stat-label">下载</div>
<div class="stat-value">21.8 GB</div>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>用户管理</h2>
<i class="fas fa-users"></i>
</div>
<div class="stat">
<div class="stat-label">总用户数</div>
<div class="stat-value" id="total-users">8</div>
</div>
<div class="stat">
<div class="stat-label">活跃用户</div>
<div class="stat-value" id="active-users">5</div>
</div>
<button class="btn btn-success" id="add-user-btn"><i class="fas fa-plus"></i> 添加用户</button>
</div>
</div>

<div class="card">
<div class="card-header">
<h2>用户列表</h2>
<i class="fas fa-list"></i>
</div>
<table>
<thead>
<tr>
<th>用户名</th>
<th>邮箱</th>
<th>状态</th>
<th>流量使用</th>
<th>到期时间</th>
<th>操作</th>
</tr>
</thead>
<tbody id="users-table-body">
<!-- 用户数据将通过JavaScript动态生成 -->
</tbody>
</table>
</div>

<div class="dashboard">
<div class="card">
<div class="card-header">
<h2>配置信息</h2>
<i class="fas fa-cog"></i>
</div>
<div class="config-box">
<code id="config-content">
<!-- 配置内容将通过JavaScript生成 -->
</code>
</div>
<button class="btn copy-btn" id="copy-config-btn"><i class="fas fa-copy"></i> 复制配置</button>
</div>

<div class="card">
<div class="card-header">
<h2>订阅链接</h2>
<i class="fas fa-link"></i>
</div>
<div class="config-box">
<code id="subscribe-link">https://v2ray.example.com/subscribe?token=abcd1234efgh5678</code>
</div>
<button class="btn copy-btn" id="copy-link-btn"><i class="fas fa-copy"></i> 复制链接</button>
<button class="btn btn-danger" id="reset-link-btn"><i class="fas fa-sync"></i> 重置链接</button>
</div>
</div>
</div>

<!-- 添加用户模态框 -->
<div class="modal" id="add-user-modal">
<div class="modal-content">
<div class="modal-header">
<h2>添加新用户</h2>
<button class="close-btn" id="close-modal">×</button>
</div>
<form id="user-form">
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" required>
</div>
<div class="form-group">
<label for="email">邮箱</label>
<input type="email" id="email" required>
</div>
<div class="form-group">
<label for="data-limit">流量限制 (GB)</label>
<input type="number" id="data-limit" min="1" value="20" required>
</div>
<div class="form-group">
<label for="expiry-date">到期时间</label>
<input type="date" id="expiry-date" required>
</div>
<div class="form-actions">
<button type="button" class="btn btn-danger" id="cancel-btn">取消</button>
<button type="submit" class="btn btn-success">保存</button>
</div>
</form>
</div>
</div>

<!-- 消息提示 -->
<div class="toast" id="toast"></div>

<script>
// 模拟用户数据
let users = [
{ id: 1, username: 'user_zhang', email: 'zhang@example.com', status: 'active', dataUsed: 4.2, dataLimit: 20, expiry: '2023-12-31' },
{ id: 2, username: 'user_wang', email: 'wang@example.com', status: 'active', dataUsed: 7.8, dataLimit: 50, expiry: '2023-11-15' },
{ id: 3, username: 'user_li', email: 'li@example.com', status: 'inactive', dataUsed: 12.3, dataLimit: 100, expiry: '2024-01-20' },
{ id: 4, username: 'user_zhao', email: 'zhao@example.com', status: 'active', dataUsed: 0.5, dataLimit: 10, expiry: '2023-10-05' }
];

// DOM 元素
const usersTableBody = document.getElementById('users-table-body');
const totalUsersEl = document.getElementById('total-users');
const activeUsersEl = document.getElementById('active-users');
const addUserBtn = document.getElementById('add-user-btn');
const addUserModal = document.getElementById('add-user-modal');
const closeModalBtn = document.getElementById('close-modal');
const cancelBtn = document.getElementById('cancel-btn');
const userForm = document.getElementById('user-form');
const toast = document.getElementById('toast');
const configContent = document.getElementById('config-content');
const copyConfigBtn = document.getElementById('copy-config-btn');
const copyLinkBtn = document.getElementById('copy-link-btn');
const resetLinkBtn = document.getElementById('reset-link-btn');
const subscribeLink = document.getElementById('subscribe-link');

// 初始化页面
function initPage() {
renderUsersTable();
updateUserStats();
generateConfig();

// 设置默认到期时间为30天后
const defaultDate = new Date();
defaultDate.setDate(defaultDate.getDate() + 30);
document.getElementById('expiry-date').valueAsDate = defaultDate;
}

// 渲染用户表格
function renderUsersTable() {
usersTableBody.innerHTML = '';

users.forEach(user => {
const row = document.createElement('tr');

row.innerHTML = `
<td>${user.username}</td>
<td>${user.email}</td>
<td><span class="status status-${user.status}">${user.status === 'active' ? '活跃' : '离线'}</span></td>
<td>${user.dataUsed}/${user.dataLimit} GB</td>
<td>${user.expiry}</td>
<td class="actions">
<button class="icon-btn" data-action="edit" data-id="${user.id}"><i class="fas fa-edit"></i></button>
<button class="icon-btn" data-action="config" data-id="${user.id}"><i class="fas fa-copy"></i></button>
<button class="icon-btn" data-action="delete" data-id="${user.id}"><i class="fas fa-trash"></i></button>
</td>
`;

usersTableBody.appendChild(row);
});

// 添加事件监听器
document.querySelectorAll('.icon-btn').forEach(btn => {
btn.addEventListener('click', handleUserAction);
});
}

// 更新用户统计信息
function updateUserStats() {
totalUsersEl.textContent = users.length;
const activeUsers = users.filter(user => user.status === 'active').length;
activeUsersEl.textContent = activeUsers;
}

// 生成V2Ray配置
function generateConfig() {
const config = {
"v": "2",
"ps": "V2Ray服务器",
"add": "v2ray.example.com",
"port": "443",
"id": generateUUID(),
"aid": "0",
"scy": "auto",
"net": "ws",
"type": "none",
"host": "",
"path": "/v2ray",
"tls": "tls",
"sni": ""
};

configContent.textContent = JSON.stringify(config, null, 2);
}

// 生成UUID
function generateUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0;
const v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}

// 显示消息提示
function showToast(message, isError = false) {
toast.textContent = message;
toast.className = isError ? 'toast error show' : 'toast show';

setTimeout(() => {
toast.className = 'toast';
}, 3000);
}

// 处理用户操作
function handleUserAction(e) {
const action = e.currentTarget.getAttribute('data-action');
const userId = parseInt(e.currentTarget.getAttribute('data-id'));
const user = users.find(u => u.id === userId);

switch(action) {
case 'edit':
alert(`编辑用户: ${user.username} (模拟操作)`);
break;
case 'config':
navigator.clipboard.writeText(JSON.stringify({
username: user.username,
email: user.email,
uuid: generateUUID()
}, null, 2));
showToast('用户配置已复制到剪贴板');
break;
case 'delete':
if (confirm(`确定要删除用户 ${user.username} 吗?`)) {
users = users.filter(u => u.id !== userId);
renderUsersTable();
updateUserStats();
showToast('用户已删除');
}
break;
}
}

// 事件监听器
addUserBtn.addEventListener('click', () => {
addUserModal.style.display = 'flex';
});

closeModalBtn.addEventListener('click', () => {
addUserModal.style.display = 'none';
});

cancelBtn.addEventListener('click', () => {
addUserModal.style.display = 'none';
});

userForm.addEventListener('submit', (e) => {
e.preventDefault();

const newUser = {
id: users.length > 0 ? Math.max(...users.map(u => u.id)) + 1 : 1,
username: document.getElementById('username').value,
email: document.getElementById('email').value,
status: 'active',
dataUsed: 0,
dataLimit: parseInt(document.getElementById('data-limit').value),
expiry: document.getElementById('expiry-date').value
};

users.push(newUser);
renderUsersTable();
updateUserStats();
addUserModal.style.display = 'none';
userForm.reset();

// 设置默认到期时间为30天后
const defaultDate = new Date();
defaultDate.setDate(defaultDate.getDate() + 30);
document.getElementById('expiry-date').valueAsDate = defaultDate;

showToast('用户添加成功');
});

copyConfigBtn.addEventListener('click', () => {
navigator.clipboard.writeText(configContent.textContent).then(() => {
showToast('配置已复制到剪贴板');
}).catch(err => {
showToast('复制失败: ' + err, true);
});
});

copyLinkBtn.addEventListener('click', () => {
navigator.clipboard.writeText(subscribeLink.textContent).then(() => {
showToast('订阅链接已复制到剪贴板');
}).catch(err => {
showToast('复制失败: ' + err, true);
});
});

resetLinkBtn.addEventListener('click', () => {
if (confirm('确定要重置订阅链接吗?这将使当前链接失效。')) {
const newToken = generateUUID().substring(0, 16).replace(/-/g, '');
subscribeLink.textContent = `https://v2ray.example.com/subscribe?token=${newToken}`;
showToast('订阅链接已重置');
}
});

// 初始化页面
initPage();
</script>
</body>
</html>

实现功能说明

这个V2Ray用户管理系统现在包含以下增强功能:

  1. 完整的用户管理功能

    • 添加新用户(通过模态框表单)
    • 删除用户(带确认提示)
    • 编辑用户(模拟功能)
    • 复制用户配置
  2. 动态数据管理

    • 使用JavaScript对象存储用户数据
    • 实时更新用户统计信息
    • 动态生成表格内容
  3. 配置生成功能

    • 自动生成V2Ray配置信息
    • 生成唯一的UUID用于配置
  4. 订阅链接管理

    • 复制订阅链接
    • 重置订阅链接(生成新token)
  5. 用户反馈机制

    • 使用Toast消息提示操作结果
    • 确认对话框防止误操作

如何连接到真实后端

要将此前端连接到真实的V2Ray后端,您需要:

  1. 实现API调用替代当前的模拟数据操作
  2. 添加用户认证和授权机制
  3. 实现与V2Ray配置文件的实时同步
  4. 添加WebSocket连接以实现实时状态更新
  5. 实现用户流量统计的数据可视化

这个实现提供了一个完整的前端界面,可以作为开发真实V2Ray用户管理系统的基础。

时间: 2025-09-16T19:40:32


👤 用户

实在不知道怎么链接到真实的后端,我是通过下面这个脚本实现代理的。我的想法其实很简单,就是为每一个用户生成一个代理订阅地址,给用户一个后台系统,可以自己注册,登录,可以查看自己的信息,订阅地址等等。当然作为管理员,我可以对用户管理。

脚本说明:https://233boy.com/sing-box/sing-box-script/

时间: 2025-09-16T19:53:23


🤖 DeepSeek (deepseek-chat)

V2Ray代理用户管理系统 - 完整实现

我理解您的需求了。您想要一个用户自助系统,让用户可以注册、登录、查看订阅信息,同时您作为管理员可以管理用户。我将为您设计一个完整的解决方案。

下面是完整的HTML代码,包含了用户前端和管理员后台,以及如何与您的sing-box脚本集成的说明:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>V2Ray代理用户管理系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        :root {
            --primary-color: #3498db;
            --secondary-color: #2c3e50;
            --accent-color: #1abc9c;
            --danger-color: #e74c3c;
            --warning-color: #f39c12;
            --success-color: #2ecc71;
            --dark-bg: #1a2332;
            --card-bg: #243145;
            --text-color: #ecf0f1;
            --border-color: #34495e;
            --light-bg: #f5f7fa;
            --light-text: #2c3e50;
            --light-border: #ddd;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        
        body {
            background-color: var(--dark-bg);
            color: var(--text-color);
            line-height: 1.6;
        }
        
        .light-mode {
            background-color: var(--light-bg);
            color: var(--light-text);
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        
        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px 0;
            border-bottom: 1px solid var(--border-color);
            margin-bottom: 30px;
        }
        
        .light-mode header {
            border-bottom-color: var(--light-border);
        }
        
        .logo {
            display: flex;
            align-items: center;
        }
        
        .logo i {
            font-size: 28px;
            color: var(--primary-color);
            margin-right: 10px;
        }
        
        .logo h1 {
            font-size: 24px;
            font-weight: 600;
        }
        
        .user-actions {
            display: flex;
            align-items: center;
            gap: 15px;
        }
        
        .user-info {
            display: flex;
            align-items: center;
        }
        
        .user-info img {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            margin-right: 10px;
            border: 2px solid var(--primary-color);
        }
        
        .dashboard {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .card {
            background-color: var(--card-bg);
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        
        .light-mode .card {
            background-color: white;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        
        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 1px solid var(--border-color);
        }
        
        .light-mode .card-header {
            border-bottom-color: var(--light-border);
        }
        
        .card-header h2 {
            font-size: 18px;
            font-weight: 500;
        }
        
        .card-header i {
            font-size: 20px;
            color: var(--primary-color);
        }
        
        .stat {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 10px;
        }
        
        .stat-value {
            font-size: 24px;
            font-weight: 700;
        }
        
        .stat-label {
            color: #a0aec0;
            font-size: 14px;
        }
        
        .light-mode .stat-label {
            color: #7f8c8d;
        }
        
        .progress-bar {
            height: 8px;
            background-color: var(--border-color);
            border-radius: 4px;
            overflow: hidden;
            margin: 10px 0;
        }
        
        .light-mode .progress-bar {
            background-color: var(--light-border);
        }
        
        .progress {
            height: 100%;
            background-color: var(--primary-color);
            border-radius: 4px;
        }
        
        .btn {
            display: inline-block;
            padding: 8px 16px;
            background-color: var(--primary-color);
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-weight: 500;
            transition: background-color 0.3s;
        }
        
        .btn:hover {
            background-color: #2980b9;
        }
        
        .btn-danger {
            background-color: var(--danger-color);
        }
        
        .btn-danger:hover {
            background-color: #c0392b;
        }
        
        .btn-success {
            background-color: var(--success-color);
        }
        
        .btn-success:hover {
            background-color: #27ae60;
        }
        
        .btn-warning {
            background-color: var(--warning-color);
        }
        
        .btn-warning:hover {
            background-color: #e67e22;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 15px;
        }
        
        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid var(--border-color);
        }
        
        .light-mode th, 
        .light-mode td {
            border-bottom-color: var(--light-border);
        }
        
        th {
            color: #a0aec0;
            font-weight: 500;
            font-size: 14px;
        }
        
        .light-mode th {
            color: #7f8c8d;
        }
        
        tr:hover {
            background-color: rgba(255, 255, 255, 0.05);
        }
        
        .light-mode tr:hover {
            background-color: rgba(0, 0, 0, 0.02);
        }
        
        .status {
            display: inline-block;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
        }
        
        .status-active {
            background-color: rgba(46, 204, 113, 0.2);
            color: var(--success-color);
        }
        
        .status-inactive {
            background-color: rgba(231, 76, 60, 0.2);
            color: var(--danger-color);
        }
        
        .actions {
            display: flex;
            gap: 8px;
        }
        
        .icon-btn {
            background: none;
            border: none;
            color: #a0aec0;
            cursor: pointer;
            font-size: 16px;
            transition: color 0.3s;
        }
        
        .light-mode .icon-btn {
            color: #7f8c8d;
        }
        
        .icon-btn:hover {
            color: var(--text-color);
        }
        
        .light-mode .icon-btn:hover {
            color: var(--light-text);
        }
        
        .config-box {
            background-color: rgba(0, 0, 0, 0.2);
            border-radius: 6px;
            padding: 15px;
            margin: 10px 0;
            font-family: monospace;
            font-size: 14px;
            overflow-x: auto;
        }
        
        .light-mode .config-box {
            background-color: rgba(0, 0, 0, 0.05);
        }
        
        .config-box code {
            color: var(--text-color);
        }
        
        .light-mode .config-box code {
            color: var(--light-text);
        }
        
        .copy-btn {
            margin-top: 10px;
        }
        
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 1000;
            justify-content: center;
            align-items: center;
        }
        
        .modal-content {
            background-color: var(--card-bg);
            border-radius: 10px;
            padding: 25px;
            width: 90%;
            max-width: 500px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
        }
        
        .light-mode .modal-content {
            background-color: white;
        }
        
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid var(--border-color);
        }
        
        .light-mode .modal-header {
            border-bottom-color: var(--light-border);
        }
        
        .modal-header h2 {
            font-size: 20px;
        }
        
        .close-btn {
            background: none;
            border: none;
            color: #a0aec0;
            font-size: 24px;
            cursor: pointer;
        }
        
        .form-group {
            margin-bottom: 15px;
        }
        
        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: 500;
        }
        
        .form-group input,
        .form-group select,
        .form-group textarea {
            width: 100%;
            padding: 10px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            background-color: rgba(0, 0, 0, 0.2);
            color: var(--text-color);
        }
        
        .light-mode .form-group input,
        .light-mode .form-group select,
        .light-mode .form-group textarea {
            background-color: white;
            border-color: var(--light-border);
            color: var(--light-text);
        }
        
        .form-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 20px;
        }
        
        .toast {
            position: fixed;
            bottom: 20px;
            right: 20px;
            padding: 15px 20px;
            background-color: var(--success-color);
            color: white;
            border-radius: 4px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            opacity: 0;
            transition: opacity 0.3s;
            z-index: 1100;
        }
        
        .toast.show {
            opacity: 1;
        }
        
        .toast.error {
            background-color: var(--danger-color);
        }
        
        .view-section {
            display: none;
        }
        
        .view-section.active {
            display: block;
        }
        
        .nav-tabs {
            display: flex;
            border-bottom: 1px solid var(--border-color);
            margin-bottom: 20px;
        }
        
        .light-mode .nav-tabs {
            border-bottom-color: var(--light-border);
        }
        
        .nav-tab {
            padding: 10px 20px;
            cursor: pointer;
            border-bottom: 2px solid transparent;
        }
        
        .nav-tab.active {
            border-bottom-color: var(--primary-color);
            color: var(--primary-color);
            font-weight: 500;
        }
        
        .theme-switch {
            margin-left: 15px;
            cursor: pointer;
            font-size: 20px;
        }
        
        .qrcode-container {
            display: flex;
            justify-content: center;
            margin: 20px 0;
        }
        
        #qrcode {
            padding: 10px;
            background: white;
            border-radius: 8px;
        }
        
        @media (max-width: 768px) {
            .dashboard {
                grid-template-columns: 1fr;
            }
            
            header {
                flex-direction: column;
                text-align: center;
                gap: 15px;
            }
            
            .user-actions {
                justify-content: center;
            }
            
            .nav-tabs {
                overflow-x: auto;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <div class="logo">
                <i class="fas fa-shield-alt"></i>
                <h1>V2Ray代理用户管理系统</h1>
            </div>
            <div class="user-actions">
                <div class="user-info" id="user-info">
                    <img src="https://ui-avatars.com/api/?name=User&background=3498db&color=fff" alt="用户头像">
                    <div>
                        <div id="user-name">未登录</div>
                        <div style="font-size: 12px; color: #a0aec0;" id="user-role">请登录或注册</div>
                    </div>
                </div>
                <button class="btn" id="login-btn">登录</button>
                <button class="btn btn-success" id="register-btn">注册</button>
                <button class="btn btn-warning" id="logout-btn" style="display: none;">退出</button>
                <button class="btn" id="admin-btn" style="display: none;">管理后台</button>
                <i class="fas fa-moon theme-switch" id="theme-switch"></i>
            </div>
        </header>
        
        <div class="nav-tabs">
            <div class="nav-tab active" data-view="dashboard">仪表盘</div>
            <div class="nav-tab" data-view="subscription">订阅信息</div>
            <div class="nav-tab" data-view="usage">使用情况</div>
            <div class="nav-tab" data-view="settings">设置</div>
            <div class="nav-tab" data-view="admin" style="display: none;" id="admin-tab">管理面板</div>
        </div>
        
        <!-- 用户仪表盘 -->
        <div class="view-section active" id="dashboard-view">
            <div class="dashboard">
                <div class="card">
                    <div class="card-header">
                        <h2>账户状态</h2>
                        <i class="fas fa-user"></i>
                    </div>
                    <div class="stat">
                        <div class="stat-label">账户状态</div>
                        <div class="status status-active" id="account-status">活跃</div>
                    </div>
                    <div class="stat">
                        <div class="stat-label">账户等级</div>
                        <div class="stat-value" id="account-level">普通用户</div>
                    </div>
                    <div class="stat">
                        <div class="stat-label">注册日期</div>
                        <div class="stat-value" id="register-date">2023-10-01</div>
                    </div>
                </div>
                
                <div class="card">
                    <div class="card-header">
                        <h2>流量统计</h2>
                        <i class="fas fa-chart-pie"></i>
                    </div>
                    <div class="stat">
                        <div class="stat-label">本月使用</div>
                        <div class="stat-value" id="data-usage">34.2/100 GB</div>
                    </div>
                    <div class="progress-bar">
                        <div class="progress" style="width: 34.2%"></div>
                    </div>
                    <div class="stat">
                        <div class="stat-label">上传</div>
                        <div class="stat-value" id="upload-usage">12.4 GB</div>
                    </div>
                    <div class="stat">
                        <div class="stat-label">下载</div>
                        <div class="stat-value" id="download-usage">21.8 GB</div>
                    </div>
                </div>
                
                <div class="card">
                    <div class="card-header">
                        <h2>服务信息</h2>
                        <i class="fas fa-server"></i>
                    </div>
                    <div class="stat">
                        <div class="stat-label">到期时间</div>
                        <div class="stat-value" id="expiry-date">2023-12-31</div>
                    </div>
                    <div class="stat">
                        <div class="stat-label">连接设备</div>
                        <div class="stat-value" id="connected-devices">3/5 台</div>
                    </div>
                    <button class="btn" id="renew-btn">续费服务</button>
                </div>
            </div>
        </div>
        
        <!-- 订阅信息 -->
        <div class="view-section" id="subscription-view">
            <div class="dashboard">
                <div class="card">
                    <div class="card-header">
                        <h2>订阅链接</h2>
                        <i class="fas fa-link"></i>
                    </div>
                    <div class="config-box">
                        <code id="subscribe-link">https://your-domain.com/subscribe?token=user-token-here</code>
                    </div>
                    <button class="btn copy-btn" id="copy-link-btn"><i class="fas fa-copy"></i> 复制链接</button>
                    <button class="btn btn-danger" id="reset-link-btn"><i class="fas fa-sync"></i> 重置链接</button>
                    
                    <div class="qrcode-container">
                        <div id="qrcode"></div>
                    </div>
                </div>
                
                <div class="card">
                    <div class="card-header">
                        <h2>客户端配置</h2>
                        <i class="fas fa-download"></i>
                    </div>
                    <p style="margin-bottom: 15px;">选择客户端下载配置文件:</p>
                    <div class="form-group">
                        <select id="client-select">
                            <option value="v2ray">V2Ray</option>
                            <option value="clash">Clash</option>
                            <option value="shadowrocket">Shadowrocket</option>
                            <option value="quantumult">Quantumult</option>
                        </select>
                    </div>
                    <button class="btn" id="download-config-btn"><i class="fas fa-download"></i> 下载配置</button>
                    
                    <div style="margin-top: 20px;">
                        <p style="margin-bottom: 10px;">手动配置参数:</p>
                        <div class="config-box">
                            <code id="manual-config">
服务器地址: your-domain.com<br>
端口: 443<br>
用户ID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx<br>
加密方式: auto<br>
传输协议: ws<br>
路径: /path
                            </code>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 使用情况 -->
        <div class="view-section" id="usage-view">
            <div class="card">
                <div class="card-header">
                    <h2>流量使用历史</h2>
                    <i class="fas fa-history"></i>
                </div>
                <div style="height: 300px; width: 100%; background-color: rgba(0,0,0,0.1); border-radius: 8px; display: flex; justify-content: center; align-items: center;">
                    <p>流量图表将显示在这里</p>
                </div>
            </div>
            
            <div class="card" style="margin-top: 20px;">
                <div class="card-header">
                    <h2>连接日志</h2>
                    <i class="fas fa-list"></i>
                </div>
                <table>
                    <thead>
                        <tr>
                            <th>时间</th>
                            <th>设备</th>
                            <th>位置</th>
                            <th>持续时间</th>
                            <th>流量使用</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>2023-10-15 14:30</td>
                            <td>Windows客户端</td>
                            <td>北京</td>
                            <td>2小时15分</td>
                            <td>1.2 GB</td>
                        </tr>
                        <tr>
                            <td>2023-10-15 10:15</td>
                            <td>Android手机</td>
                            <td>上海</td>
                            <td>45分钟</td>
                            <td>0.5 GB</td>
                        </tr>
                        <tr>
                            <td>2023-10-14 22:40</td>
                            <td>iPhone</td>
                            <td>广州</td>
                            <td>3小时20分</td>
                            <td>2.1 GB</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        
        <!-- 设置 -->
        <div class="view-section" id="settings-view">
            <div class="dashboard">
                <div class="card">
                    <div class="card-header">
                        <h2>个人资料</h2>
                        <i class="fas fa-user-cog"></i>
                    </div>
                    <div class="form-group">
                        <label for="profile-username">用户名</label>
                        <input type="text" id="profile-username" value="current_user">
                    </div>
                    <div class="form-group">
                        <label for="profile-email">邮箱地址</label>
                        <input type="email" id="profile-email" value="user@example.com">
                    </div>
                    <div class="form-group">
                        <label for="profile-password">新密码</label>
                        <input type="password" id="profile-password" placeholder="留空则不修改">
                    </div>
                    <button class="btn" id="save-profile-btn">保存更改</button>
                </div>
                
                <div class="card">
                    <div class="card-header">
                        <h2>通知设置</h2>
                        <i class="fas fa-bell"></i>
                    </div>
                    <div class="form-group" style="display: flex; align-items: center; justify-content: space-between;">
                        <label for="notify-usage">流量使用提醒</label>
                        <input type="checkbox" id="notify-usage" checked style="width: auto;">
                    </div>
                    <div class="form-group" style="display: flex; align-items: center; justify-content: space-between;">
                        <label for="notify-expiry">服务到期提醒</label>
                        <input type="checkbox" id="notify-expiry" checked style="width: auto;">
                    </div>
                    <div class="form-group" style="display: flex; align-items: center; justify-content: space-between;">
                        <label for="notify-news">产品更新通知</label>
                        <input type="checkbox" id="notify-news" style="width: auto;">
                    </div>
                    <button class="btn" id="save-notify-btn">保存设置</button>
                </div>
            </div>
        </div>
        
        <!-- 管理员面板 -->
        <div class="view-section" id="admin-view">
            <div class="card">
                <div class="card-header">
                    <h2>用户管理</h2>
                    <i class="fas fa-users"></i>
                </div>
                <div style="display: flex; justify-content: space-between; margin-bottom: 15px;">
                    <input type="text" placeholder="搜索用户..." style="padding: 8px; width: 250px; border-radius: 4px; border: 1px solid var(--border-color); background-color: rgba(0,0,0,0.2); color: var(--text-color);">
                    <button class="btn btn-success" id="admin-add-user"><i class="fas fa-plus"></i> 添加用户</button>
                </div>
                <table>
                    <thead>
                        <tr>
                            <th>用户名</th>
                            <th>邮箱</th>
                            <th>状态</th>
                            <th>流量使用</th>
                            <th>到期时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>user1</td>
                            <td>user1@example.com</td>
                            <td><span class="status status-active">活跃</span></td>
                            <td>4.2/20 GB</td>
                            <td>2023-12-31</td>
                            <td class="actions">
                                <button class="icon-btn"><i class="fas fa-edit"></i></button>
                                <button class="icon-btn"><i class="fas fa-trash"></i></button>
                            </td>
                        </tr>
                        <tr>
                            <td>user2</td>
                            <td>user2@example.com</td>
                            <td><span class="status status-active">活跃</span></td>
                            <td>7.8/50 GB</td>
                            <td>2023-11-15</td>
                            <td class="actions">
                                <button class="icon-btn"><i class="fas fa-edit"></i></button>
                                <button class="icon-btn"><i class="fas fa-trash"></i></button>
                            </td>
                        </tr>
                        <tr>
                            <td>user3</td>
                            <td>user3@example.com</td>
                            <td><span class="status status-inactive">离线</span></td>
                            <td>12.3/100 GB</td>
                            <td>2024-01-20</td>
                            <td class="actions">
                                <button class="icon-btn"><i class="fas fa-edit"></i></button>
                                <button class="icon-btn"><i class="fas fa-trash"></i></button>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <div class="dashboard" style="margin-top: 20px;">
                <div class="card">
                    <div class="card-header">
                        <h2>系统状态</h2>
                        <i class="fas fa-server"></i>
                    </div>
                    <div class="stat">
                        <div class="stat-label">运行状态</div>
                        <div class="status status-active">运行中</div>
                    </div>
                    <div class="stat">
                        <div class="stat-label">运行时间</div>
                        <div class="stat-value">12天</div>
                    </div>
                    <div class="stat">
                        <div class="stat-label">总用户数</div>
                        <div class="stat-value">25</div>
                    </div>
                    <div class="stat">
                        <div class="stat-label">活跃用户</div>
                        <div class="stat-value">18</div>
                    </div>
                </div>
                
                <div class="card">
                    <div class="card-header">
                        <h2>系统设置</h2>
                        <i class="fas fa-cog"></i>
                    </div>
                    <button class="btn" style="margin-bottom: 10px; width: 100%;">服务器配置</button>
                    <button class="btn" style="margin-bottom: 10px; width: 100%;">订阅设置</button>
                    <button class="btn" style="margin-bottom: 10px; width: 100%;">邮件模板</button>
                    <button class="btn btn-danger" style="width: 100%;">重启服务</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 登录模态框 -->
    <div class="modal" id="login-modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2>用户登录</h2>
                <button class="close-btn">×</button>
            </div>
            <form id="login-form">
                <div class="form-group">
                    <label for="login-username">用户名或邮箱</label>
                    <input type="text" id="login-username" required>
                </div>
                <div class="form-group">
                    <label for="login-password">密码</label>
                    <input type="password" id="login-password" required>
                </div>
                <div class="form-actions">
                    <button type="button" class="btn btn-danger" id="login-cancel-btn">取消</button>
                    <button type="submit" class="btn">登录</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 注册模态框 -->
    <div class="modal" id="register-modal">
        <div class="modal-content">
            <div class="modal-header">
                <h2>用户注册</h2>
                <button class="close-btn">×</button>
            </div>
            <form id="register-form">
                <div class="form-group">
                    <label for="register-username">用户名</label>
                    <input type="text" id="register-username" required>
                </div>
                <div class="form-group">
                    <label for="register-email">邮箱地址</label>
                    <input type="email" id="register-email" required>
                </div>
                <div class="form-group">
                    <label for="register-password">密码</label>
                    <input type="password" id="register-password" required>
                </div>
                <div class="form-group">
                    <label for="register-confirm-password">确认密码</label>
                    <input type="password" id="register-confirm-password" required>
                </div>
                <div class="form-actions">
                    <button type="button" class="btn btn-danger" id="register-cancel-btn">取消</button>
                    <button type="submit" class="btn btn-success">注册</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 消息提示 -->
    <div class="toast" id="toast"></div>

    <!-- 引入QRCode生成库 -->
    <script src="https://cdn.jsdelivr.net/gh/davidshimjs/qrcodejs@gh-pages/qrcode.min.js"></script>

    <script>
        // 用户数据和状态管理
        let currentUser = null;
        let isAdmin = false;
        let isDarkMode = true;
        
        // DOM 元素
        const themeSwitch = document.getElementById('theme-switch');
        const userInfo = document.getElementById('user-info');
        const userName = document.getElementById('user-name');
        const userRole = document.getElementById('user-role');
        const loginBtn = document.getElementById('login-btn');
        const registerBtn = document.getElementById('register-btn');
        const logoutBtn = document.getElementById('logout-btn');
        const adminBtn = document.getElementById('admin-btn');
        const adminTab = document.getElementById('admin-tab');
        const loginModal = document.getElementById('login-modal');
        const registerModal = document.getElementById('register-modal');
        const closeBtns = document.querySelectorAll('.close-btn');
        const loginCancelBtn = document.getElementById('login-cancel-btn');
        const registerCancelBtn = document.getElementById('register-cancel-btn');
        const loginForm = document.getElementById('login-form');
        const registerForm = document.getElementById('register-form');
        const toast = document.getElementById('toast');
        const navTabs = document.querySelectorAll('.nav-tab');
        const viewSections = document.querySelectorAll('.view-section');
        const copyLinkBtn = document.getElementById('copy-link-btn');
        const resetLinkBtn = document.getElementById('reset-link-btn');
        const subscribeLink = document.getElementById('subscribe-link');
        const qrcodeDiv = document.getElementById('qrcode');
        
        // 初始化页面
        function initPage() {
            // 检查本地存储中的用户登录状态
            const savedUser = localStorage.getItem('v2rayUser');
            if (savedUser) {
                currentUser = JSON.parse(savedUser);
                updateUIAfterLogin();
            }
            
            // 初始化QR码
            generateQRCode();
            
            // 设置事件监听器
            setupEventListeners();
        }
        
        // 设置事件监听器
        function setupEventListeners() {
            // 主题切换
            themeSwitch.addEventListener('click', toggleTheme);
            
            // 登录注册按钮
            loginBtn.addEventListener('click', () => loginModal.style.display = 'flex');
            registerBtn.addEventListener('click', () => registerModal.style.display = 'flex');
            logoutBtn.addEventListener('click', logout);
            adminBtn.addEventListener('click', () => switchView('admin'));
            
            // 关闭模态框
            closeBtns.forEach(btn => {
                btn.addEventListener('click', () => {
                    loginModal.style.display = 'none';
                    registerModal.style.display = 'none';
                });
            });
            
            loginCancelBtn.addEventListener('click', () => loginModal.style.display = 'none');
            registerCancelBtn.addEventListener('click', () => registerModal.style.display = 'none');
            
            // 表单提交
            loginForm.addEventListener('submit', handleLogin);
            registerForm.addEventListener('submit', handleRegister);
            
            // 导航标签
            navTabs.forEach(tab => {
                tab.addEventListener('click', () => {
                    const view = tab.getAttribute('data-view');
                    switchView(view);
                });
            });
            
            // 订阅相关按钮
            copyLinkBtn.addEventListener('click', copySubscribeLink);
            resetLinkBtn.addEventListener('click', resetSubscribeLink);
        }
        
        // 切换主题
        function toggleTheme() {
            isDarkMode = !isDarkMode;
            if (isDarkMode) {
                document.body.classList.remove('light-mode');
                themeSwitch.classList.remove('fa-sun');
                themeSwitch.classList.add('fa-moon');
            } else {
                document.body.classList.add('light-mode');
                themeSwitch.classList.remove('fa-moon');
                themeSwitch.classList.add('fa-sun');
            }
        }
        
        // 处理登录
        function handleLogin(e) {
            e.preventDefault();
            const username = document.getElementById('login-username').value;
            const password = document.getElementById('login-password').value;
            
            // 模拟登录验证
            if (username && password) {
                // 检查是否是管理员
                if (username === 'admin' && password === 'admin123') {
                    currentUser = {
                        username: 'admin',
                        email: 'admin@example.com',
                        role: 'admin',
                        token: 'admin-token-' + Date.now()
                    };
                    isAdmin = true;
                } else {
                    currentUser = {
                        username: username,
                        email: username + '@example.com',
                        role: 'user',
                        token: 'user-token-' + Date.now()
                    };
                    isAdmin = false;
                }
                
                // 保存到本地存储
                localStorage.setItem('v2rayUser', JSON.stringify(currentUser));
                
                // 更新UI
                updateUIAfterLogin();
                
                // 关闭模态框
                loginModal.style.display = 'none';
                
                // 显示成功消息
                showToast('登录成功!');
            } else {
                showToast('请输入用户名和密码', true);
            }
        }
        
        // 处理注册
        function handleRegister(e) {
            e.preventDefault();
            const username = document.getElementById('register-username').value;
            const email = document.getElementById('register-email').value;
            const password = document.getElementById('register-password').value;
            const confirmPassword = document.getElementById('register-confirm-password').value;
            
            if (password !== confirmPassword) {
                showToast('密码不匹配', true);
                return;
            }
            
            // 模拟注册过程
            currentUser = {
                username: username,
                email: email,
                role: 'user',
                token: 'user-token-' +

**时间**: `2025-09-16T19:53:23`

---



---

## 对话统计

- **消息总数**: 6 条
- **处理状态**: 成功转换