Update app/statics/admin/account.html
Browse files- app/statics/admin/account.html +193 -36
app/statics/admin/account.html
CHANGED
|
@@ -37,7 +37,7 @@
|
|
| 37 |
min-width:20px;
|
| 38 |
height:20px;
|
| 39 |
padding:0 7px;
|
| 40 |
-
border-
|
| 41 |
display:inline-flex;
|
| 42 |
align-items:center;
|
| 43 |
justify-content:center;
|
|
@@ -100,6 +100,15 @@
|
|
| 100 |
flex-direction:column;
|
| 101 |
gap:12px;
|
| 102 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
.stat-top {
|
| 104 |
display:flex;
|
| 105 |
align-items:center;
|
|
@@ -371,6 +380,22 @@
|
|
| 371 |
text-align:left;
|
| 372 |
border-bottom:none;
|
| 373 |
letter-spacing:.01em;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 374 |
}
|
| 375 |
td {
|
| 376 |
font-size:13px;
|
|
@@ -558,6 +583,15 @@
|
|
| 558 |
border-radius:999px;
|
| 559 |
display:inline-flex;
|
| 560 |
align-items:center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 561 |
}
|
| 562 |
.q-a { background:#f1f6fd; color:#5d7fb2 }
|
| 563 |
.q-f { background:#f2f8f4; color:#4c9168 }
|
|
@@ -608,7 +642,9 @@
|
|
| 608 |
|
| 609 |
/* Dialogs */
|
| 610 |
#modal-import .modal,
|
| 611 |
-
#modal-import-file .modal
|
|
|
|
|
|
|
| 612 |
#modal-export .modal {
|
| 613 |
width:min(440px,92vw);
|
| 614 |
padding-top:14px;
|
|
@@ -713,17 +749,26 @@
|
|
| 713 |
flex:1;
|
| 714 |
}
|
| 715 |
.import-file-name.empty { color:#999 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 716 |
</style>
|
| 717 |
</head>
|
| 718 |
<body>
|
| 719 |
|
| 720 |
-
<!-- ── Header ─────────────────────────────────────────────────────────────── -->
|
| 721 |
<div id="admin-header" data-active="/admin/account"></div>
|
| 722 |
|
| 723 |
-
<!-- ── Main ───────────────────────────────────────────────────────────────── -->
|
| 724 |
<main class="admin-main">
|
| 725 |
|
| 726 |
-
<!-- Page heading -->
|
| 727 |
<div class="page-hd">
|
| 728 |
<div>
|
| 729 |
<div class="page-title" data-i18n="account.pageHeading">账户列表</div>
|
|
@@ -745,7 +790,6 @@
|
|
| 745 |
<div class="section-title" data-i18n="account.sectionOverview">账户概览</div>
|
| 746 |
</div>
|
| 747 |
|
| 748 |
-
<!-- Stats -->
|
| 749 |
<div class="stat-grid" id="overview-stats">
|
| 750 |
<div class="stat-cell" data-stat-card="total">
|
| 751 |
<div class="stat-top">
|
|
@@ -794,9 +838,8 @@
|
|
| 794 |
</div>
|
| 795 |
</div>
|
| 796 |
|
| 797 |
-
<!-- Quota stats (6 columns) -->
|
| 798 |
<div class="stat-grid-quota" id="overview-quota-stats">
|
| 799 |
-
<div class="stat-cell" data-stat-card="calls">
|
| 800 |
<div class="stat-top">
|
| 801 |
<div class="stat-label" data-i18n="account.statCalls">调用总数</div>
|
| 802 |
<span class="stat-icon" style="color:#111">
|
|
@@ -805,7 +848,7 @@
|
|
| 805 |
</div>
|
| 806 |
<div class="stat-num" id="s-calls" style="color:#111">0</div>
|
| 807 |
</div>
|
| 808 |
-
<div class="stat-cell" data-quota-only>
|
| 809 |
<div class="stat-top">
|
| 810 |
<div class="stat-label" data-i18n="account.statAuto">Auto 余额</div>
|
| 811 |
<span class="stat-icon" style="color:#2563eb">
|
|
@@ -814,7 +857,7 @@
|
|
| 814 |
</div>
|
| 815 |
<div class="stat-num" id="s-qa" style="color:#2563eb">0</div>
|
| 816 |
</div>
|
| 817 |
-
<div class="stat-cell" data-quota-only>
|
| 818 |
<div class="stat-top">
|
| 819 |
<div class="stat-label" data-i18n="account.statFast">Fast 余额</div>
|
| 820 |
<span class="stat-icon" style="color:#16a34a">
|
|
@@ -823,7 +866,7 @@
|
|
| 823 |
</div>
|
| 824 |
<div class="stat-num" id="s-qf" style="color:#16a34a">0</div>
|
| 825 |
</div>
|
| 826 |
-
<div class="stat-cell" data-quota-only>
|
| 827 |
<div class="stat-top">
|
| 828 |
<div class="stat-label" data-i18n="account.statExpert">Expert 余额</div>
|
| 829 |
<span class="stat-icon" style="color:#7c3aed">
|
|
@@ -832,7 +875,7 @@
|
|
| 832 |
</div>
|
| 833 |
<div class="stat-num" id="s-qe" style="color:#7c3aed">0</div>
|
| 834 |
</div>
|
| 835 |
-
<div class="stat-cell" data-quota-only>
|
| 836 |
<div class="stat-top">
|
| 837 |
<div class="stat-label" data-i18n="account.statHeavy">Heavy 余额</div>
|
| 838 |
<span class="stat-icon" style="color:#b0632a">
|
|
@@ -841,7 +884,7 @@
|
|
| 841 |
</div>
|
| 842 |
<div class="stat-num" id="s-qh" style="color:#b0632a">0</div>
|
| 843 |
</div>
|
| 844 |
-
<div class="stat-cell" data-quota-only>
|
| 845 |
<div class="stat-top">
|
| 846 |
<div class="stat-label" data-i18n="account.statConsole">Console 余额</div>
|
| 847 |
<span class="stat-icon" style="color:#2e7d52">
|
|
@@ -859,7 +902,6 @@
|
|
| 859 |
</div>
|
| 860 |
</div>
|
| 861 |
|
| 862 |
-
<!-- Toolbar -->
|
| 863 |
<div class="table-toolbar">
|
| 864 |
<div class="table-toolbar-left" style="display:flex;align-items:center;gap:6px">
|
| 865 |
<button onclick="prevPage()" class="pagi-btn" id="btn-prev">
|
|
@@ -979,29 +1021,28 @@
|
|
| 979 |
</div>
|
| 980 |
</div>
|
| 981 |
|
| 982 |
-
<!-- Table -->
|
| 983 |
<div class="table-card table-freeze-last">
|
| 984 |
<table>
|
| 985 |
<thead>
|
| 986 |
<tr>
|
| 987 |
<th style="width:36px"><input type="checkbox" class="cb" id="cb-all" onchange="toggleAll(this.checked)"></th>
|
| 988 |
-
<th style="width:200px" data-i18n="account.colToken">Token</th>
|
| 989 |
-
<th class="table-center" style="width:70px" data-i18n="account.colType">类型</th>
|
| 990 |
-
<th class="table-center" style="width:70px" data-i18n="account.colStatus">状态</th>
|
| 991 |
<th data-quota-only>
|
| 992 |
<span data-i18n="account.colQuota">额度</span>
|
| 993 |
<span style="margin-left:6px;display:inline-flex;align-items:center;gap:3px;vertical-align:middle">
|
| 994 |
-
<span class="q-pill q-a">A</span>
|
| 995 |
-
<span class="q-pill q-f">F</span>
|
| 996 |
-
<span class="q-pill q-e">E</span>
|
| 997 |
-
<span class="q-pill q-h">H</span>
|
| 998 |
-
<span class="q-pill q-c">C</span>
|
| 999 |
</span>
|
| 1000 |
</th>
|
| 1001 |
-
<th class="table-center" data-i18n="account.colSuccess">成功</th>
|
| 1002 |
-
<th class="table-center" data-i18n="account.colFail">失败</th>
|
| 1003 |
-
<th class="table-center" data-i18n="account.colRate">成功率</th>
|
| 1004 |
-
<th data-i18n="account.colLastUsed">最近使用</th>
|
| 1005 |
<th data-i18n="account.colActions">操作</th>
|
| 1006 |
</tr>
|
| 1007 |
</thead>
|
|
@@ -1011,7 +1052,6 @@
|
|
| 1011 |
|
| 1012 |
</main>
|
| 1013 |
|
| 1014 |
-
<!-- ── Add Modal ───────────────────────────────────────────────────────────── -->
|
| 1015 |
<div class="modal-overlay" id="modal-import">
|
| 1016 |
<div class="modal">
|
| 1017 |
<div class="modal-title" data-i18n="account.addTitle">添加账户</div>
|
|
@@ -1039,7 +1079,6 @@
|
|
| 1039 |
</div>
|
| 1040 |
</div>
|
| 1041 |
|
| 1042 |
-
<!-- ── Import Modal ────────────────────────────────────────────────────────── -->
|
| 1043 |
<div class="modal-overlay" id="modal-import-file">
|
| 1044 |
<div class="modal">
|
| 1045 |
<div class="modal-title" data-i18n="account.importTitle">导入文件</div>
|
|
@@ -1071,7 +1110,6 @@
|
|
| 1071 |
</div>
|
| 1072 |
</div>
|
| 1073 |
|
| 1074 |
-
<!-- ── Edit Modal ─────────────────────────────────────────────────────────── -->
|
| 1075 |
<div class="modal-overlay" id="modal-edit">
|
| 1076 |
<div class="modal">
|
| 1077 |
<div class="modal-title" data-i18n="account.editTitle">编辑账户</div>
|
|
@@ -1092,7 +1130,6 @@
|
|
| 1092 |
</div>
|
| 1093 |
</div>
|
| 1094 |
|
| 1095 |
-
<!-- ── Export Modal ────────────────────────────────────────────────────────── -->
|
| 1096 |
<div class="modal-overlay" id="modal-export">
|
| 1097 |
<div class="modal" style="max-width:360px">
|
| 1098 |
<div class="modal-title" data-i18n="account.exportTitle">导出格式</div>
|
|
@@ -1104,7 +1141,6 @@
|
|
| 1104 |
</div>
|
| 1105 |
</div>
|
| 1106 |
|
| 1107 |
-
<!-- ── Confirm Modal ───────────────────────────────────────────────────────── -->
|
| 1108 |
<div class="modal-overlay" id="modal-confirm">
|
| 1109 |
<div class="modal" style="max-width:400px">
|
| 1110 |
<div class="modal-title" id="confirm-title" data-i18n="account.confirmTitle">确认</div>
|
|
@@ -1116,6 +1152,35 @@
|
|
| 1116 |
</div>
|
| 1117 |
</div>
|
| 1118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1119 |
<script src="/static/js/i18n.js?v={{APP_VERSION}}"></script>
|
| 1120 |
<script src="/static/js/auth.js?v={{APP_VERSION}}"></script>
|
| 1121 |
<script src="/static/js/admin-header.js?v={{APP_VERSION}}"></script>
|
|
@@ -1127,6 +1192,7 @@ const PAGE_SIZE_KEY = 'admin.account.page_size';
|
|
| 1127 |
const PAGE_SIZE_OPTIONS = [50, 100, 200, 500, 1000, 2000];
|
| 1128 |
|
| 1129 |
let allTokens = [], curStatus = 'all', curNsfw = 'all', curPool = 'all', curPage = 1, pageSize = loadSavedPageSize();
|
|
|
|
| 1130 |
const sel = new Set();
|
| 1131 |
const refreshingTokens = new Set();
|
| 1132 |
let _cb = null;
|
|
@@ -1245,6 +1311,68 @@ function applyStrategyUI() {
|
|
| 1245 |
});
|
| 1246 |
}
|
| 1247 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1248 |
// ── Render ─────────────────────────────────────────────────────────────────
|
| 1249 |
function render() {
|
| 1250 |
const view = getTokenView();
|
|
@@ -1252,10 +1380,11 @@ function render() {
|
|
| 1252 |
renderFilters(view);
|
| 1253 |
renderTable(view);
|
| 1254 |
applyStrategyUI();
|
|
|
|
| 1255 |
}
|
| 1256 |
|
| 1257 |
function getTokenView() {
|
| 1258 |
-
const cacheKey = `${_tokenViewVersion}|${curStatus}|${curNsfw}|${curPool}`;
|
| 1259 |
if (_tokenViewCache && _tokenViewCacheKey === cacheKey) return _tokenViewCache;
|
| 1260 |
|
| 1261 |
const stats = {
|
|
@@ -1276,7 +1405,7 @@ function getTokenView() {
|
|
| 1276 |
const nsfwCounts = { all: 0, enabled: 0, disabled: 0 };
|
| 1277 |
const poolCounts = new Map([['all', 0]]);
|
| 1278 |
const poolsSet = new Set(['basic', 'super', 'heavy']);
|
| 1279 |
-
|
| 1280 |
|
| 1281 |
for (const token of allTokens) {
|
| 1282 |
const pool = token.pool || 'basic';
|
|
@@ -1328,12 +1457,40 @@ function getTokenView() {
|
|
| 1328 |
if (matchesPool && matchesStatus && matchesNsfw) filteredItems.push(token);
|
| 1329 |
}
|
| 1330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1331 |
if (curPool !== 'all' && !poolsSet.has(curPool)) {
|
| 1332 |
curPool = 'all';
|
| 1333 |
return getTokenView();
|
| 1334 |
}
|
| 1335 |
|
| 1336 |
-
_tokenViewCacheKey =
|
| 1337 |
_tokenViewCache = {
|
| 1338 |
stats,
|
| 1339 |
statusCounts,
|
|
@@ -2252,4 +2409,4 @@ document.addEventListener('click', (e) => {
|
|
| 2252 |
});
|
| 2253 |
</script>
|
| 2254 |
</body>
|
| 2255 |
-
</html>
|
|
|
|
| 37 |
min-width:20px;
|
| 38 |
height:20px;
|
| 39 |
padding:0 7px;
|
| 40 |
+
border-radius999px;
|
| 41 |
display:inline-flex;
|
| 42 |
align-items:center;
|
| 43 |
justify-content:center;
|
|
|
|
| 100 |
flex-direction:column;
|
| 101 |
gap:12px;
|
| 102 |
}
|
| 103 |
+
.stat-cell.clickable {
|
| 104 |
+
cursor:pointer;
|
| 105 |
+
transition:background-color .15s, transform .15s, box-shadow .15s;
|
| 106 |
+
}
|
| 107 |
+
.stat-cell.clickable:hover {
|
| 108 |
+
background-color:#fafafa;
|
| 109 |
+
transform:translateY(-1px);
|
| 110 |
+
box-shadow:0 6px 16px rgba(0,0,0,0.03);
|
| 111 |
+
}
|
| 112 |
.stat-top {
|
| 113 |
display:flex;
|
| 114 |
align-items:center;
|
|
|
|
| 380 |
text-align:left;
|
| 381 |
border-bottom:none;
|
| 382 |
letter-spacing:.01em;
|
| 383 |
+
user-select:none;
|
| 384 |
+
}
|
| 385 |
+
th.sortable-th {
|
| 386 |
+
cursor:pointer;
|
| 387 |
+
transition:color .15s, background-color .15s;
|
| 388 |
+
}
|
| 389 |
+
th.sortable-th:hover {
|
| 390 |
+
color:#444;
|
| 391 |
+
background-color:#fafafa;
|
| 392 |
+
}
|
| 393 |
+
.sort-indicator {
|
| 394 |
+
font-size:10px;
|
| 395 |
+
display:inline-block;
|
| 396 |
+
margin-left:4px;
|
| 397 |
+
color:#111;
|
| 398 |
+
font-weight:bold;
|
| 399 |
}
|
| 400 |
td {
|
| 401 |
font-size:13px;
|
|
|
|
| 583 |
border-radius:999px;
|
| 584 |
display:inline-flex;
|
| 585 |
align-items:center;
|
| 586 |
+
user-select:none;
|
| 587 |
+
}
|
| 588 |
+
.q-pill.sortable-pill {
|
| 589 |
+
cursor:pointer;
|
| 590 |
+
transition:opacity .15s, transform .15s;
|
| 591 |
+
}
|
| 592 |
+
.q-pill.sortable-pill:hover {
|
| 593 |
+
opacity:.85;
|
| 594 |
+
transform:scale(1.05);
|
| 595 |
}
|
| 596 |
.q-a { background:#f1f6fd; color:#5d7fb2 }
|
| 597 |
.q-f { background:#f2f8f4; color:#4c9168 }
|
|
|
|
| 642 |
|
| 643 |
/* Dialogs */
|
| 644 |
#modal-import .modal,
|
| 645 |
+
#modal-import-file .modal,
|
| 646 |
+
#modal-audit .modal { width:min(440px,92vw) }
|
| 647 |
+
#modal-audit .modal { width:min(720px,94vw) }
|
| 648 |
#modal-export .modal {
|
| 649 |
width:min(440px,92vw);
|
| 650 |
padding-top:14px;
|
|
|
|
| 749 |
flex:1;
|
| 750 |
}
|
| 751 |
.import-file-name.empty { color:#999 }
|
| 752 |
+
|
| 753 |
+
/* Audit log styles */
|
| 754 |
+
.audit-table-wrap {
|
| 755 |
+
width:100%;
|
| 756 |
+
overflow-x:auto;
|
| 757 |
+
border:1px solid #eee;
|
| 758 |
+
border-radius:8px;
|
| 759 |
+
max-height:360px;
|
| 760 |
+
}
|
| 761 |
+
.audit-table { width:100%; border-collapse:collapse; min-width:560px }
|
| 762 |
+
.audit-table th { background:#f9f8f6; padding:8px 12px; font-size:11px; color:#8a8a8a; border-bottom:1px solid #eee }
|
| 763 |
+
.audit-table td { padding:10px 12px; font-size:12px; border-bottom:1px solid #f5f5f5; color:#444 }
|
| 764 |
</style>
|
| 765 |
</head>
|
| 766 |
<body>
|
| 767 |
|
|
|
|
| 768 |
<div id="admin-header" data-active="/admin/account"></div>
|
| 769 |
|
|
|
|
| 770 |
<main class="admin-main">
|
| 771 |
|
|
|
|
| 772 |
<div class="page-hd">
|
| 773 |
<div>
|
| 774 |
<div class="page-title" data-i18n="account.pageHeading">账户列表</div>
|
|
|
|
| 790 |
<div class="section-title" data-i18n="account.sectionOverview">账户概览</div>
|
| 791 |
</div>
|
| 792 |
|
|
|
|
| 793 |
<div class="stat-grid" id="overview-stats">
|
| 794 |
<div class="stat-cell" data-stat-card="total">
|
| 795 |
<div class="stat-top">
|
|
|
|
| 838 |
</div>
|
| 839 |
</div>
|
| 840 |
|
|
|
|
| 841 |
<div class="stat-grid-quota" id="overview-quota-stats">
|
| 842 |
+
<div class="stat-cell clickable" data-stat-card="calls" onclick="openAuditModal('calls')">
|
| 843 |
<div class="stat-top">
|
| 844 |
<div class="stat-label" data-i18n="account.statCalls">调用总数</div>
|
| 845 |
<span class="stat-icon" style="color:#111">
|
|
|
|
| 848 |
</div>
|
| 849 |
<div class="stat-num" id="s-calls" style="color:#111">0</div>
|
| 850 |
</div>
|
| 851 |
+
<div class="stat-cell clickable" data-quota-only onclick="openAuditModal('auto')">
|
| 852 |
<div class="stat-top">
|
| 853 |
<div class="stat-label" data-i18n="account.statAuto">Auto 余额</div>
|
| 854 |
<span class="stat-icon" style="color:#2563eb">
|
|
|
|
| 857 |
</div>
|
| 858 |
<div class="stat-num" id="s-qa" style="color:#2563eb">0</div>
|
| 859 |
</div>
|
| 860 |
+
<div class="stat-cell clickable" data-quota-only onclick="openAuditModal('fast')">
|
| 861 |
<div class="stat-top">
|
| 862 |
<div class="stat-label" data-i18n="account.statFast">Fast 余额</div>
|
| 863 |
<span class="stat-icon" style="color:#16a34a">
|
|
|
|
| 866 |
</div>
|
| 867 |
<div class="stat-num" id="s-qf" style="color:#16a34a">0</div>
|
| 868 |
</div>
|
| 869 |
+
<div class="stat-cell clickable" data-quota-only onclick="openAuditModal('expert')">
|
| 870 |
<div class="stat-top">
|
| 871 |
<div class="stat-label" data-i18n="account.statExpert">Expert 余额</div>
|
| 872 |
<span class="stat-icon" style="color:#7c3aed">
|
|
|
|
| 875 |
</div>
|
| 876 |
<div class="stat-num" id="s-qe" style="color:#7c3aed">0</div>
|
| 877 |
</div>
|
| 878 |
+
<div class="stat-cell clickable" data-quota-only onclick="openAuditModal('heavy')">
|
| 879 |
<div class="stat-top">
|
| 880 |
<div class="stat-label" data-i18n="account.statHeavy">Heavy 余额</div>
|
| 881 |
<span class="stat-icon" style="color:#b0632a">
|
|
|
|
| 884 |
</div>
|
| 885 |
<div class="stat-num" id="s-qh" style="color:#b0632a">0</div>
|
| 886 |
</div>
|
| 887 |
+
<div class="stat-cell clickable" data-quota-only onclick="openAuditModal('console')">
|
| 888 |
<div class="stat-top">
|
| 889 |
<div class="stat-label" data-i18n="account.statConsole">Console 余额</div>
|
| 890 |
<span class="stat-icon" style="color:#2e7d52">
|
|
|
|
| 902 |
</div>
|
| 903 |
</div>
|
| 904 |
|
|
|
|
| 905 |
<div class="table-toolbar">
|
| 906 |
<div class="table-toolbar-left" style="display:flex;align-items:center;gap:6px">
|
| 907 |
<button onclick="prevPage()" class="pagi-btn" id="btn-prev">
|
|
|
|
| 1021 |
</div>
|
| 1022 |
</div>
|
| 1023 |
|
|
|
|
| 1024 |
<div class="table-card table-freeze-last">
|
| 1025 |
<table>
|
| 1026 |
<thead>
|
| 1027 |
<tr>
|
| 1028 |
<th style="width:36px"><input type="checkbox" class="cb" id="cb-all" onchange="toggleAll(this.checked)"></th>
|
| 1029 |
+
<th style="width:200px" class="sortable-th" onclick="handleSort('token')"><span data-i18n="account.colToken">Token</span><span id="sort-token" class="sort-indicator"></span></th>
|
| 1030 |
+
<th class="table-center sortable-th" style="width:70px" onclick="handleSort('pool')"><span data-i18n="account.colType">类型</span><span id="sort-pool" class="sort-indicator"></span></th>
|
| 1031 |
+
<th class="table-center sortable-th" style="width:70px" onclick="handleSort('status')"><span data-i18n="account.colStatus">状态</span><span id="sort-status" class="sort-indicator"></span></th>
|
| 1032 |
<th data-quota-only>
|
| 1033 |
<span data-i18n="account.colQuota">额度</span>
|
| 1034 |
<span style="margin-left:6px;display:inline-flex;align-items:center;gap:3px;vertical-align:middle">
|
| 1035 |
+
<span class="q-pill q-a sortable-pill" onclick="handleSort('quota_auto')" title="按 Auto 排序">A<span id="sort-quota_auto" class="sort-indicator"></span></span>
|
| 1036 |
+
<span class="q-pill q-f_sort sortable-pill q-f" onclick="handleSort('quota_fast')" title="按 Fast 排序">F<span id="sort-quota_fast" class="sort-indicator"></span></span>
|
| 1037 |
+
<span class="q-pill q-e sortable-pill" onclick="handleSort('quota_expert')" title="按 Expert 排序">E<span id="sort-quota_expert" class="sort-indicator"></span></span>
|
| 1038 |
+
<span class="q-pill q-h sortable-pill" onclick="handleSort('quota_heavy')" title="按 Heavy 排序">H<span id="sort-quota_heavy" class="sort-indicator"></span></span>
|
| 1039 |
+
<span class="q-pill q-c sortable-pill" onclick="handleSort('quota_console')" title="按 Console 排序">C<span id="sort-quota_console" class="sort-indicator"></span></span>
|
| 1040 |
</span>
|
| 1041 |
</th>
|
| 1042 |
+
<th class="table-center sortable-th" onclick="handleSort('success')"><span data-i18n="account.colSuccess">成功</span><span id="sort-success" class="sort-indicator"></span></th>
|
| 1043 |
+
<th class="table-center sortable-th" onclick="handleSort('fail')"><span data-i18n="account.colFail">失败</span><span id="sort-fail" class="sort-indicator"></span></th>
|
| 1044 |
+
<th class="table-center sortable-th" onclick="handleSort('rate')"><span data-i18n="account.colRate">成功率</span><span id="sort-rate" class="sort-indicator"></span></th>
|
| 1045 |
+
<th class="sortable-th" onclick="handleSort('last_used')"><span data-i18n="account.colLastUsed">最近使用</span><span id="sort-last_used" class="sort-indicator"></span></th>
|
| 1046 |
<th data-i18n="account.colActions">操作</th>
|
| 1047 |
</tr>
|
| 1048 |
</thead>
|
|
|
|
| 1052 |
|
| 1053 |
</main>
|
| 1054 |
|
|
|
|
| 1055 |
<div class="modal-overlay" id="modal-import">
|
| 1056 |
<div class="modal">
|
| 1057 |
<div class="modal-title" data-i18n="account.addTitle">添加账户</div>
|
|
|
|
| 1079 |
</div>
|
| 1080 |
</div>
|
| 1081 |
|
|
|
|
| 1082 |
<div class="modal-overlay" id="modal-import-file">
|
| 1083 |
<div class="modal">
|
| 1084 |
<div class="modal-title" data-i18n="account.importTitle">导入文件</div>
|
|
|
|
| 1110 |
</div>
|
| 1111 |
</div>
|
| 1112 |
|
|
|
|
| 1113 |
<div class="modal-overlay" id="modal-edit">
|
| 1114 |
<div class="modal">
|
| 1115 |
<div class="modal-title" data-i18n="account.editTitle">编辑账户</div>
|
|
|
|
| 1130 |
</div>
|
| 1131 |
</div>
|
| 1132 |
|
|
|
|
| 1133 |
<div class="modal-overlay" id="modal-export">
|
| 1134 |
<div class="modal" style="max-width:360px">
|
| 1135 |
<div class="modal-title" data-i18n="account.exportTitle">导出格式</div>
|
|
|
|
| 1141 |
</div>
|
| 1142 |
</div>
|
| 1143 |
|
|
|
|
| 1144 |
<div class="modal-overlay" id="modal-confirm">
|
| 1145 |
<div class="modal" style="max-width:400px">
|
| 1146 |
<div class="modal-title" id="confirm-title" data-i18n="account.confirmTitle">确认</div>
|
|
|
|
| 1152 |
</div>
|
| 1153 |
</div>
|
| 1154 |
|
| 1155 |
+
<div class="modal-overlay" id="modal-audit">
|
| 1156 |
+
<div class="modal">
|
| 1157 |
+
<div class="modal-title" id="audit-title">调用审计明细</div>
|
| 1158 |
+
<div class="dialog-body">
|
| 1159 |
+
<div class="audit-table-wrap">
|
| 1160 |
+
<table class="audit-table">
|
| 1161 |
+
<thead>
|
| 1162 |
+
<tr>
|
| 1163 |
+
<th>请求时间</th>
|
| 1164 |
+
<th>设备 IP</th>
|
| 1165 |
+
<th>客户端 (User-Agent)</th>
|
| 1166 |
+
<th>会话 ID (Conversation ID)</th>
|
| 1167 |
+
<th>消耗 Token</th>
|
| 1168 |
+
</tr>
|
| 1169 |
+
</thead>
|
| 1170 |
+
<tbody id="audit-tbody">
|
| 1171 |
+
<tr>
|
| 1172 |
+
<td colspan="5" style="text-align:center;color:#aaa;padding:24px;">暂无审计记录</td>
|
| 1173 |
+
</tr>
|
| 1174 |
+
</tbody>
|
| 1175 |
+
</table>
|
| 1176 |
+
</div>
|
| 1177 |
+
</div>
|
| 1178 |
+
<div class="dialog-actions">
|
| 1179 |
+
<button onclick="closeModal('modal-audit')" class="dialog-btn dialog-btn-primary">关闭</button>
|
| 1180 |
+
</div>
|
| 1181 |
+
</div>
|
| 1182 |
+
</div>
|
| 1183 |
+
|
| 1184 |
<script src="/static/js/i18n.js?v={{APP_VERSION}}"></script>
|
| 1185 |
<script src="/static/js/auth.js?v={{APP_VERSION}}"></script>
|
| 1186 |
<script src="/static/js/admin-header.js?v={{APP_VERSION}}"></script>
|
|
|
|
| 1192 |
const PAGE_SIZE_OPTIONS = [50, 100, 200, 500, 1000, 2000];
|
| 1193 |
|
| 1194 |
let allTokens = [], curStatus = 'all', curNsfw = 'all', curPool = 'all', curPage = 1, pageSize = loadSavedPageSize();
|
| 1195 |
+
let sortKey = '', sortOrder = 'desc'; // Sorting state variables
|
| 1196 |
const sel = new Set();
|
| 1197 |
const refreshingTokens = new Set();
|
| 1198 |
let _cb = null;
|
|
|
|
| 1311 |
});
|
| 1312 |
}
|
| 1313 |
|
| 1314 |
+
// ── Sorting Logic ──────────────────────────────────────────────────────────
|
| 1315 |
+
function handleSort(key) {
|
| 1316 |
+
if (sortKey === key) {
|
| 1317 |
+
sortOrder = sortOrder === 'asc' ? 'desc' : 'asc';
|
| 1318 |
+
} else {
|
| 1319 |
+
sortKey = key;
|
| 1320 |
+
sortOrder = 'desc';
|
| 1321 |
+
}
|
| 1322 |
+
invalidateTokenView();
|
| 1323 |
+
render();
|
| 1324 |
+
}
|
| 1325 |
+
|
| 1326 |
+
function updateSortIndicators() {
|
| 1327 |
+
const keys = ['token', 'pool', 'status', 'quota_auto', 'quota_fast', 'quota_expert', 'quota_heavy', 'quota_console', 'success', 'fail', 'rate', 'last_used'];
|
| 1328 |
+
keys.forEach(k => {
|
| 1329 |
+
const el = document.getElementById(`sort-${k}`);
|
| 1330 |
+
if (el) {
|
| 1331 |
+
if (sortKey === k) {
|
| 1332 |
+
el.textContent = sortOrder === 'asc' ? ' 🔼' : ' 🔽';
|
| 1333 |
+
} else {
|
| 1334 |
+
el.textContent = '';
|
| 1335 |
+
}
|
| 1336 |
+
}
|
| 1337 |
+
});
|
| 1338 |
+
}
|
| 1339 |
+
|
| 1340 |
+
// ── Audit Drill-down ───────────────────────────────────────────────────────
|
| 1341 |
+
async function openAuditModal(type) {
|
| 1342 |
+
const titleMap = {
|
| 1343 |
+
calls: '调用总数审计明细',
|
| 1344 |
+
auto: 'Auto 额度调用分布审计',
|
| 1345 |
+
fast: 'Fast 额度调用分布审计',
|
| 1346 |
+
expert: 'Expert 额度调用分布审计',
|
| 1347 |
+
heavy: 'Heavy 额度调用分布审计',
|
| 1348 |
+
console: 'Console 额度调用分布审计'
|
| 1349 |
+
};
|
| 1350 |
+
document.getElementById('audit-title').textContent = titleMap[type] || '调用审计明细';
|
| 1351 |
+
const tbody = document.getElementById('audit-tbody');
|
| 1352 |
+
tbody.innerHTML = `<tr><td colspan="5" style="text-align:center;padding:32px;color:#666;">正在从后台加载链路审计数据...</td></tr>`;
|
| 1353 |
+
openModal('modal-audit');
|
| 1354 |
+
|
| 1355 |
+
try {
|
| 1356 |
+
const data = await _api('GET', `/audit/logs?type=${type}`).catch(() => ({ logs: [] }));
|
| 1357 |
+
const logs = data.logs || [];
|
| 1358 |
+
if (!logs.length) {
|
| 1359 |
+
tbody.innerHTML = `<tr><td colspan="5" style="text-align:center;color:#999;padding:32px;">当前通道近期没有上游日志产生 (直连/历史日志为空)</td></tr>`;
|
| 1360 |
+
return;
|
| 1361 |
+
}
|
| 1362 |
+
tbody.innerHTML = logs.map(log => `
|
| 1363 |
+
<tr>
|
| 1364 |
+
<td style="font-variant-numeric:tabular-nums;">${fmtDate(log.created_at || log.time)}</td>
|
| 1365 |
+
<td style="font-family:ui-monospace,monospace;color:#111;">${log.client_ip || log.ip || '—'}</td>
|
| 1366 |
+
<td style="max-width:160px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="${xe(log.user_agent || '')}">${log.user_agent || '—'}</td>
|
| 1367 |
+
<td style="font-family:ui-monospace,monospace;font-size:11px;color:#666;">${log.conversation_id || '—'}</td>
|
| 1368 |
+
<td style="font-family:ui-monospace,monospace;color:#444;">${mask(log.account_token || log.token || '—')}</td>
|
| 1369 |
+
</tr>
|
| 1370 |
+
`).join('');
|
| 1371 |
+
} catch (e) {
|
| 1372 |
+
tbody.innerHTML = `<tr><td colspan="5" style="text-align:center;color:#b66a63;padding:32px;">读取审计记录失败: ${e.message}</td></tr>`;
|
| 1373 |
+
}
|
| 1374 |
+
}
|
| 1375 |
+
|
| 1376 |
// ── Render ─────────────────────────────────────────────────────────────────
|
| 1377 |
function render() {
|
| 1378 |
const view = getTokenView();
|
|
|
|
| 1380 |
renderFilters(view);
|
| 1381 |
renderTable(view);
|
| 1382 |
applyStrategyUI();
|
| 1383 |
+
updateSortIndicators();
|
| 1384 |
}
|
| 1385 |
|
| 1386 |
function getTokenView() {
|
| 1387 |
+
const cacheKey = `${_tokenViewVersion}|${curStatus}|${curNsfw}|${curPool}|${sortKey}|${sortOrder}`;
|
| 1388 |
if (_tokenViewCache && _tokenViewCacheKey === cacheKey) return _tokenViewCache;
|
| 1389 |
|
| 1390 |
const stats = {
|
|
|
|
| 1405 |
const nsfwCounts = { all: 0, enabled: 0, disabled: 0 };
|
| 1406 |
const poolCounts = new Map([['all', 0]]);
|
| 1407 |
const poolsSet = new Set(['basic', 'super', 'heavy']);
|
| 1408 |
+
let filteredItems = [];
|
| 1409 |
|
| 1410 |
for (const token of allTokens) {
|
| 1411 |
const pool = token.pool || 'basic';
|
|
|
|
| 1457 |
if (matchesPool && matchesStatus && matchesNsfw) filteredItems.push(token);
|
| 1458 |
}
|
| 1459 |
|
| 1460 |
+
// Frontend Sorting Logic Insertion
|
| 1461 |
+
if (sortKey) {
|
| 1462 |
+
filteredItems.sort((a, b) => {
|
| 1463 |
+
let vA, vB;
|
| 1464 |
+
if (sortKey === 'token') { vA = a.token || ''; vB = b.token || ''; }
|
| 1465 |
+
else if (sortKey === 'pool') { vA = a.pool || 'basic'; vB = b.pool || 'basic'; }
|
| 1466 |
+
else if (sortKey === 'status') { vA = a.status || ''; vB = b.status || ''; }
|
| 1467 |
+
else if (sortKey === 'quota_auto') { vA = a.quota?.auto?.remaining || 0; vB = b.quota?.auto?.remaining || 0; }
|
| 1468 |
+
else if (sortKey === 'quota_fast') { vA = a.quota?.fast?.remaining || 0; vB = b.quota?.fast?.remaining || 0; }
|
| 1469 |
+
else if (sortKey === 'quota_expert') { vA = a.quota?.expert?.remaining || 0; vB = b.quota?.expert?.remaining || 0; }
|
| 1470 |
+
else if (sortKey === 'quota_heavy') { vA = a.quota?.heavy?.remaining || 0; vB = b.quota?.heavy?.remaining || 0; }
|
| 1471 |
+
else if (sortKey === 'quota_console') { vA = a.quota?.console?.remaining || 0; vB = b.quota?.console?.remaining || 0; }
|
| 1472 |
+
else if (sortKey === 'success') { vA = a.use_count || 0; vB = b.use_count || 0; }
|
| 1473 |
+
else if (sortKey === 'fail') { vA = a.fail_count || 0; vB = b.fail_count || 0; }
|
| 1474 |
+
else if (sortKey === 'rate') {
|
| 1475 |
+
const totalA = (a.use_count || 0) + (a.fail_count || 0);
|
| 1476 |
+
const totalB = (b.use_count || 0) + (b.fail_count || 0);
|
| 1477 |
+
vA = totalA ? (a.use_count || 0) / totalA : 0;
|
| 1478 |
+
vB = totalB ? (b.use_count || 0) / totalB : 0;
|
| 1479 |
+
}
|
| 1480 |
+
else if (sortKey === 'last_used') { vA = a.last_used_at || 0; vB = b.last_used_at || 0; }
|
| 1481 |
+
|
| 1482 |
+
if (vA < vB) return sortOrder === 'asc' ? -1 : 1;
|
| 1483 |
+
if (vA > vB) return sortOrder === 'asc' ? 1 : -1;
|
| 1484 |
+
return 0;
|
| 1485 |
+
});
|
| 1486 |
+
}
|
| 1487 |
+
|
| 1488 |
if (curPool !== 'all' && !poolsSet.has(curPool)) {
|
| 1489 |
curPool = 'all';
|
| 1490 |
return getTokenView();
|
| 1491 |
}
|
| 1492 |
|
| 1493 |
+
_tokenViewCacheKey = cacheKey;
|
| 1494 |
_tokenViewCache = {
|
| 1495 |
stats,
|
| 1496 |
statusCounts,
|
|
|
|
| 2409 |
});
|
| 2410 |
</script>
|
| 2411 |
</body>
|
| 2412 |
+
</html>
|