File size: 61,281 Bytes
f9cbb48 87af27f f9cbb48 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 |
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JetBrains激活链接管理系统</title>
<!-- 使用CDN引入Vue 3和Element Plus,指定固定版本 -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/index.css" />
<script src="https://unpkg.com/[email protected]/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/[email protected]"></script>
<script src="https://unpkg.com/@element-plus/[email protected]"></script>
<script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: #f5f7fa;
color: #303133;
}
.app-container {
padding: 8px;
}
.dashboard-card {
margin-bottom: 20px;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
background-color: #fff;
}
.dashboard-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 20px;
border-bottom: 1px solid #ebeef5;
}
.el-table .status-column {
display: flex;
align-items: center;
justify-content: center;
}
.el-table .status-0 {
color: #909399;
}
.el-table .status-1 {
color: #409EFF;
}
.el-table .status-2 {
color: #F56C6C;
}
.el-table .status-3 {
color: #67C23A;
}
.operation-btn {
margin-right: 5px;
}
.statistics-card {
text-align: center;
padding: 20px;
}
.statistics-value {
font-size: 36px;
font-weight: bold;
}
.statistics-label {
font-size: 14px;
color: #909399;
}
.task-card {
margin-bottom: 15px;
}
.copy-button {
margin-left: 5px;
}
.el-tag {
margin: 2px;
}
.tab-container {
padding: 15px;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
.required-field::after {
content: ' *';
color: #F56C6C;
}
.el-table .id-column,
.el-table .register-time-column,
.el-table .username-column,
.el-table .email-column {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.el-table .email-column {
max-width: 250px;
}
/* 调试样式 - 显示表格边框和背景色 */
.el-table {
border: 1px solid #dcdfe6;
}
.el-table th {
background-color: #f5f7fa !important;
color: #606266;
font-weight: bold;
text-align: center !important;
}
.el-table td {
text-align: center;
}
/* 确保ID列和时间列有足够的宽度 */
.el-table .id-column {
min-width: 80px !important;
width: 80px !important;
}
.el-table .register-time-column {
min-width: 180px !important;
width: 180px !important;
}
.el-table .username-column {
min-width: 250px !important;
}
.el-table .email-column {
min-width: 180px !important;
}
/* 必填字段标记 */
.required::after {
content: '*';
color: #F56C6C;
margin-left: 4px;
}
@media (max-width: 900px) {
.app-container {
padding: 2px !important;
}
.dashboard-card {
margin-bottom: 8px;
padding: 0 2px;
}
.statistics-card {
border-radius: 10px;
box-shadow: 0 2px 8px #eee;
padding: 10px 0;
text-align: center !important;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.statistics-value {
font-size: 28px;
text-align: center !important;
width: 100%;
margin: 0 auto;
}
.statistics-label {
font-size: 16px;
text-align: center !important;
width: 100%;
margin: 0 auto;
}
.tab-container {
padding: 4px;
}
.el-row.filter-row {
margin: 0 -2px;
}
.el-col.filter-col {
margin-bottom: 4px;
padding: 0 2px;
}
.el-table {
border-radius: 6px;
box-shadow: 0 1px 4px #eee;
font-size: 15px;
}
.el-table th, .el-table td {
padding-left: 2px;
padding-right: 2px;
}
.el-pagination {
font-size: 15px;
}
}
</style>
</head>
<body>
<!--- /> 标签改为标准的成对闭合形式,否则显示将不正常-->
<div id="app" class="app-container">
<el-container>
<el-header style="height: auto; padding: 0; margin-bottom: 20px;">
<div class="dashboard-card">
<div class="dashboard-header">
<h2>JetBrains激活链接管理系统</h2>
<div>
<el-button type="primary" @click="showImportDialog">导入数据</el-button>
<el-button type="success" @click="showExportDialog">导出数据</el-button>
<el-button type="danger" @click="resetFailedAccounts">重置失败账号</el-button>
<el-button type="warning" @click="logout" style="margin-left: 10px;">退出登录</el-button>
</div>
</div>
</div>
</el-header>
<el-main>
<!-- 统计信息卡片 /> 标签改为标准的成对闭合形式,否则显示将不正常 -->
<el-row :gutter="20">
<el-col :span="4">
<el-card shadow="hover" class="statistics-card">
<div class="statistics-value">{{ statistics.total }}</div>
<div class="statistics-label">总数</div>
</el-card>
</el-col>
<!-- <el-col :span="5">
<el-card shadow="hover" class="statistics-card" style="background-color: #f0f9eb;">
<div class="statistics-value" style="color: #67C23A;">{{ statistics.link_extracted }}</div>
<div class="statistics-label">链接</div>
</el-card>
</el-col> -->
<el-col :span="5">
<el-card shadow="hover" class="statistics-card" style="background-color: #f9f9e3;">
<div class="statistics-value" style="color: #e6a23c;">{{ statistics.unused }}</div>
<div class="statistics-label">未用</div>
</el-card>
</el-col>
<el-col :span="5">
<el-card shadow="hover" class="statistics-card" style="background-color: #ecf5ff;">
<div class="statistics-value" style="color: #409EFF;">{{ statistics.submitted }}</div>
<div class="statistics-label">提交</div>
</el-card>
</el-col>
<el-col :span="5">
<el-card shadow="hover" class="statistics-card" style="background-color: #fef0f0;">
<div class="statistics-value" style="color: #F56C6C;">{{ statistics.failed }}</div>
<div class="statistics-label">失败</div>
</el-card>
</el-col>
<el-col :span="5">
<el-card shadow="hover" class="statistics-card" style="background-color: #f4f4f5;">
<div class="statistics-value" style="color: #909399;">{{ statistics.pending }}</div>
<div class="statistics-label">未取</div>
</el-card>
</el-col>
</el-row>
<!-- 主要标签页 -->
<el-tabs type="border-card" v-model="activeTab" @tab-click="handleTabClick">
<!-- 账号管理标签页 -->
<el-tab-pane label="账号管理" name="accounts">
<div class="tab-container">
<div style="margin-bottom: 20px;">
<el-row :gutter="10" class="filter-row" style="flex-wrap: nowrap; display: flex;">
<el-col :span="3" class="filter-col" style="min-width: 120px;">
<el-select v-model="accountsFilter.status" placeholder="选择状态" clearable style="width: 100%;" @change="handleStatusChange">
<el-option label="未提交" :value="0"></el-option>
<el-option label="已提交" :value="1"></el-option>
<el-option label="提交失败" :value="2"></el-option>
<el-option label="已提取链接" :value="3"></el-option>
</el-select>
</el-col>
<el-col :span="3" class="filter-col" style="min-width: 140px;">
<el-date-picker v-model="accountsFilter.registerTimeStart" type="date" placeholder="注册起始日期" style="width: 100%;" format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable></el-date-picker>
</el-col>
<el-col :span="3" class="filter-col" style="min-width: 140px;">
<el-date-picker v-model="accountsFilter.registerTimeEnd" type="date" placeholder="注册结束日期" style="width: 100%;" format="YYYY-MM-DD" value-format="YYYY-MM-DD" clearable></el-date-picker>
</el-col>
<el-col :span="2" class="filter-col" style="min-width: 90px;">
<el-input v-model="accountsFilter.idMin" placeholder="最小ID" clearable></el-input>
</el-col>
<el-col :span="2" class="filter-col" style="min-width: 90px;">
<el-input v-model="accountsFilter.idMax" placeholder="最大ID" clearable></el-input>
</el-col>
<el-col :span="3" class="filter-col" style="min-width: 120px;">
<el-select v-model="accountsFilter.hasActivationLink" placeholder="激活链接" clearable style="width: 100%;">
<el-option label="全部" value=""></el-option>
<el-option label="有激活链接" value="yes"></el-option>
<el-option label="无激活链接" value="no"></el-option>
</el-select>
</el-col>
<el-col :span="3" class="filter-col" style="min-width: 120px;">
<el-select v-model="accountsFilter.used" placeholder="使用状态" clearable style="width: 100%;">
<el-option label="全部" :value="''"></el-option>
<el-option label="未被使用" :value="0"></el-option>
<el-option label="已被使用" :value="1"></el-option>
</el-select>
</el-col>
<el-col :span="4" class="filter-col" style="min-width: 160px;">
<el-input v-model="accountsFilter.search" placeholder="邮箱/备注" clearable></el-input>
</el-col>
</el-row>
</div>
<el-row :gutter="20" style="margin-bottom: 10px;">
<el-col :span="24" style="text-align: right;">
<el-button type="primary" :disabled="selectedAccounts.length === 0" @click="batchToggleUsed(1)">
批量标记为已使用
</el-button>
<el-button type="info" :disabled="selectedAccounts.length === 0" @click="batchToggleUsed(0)">
批量标记为未使用
</el-button>
</el-col>
</el-row>
<el-table
:data="accounts"
style="width: 100%;overflow-x:auto;"
v-loading="loading.accounts"
@selection-change="handleSelectionChange"
border
stripe
highlight-current-row
>
<el-table-column type="selection" width="50"> </el-table-column>
<el-table-column label="ID" width="80" sortable>
<template #default="scope">
{{ scope.row.id || '-' }}
</template>
</el-table-column>
<el-table-column label="注册时间" width="180" sortable>
<template #default="scope">
{{ scope.row.register_time || '-' }}
</template>
</el-table-column>
<el-table-column label="用户名" min-width="250" show-overflow-tooltip>
<template #default="scope">
{{ scope.row.username || '-' }}
</template>
</el-table-column>
<el-table-column label="状态" width="120">
<template #default="scope">
<el-tag :type="getStatusType(scope.row.status)" size="small">
{{ getStatusText(scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="激活链接" min-width="300">
<template #default="scope">
<div v-if="scope.row.activation_link" style="display: flex; align-items: center;">
<el-tooltip :content="scope.row.activation_link" placement="top" effect="light">
<span style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;">
{{ scope.row.activation_link }}
</span>
</el-tooltip>
<el-button
size="small"
type="primary"
class="copy-button"
@click="copyToClipboard(scope.row.activation_link, scope.row)"
>
复制
</el-button>
</div>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="已被使用" width="100">
<template #default="scope">
<el-tag :type="scope.row.used ? 'success' : 'info'" @click="toggleAccountUsed(scope.row)" style="cursor:pointer;">
{{ scope.row.used ? '✔ 已使用' : '未使用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="250" fixed="right">
<template #default="scope">
<el-button
size="small"
type="primary"
@click="submitSingleAccount(scope.row)"
:disabled="scope.row.status === 1 || scope.row.status === 3"
>
提交
</el-button>
<el-button
size="small"
type="success"
@click="extractSingleAccount(scope.row)"
:disabled="scope.row.status !== 1"
>
提取
</el-button>
<el-button
size="small"
@click="viewAccountDetails(scope.row)"
>
详情
</el-button>
<el-button
size="small"
type="danger"
@click="deleteAccount(scope.row)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<div style="margin-top: 20px; display: flex; justify-content: center;">
<el-pagination
v-model:current-page="pagination.current"
v-model:page-size="pagination.pageSize"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="pagination.total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
</div>
</el-tab-pane>
<!-- 任务管理标签页 -->
<el-tab-pane label="任务管理" name="tasks">
<div class="tab-container">
<el-button type="primary" @click="loadTasks" style="margin-bottom: 20px;">刷新任务列表</el-button>
<el-timeline>
<el-timeline-item
v-for="(task, id) in tasks"
:key="id"
:type="getTaskStatusType(task.status)"
:icon="getTaskStatusIcon(task.status)"
:timestamp="task.start_time"
>
<el-card class="task-card">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div>
<span style="font-weight: bold;">{{ getTaskTypeText(task.type) }} - {{ id }}</span>
<el-tag size="small" style="margin-left: 10px;" :type="getTaskStatusType(task.status)">
{{ getTaskStatusText(task.status) }}
</el-tag>
</div>
<div v-if="task.status === 'completed'">
<span style="margin-right: 10px;">成功: {{ task.success_count || 0 }}</span>
<span>失败: {{ task.error_count || 0 }}</span>
</div>
</div>
<div v-if="task.error" style="color: #F56C6C; margin-top: 10px;">
错误: {{ task.error }}
</div>
<div v-if="task.account_ids && task.account_ids.length > 0" style="margin-top: 10px;">
<span>处理账号: {{ task.account_ids.length }}个</span>
</div>
</el-card>
</el-timeline-item>
</el-timeline>
<div v-if="Object.keys(tasks).length === 0" style="text-align: center; padding: 30px;">
<el-empty description="暂无任务记录" />
</div>
</div>
</el-tab-pane>
<!-- 操作日志标签页 -->
<el-tab-pane label="操作日志" name="logs">
<div class="tab-container">
<div style="margin-bottom: 20px;">
<el-row :gutter="20">
<el-col :span="8">
<el-input v-model="logsFilter.username" placeholder="用户名" clearable></el-input>
</el-col>
<el-col :span="8">
<el-select v-model="logsFilter.operation" placeholder="操作类型" clearable style="width: 100%;">
<el-option label="提交邮箱" value="submit_email"></el-option>
<el-option label="提取链接" value="extract_link"></el-option>
<el-option label="后台提交" value="submit_email_background"></el-option>
<el-option label="后台提取" value="extract_link_background"></el-option>
<el-option label="更新状态" value="update_status"></el-option>
</el-select>
</el-col>
<el-col :span="8">
<el-select v-model="logsFilter.status" placeholder="操作状态" clearable style="width: 100%;">
<el-option label="成功" value="success"></el-option>
<el-option label="失败" value="failed"></el-option>
<el-option label="处理中" value="processing"></el-option>
<el-option label="错误" value="error"></el-option>
</el-select>
</el-col>
</el-row>
</div>
<el-table
:data="logs"
style="width: 100%"
v-loading="loading.logs"
border
>
<el-table-column label="ID" width="80">
<template #default="scope">
{{ scope.row.log_id || scope.row.id || '-' }}
</template>
</el-table-column>
<el-table-column label="用户名" min-width="150">
<template #default="scope">
{{ scope.row.account_username || scope.row.username || '-' }}
</template>
</el-table-column>
<el-table-column label="操作" width="180">
<template #default="scope">
<el-tag size="small">{{ getOperationText(scope.row.operation) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="状态" width="120">
<template #default="scope">
<el-tag :type="getLogStatusType(scope.row.status)" size="small">
{{ scope.row.status }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="消息" min-width="200">
<template #default="scope">
<el-tag size="small">{{ getMessageText(scope.row.message) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="时间" width="180">
<template #default="scope">
{{ scope.row.created_at || scope.row.timestamp || '-' }}
</template>
</el-table-column>
</el-table>
<div style="margin-top: 20px; display: flex; justify-content: center;">
<el-pagination
v-model:current-page="logsPagination.current"
v-model:page-size="logsPagination.pageSize"
:page-sizes="[20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
:total="logsPagination.total"
@size-change="handleLogsSizeChange"
@current-change="handleLogsCurrentChange"
/>
</div>
</div>
</el-tab-pane>
</el-tabs>
</el-main>
</el-container>
<!-- 导入数据对话框 -->
<el-dialog title="导入数据" v-model="dialogs.import" width="500px">
<el-form label-width="100px">
<el-form-item label="选择文件" required>
<input type="file" @change="handleImportFileChange" accept=".txt,.csv" />
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogs.import = false">取消</el-button>
<el-button type="primary" @click="importAccounts" :loading="loading.import">导入</el-button>
</span>
</template>
</el-dialog>
<!-- 导出数据对话框 -->
<el-dialog title="导出数据" v-model="dialogs.export" width="500px">
<el-form :model="exportForm" label-width="100px">
<el-form-item label="文件名">
<el-input v-model="exportForm.filename" placeholder="导出文件名"></el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogs.export = false">取消</el-button>
<el-button type="primary" @click="exportAccounts" :loading="loading.export">导出</el-button>
</span>
</template>
</el-dialog>
<!-- 账号详情对话框 -->
<el-dialog title="账号详情" v-model="dialogs.accountDetails" width="700px">
<el-descriptions v-if="currentAccount" :column="1" border>
<el-descriptions-item label="ID">{{ currentAccount.id }}</el-descriptions-item>
<el-descriptions-item label="注册时间">{{ currentAccount.register_time }}</el-descriptions-item>
<el-descriptions-item label="用户名">{{ currentAccount.username }}</el-descriptions-item>
<el-descriptions-item label="密码">{{ currentAccount.password }}</el-descriptions-item>
<el-descriptions-item label="密保邮箱">{{ currentAccount.security_email || '-' }}</el-descriptions-item>
<el-descriptions-item label="状态">
<el-tag :type="getStatusType(currentAccount.status)">
{{ getStatusText(currentAccount.status) }}
</el-tag>
</el-descriptions-item>
<el-descriptions-item label="激活链接">
<div v-if="currentAccount.activation_link" style="display: flex; align-items: center;">
<span style="word-break: break-all;">{{ currentAccount.activation_link }}</span>
<el-button
size="small"
type="primary"
class="copy-button"
@click="copyToClipboard(currentAccount.activation_link, currentAccount)"
>
复制
</el-button>
</div>
<span v-else>-</span>
</el-descriptions-item>
<el-descriptions-item label="更新时间">{{ currentAccount.updated_at || '-' }}</el-descriptions-item>
<el-descriptions-item label="备注">{{ currentAccount.notes || '-' }}</el-descriptions-item>
</el-descriptions>
<div style="margin-top: 20px;">
<h3>更新状态</h3>
<el-form :model="statusUpdateForm" label-width="100px">
<el-form-item label="状态">
<el-select v-model="statusUpdateForm.status" placeholder="选择状态" style="width: 100%;">
<el-option label="未提交" :value="0"></el-option>
<el-option label="已提交" :value="1"></el-option>
<el-option label="提交失败" :value="2"></el-option>
<el-option label="已提取链接" :value="3"></el-option>
</el-select>
</el-form-item>
<el-form-item label="激活链接">
<el-input v-model="statusUpdateForm.activation_link" placeholder="可选"></el-input>
</el-form-item>
<el-form-item label="备注">
<el-input v-model="statusUpdateForm.notes" type="textarea" placeholder="可选"></el-input>
</el-form-item>
</el-form>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogs.accountDetails = false">取消</el-button>
<el-button type="primary" @click="updateAccountStatus" :loading="loading.updateStatus">更新</el-button>
</span>
</template>
</el-dialog>
<!-- 提交邮箱对话框 -->
<el-dialog title="提交邮箱" v-model="dialogs.submit" width="500px">
<el-form :model="submitForm" label-width="100px">
<el-form-item label="最大线程数">
<el-input-number v-model="submitForm.max_workers" :min="1" :max="10"></el-input-number>
</el-form-item>
<el-form-item label="代理服务器">
<el-input v-model="submitForm.proxy" placeholder="可选,例如:http://127.0.0.1:60060"></el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogs.submit = false">取消</el-button>
<el-button type="primary" @click="confirmSubmit" :loading="loading.submit">提交</el-button>
</span>
</template>
</el-dialog>
<!-- 提取链接对话框 -->
<el-dialog title="提取链接" v-model="dialogs.extract" width="500px">
<el-form :model="extractForm" label-width="100px">
<el-form-item label="最大线程数">
<el-input-number v-model="extractForm.max_workers" :min="1" :max="5"></el-input-number>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogs.extract = false">取消</el-button>
<el-button type="primary" @click="confirmExtract" :loading="loading.extract">提取</el-button>
</span>
</template>
</el-dialog>
<!-- 登录验证对话框 -->
<el-dialog title="登录验证" v-model="dialogs.login" width="350px" :close-on-click-modal="false" :show-close="false">
<el-form @submit.prevent="handleLogin">
<el-form-item label="密码">
<el-input v-model="loginForm.password" type="password" autocomplete="off" @keyup.enter="handleLogin"></el-input>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="handleLogin" :loading="loading.login">登录</el-button>
</span>
</template>
</el-dialog>
</div>
<script>
const { createApp, ref, reactive, onMounted, computed, nextTick, watch, onUnmounted } = Vue;
// 后端API基础URL
const API_BASE_URL = 'https://168.fucku.tech';
const app = createApp({
setup() {
// 状态管理
const activeTab = ref('accounts');
const accounts = ref([]);
const selectedAccounts = ref([]);
const currentAccount = ref(null);
const tasks = ref({});
const logs = ref([]);
const statistics = reactive({
total: 0,
pending: 0,
submitted: 0,
failed: 0,
link_extracted: 0,
unused: 0
});
// 任务轮询相关状态
const runningTaskPolls = reactive({});
// 分页配置
const pagination = reactive({
current: 1,
pageSize: 10,
total: 0
});
const logsPagination = reactive({
current: 1,
pageSize: 20,
total: 0
});
// 过滤器
const accountsFilter = reactive({
status: null,
search: '',
registerTimeStart: '',
registerTimeEnd: '',
idMin: '',
idMax: '',
hasActivationLink: '', // '', 'yes', 'no'
used: '' // 新增
});
const logsFilter = reactive({
username: '',
operation: '',
status: ''
});
// 表单数据
const importForm = reactive({
filepath: 'user-4-21-success.txt'
});
const exportForm = reactive({
filename: 'export_results.txt',
status: null
});
const statusUpdateForm = reactive({
status: 0,
activation_link: '',
notes: ''
});
const submitForm = reactive({
max_workers: 1,
proxy: ''
});
const extractForm = reactive({
max_workers: 1
});
const loginForm = reactive({ password: '' });
// 对话框控制
const dialogs = reactive({
import: false,
export: false,
accountDetails: false,
submit: false,
extract: false,
login: false
});
// 加载状态
const loading = reactive({
accounts: false,
tasks: false,
logs: false,
statistics: false,
import: false,
export: false,
updateStatus: false,
submit: false,
extract: false,
login: false
});
// token管理
const getToken = () => {
return document.cookie.replace(/(?:(?:^|.*;\s*)token\s*\=\s*([^;]*).*$)|^.*$/, "$1");
};
const setToken = (token) => {
document.cookie = `token=${token};path=/;max-age=2592000`;
};
const clearToken = () => {
document.cookie = 'token=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
};
// axios请求拦截
axios.interceptors.request.use(config => {
const token = getToken();
if (token) config.headers.token = token;
return config;
});
// 初始化
onMounted(async () => {
if (!(await checkLogin())) return;
console.log('应用已加载,开始获取数据');
loadAccounts();
loadStatistics();
loadTasks();
// 监听过滤器变化
watch([
() => accountsFilter.status,
() => accountsFilter.search,
() => accountsFilter.registerTimeStart,
() => accountsFilter.registerTimeEnd,
() => accountsFilter.idMin,
() => accountsFilter.idMax,
() => accountsFilter.hasActivationLink,
() => accountsFilter.used
], () => {
pagination.current = 1;
loadAccounts();
});
watch([
() => logsFilter.username,
() => logsFilter.operation,
() => logsFilter.status
], () => {
logsPagination.current = 1;
loadLogs();
});
});
// 登录逻辑
const handleLogin = async () => {
if (!loginForm.password) {
ElementPlus.ElMessage.warning('请输入密码');
return;
}
loading.login = true;
try {
const res = await axios.post(`${API_BASE_URL}/login`, { password: loginForm.password });
setToken(res.data.token);
dialogs.login = false;
ElementPlus.ElMessage.success('登录成功');
// 登录后自动加载数据
loadAccounts();
loadStatistics();
loadTasks();
} catch (e) {
ElementPlus.ElMessage.error(e.response?.data?.detail || '登录失败');
} finally {
loading.login = false;
}
};
// 退出登录
const logout = () => {
clearToken();
dialogs.login = true;
};
// 检查token
const checkLogin = async () => {
const token = getToken();
if (!token) {
dialogs.login = true;
return false;
}
// 简单校验token有效性(可选:请求一个接口)
try {
await axios.get(`${API_BASE_URL}/statistics`);
return true;
} catch {
dialogs.login = true;
return false;
}
};
// 轮询任务状态的功能
const startTaskPolling = (taskId) => {
console.log(`开始轮询任务 ${taskId} 的状态`);
if (runningTaskPolls[taskId]) {
// 如果已经在轮询这个任务,则不重复创建
return;
}
// 创建一个轮询间隔,每10秒查询一次任务状态
const intervalId = setInterval(async () => {
try {
const response = await axios.get(`${API_BASE_URL}/tasks/${taskId}`);
const taskData = response.data;
// 更新本地任务数据
tasks.value = { ...tasks.value, [taskId]: taskData };
// 如果任务已完成或失败,停止轮询
if (taskData.status === 'completed' || taskData.status === 'failed') {
console.log(`任务 ${taskId} 已${taskData.status === 'completed' ? '完成' : '失败'},停止轮询`);
clearInterval(runningTaskPolls[taskId]);
delete runningTaskPolls[taskId];
// 提醒用户任务已完成
ElementPlus.ElMessage({
message: `任务 ${taskId} 已${taskData.status === 'completed' ? '完成' : '失败'},成功: ${taskData.success_count || 0},失败: ${taskData.error_count || 0}`,
type: taskData.status === 'completed' ? 'success' : 'warning',
duration: 5000
});
// 如果任务成功,刷新账号列表和统计信息
if (taskData.status === 'completed') {
loadAccounts();
loadStatistics();
}
}
} catch (error) {
console.error(`轮询任务 ${taskId} 状态失败:`, error);
// 如果出错,也停止轮询
clearInterval(runningTaskPolls[taskId]);
delete runningTaskPolls[taskId];
}
}, 10000); // 每10秒轮询一次
// 保存轮询间隔ID,以便稍后可以停止它
runningTaskPolls[taskId] = intervalId;
};
// 加载账号列表
const loadAccounts = async () => {
loading.accounts = true;
try {
const params = {
page: pagination.current,
per_page: pagination.pageSize
};
if (accountsFilter.status !== null && accountsFilter.status !== '') params.status = accountsFilter.status;
if (accountsFilter.search) params.search = accountsFilter.search;
if (accountsFilter.registerTimeStart) params.register_time_start = accountsFilter.registerTimeStart;
if (accountsFilter.registerTimeEnd) params.register_time_end = accountsFilter.registerTimeEnd;
if (accountsFilter.idMin) params.id_min = accountsFilter.idMin;
if (accountsFilter.idMax) params.id_max = accountsFilter.idMax;
if (accountsFilter.hasActivationLink) params.has_activation_link = accountsFilter.hasActivationLink;
if (accountsFilter.used !== '' && accountsFilter.used !== null && accountsFilter.used !== undefined) params.used = accountsFilter.used;
console.log('请求参数:', params);
const response = await axios.get(`${API_BASE_URL}/accounts`, { params });
console.log('API响应:', response.data);
if (response.data && Array.isArray(response.data.accounts)) {
accounts.value = response.data.accounts;
pagination.total = response.data.total;
// 调试信息 - 检查每个账号数据
accounts.value.forEach((account, index) => {
console.log(`账号[${index}]:`, account);
if (!account.id) console.warn(`账号[${index}] 缺少ID字段`);
if (!account.register_time) console.warn(`账号[${index}] 缺少注册时间字段`);
if (!account.username) console.warn(`账号[${index}] 缺少用户名字段`);
});
// 如果应该有数据但显示不出来,尝试强制更新视图
if (accounts.value.length > 0) {
nextTick(() => {
console.log('视图已更新');
});
}
} else {
console.error('API返回的数据格式不正确:', response.data);
ElementPlus.ElMessage.warning('API返回的数据格式不正确');
}
} catch (error) {
console.error('加载账号失败:', error);
ElementPlus.ElMessage.error('加载账号失败: ' + (error.response?.data?.detail || error.message));
} finally {
loading.accounts = false;
}
};
// 加载统计信息
const loadStatistics = async () => {
loading.statistics = true;
try {
const response = await axios.get(`${API_BASE_URL}/statistics`);
Object.assign(statistics, response.data);
} catch (error) {
console.error('加载统计信息失败:', error);
ElementPlus.ElMessage.error('加载统计信息失败: ' + (error.response?.data?.detail || error.message));
} finally {
loading.statistics = false;
}
};
// 加载任务列表
const loadTasks = async () => {
loading.tasks = true;
try {
const response = await axios.get(`${API_BASE_URL}/tasks`);
tasks.value = response.data;
// 检查并为所有正在运行的任务启动轮询
Object.entries(response.data).forEach(([taskId, taskData]) => {
if (taskData.status === 'running' && !runningTaskPolls[taskId]) {
startTaskPolling(taskId);
}
});
} catch (error) {
console.error('加载任务列表失败:', error);
ElementPlus.ElMessage.error('加载任务列表失败: ' + (error.response?.data?.detail || error.message));
} finally {
loading.tasks = false;
}
};
// 加载日志列表
const loadLogs = async () => {
loading.logs = true;
try {
const params = {
page: logsPagination.current,
per_page: logsPagination.pageSize
};
if (logsFilter.username) {
params.username = logsFilter.username;
}
if (logsFilter.operation) {
params.operation = logsFilter.operation;
}
if (logsFilter.status) {
params.status = logsFilter.status;
}
const response = await axios.get(`${API_BASE_URL}/logs`, { params });
logs.value = response.data.logs;
logsPagination.total = response.data.total;
} catch (error) {
console.error('加载日志失败:', error);
ElementPlus.ElMessage.error('加载日志失败: ' + (error.response?.data?.detail || error.message));
} finally {
loading.logs = false;
}
};
// 分页事件处理
const handleSizeChange = (size) => {
pagination.pageSize = size;
loadAccounts();
};
const handleCurrentChange = (page) => {
pagination.current = page;
loadAccounts();
};
const handleLogsSizeChange = (size) => {
logsPagination.pageSize = size;
loadLogs();
};
const handleLogsCurrentChange = (page) => {
logsPagination.current = page;
loadLogs();
};
// 表格选择事件
const handleSelectionChange = (selection) => {
selectedAccounts.value = selection;
};
// 标签页点击事件
const handleTabClick = (tab) => {
if (tab.props.name === 'logs') {
loadLogs();
}
};
// 导入账号
const showImportDialog = () => {
dialogs.import = true;
};
const handleImportFileChange = (event) => {
const file = event.target.files[0];
if (file) {
importForm.filepath = file;
}
};
const importAccounts = async () => {
if (!importForm.filepath) {
ElementPlus.ElMessage.warning('请选择文件');
return;
}
loading.import = true;
try {
const formData = new FormData();
formData.append('file', importForm.filepath);
const response = await axios.post(`${API_BASE_URL}/import`, formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
});
ElementPlus.ElMessage.success(`成功导入 ${response.data.imported_count} 个账号`);
dialogs.import = false;
// 重新加载数据
loadAccounts();
loadStatistics();
} catch (error) {
console.error('导入账号失败:', error);
ElementPlus.ElMessage.error('导入账号失败: ' + (error.response?.data?.detail || error.message));
} finally {
loading.import = false;
}
};
// 导出账号
const showExportDialog = () => {
dialogs.export = true;
};
const exportAccounts = async () => {
if (!exportForm.filename) {
ElementPlus.ElMessage.warning('请输入文件名');
return;
}
loading.export = true;
try {
// 导出时使用当前筛选条件
const params = {
filename: exportForm.filename
};
if (accountsFilter.status !== null && accountsFilter.status !== '') params.status = accountsFilter.status;
if (accountsFilter.used !== '' && accountsFilter.used !== null && accountsFilter.used !== undefined) params.used = accountsFilter.used;
if (accountsFilter.hasActivationLink) params.has_activation_link = accountsFilter.hasActivationLink;
if (accountsFilter.search) params.search = accountsFilter.search;
if (accountsFilter.registerTimeStart) params.register_time_start = accountsFilter.registerTimeStart;
if (accountsFilter.registerTimeEnd) params.register_time_end = accountsFilter.registerTimeEnd;
if (accountsFilter.idMin) params.id_min = accountsFilter.idMin;
if (accountsFilter.idMax) params.id_max = accountsFilter.idMax;
// 使用axios以blob方式请求导出数据
const response = await axios.post(`${API_BASE_URL}/export`, params, {
responseType: 'blob' // 设置响应类型为blob
});
// 创建Blob链接并触发下载
const blob = new Blob([response.data], { type: 'text/plain' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', exportForm.filename); // 使用用户指定的文件名
document.body.appendChild(link);
link.click();
// 清理资源
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
ElementPlus.ElMessage.success('文件已导出并下载到本地');
dialogs.export = false;
} catch (error) {
console.error('导出账号失败:', error);
ElementPlus.ElMessage.error('导出账号失败: ' + (error.response?.data?.detail || error.message));
} finally {
loading.export = false;
}
};
// 重置失败账号
const resetFailedAccounts = async () => {
try {
const response = await axios.post(`${API_BASE_URL}/reset-failed`);
ElementPlus.ElMessage.success(response.data.message);
// 重新加载数据
loadAccounts();
loadStatistics();
} catch (error) {
console.error('重置失败账号出错:', error);
ElementPlus.ElMessage.error('重置失败账号出错: ' + (error.response?.data?.detail || error.message));
}
};
// 查看账号详情
const viewAccountDetails = (account) => {
currentAccount.value = {...account};
statusUpdateForm.status = account.status;
statusUpdateForm.activation_link = account.activation_link || '';
statusUpdateForm.notes = account.notes || '';
dialogs.accountDetails = true;
};
// 更新账号状态
const updateAccountStatus = async () => {
if (currentAccount.value === null) {
return;
}
loading.updateStatus = true;
try {
const response = await axios.post(
`${API_BASE_URL}/accounts/${currentAccount.value.id}/status`,
statusUpdateForm
);
ElementPlus.ElMessage.success('账号状态更新成功');
// 更新本地数据
const index = accounts.value.findIndex(a => a.id === currentAccount.value.id);
if (index !== -1) {
accounts.value[index] = response.data;
}
dialogs.accountDetails = false;
// 重新加载统计数据
loadStatistics();
} catch (error) {
console.error('更新账号状态失败:', error);
ElementPlus.ElMessage.error('更新账号状态失败: ' + (error.response?.data?.detail || error.message));
} finally {
loading.updateStatus = false;
}
};
// 删除账号
const deleteAccount = (account) => {
ElementPlus.ElMessageBox.confirm(
`确定要删除账号【${account.username}】吗?`,
'删除确认',
{
confirmButtonText: '删除',
cancelButtonText: '取消',
type: 'warning',
}
).then(async () => {
try {
await axios.delete(`${API_BASE_URL}/accounts/${account.id}`);
ElementPlus.ElMessage.success('账号已删除');
loadAccounts();
loadStatistics();
} catch (error) {
ElementPlus.ElMessage.error('删除失败: ' + (error.response?.data?.detail || error.message));
}
}).catch(() => {});
};
// 提交邮箱相关
const submitSelectedAccounts = () => {
submitForm.account_ids = selectedAccounts.value.map(account => account.id);
dialogs.submit = true;
};
const submitSingleAccount = (account) => {
submitForm.account_ids = [account.id];
dialogs.submit = true;
};
const confirmSubmit = async () => {
loading.submit = true;
try {
const response = await axios.post(`${API_BASE_URL}/submit`, {
account_ids: submitForm.account_ids,
max_workers: submitForm.max_workers,
proxy: submitForm.proxy || null
});
const taskId = response.data.task_id;
ElementPlus.ElMessage.success('提交任务已启动,任务ID: ' + taskId);
dialogs.submit = false;
// 切换到任务标签页
activeTab.value = 'tasks';
// 延迟刷新任务列表
setTimeout(() => {
loadTasks();
// 开始轮询任务状态
startTaskPolling(taskId);
}, 1000);
} catch (error) {
console.error('提交邮箱失败:', error);
ElementPlus.ElMessage.error('提交邮箱失败: ' + (error.response?.data?.detail || error.message));
} finally {
loading.submit = false;
}
};
// 提取链接相关
const extractSelectedAccounts = () => {
extractForm.account_ids = selectedAccounts.value
.filter(account => account.status === 1)
.map(account => account.id);
if (extractForm.account_ids.length === 0) {
ElementPlus.ElMessage.warning('没有选择已提交的账号');
return;
}
dialogs.extract = true;
};
const extractSingleAccount = (account) => {
if (account.status !== 1) {
ElementPlus.ElMessage.warning('只能为已提交的账号提取链接');
return;
}
extractForm.account_ids = [account.id];
dialogs.extract = true;
};
const confirmExtract = async () => {
loading.extract = true;
try {
const response = await axios.post(`${API_BASE_URL}/extract`, {
account_ids: extractForm.account_ids,
max_workers: extractForm.max_workers
});
const taskId = response.data.task_id;
ElementPlus.ElMessage.success('提取任务已启动,任务ID: ' + taskId);
dialogs.extract = false;
// 切换到任务标签页
activeTab.value = 'tasks';
// 延迟刷新任务列表
setTimeout(() => {
loadTasks();
// 开始轮询任务状态
startTaskPolling(taskId);
}, 1000);
} catch (error) {
console.error('提取链接失败:', error);
ElementPlus.ElMessage.error('提取链接失败: ' + (error.response?.data?.detail || error.message));
} finally {
loading.extract = false;
}
};
// 切换账号used状态
const toggleAccountUsed = async (account) => {
try {
const response = await axios.post(`${API_BASE_URL}/accounts/${account.id}/toggle-used`);
account.used = response.data.used;
ElementPlus.ElMessage.success('已切换使用状态');
} catch (error) {
ElementPlus.ElMessage.error('切换失败: ' + (error.response?.data?.detail || error.message));
}
};
// 批量切换账号used状态
const batchToggleUsed = async (usedValue) => {
if (selectedAccounts.value.length === 0) return;
const ids = selectedAccounts.value.map(acc => acc.id);
const confirmMsg = usedValue ? `确定将选中账号批量标记为“已使用”?` : `确定将选中账号批量标记为“未使用”?`;
ElementPlus.ElMessageBox.confirm(confirmMsg, '批量操作确认', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
try {
await axios.post(`${API_BASE_URL}/accounts/batch-toggle-used`, { ids, used: usedValue });
ElementPlus.ElMessage.success('批量操作成功');
loadAccounts();
} catch (error) {
ElementPlus.ElMessage.error('批量操作失败: ' + (error.response?.data?.detail || error.message));
}
}).catch(() => {});
};
// 复制到剪贴板并自动标记为已使用
const copyToClipboard = (text, account) => {
navigator.clipboard.writeText(text).then(async () => {
ElementPlus.ElMessage({
message: '已复制到剪贴板',
type: 'success',
duration: 1500
});
// 自动标记为已使用
if (account && !account.used) {
try {
const response = await axios.post(`${API_BASE_URL}/accounts/${account.id}/toggle-used`);
account.used = response.data.used;
} catch (error) {
// 忽略错误
}
}
}).catch(err => {
console.error('复制失败:', err);
ElementPlus.ElMessage.error('复制失败');
});
};
// 清理函数 - 组件卸载时调用
onUnmounted(() => {
// 清理所有正在运行的轮询
Object.values(runningTaskPolls).forEach(intervalId => {
clearInterval(intervalId);
});
});
// 工具函数 - 获取状态文本
const getStatusText = (status) => {
const statusMap = {
0: '未提交',
1: '已提交',
2: '提交失败',
3: '已提取链接'
};
return statusMap[status] || '未知状态';
};
// 工具函数 - 获取状态类型(Element UI的tag类型)
const getStatusType = (status) => {
const typeMap = {
0: 'info', // 未提交
1: 'primary', // 已提交
2: 'danger', // 提交失败
3: 'success' // 已提取链接
};
return typeMap[status] || 'info';
};
// 工具函数 - 获取任务状态文本
const getTaskStatusText = (status) => {
const statusMap = {
'running': '运行中',
'completed': '已完成',
'failed': '失败'
};
return statusMap[status] || status;
};
// 工具函数 - 获取任务状态类型
const getTaskStatusType = (status) => {
const typeMap = {
'running': 'primary',
'completed': 'success',
'failed': 'danger'
};
return typeMap[status] || 'info';
};
// 工具函数 - 获取任务状态图标
const getTaskStatusIcon = (status) => {
const iconMap = {
'running': 'Loading',
'completed': 'Check',
'failed': 'Close'
};
return iconMap[status] || '';
};
// 工具函数 - 获取任务类型文本
const getTaskTypeText = (type) => {
const typeMap = {
'submit': '提交邮箱',
'extract': '提取链接'
};
return typeMap[type] || type;
};
// 工具函数 - 获取操作文本
const getOperationText = (operation) => {
const operationMap = {
'submit_email': '提交邮箱',
'extract_link': '提取链接',
'submit_email_background': '后台提交',
'extract_link_background': '后台提取',
'update_status': '更新状态'
};
return operationMap[operation] || operation;
};
// 工具函数 - 获取日志记录文本
const getMessageText = (message) => { // 获取日志记录文本
//直接返回消息
return message || '-';
};
// 工具函数 - 获取日志状态类型
const getLogStatusType = (status) => {
const typeMap = {
'success': 'success',
'failed': 'danger',
'error': 'danger',
'processing': 'warning'
};
return typeMap[status] || 'info';
};
// 工具函数 - 处理状态筛选变化
const handleStatusChange = (value) => {
console.log('状态筛选变化:', value);
};
return {
activeTab,
accounts,
selectedAccounts,
currentAccount,
tasks,
logs,
statistics,
pagination,
logsPagination,
accountsFilter,
logsFilter,
importForm,
exportForm,
statusUpdateForm,
submitForm,
extractForm,
loginForm,
dialogs,
loading,
// 方法
loadAccounts,
loadStatistics,
loadTasks,
loadLogs,
handleSizeChange,
handleCurrentChange,
handleLogsSizeChange,
handleLogsCurrentChange,
handleSelectionChange,
handleTabClick,
showImportDialog,
handleImportFileChange,
importAccounts,
showExportDialog,
exportAccounts,
resetFailedAccounts,
viewAccountDetails,
updateAccountStatus,
deleteAccount,
submitSelectedAccounts,
submitSingleAccount,
confirmSubmit,
extractSelectedAccounts,
extractSingleAccount,
confirmExtract,
toggleAccountUsed,
batchToggleUsed,
copyToClipboard,
handleLogin,
logout,
checkLogin,
// 工具函数
getStatusText,
getStatusType,
getTaskStatusText,
getTaskStatusType,
getTaskStatusIcon,
getTaskTypeText,
getOperationText,
getLogStatusType,
getMessageText,
handleStatusChange
};
}
});
// // 全局注册Element Plus
// for (const [key, component] of Object.entries(ElementPlus)) {
// app.component(key, component);
// }
// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component);
}
// 使用Element Plus
app.use(ElementPlus);
app.mount('#app');
</script>
</body>
</html> |