keungliang commited on
Commit
9d1a715
·
verified ·
1 Parent(s): cfd4b5a

Upload 2 files

Browse files
Files changed (2) hide show
  1. templates/login.html +77 -0
  2. templates/manager.html +1081 -0
templates/login.html ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>登录</title>
6
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap" rel="stylesheet">
7
+ <style>
8
+ :root {
9
+ --bg-primary: #f4f6f9;
10
+ --card-bg: #ffffff;
11
+ --text-primary: #2c3e50;
12
+ --text-secondary: #6c757d;
13
+ --border-color: #e2e8f0;
14
+ --primary-color: #3498db;
15
+ }
16
+ * { box-sizing: border-box; margin: 0; padding: 0; }
17
+ body {
18
+ font-family: 'Inter', sans-serif;
19
+ background-color: var(--bg-primary);
20
+ color: var(--text-primary);
21
+ display: flex;
22
+ justify-content: center;
23
+ align-items: center;
24
+ height: 100vh;
25
+ }
26
+ .login-form {
27
+ background: var(--card-bg);
28
+ padding: 40px;
29
+ border-radius: 16px;
30
+ box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
31
+ width: 100%;
32
+ max-width: 400px;
33
+ }
34
+ h2 {
35
+ text-align: center;
36
+ margin-bottom: 20px;
37
+ color: var(--text-primary);
38
+ }
39
+ input {
40
+ width: 100%;
41
+ padding: 12px 15px;
42
+ margin: 10px 0;
43
+ border: 1px solid var(--border-color);
44
+ border-radius: 8px;
45
+ font-size: 16px;
46
+ }
47
+ button {
48
+ width: 100%;
49
+ padding: 12px;
50
+ background-color: var(--primary-color);
51
+ color: white;
52
+ border: none;
53
+ border-radius: 8px;
54
+ cursor: pointer;
55
+ transition: background-color 0.3s;
56
+ }
57
+ button:hover { background-color: #2980b9; }
58
+ </style>
59
+ </head>
60
+ <body>
61
+ <div class="login-form">
62
+ <h2>管理员登录</h2>
63
+ <form action="/manager/login" method="post">
64
+ <input type="password" name="password" placeholder="输入管理员密码" required>
65
+ <button type="submit">登录</button>
66
+ </form>
67
+ </div>
68
+ {% if error %}
69
+ <div id="notification" style="position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background-color: #f44336; color: white; padding: 10px 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.2); display: block; z-index: 1000;">密码错误</div>
70
+ <script>
71
+ setTimeout(() => {
72
+ document.getElementById('notification').style.display = 'none';
73
+ }, 2000);
74
+ </script>
75
+ {% endif %}
76
+ </body>
77
+ </html>
templates/manager.html CHANGED
@@ -0,0 +1,1081 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>GrokAPI管理面板</title>
7
+ <style type="text/css">@font-face {font-family:Inter;font-style:normal;font-weight:300;src:url(/cf-fonts/v/inter/5.0.16/vietnamese/wght/normal.woff2);unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:300;src:url(/cf-fonts/v/inter/5.0.16/cyrillic/wght/normal.woff2);unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:300;src:url(/cf-fonts/v/inter/5.0.16/greek-ext/wght/normal.woff2);unicode-range:U+1F00-1FFF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:300;src:url(/cf-fonts/v/inter/5.0.16/cyrillic-ext/wght/normal.woff2);unicode-range:U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:300;src:url(/cf-fonts/v/inter/5.0.16/greek/wght/normal.woff2);unicode-range:U+0370-03FF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:300;src:url(/cf-fonts/v/inter/5.0.16/latin/wght/normal.woff2);unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:300;src:url(/cf-fonts/v/inter/5.0.16/latin-ext/wght/normal.woff2);unicode-range:U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:400;src:url(/cf-fonts/v/inter/5.0.16/latin/wght/normal.woff2);unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:400;src:url(/cf-fonts/v/inter/5.0.16/greek-ext/wght/normal.woff2);unicode-range:U+1F00-1FFF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:400;src:url(/cf-fonts/v/inter/5.0.16/cyrillic-ext/wght/normal.woff2);unicode-range:U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:400;src:url(/cf-fonts/v/inter/5.0.16/greek/wght/normal.woff2);unicode-range:U+0370-03FF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:400;src:url(/cf-fonts/v/inter/5.0.16/cyrillic/wght/normal.woff2);unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:400;src:url(/cf-fonts/v/inter/5.0.16/latin-ext/wght/normal.woff2);unicode-range:U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:400;src:url(/cf-fonts/v/inter/5.0.16/vietnamese/wght/normal.woff2);unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:600;src:url(/cf-fonts/v/inter/5.0.16/cyrillic/wght/normal.woff2);unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:600;src:url(/cf-fonts/v/inter/5.0.16/latin-ext/wght/normal.woff2);unicode-range:U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:600;src:url(/cf-fonts/v/inter/5.0.16/greek-ext/wght/normal.woff2);unicode-range:U+1F00-1FFF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:600;src:url(/cf-fonts/v/inter/5.0.16/latin/wght/normal.woff2);unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:600;src:url(/cf-fonts/v/inter/5.0.16/vietnamese/wght/normal.woff2);unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:600;src:url(/cf-fonts/v/inter/5.0.16/greek/wght/normal.woff2);unicode-range:U+0370-03FF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:600;src:url(/cf-fonts/v/inter/5.0.16/cyrillic-ext/wght/normal.woff2);unicode-range:U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:700;src:url(/cf-fonts/v/inter/5.0.16/cyrillic-ext/wght/normal.woff2);unicode-range:U+0460-052F,U+1C80-1C88,U+20B4,U+2DE0-2DFF,U+A640-A69F,U+FE2E-FE2F;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:700;src:url(/cf-fonts/v/inter/5.0.16/greek-ext/wght/normal.woff2);unicode-range:U+1F00-1FFF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:700;src:url(/cf-fonts/v/inter/5.0.16/latin/wght/normal.woff2);unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:700;src:url(/cf-fonts/v/inter/5.0.16/latin-ext/wght/normal.woff2);unicode-range:U+0100-02AF,U+0304,U+0308,U+0329,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20CF,U+2113,U+2C60-2C7F,U+A720-A7FF;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:700;src:url(/cf-fonts/v/inter/5.0.16/vietnamese/wght/normal.woff2);unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:700;src:url(/cf-fonts/v/inter/5.0.16/cyrillic/wght/normal.woff2);unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;font-display:swap;}@font-face {font-family:Inter;font-style:normal;font-weight:700;src:url(/cf-fonts/v/inter/5.0.16/greek/wght/normal.woff2);unicode-range:U+0370-03FF;font-display:swap;}</style>
8
+ <style>
9
+ :root {
10
+ --primary: #3498db;
11
+ --primary-hover: #1575b5;
12
+ --secondary: #64748B;
13
+ --success: #10B981;
14
+ --danger: #EF4444;
15
+ --warning: #F59E0B;
16
+ --bg-light: #F8FAFC;
17
+ --bg-white: #FFFFFF;
18
+ --text-dark: #1F2937;
19
+ --text-muted: #64748B;
20
+ --border: #E2E8F0;
21
+ --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
22
+ --card-border: #E2E8F0;
23
+ --progress-bg: #E2E8F0;
24
+ --status-active-bg: rgba(16, 185, 129, 0.1);
25
+ --status-expired-bg: rgba(239, 68, 68, 0.1);
26
+ --progress-fill-success: #10B981;
27
+ --progress-fill-warning: #F59E0B;
28
+ --progress-fill-danger: #EF4444;
29
+ }
30
+
31
+ * { box-sizing: border-box; margin: 0; padding: 0; }
32
+ body { font-family: 'Inter', sans-serif; background: var(--bg-light); color: var(--text-dark); line-height: 1.6; min-height: 100vh; padding-top: 5rem; }
33
+ .container { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }
34
+ .card { background: var(--bg-white); border-radius: 0.75rem; box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; border: 1px solid var(--card-border); }
35
+
36
+ .search-section {
37
+ position: fixed;
38
+ top: 0;
39
+ left: 0;
40
+ right: 0;
41
+ z-index: 100;
42
+ background: var(--bg-white);
43
+ box-shadow: var(--shadow);
44
+ padding: 1rem 1.5rem;
45
+ margin: 0;
46
+ }
47
+ .search-section .card {
48
+ padding: 0;
49
+ margin: 0;
50
+ box-shadow: none;
51
+ border: none;
52
+ }
53
+ .search-input {
54
+ width: 100%;
55
+ padding: 0.75rem 1rem 0.75rem 2.5rem;
56
+ border: 1px solid #CBD5E1;
57
+ border-radius: 0.5rem;
58
+ font-size: 0.9rem;
59
+ background: #F9FAFB url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="%2364748B" stroke-width="2"><circle cx="7" cy="7" r="5"/><path d="M11 11l4 4"/></svg>') no-repeat 0.75rem center;
60
+ transition: border-color 0.2s ease, box-shadow 0.2s ease;
61
+ }
62
+ .search-input:focus {
63
+ border-color: #0f5fc3;
64
+ outline: none;
65
+ box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
66
+ }
67
+ .btn-base { padding: 0.5rem 1rem; border-radius: 0.5rem; border: none; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 0.5rem; transition: transform 0.2s ease, background 0.3s ease, box-shadow 0.2s ease; }
68
+ .btn { background: linear-gradient(135deg, var(--primary) 0%, #0f5fc3 100%); color: white; }
69
+ .btn:hover { background: linear-gradient(135deg, var(--primary-hover) 0%, #0f5fc3 100%); transform: translateY(-2px); box-shadow: 0 4px 15px rgba(107, 70, 193, 0.3); }
70
+ .btn-secondary { background: linear-gradient(135deg, var(--primary) 0%, #0f5fc3 100%); color: white; width: 2rem; height: 2rem; padding: 0; justify-content: center; }
71
+ .btn-secondary:hover { background: linear-gradient(135deg, var(--primary-hover) 0%, #0f5fc3 100%); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(107, 70, 193, 0.3); }
72
+ .btn-danger { background: var(--danger); width: 2rem; height: 2rem; padding: 0; justify-content: center; }
73
+ .btn-danger:hover { background: #DC2626; }
74
+ .token-manage-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1rem; }
75
+ .input-group { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
76
+ .input-field { flex: 1; min-width: 0; padding: 0.75rem; border: 1px solid #CBD5E1; border-radius: 0.5rem; font-size: 0.9rem; background: #F9FAFB; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
77
+ .input-field:focus { border-color: #0f5fc3; outline: none; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2); }
78
+ #statusFilter, #modelSelect { background: #F9FAFB; border: 1px solid #CBD5E1; color: var(--text-dark); }
79
+ #statusFilter:focus, #modelSelect:focus { border-color: #0f5fc3; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2); }
80
+ .token-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
81
+ .token-card { background: var(--bg-white); border: 1px solid var(--card-border); border-radius: 0.75rem; box-shadow: var(--shadow); padding: 1rem; display: flex; flex-direction: column; gap: 1rem; transition: transform 0.2s ease; max-width: 100%; overflow: hidden; }
82
+ .token-card:hover { transform: translateY(-4px); }
83
+ .token-checkbox { display: none; }
84
+ .token-checkbox.show { display: block; position: absolute; top: 1rem; left: 1rem; }
85
+ .token-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.75rem; }
86
+ .token-title { font-weight: 600; font-size: 0.9rem; color: var(--text-dark); flex: 1 1 auto; max-width: calc(100% - 80px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
87
+ .token-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
88
+ .model-list { display: grid; gap: 0.75rem; }
89
+ .model-item { display: grid; grid-template-columns: 1fr 2fr 80px; gap: 0.5rem; align-items: center; padding: 0.5rem; background: rgba(248, 250, 252, 0.5); border-radius: 0.5rem; }
90
+ .model-name { font-size: 0.85rem; font-weight: 500; color: var(--text-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
91
+ .progress-container { display: flex; align-items: center; gap: 0.5rem; }
92
+ .progress-bar { flex: 1; height: 0.375rem; background: var(--progress-bg); border-radius: 1rem; overflow: hidden; }
93
+ .progress-fill { height: 100%; border-radius: 1rem; transition: width 0.3s ease; }
94
+ .progress-text { font-size: 0.75rem; color: var(--text-muted); min-width: 40px; }
95
+ .status { font-size: 0.75rem; padding: 0.25rem 0.75rem; border-radius: 1rem; text-align: center; font-weight: 500; }
96
+ .status-active { background: var(--status-active-bg); color: var(--success); }
97
+ .status-expired { background: var(--status-expired-bg); color: var(--danger); position: relative; }
98
+ .status-expired .tooltip { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--text-dark); color: white; padding: 0.25rem 0.5rem; border-radius: 0.25rem; font-size: 0.75rem; white-space: nowrap; opacity: 0; visibility: hidden; transition: opacity 0.2s; margin-bottom: 0.5rem; }
99
+ .status-expired:hover .tooltip { opacity: 1; visibility: visible; }
100
+ .notification { position: fixed; top: 5rem; left: 50%; transform: translateX(-50%); background: var(--primary); color: white; padding: 0.75rem 1.5rem; border-radius: 0.5rem; box-shadow: var(--shadow); z-index: 1000; display: none; animation: slideIn 0.3s ease; }
101
+ @keyframes slideIn { from { transform: translateX(-50%) translateY(-100%); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
102
+
103
+ .overview-section { background: var(--bg-white); border-radius: 1rem; padding: 1.5rem; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06); position: relative; overflow: hidden; }
104
+ .overview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
105
+ .overview-title { font-size: 1.5rem; font-weight: 700; color: var(--text-dark); }
106
+ .overview-actions { display: flex; gap: 0.75rem; }
107
+ .overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
108
+ .overview-card { background: linear-gradient(135deg, #F9FAFB 0%, #F1F5F9 100%); border-radius: 0.75rem; padding: 1rem; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04); transition: transform 0.2s ease, box-shadow 0.2s ease; display: flex; align-items: center; gap: 1rem; position: relative; border: 1px solid rgba(107, 70, 193, 0.1); }
109
+ .overview-card:hover { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(107, 70, 193, 0.15); }
110
+ .overview-icon { width: 2.5rem; height: 2.5rem; background: linear-gradient(135deg, rgba(107, 70, 193, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%); border-radius: 0.5rem; display: flex; align-items: center; justify-content: center; color: var(--primary); flex-shrink: 0; }
111
+ .overview-content { display: flex; flex-direction: column; gap: 0.25rem; }
112
+ .overview-label { font-size: 0.9rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05px; }
113
+ .overview-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
114
+ .overview-card::after { content: attr(data-tooltip); position: absolute; top: -2.5rem; left: 50%; transform: translateX(-50%); background: rgba(31, 41, 55, 0.9); color: white; padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: 0.85rem; white-space: nowrap; opacity: 0; visibility: hidden; transition: opacity 0.2s ease; pointer-events: none; }
115
+ .overview-card:hover::after { opacity: 1; visibility: visible; }
116
+
117
+ .pagination { display: flex; justify-content: center; align-items: center; gap: 0.5rem; margin-top: 1.5rem; }
118
+ .pagination-btn { padding: 0.5rem 1rem; border-radius: 0.5rem; border: 1px solid var(--border); background: var(--bg-white); cursor: pointer; font-size: 0.9rem; transition: background 0.2s ease; }
119
+ .pagination-btn:hover { background: var(--bg-light); }
120
+ .pagination-btn:disabled { opacity: 0.5; cursor: not-allowed; }
121
+ .pagination-select { padding: 0.5rem; border: 1px solid var(--border); border-radius: 0.5rem; font-size: 0.9rem; }
122
+
123
+ @media (max-width: 768px) {
124
+ .overview-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }
125
+ .overview-card { padding: 0.75rem; }
126
+ .overview-icon { width: 2rem; height: 2rem; }
127
+ .overview-value { font-size: 1.5rem; }
128
+ .overview-label { font-size: 0.85rem; }
129
+ .token-grid { grid-template-columns: 1fr; gap: 1rem; }
130
+ .token-card { padding: 0.75rem; }
131
+ }
132
+
133
+ @media (min-width: 768px) {
134
+ .token-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
135
+ .token-card { min-height: 240px; }
136
+ .token-manage-grid { grid-template-columns: repeat(2, 1fr); }
137
+ }
138
+
139
+ @media (max-width: 480px) {
140
+ body { padding: 5rem 1rem 1rem; }
141
+ .card { padding: 1rem; }
142
+ .overview-section { padding: 1rem; }
143
+ .overview-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
144
+ .overview-actions { width: 100%; justify-content: flex-end; }
145
+ .overview-grid { grid-template-columns: 1fr; gap: 0.75rem; }
146
+ .overview-card { padding: 1rem; }
147
+ .overview-value { font-size: 1.5rem; }
148
+ .search-section { padding: 0.5rem 1rem; }
149
+ .search-section .input-group { flex-direction: column; gap: 0.5rem; }
150
+ .search-input, #statusFilter { width: 100%; }
151
+ .pagination { flex-wrap: wrap; gap: 0.75rem; }
152
+ .input-group label { width: 100%; margin-bottom: 0.5rem; }
153
+ .input-field { width: 100%; }
154
+ }
155
+ </style>
156
+ </head>
157
+ <body>
158
+ <div class="search-section">
159
+ <div class="card">
160
+ <div class="input-group">
161
+ <input type="text" class="search-input" id="searchInput" placeholder="搜索 Token..." aria-label="搜索 Token" style="flex: 1;">
162
+ <select class="input-field" id="statusFilter" style="width: 120px;" aria-label="筛选 Token 状态">
163
+ <option value="all">全部</option>
164
+ <option value="active">活跃</option>
165
+ <option value="expired">失效</option>
166
+ </select>
167
+ </div>
168
+ </div>
169
+ </div>
170
+
171
+ <div class="container">
172
+ <div class="overview-section card">
173
+ <div class="overview-header">
174
+ <h2 class="overview-title">概览</h2>
175
+ <div class="overview-actions">
176
+ <button class="btn btn-base" id="batchDeleteTokens" aria-label="批量删除选中的 Token">
177
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
178
+ <path d="M3 6h18M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2M10 11v6M14 11v6M4 6v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6"/>
179
+ </svg>
180
+ 批量删除
181
+ </button>
182
+ <button class="btn btn-base" id="refreshTokens" aria-label="刷新 Token 列表">
183
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
184
+ <path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/>
185
+ <path d="M21 3v5h-5"/>
186
+ <path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/>
187
+ <path d="M3 21v-5h5"/>
188
+ </svg>
189
+ 刷新
190
+ </button>
191
+ </div>
192
+ </div>
193
+ <div class="overview-grid">
194
+ <div class="overview-card" data-tooltip="总共管理的Token数量">
195
+ <div class="overview-icon">
196
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
197
+ <path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/>
198
+ <rect x="8" y="2" width="8" height="4" rx="1"/>
199
+ </svg>
200
+ </div>
201
+ <div class="overview-content">
202
+ <span class="overview-label">Token 总数</span>
203
+ <span class="overview-value" id="totalTokens">0</span>
204
+ </div>
205
+ </div>
206
+ <div class="overview-card" data-tooltip="grok-2 模型剩余可用次数">
207
+ <div class="overview-icon">
208
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
209
+ <path d="M12 2v20M2 12h20"/>
210
+ </svg>
211
+ </div>
212
+ <div class="overview-content">
213
+ <span class="overview-label">grok-2</span>
214
+ <span class="overview-value" id="grok-2-count">0</span>
215
+ </div>
216
+ </div>
217
+ <div class="overview-card" data-tooltip="grok-3 模型剩余可用次数">
218
+ <div class="overview-icon">
219
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
220
+ <circle cx="12" cy="12" r="10"/>
221
+ <path d="M12 2v4M12 18v4"/>
222
+ </svg>
223
+ </div>
224
+ <div class="overview-content">
225
+ <span class="overview-label">grok-3</span>
226
+ <span class="overview-value" id="grok-3-count">0</span>
227
+ </div>
228
+ </div>
229
+ <div class="overview-card" data-tooltip="grok-3-deepsearch 模型剩余可用次数">
230
+ <div class="overview-icon">
231
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
232
+ <circle cx="11" cy="11" r="8"/>
233
+ <path d="M21 21l-4.35-4.35"/>
234
+ </svg>
235
+ </div>
236
+ <div class="overview-content">
237
+ <span class="overview-label">grok-3-deepsearch</span>
238
+ <span class="overview-value" id="grok-3-deepsearch-count">0</span>
239
+ </div>
240
+ </div>
241
+ <div class="overview-card" data-tooltip="grok-3-deepersearch 模型剩余可用次数">
242
+ <div class="overview-icon">
243
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
244
+ <circle cx="11" cy="11" r="8"/>
245
+ <path d="M21 21l-4.35-4.35"/>
246
+ </svg>
247
+ </div>
248
+ <div class="overview-content">
249
+ <span class="overview-label">grok-3-deepersearch</span>
250
+ <span class="overview-value" id="grok-3-deepersearch-count">0</span>
251
+ </div>
252
+ </div>
253
+ <div class="overview-card" data-tooltip="grok-3-reasoning 模型剩余可用次数">
254
+ <div class="overview-icon">
255
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
256
+ <path d="M12 2a10 10 0 0 0-10 10c0 5 8 13 10 13s10-8 10-13a10 10 0 0 0-10-10z"/>
257
+ </svg>
258
+ </div>
259
+ <div class="overview-content">
260
+ <span class="overview-label">grok-3-reasoning</span>
261
+ <span class="overview-value" id="grok-3-reasoning-count">0</span>
262
+ </div>
263
+ </div>
264
+ </div>
265
+ </div>
266
+
267
+ <div class="card">
268
+ <h3>Token 管理</h3>
269
+ <div class="token-manage-grid">
270
+ <div>
271
+ <h4 style="margin-bottom: 0.75rem;">添加单个 SSO Token</h4>
272
+ <div class="input-group">
273
+ <input type="text" class="input-field" id="singleTokenInput" placeholder="输入单个 SSO Token" aria-label="输入单个 SSO Token">
274
+ <button class="btn btn-base" id="addSingleTokenBtn" aria-label="添加单个 SSO Token">添加</button>
275
+ </div>
276
+ </div>
277
+ <div>
278
+ <h4 style="margin-bottom: 0.75rem;">设置 CF Clearance</h4>
279
+ <div class="input-group">
280
+ <input type="text" class="input-field" id="cfInput" placeholder="输入 CF Clearance" aria-label="输入 CF Clearance">
281
+ <button class="btn btn-base" id="setCfBtn" aria-label="设置 CF Clearance">设置</button>
282
+ </div>
283
+ </div>
284
+ <div>
285
+ <h4 style="margin-bottom: 0.75rem;">批量添加 SSO Token</h4>
286
+ <div class="input-group">
287
+ <input type="text" class="input-field" id="batchTokenInput" placeholder="输入多个 SSO Token(用逗号隔开,如 ey1,ey2)" aria-label="输入多个 SSO Token">
288
+ <button class="btn btn-base" id="addBatchTokenBtn" aria-label="批量添加 SSO Token">添加</button>
289
+ </div>
290
+ </div>
291
+ <div>
292
+ <h4 style="margin-bottom: 0.75rem;">检测模型可用性</h4>
293
+ <div class="input-group">
294
+ <select class="input-field" id="modelSelect" style="width: 150px;" aria-label="选择要检测的模型">
295
+ <option value="grok-2">grok-2</option>
296
+ <option value="grok-3" selected>grok-3</option>
297
+ <option value="grok-3-reasoning">grok-3-reasoning</option>
298
+ <option value="grok-3-deepsearch">grok-3-deepsearch</option>
299
+ </select>
300
+ <button class="btn btn-base" id="testAvailabilityBtn" aria-label="检测模型可用性">检测</button>
301
+ </div>
302
+ </div>
303
+ <div>
304
+ <h4 style="margin-bottom: 0.75rem;">Base URL</h4>
305
+ <div class="input-group">
306
+ <input type="text" class="input-field" id="baseUrl" readonly aria-label="Base URL" value="">
307
+ <button class="btn btn-base" id="copyBaseUrlBtn" aria-label="复制 Base URL">
308
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
309
+ <rect x="9" y="9" width="13" height="13" rx="2"/>
310
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
311
+ </svg>
312
+ 复制
313
+ </button>
314
+ </div>
315
+ </div>
316
+ <div>
317
+ <h4 style="margin-bottom: 0.75rem;">API Key</h4>
318
+ <div class="input-group">
319
+ <input type="text" class="input-field" id="apiKey" aria-label="API Key">
320
+ <button class="btn btn-base" id="copyApiKeyBtn" aria-label="复制 API Key">
321
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
322
+ <rect x="9" y="9" width="13" height="13" rx="2"/>
323
+ <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/>
324
+ </svg>
325
+ 复制
326
+ </button>
327
+ </div>
328
+ </div>
329
+ </div>
330
+ </div>
331
+
332
+ <div class="token-grid" id="tokenGrid"></div>
333
+ <div class="pagination" id="pagination">
334
+ <button class="pagination-btn" id="prevPage" aria-label="上一页">上一页</button>
335
+ <select class="pagination-select" id="pageSelect" aria-label="选择页面"></select>
336
+ <button class="pagination-btn" id="nextPage" aria-label="下一页">下一页</button>
337
+ </div>
338
+ </div>
339
+
340
+ <div class="notification" id="notification"></div>
341
+
342
+ <script>
343
+ var modelConfig = {
344
+ "grok-3": { RequestFrequency: 20, ExpirationTime: 7200000 },
345
+ "grok-3-deepsearch": { RequestFrequency: 10, ExpirationTime: 86400000 },
346
+ "grok-3-deepersearch": { RequestFrequency: 3, ExpirationTime: 86400000 },
347
+ "grok-3-reasoning": { RequestFrequency: 10, ExpirationTime: 86400000 },
348
+ "grok-4": { RequestFrequency: 20, ExpirationTime: 7200000 }
349
+ };
350
+
351
+ let tokenMap = {};
352
+ let batchDeleteMode = false;
353
+ let lastUpdateTime = 0;
354
+ let currentPage = 1;
355
+ const itemsPerPage = 30;
356
+
357
+ function getProgressColor(percentage, isValid) {
358
+ if (!isValid) return '#94A3B8';
359
+ if (percentage > 70) return 'var(--progress-fill-danger)';
360
+ if (percentage > 30) return 'var(--progress-fill-warning)';
361
+ return 'var(--progress-fill-success)';
362
+ }
363
+
364
+ function calculateModelRemaining() {
365
+ const modelRemaining = {};
366
+ Object.keys(modelConfig).forEach(modelName => {
367
+ var maxRequests = modelConfig[modelName].RequestFrequency;
368
+ modelRemaining[modelName] = 0;
369
+ Object.values(tokenMap).forEach(tokenData => {
370
+ const modelData = tokenData[modelName];
371
+ if(modelData){
372
+ if (!modelData.isSuper) {
373
+ modelRemaining[modelName] = 0;
374
+ }
375
+ else if (modelData.isValid) {
376
+ modelRemaining[modelName] += maxRequests - modelData.totalRequestCount;
377
+ }
378
+ }
379
+ });
380
+ });
381
+ return modelRemaining;
382
+ }
383
+
384
+ function updateTokenCounters() {
385
+ const totalTokensElement = document.getElementById('totalTokens');
386
+ if (totalTokensElement) {
387
+ totalTokensElement.textContent = Object.keys(tokenMap).length;
388
+ } else {
389
+ console.warn('Element with ID "totalTokens" not found.');
390
+ }
391
+
392
+ const modelRemaining = calculateModelRemaining();
393
+ const modelIds = ['grok-3', 'grok-3-deepsearch', 'grok-3-deepersearch', 'grok-3-reasoning','grok-4'];
394
+ modelIds.forEach(modelName => {
395
+ const countElement = document.getElementById(`${modelName}-count`);
396
+ if (countElement) {
397
+ countElement.textContent = modelRemaining[modelName] || 0;
398
+ } else {
399
+ console.warn(`Element with ID "${modelName}-count" not found.`);
400
+ }
401
+ });
402
+ }
403
+
404
+ async function updateExpiredTokenTimers() {
405
+ const currentTime = Date.now();
406
+ if (currentTime - lastUpdateTime < 5000) return;
407
+
408
+ let shouldRefresh = false;
409
+ Object.values(tokenMap).forEach(tokenData => {
410
+ Object.entries(tokenData).forEach(([modelName, modelData]) => {
411
+ if (!modelData.isValid) {
412
+ if(modelData.isSuper){
413
+ ExpirationTime = 3 * 60 * 60 * 1000;
414
+ }else{
415
+ ExpirationTime = modelConfig[modelName].ExpirationTime;
416
+ }
417
+ const recoveryTime = modelData.invalidatedTime + ExpirationTime;
418
+ if (recoveryTime <= currentTime) {
419
+ shouldRefresh = true;
420
+ }
421
+ }
422
+ });
423
+ });
424
+
425
+ if (shouldRefresh) {
426
+ lastUpdateTime = currentTime;
427
+ await fetchTokenMap();
428
+ showNotification('Token 状态已自动更新');
429
+ } else {
430
+ renderTokenDiff(tokenMap);
431
+ }
432
+ }
433
+
434
+ function getTooltipText(invalidatedTime, expirationTime) {
435
+ const currentTime = Date.now();
436
+ const recoveryTime = invalidatedTime + expirationTime;
437
+ const remainingTime = recoveryTime - currentTime;
438
+ if (remainingTime > 0) {
439
+ const minutes = Math.floor(remainingTime / 60000);
440
+ const seconds = Math.floor((remainingTime % 60000) / 1000);
441
+ return `${minutes}分${seconds}秒后恢复`;
442
+ }
443
+ return '已可恢复';
444
+ }
445
+
446
+ function createTokenCard(token, tokenData) {
447
+ const tokenCard = document.createElement('div');
448
+ tokenCard.className = 'token-card';
449
+ tokenCard.setAttribute('data-token', token);
450
+
451
+ const checkbox = document.createElement('input');
452
+ checkbox.type = 'checkbox';
453
+ checkbox.className = `token-checkbox ${batchDeleteMode ? 'show' : ''}`;
454
+ checkbox.value = token;
455
+
456
+ const tokenHeader = document.createElement('div');
457
+ tokenHeader.className = 'token-header';
458
+
459
+ const tokenTitle = document.createElement('div');
460
+ tokenTitle.className = 'token-title';
461
+ tokenTitle.textContent = token;
462
+ tokenTitle.title = token;
463
+
464
+ const tokenActions = document.createElement('div');
465
+ tokenActions.className = 'token-actions';
466
+
467
+ const copyBtn = document.createElement('button');
468
+ copyBtn.className = 'btn btn-secondary btn-base';
469
+ copyBtn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>';
470
+ copyBtn.setAttribute('aria-label', '复制 Token 到剪贴板');
471
+ copyBtn.addEventListener('click', async () => {
472
+ try {
473
+ await navigator.clipboard.writeText(token);
474
+ showNotification('Token 已复制到剪贴板');
475
+ } catch (err) {
476
+ showNotification('复制失败,请重试');
477
+ }
478
+ });
479
+
480
+ const deleteBtn = document.createElement('button');
481
+ deleteBtn.className = 'btn btn-danger btn-base';
482
+ deleteBtn.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 6h18M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2M10 11v6M14 11v6M4 6v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6"/></svg>';
483
+ deleteBtn.setAttribute('aria-label', `删除 Token ${token}`);
484
+ deleteBtn.addEventListener('click', async () => {
485
+ if (confirm(`确认删除 token: ${token}?`)) {
486
+ try {
487
+ const baseUrl = document.getElementById('baseUrl').value;
488
+ const response = await fetch(`${baseUrl}/manager/api/delete`, {
489
+ method: 'POST',
490
+ headers: { 'Content-Type': 'application/json' },
491
+ body: JSON.stringify({ sso: token })
492
+ });
493
+ if (response.ok) {
494
+ await fetchTokenMap();
495
+ showNotification('Token 删除成功');
496
+ } else {
497
+ showNotification('删除 Token 失败');
498
+ }
499
+ } catch (error) {
500
+ showNotification('删除 Token 出错');
501
+ }
502
+ }
503
+ });
504
+
505
+ tokenActions.appendChild(copyBtn);
506
+ tokenActions.appendChild(deleteBtn);
507
+ tokenHeader.appendChild(tokenTitle);
508
+ tokenHeader.appendChild(tokenActions);
509
+
510
+ const modelList = document.createElement('div');
511
+ modelList.className = 'model-list';
512
+
513
+ Object.entries(modelConfig).forEach(([modelName, config]) => {
514
+ const modelItem = document.createElement('div');
515
+ modelItem.className = 'model-item';
516
+
517
+ const modelNameSpan = document.createElement('div');
518
+ modelNameSpan.className = 'model-name';
519
+ modelNameSpan.textContent = modelName;
520
+
521
+ const progressContainer = document.createElement('div');
522
+ progressContainer.className = 'progress-container';
523
+
524
+ const progressBar = document.createElement('div');
525
+ progressBar.className = 'progress-bar';
526
+ const progressFill = document.createElement('div');
527
+ progressFill.className = 'progress-fill';
528
+
529
+ const modelData = tokenData[modelName];
530
+ if(!modelData) return;
531
+ const isSuper = modelData.isSuper;
532
+ let requestCount = modelData.totalRequestCount;
533
+ let maxRequests = config.RequestFrequency;
534
+ if (isSuper) {
535
+ switch (modelName) {
536
+ case "grok-3":
537
+ maxRequests = 100;
538
+ break;
539
+ case "grok-3-deepsearch":
540
+ maxRequests = 30;
541
+ break;
542
+ case "grok-3-deepersearch":
543
+ maxRequests = 10;
544
+ break;
545
+ case "grok-3-reasoning":
546
+ maxRequests = 30;
547
+ break;
548
+ case "grok-4":
549
+ maxRequests = 20;
550
+ }
551
+ }
552
+ const percentage = Math.min((requestCount / maxRequests) * 100, 100);
553
+
554
+ progressFill.style.width = `${percentage}%`;
555
+ progressFill.style.backgroundColor = getProgressColor(percentage, modelData.isValid);
556
+ progressBar.appendChild(progressFill);
557
+
558
+ const progressText = document.createElement('div');
559
+ progressText.className = 'progress-text';
560
+ progressText.textContent = `${requestCount}/${maxRequests}`;
561
+
562
+ const status = document.createElement('div');
563
+ status.className = 'status';
564
+ if (!modelData.isValid) {
565
+ if(modelData.isSuper){
566
+ ExpirationTime = 3 * 60 * 60 * 1000;
567
+ }
568
+ else{
569
+ ExpirationTime = config.ExpirationTime;
570
+ }
571
+ status.classList.add('status-expired');
572
+ status.textContent = '失效';
573
+ status.setAttribute('data-invalidated-time', modelData.invalidatedTime);
574
+ status.setAttribute('data-expiration-time', ExpirationTime);
575
+ const tooltip = document.createElement('div');
576
+ tooltip.className = 'tooltip';
577
+ tooltip.textContent = getTooltipText(modelData.invalidatedTime, ExpirationTime);
578
+ status.appendChild(tooltip);
579
+ } else {
580
+ status.classList.add('status-active');
581
+ status.textContent = '活跃';
582
+ }
583
+
584
+ progressContainer.appendChild(progressBar);
585
+ progressContainer.appendChild(progressText);
586
+
587
+ modelItem.appendChild(modelNameSpan);
588
+ modelItem.appendChild(progressContainer);
589
+ modelItem.appendChild(status);
590
+ modelList.appendChild(modelItem);
591
+ });
592
+
593
+ tokenCard.appendChild(checkbox);
594
+ tokenCard.appendChild(tokenHeader);
595
+ tokenCard.appendChild(modelList);
596
+ return tokenCard;
597
+ }
598
+
599
+ function updateTokenCard(token, tokenData) {
600
+ const tokenCard = document.querySelector(`[data-token="${token}"]`);
601
+ const modelItems = tokenCard.querySelectorAll('.model-item');
602
+ let index = 0;
603
+ Object.entries(modelConfig).forEach(([modelName, config]) => {
604
+ const modelItem = modelItems[index++];
605
+ const modelData = tokenData[modelName];
606
+ if(!modelData) return;
607
+ const isSuper = modelData.isSuper;
608
+ let requestCount = modelData.totalRequestCount;
609
+ let maxRequests = config.RequestFrequency;
610
+ if (isSuper) {
611
+ switch (modelName) {
612
+ case "grok-3":
613
+ maxRequests = 100;
614
+ break;
615
+ case "grok-3-deepsearch":
616
+ maxRequests = 30;
617
+ break;
618
+ case "grok-3-deepersearch":
619
+ maxRequests = 10;
620
+ break;
621
+ case "grok-3-reasoning":
622
+ maxRequests = 30;
623
+ break;
624
+ case "grok-4":
625
+ maxRequests = 20;
626
+ }
627
+ }
628
+ const percentage = Math.min((requestCount / maxRequests) * 100, 100);
629
+
630
+ const progressFill = modelItem.querySelector('.progress-fill');
631
+ progressFill.style.width = `${percentage}%`;
632
+ progressFill.style.backgroundColor = getProgressColor(percentage, modelData.isValid);
633
+
634
+ const progressText = modelItem.querySelector('.progress-text');
635
+ progressText.textContent = `${requestCount}/${maxRequests}`;
636
+
637
+ const status = modelItem.querySelector('.status');
638
+ status.className = 'status';
639
+ if (!modelData.isValid) {
640
+ if(modelData.isSuper){
641
+ ExpirationTime = 3 * 60 * 60 * 1000;
642
+ }
643
+ else{
644
+ ExpirationTime = config.ExpirationTime;
645
+ }
646
+ status.classList.add('status-expired');
647
+ status.textContent = '失效';
648
+ status.setAttribute('data-invalidated-time', modelData.invalidatedTime);
649
+ status.setAttribute('data-expiration-time', ExpirationTime);
650
+ const tooltip = status.querySelector('.tooltip') || document.createElement('div');
651
+ tooltip.className = 'tooltip';
652
+ tooltip.textContent = getTooltipText(modelData.invalidatedTime, ExpirationTime);
653
+ if (!status.contains(tooltip)) status.appendChild(tooltip);
654
+ } else {
655
+ status.classList.add('status-active');
656
+ status.textContent = '活跃';
657
+ const tooltip = status.querySelector('.tooltip');
658
+ if (tooltip) tooltip.remove();
659
+ }
660
+ });
661
+ const checkbox = tokenCard.querySelector('.token-checkbox');
662
+ checkbox.className = `token-checkbox ${batchDeleteMode ? 'show' : ''}`;
663
+ }
664
+
665
+ function renderTokenDiff(newTokenMap) {
666
+ const tokenGrid = document.getElementById('tokenGrid');
667
+ if (!tokenGrid) {
668
+ console.error('Token grid element not found.');
669
+ return;
670
+ }
671
+ const existingTokens = new Set(Array.from(tokenGrid.children).map(card => card.getAttribute('data-token')));
672
+ const filteredTokens = filterTokensArray(Object.entries(newTokenMap));
673
+ const totalItems = filteredTokens.length;
674
+ const totalPages = Math.ceil(totalItems / itemsPerPage);
675
+ currentPage = Math.min(currentPage, totalPages) || 1;
676
+
677
+ const startIndex = (currentPage - 1) * itemsPerPage;
678
+ const endIndex = Math.min(startIndex + itemsPerPage, totalItems);
679
+ const tokensToRender = filteredTokens.slice(startIndex, endIndex);
680
+
681
+ const newTokens = new Set(tokensToRender.map(([token]) => token));
682
+
683
+ existingTokens.forEach(token => {
684
+ if (!newTokens.has(token)) {
685
+ tokenGrid.querySelector(`[data-token="${token}"]`).remove();
686
+ }
687
+ });
688
+
689
+ tokensToRender.forEach(([token, tokenData]) => {
690
+ if (!existingTokens.has(token)) {
691
+ const tokenCard = createTokenCard(token, tokenData);
692
+ tokenGrid.appendChild(tokenCard);
693
+ } else {
694
+ updateTokenCard(token, tokenData);
695
+ }
696
+ });
697
+
698
+ updateTokenCounters();
699
+ renderPagination(totalPages);
700
+ }
701
+
702
+ function filterTokensArray(tokenEntries) {
703
+ const searchInput = document.getElementById('searchInput');
704
+ const statusFilter = document.getElementById('statusFilter');
705
+ if (!searchInput || !statusFilter) {
706
+ console.error('Search input or status filter element not found.');
707
+ return tokenEntries;
708
+ }
709
+ const searchTerm = searchInput.value.toLowerCase();
710
+ const statusFilterValue = statusFilter.value;
711
+
712
+ return tokenEntries.filter(([token, tokenData]) => {
713
+ const hasActive = Object.values(tokenData).some(data => data.isValid);
714
+ const hasExpired = Object.values(tokenData).some(data => !data.isValid);
715
+
716
+ let display = true;
717
+ if (!token.toLowerCase().includes(searchTerm)) display = false;
718
+ if (statusFilterValue === 'active' && !hasActive) display = false;
719
+ if (statusFilterValue === 'expired' && !hasExpired) display = false;
720
+
721
+ return display;
722
+ });
723
+ }
724
+
725
+ function renderPagination(totalPages) {
726
+ const pageSelect = document.getElementById('pageSelect');
727
+ if (!pageSelect) {
728
+ console.error('Page select element not found.');
729
+ return;
730
+ }
731
+ pageSelect.innerHTML = '';
732
+ for (let i = 1; i <= totalPages; i++) {
733
+ const option = document.createElement('option');
734
+ option.value = i;
735
+ option.textContent = `第 ${i} 页`;
736
+ if (i === currentPage) option.selected = true;
737
+ pageSelect.appendChild(option);
738
+ }
739
+
740
+ const prevPage = document.getElementById('prevPage');
741
+ const nextPage = document.getElementById('nextPage');
742
+ if (prevPage) prevPage.disabled = currentPage === 1;
743
+ if (nextPage) nextPage.disabled = currentPage === totalPages || totalPages === 0;
744
+ }
745
+
746
+ async function fetchTokenMap() {
747
+ console.log('开始获取 tokenMap');
748
+ try {
749
+ const baseUrlElement = document.getElementById('baseUrl');
750
+ if (!baseUrlElement) {
751
+ throw new Error('Base URL 元素未找到');
752
+ }
753
+ const baseUrl = baseUrlElement.value;
754
+ console.log('请求 URL:', `${baseUrl}/manager/api/get`);
755
+ const response = await fetch(`${baseUrl}/manager/api/get`);
756
+ if (!response.ok) {
757
+ const errorText = await response.text();
758
+ throw new Error(`获取 Token 失败: ${response.status} - ${errorText}`);
759
+ }
760
+ const data = await response.json();
761
+ console.log('获取到的数据:', data);
762
+ if (!data || typeof data !== 'object') {
763
+ throw new Error('返回的数据不是有效的 Token Map');
764
+ }
765
+ tokenMap = data;
766
+ renderTokenDiff(tokenMap);
767
+ console.log('tokenMap 更新成功');
768
+ } catch (error) {
769
+ console.error('获取 Token 出错:', error);
770
+ showNotification(`获取 Token 出错: ${error.message}`);
771
+ }
772
+ }
773
+
774
+ document.addEventListener('DOMContentLoaded', () => {
775
+ const baseUrlInput = document.getElementById('baseUrl');
776
+ if (baseUrlInput) {
777
+ baseUrlInput.value = window.location.origin;
778
+ } else {
779
+ console.error('Base URL input element not found.');
780
+ }
781
+
782
+ const apiKeyInput = document.getElementById('apiKey');
783
+ if (apiKeyInput) {
784
+ const savedApiKey = localStorage.getItem('apiKey');
785
+ apiKeyInput.value = savedApiKey || 'sk-1234567';
786
+ apiKeyInput.addEventListener('change', () => {
787
+ const newApiKey = apiKeyInput.value.trim();
788
+ if (newApiKey) {
789
+ localStorage.setItem('apiKey', newApiKey);
790
+ showNotification(`API Key 已更新为: ${newApiKey}`);
791
+ } else {
792
+ apiKeyInput.value = localStorage.getItem('apiKey') || 'sk-1234567';
793
+ showNotification('API Key 不能为空,已恢复为上次保存的值');
794
+ }
795
+ });
796
+ } else {
797
+ console.error('API Key input element not found.');
798
+ }
799
+
800
+ const copyBaseUrlBtn = document.getElementById('copyBaseUrlBtn');
801
+ if (copyBaseUrlBtn) {
802
+ copyBaseUrlBtn.addEventListener('click', async () => {
803
+ try {
804
+ await navigator.clipboard.writeText(baseUrlInput.value);
805
+ showNotification('Base URL 已复制到剪贴板');
806
+ } catch (err) {
807
+ showNotification('复制失败,请重试');
808
+ }
809
+ });
810
+ }
811
+
812
+ const copyApiKeyBtn = document.getElementById('copyApiKeyBtn');
813
+ if (copyApiKeyBtn) {
814
+ copyApiKeyBtn.addEventListener('click', async () => {
815
+ try {
816
+ await navigator.clipboard.writeText(apiKeyInput.value);
817
+ showNotification('API Key 已复制到剪贴板');
818
+ } catch (err) {
819
+ showNotification('复制失败,请重试');
820
+ }
821
+ });
822
+ }
823
+
824
+ const addSingleTokenBtn = document.getElementById('addSingleTokenBtn');
825
+ if (addSingleTokenBtn) {
826
+ addSingleTokenBtn.addEventListener('click', async () => {
827
+ const tokenInput = document.getElementById('singleTokenInput');
828
+ const tokenText = tokenInput.value.trim();
829
+ if (tokenText) {
830
+ try {
831
+ const baseUrl = document.getElementById('baseUrl').value;
832
+ const response = await fetch(`${baseUrl}/manager/api/add`, {
833
+ method: 'POST',
834
+ headers: { 'Content-Type': 'application/json' },
835
+ body: JSON.stringify({ sso: tokenText })
836
+ });
837
+ if (response.ok) {
838
+ tokenInput.value = '';
839
+ await fetchTokenMap();
840
+ showNotification('Token 添加成功');
841
+ } else {
842
+ showNotification('添加 Token 失败');
843
+ }
844
+ } catch (error) {
845
+ showNotification('添加 Token 出错');
846
+ }
847
+ } else {
848
+ showNotification('请输入 Token');
849
+ }
850
+ });
851
+ }
852
+
853
+ const addBatchTokenBtn = document.getElementById('addBatchTokenBtn');
854
+ if (addBatchTokenBtn) {
855
+ addBatchTokenBtn.addEventListener('click', async () => {
856
+ const tokenInput = document.getElementById('batchTokenInput');
857
+ const tokenText = tokenInput.value.trim();
858
+ if (tokenText) {
859
+ const tokens = tokenText.split(',').map(t => t.trim()).filter(t => t.length > 0);
860
+ if (tokens.length === 0) {
861
+ showNotification('请输入至少一个有效的 Token');
862
+ return;
863
+ }
864
+ try {
865
+ const baseUrl = document.getElementById('baseUrl').value;
866
+ const successes = [];
867
+ const failures = [];
868
+ for (const token of tokens) {
869
+ const response = await fetch(`${baseUrl}/manager/api/add`, {
870
+ method: 'POST',
871
+ headers: { 'Content-Type': 'application/json' },
872
+ body: JSON.stringify({ sso: token })
873
+ });
874
+ if (response.ok) {
875
+ successes.push(token);
876
+ } else {
877
+ failures.push(token);
878
+ }
879
+ }
880
+ tokenInput.value = '';
881
+ await fetchTokenMap();
882
+ if (successes.length > 0 && failures.length === 0) {
883
+ showNotification(`成功添加 ${successes.length} 个 Token`);
884
+ } else if (successes.length > 0 && failures.length > 0) {
885
+ showNotification(`成功添加 ${successes.length} 个 Token,失败 ${failures.length} 个`);
886
+ } else {
887
+ showNotification('所有 Token 添加失败');
888
+ }
889
+ } catch (error) {
890
+ showNotification('添加 Token 时出错');
891
+ }
892
+ } else {
893
+ showNotification('请输入 Token');
894
+ }
895
+ });
896
+ }
897
+
898
+ const setCfBtn = document.getElementById('setCfBtn');
899
+ if (setCfBtn) {
900
+ setCfBtn.addEventListener('click', async () => {
901
+ const cfInput = document.getElementById('cfInput');
902
+ const newCf = cfInput.value.trim();
903
+ if (newCf) {
904
+ try {
905
+ const baseUrl = document.getElementById('baseUrl').value;
906
+ const response = await fetch(`${baseUrl}/manager/api/cf_clearance`, {
907
+ method: 'POST',
908
+ headers: { 'Content-Type': 'application/json' },
909
+ body: JSON.stringify({ cf_clearance: newCf })
910
+ });
911
+ if (response.ok) {
912
+ cfInput.value = '';
913
+ showNotification('CF Clearance 设置成功');
914
+ } else {
915
+ showNotification('设置 CF Clearance 失败');
916
+ }
917
+ } catch (error) {
918
+ showNotification('设置 CF Clearance 出错');
919
+ }
920
+ }
921
+ });
922
+ }
923
+
924
+ const testAvailabilityBtn = document.getElementById('testAvailabilityBtn');
925
+ if (testAvailabilityBtn) {
926
+ testAvailabilityBtn.addEventListener('click', async () => {
927
+ const selectedModel = document.getElementById('modelSelect').value;
928
+ const baseUrl = document.getElementById('baseUrl').value;
929
+ const apiKey = document.getElementById('apiKey').value.trim();
930
+ const apiUrl = `${baseUrl}/v1/chat/completions`;
931
+ try {
932
+ const response = await fetch(apiUrl, {
933
+ method: 'POST',
934
+ headers: {
935
+ 'Content-Type': 'application/json',
936
+ 'Authorization': `Bearer ${apiKey}`
937
+ },
938
+ body: JSON.stringify({
939
+ model: selectedModel,
940
+ messages: [{ role: 'user', content: 'Hello' }],
941
+ max_tokens: 10
942
+ })
943
+ });
944
+ if (response.ok) {
945
+ const data = await response.json();
946
+ if (data.choices && data.choices.length > 0) {
947
+ showNotification(`${selectedModel} 模型可用`);
948
+ } else {
949
+ showNotification(`${selectedModel} 模型不可用`);
950
+ }
951
+ } else {
952
+ const errorText = await response.text();
953
+ showNotification(`${selectedModel} 模型不可用(错误: ${response.status} - ${errorText})`);
954
+ }
955
+ } catch (error) {
956
+ console.error('检测模型出错:', error);
957
+ showNotification(`检测 ${selectedModel} 失败,请检查网络或接口`);
958
+ }
959
+ });
960
+ }
961
+
962
+ const batchDeleteTokens = document.getElementById('batchDeleteTokens');
963
+ if (batchDeleteTokens) {
964
+ batchDeleteTokens.addEventListener('click', async () => {
965
+ if (!batchDeleteMode) {
966
+ batchDeleteMode = true;
967
+ renderTokenDiff(tokenMap);
968
+ showNotification('请选择要删除的 Token');
969
+ } else {
970
+ const selectedTokens = Array.from(document.querySelectorAll('.token-checkbox:checked')).map(cb => cb.value);
971
+ if (selectedTokens.length === 0) {
972
+ showNotification('请至少选择一个 Token');
973
+ return;
974
+ }
975
+ if (confirm(`确认删除 ${selectedTokens.length} 个 Token?`)) {
976
+ try {
977
+ const baseUrl = document.getElementById('baseUrl').value;
978
+ const successes = [];
979
+ const failures = [];
980
+ for (const token of selectedTokens) {
981
+ const response = await fetch(`${baseUrl}/manager/api/delete`, {
982
+ method: 'POST',
983
+ headers: { 'Content-Type': 'application/json' },
984
+ body: JSON.stringify({ sso: token })
985
+ });
986
+ if (response.ok) {
987
+ successes.push(token);
988
+ } else {
989
+ failures.push(token);
990
+ }
991
+ }
992
+ batchDeleteMode = false;
993
+ await fetchTokenMap();
994
+ if (successes.length > 0 && failures.length === 0) {
995
+ showNotification(`成功删除 ${successes.length} 个 Token`);
996
+ } else if (successes.length > 0 && failures.length > 0) {
997
+ showNotification(`成功删除 ${successes.length} 个 Token,失败 ${failures.length} 个`);
998
+ } else {
999
+ showNotification('所有 Token 删除失败');
1000
+ }
1001
+ } catch (error) {
1002
+ showNotification('删除 Token 时出错');
1003
+ }
1004
+ }
1005
+ }
1006
+ });
1007
+ }
1008
+
1009
+ const searchInput = document.getElementById('searchInput');
1010
+ if (searchInput) searchInput.addEventListener('input', () => renderTokenDiff(tokenMap));
1011
+
1012
+ const statusFilter = document.getElementById('statusFilter');
1013
+ if (statusFilter) statusFilter.addEventListener('change', () => renderTokenDiff(tokenMap));
1014
+
1015
+ const refreshTokens = document.getElementById('refreshTokens');
1016
+ if (refreshTokens) {
1017
+ refreshTokens.addEventListener('click', async () => {
1018
+ await fetchTokenMap();
1019
+ showNotification('Token 列表已刷新');
1020
+ });
1021
+ } else {
1022
+ console.error('Refresh Tokens button not found.');
1023
+ }
1024
+
1025
+ const prevPage = document.getElementById('prevPage');
1026
+ if (prevPage) {
1027
+ prevPage.addEventListener('click', () => {
1028
+ if (currentPage > 1) {
1029
+ currentPage--;
1030
+ renderTokenDiff(tokenMap);
1031
+ }
1032
+ });
1033
+ }
1034
+
1035
+ const nextPage = document.getElementById('nextPage');
1036
+ if (nextPage) {
1037
+ nextPage.addEventListener('click', () => {
1038
+ const totalPages = Math.ceil(filterTokensArray(Object.entries(tokenMap)).length / itemsPerPage);
1039
+ if (currentPage < totalPages) {
1040
+ currentPage++;
1041
+ renderTokenDiff(tokenMap);
1042
+ }
1043
+ });
1044
+ }
1045
+
1046
+ const pageSelect = document.getElementById('pageSelect');
1047
+ if (pageSelect) {
1048
+ pageSelect.addEventListener('change', (e) => {
1049
+ currentPage = parseInt(e.target.value, 10);
1050
+ renderTokenDiff(tokenMap);
1051
+ });
1052
+ }
1053
+
1054
+ fetchTokenMap(); // 页面加载时获取 Token
1055
+
1056
+ let timer = setInterval(updateExpiredTokenTimers, 60000);
1057
+ document.addEventListener('visibilitychange', () => {
1058
+ if (document.hidden) {
1059
+ clearInterval(timer);
1060
+ } else {
1061
+ timer = setInterval(updateExpiredTokenTimers, 60000);
1062
+ }
1063
+ });
1064
+ });
1065
+
1066
+ function showNotification(message) {
1067
+ const notification = document.getElementById('notification');
1068
+ if (notification) {
1069
+ notification.textContent = message;
1070
+ notification.style.display = 'block';
1071
+ const duration = Math.max(2000, message.length * 100);
1072
+ setTimeout(() => {
1073
+ notification.style.display = 'none';
1074
+ }, duration);
1075
+ } else {
1076
+ console.warn('Notification element not found.');
1077
+ }
1078
+ }
1079
+ </script>
1080
+ </body>
1081
+ </html>