tomasdj commited on
Commit
dc05e5b
·
verified ·
1 Parent(s): 6eb7955

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +2007 -0
index.html ADDED
@@ -0,0 +1,2007 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN" data-theme="light">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Business Gemini Pool 管理控制台</title>
7
+ <style>
8
+ /* [OPTIMIZATION] 1. 全局样式优化与变量调整 */
9
+ :root {
10
+ /* 核心颜色保持不变 */
11
+ --primary: #4285f4;
12
+ --primary-hover: #3367d6;
13
+ --primary-light: rgba(66, 133, 244, 0.1);
14
+ --success: #34a853;
15
+ --success-light: rgba(52, 168, 83, 0.1);
16
+ --danger: #ea4335;
17
+ --danger-light: rgba(234, 67, 53, 0.1);
18
+ --warning: #fbbc04;
19
+ --warning-light: rgba(251, 188, 4, 0.1);
20
+
21
+ /* [NEW] 引入更精细的变量控制 */
22
+ --radius-sm: 6px;
23
+ --radius-md: 12px; /* 增大圆角,更柔和 */
24
+ --radius-lg: 16px;
25
+ --transition-ease: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); /* [NEW] 现代化的缓动函数 */
26
+
27
+ --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; /* [NEW] 引入更适合UI的字体 */
28
+ }
29
+
30
+ /* [OPTIMIZATION] 2. Light & Dark Theme 优化,增强对比度和质感 */
31
+ [data-theme="light"] {
32
+ --bg-color: #f7f8fc; /* 更柔和的背景色 */
33
+ --card-bg: #ffffff;
34
+ --text-main: #1f2328;
35
+ --text-muted: #656d76;
36
+ --border: #e4e7eb; /* 更浅的边框色 */
37
+ --hover-bg: #f2f3f5;
38
+ --input-bg: #ffffff;
39
+ --shadow-sm: 0 1px 2px 0 rgba(27, 31, 35, 0.04);
40
+ --shadow-md: 0 4px 8px 0 rgba(27, 31, 35, 0.06), 0 1px 2px 0 rgba(27, 31, 35, 0.05); /* 更柔和的阴影 */
41
+ --shadow-lg: 0 10px 20px 0 rgba(27, 31, 35, 0.07), 0 3px 6px 0 rgba(27, 31, 35, 0.05);
42
+ }
43
+
44
+ [data-theme="dark"] {
45
+ --bg-color: #1a1b1e;
46
+ --card-bg: #242528;
47
+ --text-main: #e8eaed;
48
+ --text-muted: #9aa0a6;
49
+ --border: #3a3c40;
50
+ --hover-bg: #303134;
51
+ --input-bg: #2f3033;
52
+ --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
53
+ --shadow-md: 0 4px 8px 0 rgba(0, 0, 0, 0.15), 0 1px 2px 0 rgba(0, 0, 0, 0.1);
54
+ --shadow-lg: 0 10px 20px 0 rgba(0, 0, 0, 0.2), 0 3px 6px 0 rgba(0, 0, 0, 0.15);
55
+ }
56
+
57
+ * {
58
+ margin: 0;
59
+ padding: 0;
60
+ box-sizing: border-box;
61
+ }
62
+
63
+ body {
64
+ font-family: var(--font-main);
65
+ background-color: var(--bg-color);
66
+ color: var(--text-main);
67
+ min-height: 100vh;
68
+ transition: background-color 0.3s, color 0.3s;
69
+ -webkit-font-smoothing: antialiased;
70
+ -moz-osx-font-smoothing: grayscale;
71
+ }
72
+
73
+ .container {
74
+ max-width: 1400px;
75
+ margin: 0 auto;
76
+ padding: 32px; /* 增加页面内边距 */
77
+ }
78
+
79
+ /* [OPTIMIZATION] 3. Header 重新设计,更简洁大气 */
80
+ .header {
81
+ display: flex;
82
+ justify-content: space-between;
83
+ align-items: center;
84
+ margin-bottom: 32px;
85
+ /* 移除背景和阴影,使其融入页面 */
86
+ }
87
+
88
+ .header-left { display: flex; align-items: center; gap: 16px; }
89
+
90
+ .logo {
91
+ width: 44px;
92
+ height: 44px;
93
+ background: linear-gradient(135deg, #4285f4, #34a853, #fbbc04, #ea4335);
94
+ border-radius: var(--radius-md);
95
+ display: flex;
96
+ align-items: center;
97
+ justify-content: center;
98
+ color: white;
99
+ font-weight: 600;
100
+ font-size: 22px;
101
+ transform: rotate(-10deg); /* [NEW] 增加一点趣味性 */
102
+ transition: var(--transition-ease);
103
+ }
104
+ .logo:hover { transform: rotate(0deg) scale(1.05); }
105
+
106
+ .header h1 {
107
+ font-size: 26px; /* 增大标题字号 */
108
+ font-weight: 600;
109
+ color: var(--text-main);
110
+ }
111
+
112
+ .header h1 span {
113
+ color: var(--text-muted);
114
+ font-weight: 400;
115
+ font-size: 16px;
116
+ margin-left: 10px;
117
+ }
118
+
119
+ .header-right { display: flex; align-items: center; gap: 16px; }
120
+
121
+ .status-indicator {
122
+ display: flex;
123
+ align-items: center;
124
+ gap: 8px;
125
+ padding: 8px 16px;
126
+ background: var(--success-light);
127
+ border: 1px solid rgba(52, 168, 83, 0.2);
128
+ border-radius: 50px; /* 改为胶囊形状 */
129
+ font-size: 14px;
130
+ color: var(--success);
131
+ font-weight: 500;
132
+ }
133
+ .status-indicator::before {
134
+ content: ''; width: 8px; height: 8px;
135
+ background: var(--success); border-radius: 50%;
136
+ animation: pulse 2s infinite;
137
+ }
138
+ @keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.7; transform: scale(0.9); } }
139
+
140
+ .theme-toggle {
141
+ width: 44px; height: 44px; border: 1px solid var(--border);
142
+ background: var(--card-bg); border-radius: var(--radius-md);
143
+ cursor: pointer; display: flex; align-items: center; justify-content: center;
144
+ font-size: 20px; transition: var(--transition-ease);
145
+ }
146
+ .theme-toggle:hover { background: var(--hover-bg); border-color: var(--primary); transform: translateY(-2px); }
147
+
148
+ /* [OPTIMIZATION] 4. Tabs 重新设计,更现代、更 subtle */
149
+ .tabs {
150
+ display: flex;
151
+ gap: 16px;
152
+ border-bottom: 1px solid var(--border); /* 底部线条导航 */
153
+ margin-bottom: 32px;
154
+ }
155
+ .tab {
156
+ padding: 14px 4px; /* 减少水平padding,通过gap控制间距 */
157
+ border: none; border-bottom: 2px solid transparent;
158
+ background: transparent; color: var(--text-muted);
159
+ font-size: 15px; font-weight: 500;
160
+ cursor: pointer; border-radius: 0;
161
+ transition: var(--transition-ease);
162
+ display: flex; align-items: center; justify-content: center;
163
+ gap: 8px;
164
+ }
165
+ .tab:hover { color: var(--primary); }
166
+ .tab.active { color: var(--primary); border-bottom-color: var(--primary); }
167
+ .tab-icon { font-size: 20px; }
168
+
169
+
170
+ /* Status Badge */
171
+ .badge {
172
+ display: inline-flex;
173
+ align-items: center;
174
+ gap: 6px;
175
+ padding: 6px 12px;
176
+ border-radius: 20px;
177
+ font-size: 12px;
178
+ font-weight: 500;
179
+ }
180
+
181
+ .badge::before {
182
+ content: '';
183
+ width: 6px;
184
+ height: 6px;
185
+ border-radius: 50%;
186
+ }
187
+
188
+ .badge-success {
189
+ background: var(--success-light);
190
+ color: var(--success);
191
+ }
192
+
193
+ .badge-success::before {
194
+ background: var(--success);
195
+ }
196
+
197
+ .badge-danger {
198
+ background: var(--danger-light);
199
+ color: var(--danger);
200
+ }
201
+
202
+ .badge-danger::before {
203
+ background: var(--danger);
204
+ }
205
+
206
+ .cooldown-hint {
207
+ display: block;
208
+ color: var(--text-muted);
209
+ font-size: 12px;
210
+ margin-top: 4px;
211
+ }
212
+
213
+ .log-level-control {
214
+ display: flex;
215
+ align-items: center;
216
+ gap: 8px;
217
+ background: var(--card-bg);
218
+ border: 1px solid var(--border);
219
+ border-radius: var(--radius-md);
220
+ padding: 6px 10px;
221
+ }
222
+ .log-level-control label {
223
+ font-size: 12px;
224
+ color: var(--text-muted);
225
+ }
226
+ .log-level-select {
227
+ border: 1px solid var(--border);
228
+ background: var(--input-bg);
229
+ color: var(--text-main);
230
+ border-radius: var(--radius-sm);
231
+ padding: 6px 8px;
232
+ }
233
+
234
+ .token-actions {
235
+ display: flex;
236
+ gap: 8px;
237
+ flex-wrap: wrap;
238
+ margin-bottom: 12px;
239
+ }
240
+ .token-input {
241
+ flex: 1;
242
+ min-width: 240px;
243
+ }
244
+
245
+ .badge-warning {
246
+ background: var(--warning-light);
247
+ color: #b06000;
248
+ }
249
+
250
+ .badge-warning::before {
251
+ background: var(--warning);
252
+ }
253
+
254
+ /* [OPTIMIZATION] 5. 动画效果增强 */
255
+ .tab-content { display: none; }
256
+ .tab-content.active { display: block; animation: contentFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
257
+ @keyframes contentFadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
258
+
259
+ /* [OPTIMIZATION] 6. Card 样式优化 */
260
+ .card {
261
+ background: var(--card-bg);
262
+ border-radius: var(--radius-lg);
263
+ box-shadow: var(--shadow-md);
264
+ border: 1px solid var(--border);
265
+ margin-bottom: 32px;
266
+ overflow: hidden;
267
+ transition: var(--transition-ease);
268
+ }
269
+ .card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-lg); }
270
+
271
+ .card-header {
272
+ display: flex; justify-content: space-between; align-items: center;
273
+ padding: 20px 24px; border-bottom: 1px solid var(--border);
274
+ }
275
+ .card-title {
276
+ font-size: 18px; font-weight: 600; color: var(--text-main);
277
+ display: flex; align-items: center; gap: 12px;
278
+ }
279
+ .card-title-icon { font-size: 22px; color: var(--text-muted); }
280
+ .card-body { padding: 24px; }
281
+
282
+ /* [OPTIMIZATION] 7. Button 样式优化 */
283
+ .btn {
284
+ padding: 10px 20px; border: none; border-radius: var(--radius-md);
285
+ cursor: pointer; font-size: 14px; font-weight: 500;
286
+ display: inline-flex; align-items: center; justify-content: center; gap: 8px;
287
+ transition: var(--transition-ease); text-decoration: none;
288
+ }
289
+ .btn:disabled { opacity: 0.5; cursor: not-allowed; }
290
+ .btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-md); }
291
+ .btn-primary { background: var(--primary); color: white; }
292
+ .btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
293
+
294
+ .btn-outline {
295
+ background: transparent; color: var(--text-muted);
296
+ border: 1px solid var(--border);
297
+ }
298
+ .btn-outline:hover:not(:disabled) { border-color: var(--text-main); color: var(--text-main); }
299
+ /* 其他按钮颜色保持 */
300
+ .btn-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(52, 168, 83, 0.2); }
301
+ .btn-success:hover:not(:disabled) { background: var(--success); color: white; border-color: var(--success); }
302
+ .btn-danger { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(234, 67, 53, 0.2); }
303
+ .btn-danger:hover:not(:disabled) { background: var(--danger); color: white; border-color: var(--danger); }
304
+
305
+ .btn-sm { padding: 6px 14px; font-size: 13px; border-radius: var(--radius-sm); }
306
+ .btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-md); display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
307
+ .btn-warning { background: #fff3cd; color: #856404; border: 1px solid rgba(133, 100, 4, 0.2); }
308
+ .btn-warning:hover:not(:disabled) { background: #ffc107; color: #212529; border-color: #ffc107; }
309
+
310
+ /* [OPTIMIZATION] 8. Table 样式优化,增强可读性 */
311
+ .table-container { overflow-x: auto; }
312
+ table { width: 100%; border-collapse: collapse; }
313
+ th {
314
+ text-align: left; padding: 16px 24px; font-size: 13px;
315
+ font-weight: 500; color: var(--text-muted); text-transform: uppercase;
316
+ letter-spacing: 0.5px; background: transparent; /* 移除背景色 */
317
+ border-bottom: 2px solid var(--border); /* 加粗底部边框 */
318
+ }
319
+ td {
320
+ padding: 18px 24px; border-bottom: 1px solid var(--border);
321
+ font-size: 14px; color: var(--text-main);
322
+ transition: background-color 0.2s;
323
+ }
324
+ tr:last-child td { border-bottom: none; }
325
+ tr:hover td { background: var(--hover-bg); }
326
+
327
+ /* [OPTIMIZATION] 9. Form 样式优化 */
328
+ .form-group {
329
+ display: flex;
330
+ flex-direction: column;
331
+ margin-bottom: 20px;
332
+ }
333
+ .form-group label,
334
+ .form-label {
335
+ display: block;
336
+ margin-bottom: 12px;
337
+ font-size: 14px;
338
+ font-weight: 600;
339
+ color: var(--text-main);
340
+ letter-spacing: 0.2px;
341
+ }
342
+ .form-group input, .form-group textarea, .form-group select,
343
+ .form-input,
344
+ .form-textarea {
345
+ width: 100%;
346
+ padding: 14px 16px;
347
+ border-radius: var(--radius-md);
348
+ border: 1px solid var(--border);
349
+ background: var(--bg);
350
+ color: var(--text-main);
351
+ font-size: 14px;
352
+ transition: var(--transition-ease);
353
+ box-sizing: border-box;
354
+ line-height: 1.5;
355
+ }
356
+ .form-textarea {
357
+ min-height: 90px;
358
+ resize: vertical;
359
+ font-family: inherit;
360
+ }
361
+ .form-group input:focus, .form-group textarea:focus, .form-group select:focus {
362
+ outline: none;
363
+ border-color: var(--primary);
364
+ box-shadow: 0 0 0 3px var(--primary-light), 0 1px 2px rgba(0,0,0,0.05) inset;
365
+ }
366
+ .form-group input:disabled {
367
+ background: var(--hover-bg);
368
+ color: var(--text-muted);
369
+ cursor: not-allowed;
370
+ }
371
+ .form-group small {
372
+ display: block;
373
+ margin-top: 6px;
374
+ font-size: 13px;
375
+ color: var(--text-muted);
376
+ }
377
+ .form-row {
378
+ display: grid;
379
+ grid-template-columns: 1fr 1fr;
380
+ gap: 24px;
381
+ }
382
+
383
+ /* Settings Section 样式 */
384
+ .settings-section {
385
+ background: var(--bg);
386
+ border: 1px solid var(--border);
387
+ border-radius: var(--radius-lg);
388
+ padding: 28px;
389
+ margin-bottom: 28px;
390
+ }
391
+ .settings-section:last-child {
392
+ margin-bottom: 0;
393
+ }
394
+ .settings-section h3 {
395
+ font-size: 17px;
396
+ font-weight: 600;
397
+ color: var(--text-main);
398
+ margin-bottom: 24px;
399
+ padding-bottom: 16px;
400
+ border-bottom: 1px solid var(--border);
401
+ display: flex;
402
+ align-items: center;
403
+ }
404
+ .settings-section .form-group {
405
+ margin-bottom: 24px;
406
+ }
407
+ .settings-section .form-group:last-of-type {
408
+ margin-bottom: 20px;
409
+ }
410
+
411
+ /* [OPTIMIZATION] 10. Modal 动画与样式优化 */
412
+ .modal {
413
+ display: flex; /* 改为flex,便于控制 */
414
+ align-items: center; justify-content: center;
415
+ position: fixed; top: 0; left: 0; width: 100%; height: 100%;
416
+ background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(5px);
417
+ z-index: 1000; opacity: 0; visibility: hidden;
418
+ transition: opacity 0.3s, visibility 0.3s;
419
+ }
420
+ .modal.show { opacity: 1; visibility: visible; }
421
+ .modal-content {
422
+ background: var(--card-bg); border-radius: var(--radius-lg);
423
+ width: 600px; max-width: 90vw; max-height: 90vh;
424
+ overflow-y: auto; box-shadow: var(--shadow-lg);
425
+ transform: translateY(20px) scale(0.98);
426
+ transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
427
+ }
428
+ .modal.show .modal-content { transform: translateY(0) scale(1); }
429
+ .modal-header { padding: 24px; border-bottom: 1px solid var(--border); }
430
+ .modal-header h3 { font-size: 20px; font-weight: 600; display: inline-block; }
431
+ .modal-close {
432
+ width: 36px; height: 36px; border: none; background: transparent;
433
+ color: var(--text-muted); cursor: pointer; border-radius: 50%;
434
+ display: flex; align-items: center; justify-content: center;
435
+ font-size: 22px; transition: var(--transition-ease);
436
+ float: right;
437
+ }
438
+ .modal-close:hover { background: var(--hover-bg); color: var(--text-main); transform: rotate(90deg); }
439
+ .modal-body { padding: 24px; }
440
+ .modal-footer {
441
+ display: flex; justify-content: flex-end; gap: 12px;
442
+ padding: 20px 24px; border-top: 1px solid var(--border);
443
+ background: var(--hover-bg);
444
+ border-bottom-left-radius: var(--radius-lg);
445
+ border-bottom-right-radius: var(--radius-lg);
446
+ }
447
+
448
+
449
+ /* [OPTIMIZATION] 11. Stats Card 优化 */
450
+ .stats-grid {
451
+ display: grid;
452
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
453
+ gap: 24px;
454
+ margin-bottom: 32px;
455
+ }
456
+ .stat-card {
457
+ background: var(--card-bg); border: 1px solid var(--border);
458
+ border-radius: var(--radius-lg); padding: 24px;
459
+ display: flex; flex-direction: column; /* 垂直布局 */
460
+ align-items: flex-start; gap: 16px;
461
+ transition: var(--transition-ease);
462
+ /* [NEW] 入场动画 */
463
+ opacity: 0;
464
+ transform: translateY(20px);
465
+ animation: fadeIn-up 0.5s ease-out forwards;
466
+ }
467
+ /* [NEW] Staggered Animation for Stats Cards */
468
+ .stat-card:nth-child(1) { animation-delay: 0.1s; }
469
+ .stat-card:nth-child(2) { animation-delay: 0.2s; }
470
+ .stat-card:nth-child(3) { animation-delay: 0.3s; }
471
+ .stat-card:nth-child(4) { animation-delay: 0.4s; }
472
+
473
+ @keyframes fadeIn-up {
474
+ to {
475
+ opacity: 1;
476
+ transform: translateY(0);
477
+ }
478
+ }
479
+ .stat-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: var(--primary); }
480
+
481
+ .stat-info-top { display: flex; justify-content: space-between; align-items: center; width: 100%; }
482
+ .stat-info-top p { font-size: 14px; font-weight: 500; color: var(--text-muted); }
483
+
484
+ .stat-icon {
485
+ width: 40px; height: 40px; border-radius: var(--radius-md);
486
+ display: flex; align-items: center; justify-content: center; font-size: 20px;
487
+ }
488
+
489
+ .stat-info-bottom h3 { font-size: 32px; font-weight: 600; color: var(--text-main); }
490
+ .stat-icon.blue { background: var(--primary-light); color: var(--primary); }
491
+ .stat-icon.green { background: var(--success-light); color: var(--success); }
492
+ .stat-icon.red { background: var(--danger-light); color: var(--danger); }
493
+ .stat-icon.yellow { background: var(--warning-light); color: #b06000; }
494
+
495
+ /* 其他样式保持或微调 */
496
+ .badge {
497
+ padding: 5px 12px; border-radius: 50px;
498
+ font-size: 12px; font-weight: 500;
499
+ }
500
+ .empty-state { text-align: center; padding: 80px 20px; color: var(--text-muted); }
501
+ .empty-state-icon { font-size: 56px; margin-bottom: 20px; opacity: 0.4; }
502
+
503
+ .toast {
504
+ position: fixed; bottom: 32px; left: 50%;
505
+ transform: translateX(-50%) translateY(100px);
506
+ background: var(--card-bg); border: 1px solid var(--border);
507
+ border-radius: var(--radius-md); padding: 16px 24px;
508
+ box-shadow: var(--shadow-lg); min-width: 320px;
509
+ z-index: 2000; opacity: 0; visibility: hidden;
510
+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
511
+ display: flex; align-items: center; gap: 12px;
512
+ }
513
+ .toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
514
+
515
+ /* [NEW] SVG Icon Styles */
516
+ .icon {
517
+ width: 1em;
518
+ height: 1em;
519
+ stroke-width: 2;
520
+ fill: none;
521
+ stroke: currentColor;
522
+ stroke-linecap: round;
523
+ stroke-linejoin: round;
524
+ }
525
+
526
+ /* Responsive */
527
+ @media (max-width: 768px) {
528
+ .container { padding: 24px 16px; }
529
+ .header { flex-direction: column; gap: 24px; text-align: center; }
530
+ .tabs {
531
+ gap: 8px;
532
+ /* [NEW] 允许在移动端横向滚动 */
533
+ overflow-x: auto;
534
+ white-space: nowrap;
535
+ -ms-overflow-style: none; /* IE and Edge */
536
+ scrollbar-width: none; /* Firefox */
537
+ }
538
+ .tabs::-webkit-scrollbar { display: none; } /* Chrome, Safari, and Opera */
539
+ .tab { flex-shrink: 0; }
540
+ .form-row { grid-template-columns: 1fr; }
541
+ .stats-grid { gap: 16px; }
542
+ }
543
+ </style>
544
+ </head>
545
+ <body>
546
+ <!-- [NEW] SVG Icon Definitions -->
547
+ <svg width="0" height="0" style="display: none;">
548
+ <symbol id="icon-users" viewBox="0 0 24 24"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="9" cy="7" r="4"></circle><path d="M23 21v-2a4 4 0 0 0-3-3.87"></path><path d="M16 3.13a4 4 0 0 1 0 7.75"></path></symbol>
549
+ <symbol id="icon-robot" viewBox="0 0 24 24"><path d="M12 8V4H8"></path><rect x="4" y="12" width="16" height="8" rx="2"></rect><path d="M2 12h20"></path><path d="M12 12V8a4 4 0 0 0-4-4"></path></symbol>
550
+ <symbol id="icon-settings" viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 0 2l-.15.08a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l-.22-.38a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1 0-2l.15-.08a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"></path><circle cx="12" cy="12" r="3"></circle></symbol>
551
+ <symbol id="icon-server" viewBox="0 0 24 24"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"></rect><rect x="2" y="14" width="20" height="8" rx="2" ry="2"></rect><line x1="6" y1="6" x2="6.01" y2="6"></line><line x1="6" y1="18" x2="6.01" y2="18"></line></symbol>
552
+ <symbol id="icon-list" viewBox="0 0 24 24"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3.01" y2="6"></line><line x1="3" y1="12" x2="3.01" y2="12"></line><line x1="3" y1="18" x2="3.01" y2="18"></line></symbol>
553
+ <symbol id="icon-plus" viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></symbol>
554
+ <symbol id="icon-check" viewBox="0 0 24 24"><polyline points="20 6 9 17 4 12"></polyline></symbol>
555
+ <symbol id="icon-x" viewBox="0 0 24 24"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></symbol>
556
+ <symbol id="icon-refresh" viewBox="0 0 24 24"><polyline points="23 4 23 10 17 10"></polyline><path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10"></path></symbol>
557
+ <symbol id="icon-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></symbol>
558
+ <symbol id="icon-moon" viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></symbol>
559
+ <symbol id="icon-message" viewBox="0 0 24 24"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></symbol>
560
+ <symbol id="icon-play" viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"></polygon></symbol>
561
+ <symbol id="icon-pause" viewBox="0 0 24 24"><rect x="6" y="4" width="4" height="16"></rect><rect x="14" y="4" width="4" height="16"></rect></symbol>
562
+ <symbol id="icon-zap" viewBox="0 0 24 24"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon></symbol>
563
+ <symbol id="icon-key" viewBox="0 0 24 24"><path d="M21 2l-2 2"></path><path d="M9 6l-2 2"></path><circle cx="7.5" cy="15.5" r="5.5"></circle><path d="M21 2l-9.6 9.6"></path><path d="M15.5 7.5l3 3"></path><path d="M16 13l-3-3"></path></symbol>
564
+ </svg>
565
+
566
+ <div class="container">
567
+ <!-- Header -->
568
+ <header class="header">
569
+ <div class="header-left">
570
+ <div class="logo">G</div>
571
+ <h1>Business Gemini Pool <span>管理控制台</span></h1>
572
+ </div>
573
+ <div class="header-right">
574
+ <div class="status-indicator" id="serviceStatus">服务运行中</div>
575
+ <div class="log-level-control">
576
+ <label for="logLevelSelect">日志</label>
577
+ <select id="logLevelSelect" class="log-level-select" onchange="updateLogLevel(this.value)">
578
+ <option value="DEBUG">DEBUG</option>
579
+ <option value="INFO" selected>INFO</option>
580
+ <option value="ERROR">ERROR</option>
581
+ </select>
582
+ </div>
583
+ <button class="btn btn-outline" id="loginButton" style="padding: 8px 12px;" onclick="showLoginModal()">登录</button>
584
+ <a href="chat_history.html" class="btn btn-primary" style="padding: 8px 16px; font-size: 14px; text-decoration: none; display: flex; align-items: center; gap: 6px;" title="进入在线对话">
585
+ <svg class="icon" style="width: 16px; height: 16px;"><use xlink:href="#icon-message"></use></svg>
586
+ 在线对话
587
+ </a>
588
+ <button class="theme-toggle" onclick="toggleTheme()" title="切换主题">
589
+ <span id="themeIconContainer">
590
+ <svg class="icon"><use xlink:href="#icon-sun"></use></svg>
591
+ </span>
592
+ </button>
593
+ </div>
594
+ </header>
595
+
596
+ <!-- Tabs -->
597
+ <div class="tabs">
598
+ <button class="tab active" onclick="switchTab('accounts')">
599
+ <svg class="icon tab-icon"><use xlink:href="#icon-users"></use></svg>
600
+ 账号管理
601
+ </button>
602
+ <button class="tab" onclick="switchTab('models')">
603
+ <svg class="icon tab-icon"><use xlink:href="#icon-robot"></use></svg>
604
+ 模型管理
605
+ </button>
606
+ <button class="tab" onclick="switchTab('settings')">
607
+ <svg class="icon tab-icon"><use xlink:href="#icon-settings"></use></svg>
608
+ 系统设置
609
+ </button>
610
+ <button class="tab" onclick="switchTab('tokens')">
611
+ <svg class="icon tab-icon"><use xlink:href="#icon-key"></use></svg>
612
+ Token 管理
613
+ </button>
614
+ </div>
615
+
616
+ <!-- 账号管理 -->
617
+ <div id="accounts" class="tab-content active">
618
+ <!-- Stats -->
619
+ <div class="stats-grid">
620
+ <div class="stat-card">
621
+ <div class="stat-info-top">
622
+ <p>总账号数</p>
623
+ <div class="stat-icon blue"><svg class="icon"><use xlink:href="#icon-users"></use></svg></div>
624
+ </div>
625
+ <div class="stat-info-bottom">
626
+ <h3 id="totalAccounts">0</h3>
627
+ </div>
628
+ </div>
629
+ <div class="stat-card">
630
+ <div class="stat-info-top">
631
+ <p>可用账号</p>
632
+ <div class="stat-icon green"><svg class="icon"><use xlink:href="#icon-check"></use></svg></div>
633
+ </div>
634
+ <div class="stat-info-bottom">
635
+ <h3 id="availableAccounts">0</h3>
636
+ </div>
637
+ </div>
638
+ <div class="stat-card">
639
+ <div class="stat-info-top">
640
+ <p>不可用账号</p>
641
+ <div class="stat-icon red"><svg class="icon"><use xlink:href="#icon-x"></use></svg></div>
642
+ </div>
643
+ <div class="stat-info-bottom">
644
+ <h3 id="unavailableAccounts">0</h3>
645
+ </div>
646
+ </div>
647
+ <div class="stat-card">
648
+ <div class="stat-info-top">
649
+ <p>当前轮训索引</p>
650
+ <div class="stat-icon yellow"><svg class="icon"><use xlink:href="#icon-refresh"></use></svg></div>
651
+ </div>
652
+ <div class="stat-info-bottom">
653
+ <h3 id="currentIndex">0</h3>
654
+ </div>
655
+ </div>
656
+ </div>
657
+
658
+ <div class="card">
659
+ <div class="card-header">
660
+ <div class="card-title">
661
+ <svg class="icon card-title-icon"><use xlink:href="#icon-list"></use></svg>
662
+ 账号列表
663
+ </div>
664
+ <button class="btn btn-primary" onclick="showAddAccountModal()">
665
+ <svg class="icon"><use xlink:href="#icon-plus"></use></svg>
666
+ 添加账号
667
+ </button>
668
+ </div>
669
+ <div class="table-container">
670
+ <table id="accountsTable">
671
+ <thead>
672
+ <tr>
673
+ <th>序号</th>
674
+ <th>Team ID</th>
675
+ <th>csesidx</th>
676
+ <th>User Agent</th>
677
+ <th>状态</th>
678
+ <th>操作</th>
679
+ </tr>
680
+ </thead>
681
+ <tbody id="accountsTableBody"></tbody>
682
+ </table>
683
+ </div>
684
+ </div>
685
+ </div>
686
+
687
+ <!-- 模型管理 (HTML结构类似,图标已替换) -->
688
+ <div id="models" class="tab-content">
689
+ <div class="card">
690
+ <div class="card-header">
691
+ <div class="card-title">
692
+ <svg class="icon card-title-icon"><use xlink:href="#icon-robot"></use></svg>
693
+ 模型列表
694
+ </div>
695
+ <button class="btn btn-primary" onclick="showAddModelModal()">
696
+ <svg class="icon"><use xlink:href="#icon-plus"></use></svg>
697
+ 添加模型
698
+ </button>
699
+ </div>
700
+ <div class="table-container">
701
+ <table id="modelsTable">
702
+ <thead>
703
+ <tr>
704
+ <th>模型ID</th>
705
+ <th>名称</th>
706
+ <th>描述</th>
707
+ <th>上下文长度</th>
708
+ <th>最大Token</th>
709
+ <th>状态</th>
710
+ <th>操作</th>
711
+ </tr>
712
+ </thead>
713
+ <tbody id="modelsTableBody"></tbody>
714
+ </table>
715
+ </div>
716
+ </div>
717
+ </div>
718
+
719
+ <!-- 系统设置 (HTML结构类似,图标已替换) -->
720
+ <div id="settings" class="tab-content">
721
+ <div class="card">
722
+ <div class="card-header">
723
+ <div class="card-title">
724
+ <svg class="icon card-title-icon"><use xlink:href="#icon-settings"></use></svg>
725
+ 系统配置
726
+ </div>
727
+ </div>
728
+ <div class="card-body">
729
+ <form id="settingsForm">
730
+ <div class="settings-section">
731
+ <h3>代理设置</h3>
732
+ <div class="form-group">
733
+ <label class="form-label" for="proxyUrl">代理地址</label>
734
+ <input type="text" class="form-input" id="proxyUrl" placeholder="http://127.0.0.1:7890">
735
+ <small>用于访问Google API的代理服务器地址</small>
736
+ <div class="proxy-status" id="proxyStatus"></div>
737
+ </div>
738
+ <div class="form-group">
739
+ <label class="form-label" for="imageOutputMode">图片输出模式</label>
740
+ <select class="form-input" id="imageOutputMode">
741
+ <option value="url">图片URL(默认)</option>
742
+ <option value="base64">Base64 Data URL</option>
743
+ </select>
744
+ <small>控制聊天接口返回的图片是以URL形式还是以 data:image/...;base64,... 形式输出</small>
745
+ </div>
746
+ <div style="display: flex; gap: 12px;">
747
+ <button type="button" class="btn btn-outline" onclick="testProxy()">
748
+ 测试代理
749
+ </button>
750
+ <button type="button" class="btn btn-primary" onclick="saveSettings()">
751
+ 保存设置
752
+ </button>
753
+ </div>
754
+ </div>
755
+
756
+ <div class="settings-section">
757
+ <h3><svg class="icon" style="width: 1em; height: 1em; vertical-align: -2px; margin-right: 8px;"><use xlink:href="#icon-server"></use></svg>服务信息</h3>
758
+ <div class="form-row">
759
+ <div class="form-group">
760
+ <label class="form-label">服务端口</label>
761
+ <input type="text" class="form-input" value="8000" disabled>
762
+ </div>
763
+ <div class="form-group">
764
+ <label class="form-label">API地址</label>
765
+ <input type="text" class="form-input" value="http://localhost:8000/v1" disabled>
766
+ </div>
767
+ </div>
768
+ </div>
769
+
770
+ <div class="settings-section">
771
+ <h3>配置文件</h3>
772
+ <div class="form-group">
773
+ <label class="form-label" for="configJson">当前配置 (JSON)</label>
774
+ <textarea class="form-textarea" id="configJson" rows="15" readonly></textarea>
775
+ <small>配置文件路径: business_gemini_session.json</small>
776
+ </div>
777
+ <div style="display: flex; gap: 12px; flex-wrap: wrap;">
778
+ <button type="button" class="btn btn-outline" onclick="refreshConfig()">
779
+ 刷新配置
780
+ </button>
781
+ <button type="button" class="btn btn-outline" onclick="downloadConfig()">
782
+ 下载配置
783
+ </button>
784
+ <button type="button" class="btn btn-primary" onclick="uploadConfig()">
785
+ 导入配置
786
+ </button>
787
+ <input type="file" id="configFileInput" accept=".json" style="display: none;" onchange="handleConfigUpload(event)">
788
+ </div>
789
+ </div>
790
+ </form>
791
+ </div>
792
+ </div>
793
+ </div>
794
+
795
+ <!-- Token 管理 -->
796
+ <div id="tokens" class="tab-content">
797
+ <div class="card">
798
+ <div class="card-header" style="display:flex; justify-content:space-between; align-items:center;">
799
+ <div class="card-title" style="display:flex; align-items:center; gap:8px;">
800
+ <svg class="icon card-title-icon"><use xlink:href="#icon-key"></use></svg>
801
+ Token 管理
802
+ </div>
803
+ <div class="token-actions">
804
+ <input id="manualToken" class="form-input token-input" placeholder="手动输入 Token(留空自动生成)">
805
+ <button class="btn btn-outline" type="button" onclick="generateToken()">生成 Token</button>
806
+ <button class="btn btn-primary" type="button" onclick="addToken()">添加 Token</button>
807
+ </div>
808
+ </div>
809
+ <table class="table">
810
+ <thead>
811
+ <tr>
812
+ <th style="width:70%;">Token</th>
813
+ <th>操作</th>
814
+ </tr>
815
+ </thead>
816
+ <tbody id="tokensTableBody">
817
+ <tr><td colspan="2" class="empty-state">加载中...</td></tr>
818
+ </tbody>
819
+ </table>
820
+ </div>
821
+ </div>
822
+ </div>
823
+
824
+ <!-- 模态框 (已优化关闭按钮) -->
825
+ <div class="modal" id="addAccountModal">
826
+ <div class="modal-content">
827
+ <div class="modal-header">
828
+ <h3>添加账号</h3>
829
+ <button class="modal-close" onclick="closeModal('addAccountModal')" title="关闭">&times;</button>
830
+ </div>
831
+ <!-- Modal Body and Footer ... (No functional changes needed) -->
832
+ <div class="modal-body">
833
+ <div class="form-group">
834
+ <label class="form-label" for="newAccountJson">粘贴账号JSON(可直接复制工具输出)</label>
835
+ <textarea class="form-textarea" id="newAccountJson" placeholder='{"team_id":"...","secure_c_ses":"...","host_c_oses":"...","csesidx":"...","user_agent":"..."}' rows="4"></textarea>
836
+ <div style="display:flex; gap:8px; margin-top:8px;">
837
+ <button class="btn btn-outline btn-sm" type="button" onclick="parseAccountJson()">解析填充</button>
838
+ <button class="btn btn-outline btn-sm" type="button" onclick="pasteAccountJson()">从剪贴板读取并填充</button>
839
+ </div>
840
+ </div>
841
+ <div class="form-group">
842
+ <label class="form-label" for="newTeamId">Team ID</label>
843
+ <input type="text" class="form-input" id="newTeamId" placeholder="输入Team ID">
844
+ </div>
845
+ <div class="form-group">
846
+ <label class="form-label" for="newSecureCses">Cookie中的__Secure-C_SES</label>
847
+ <textarea class="form-textarea" id="newSecureCses" placeholder="输入Cookie中的__Secure-C_SES" rows="3"></textarea>
848
+ </div>
849
+ <div class="form-group">
850
+ <label class="form-label" for="newHostCoses">Cookie中的__Host-C_OSES</label>
851
+ <textarea class="form-textarea" id="newHostCoses" placeholder="输入Cookie中的__Host-C_OSES" rows="3"></textarea>
852
+ </div>
853
+ <div class="form-group">
854
+ <label class="form-label" for="newCsesidx">CSESIDX</label>
855
+ <input type="text" class="form-input" id="newCsesidx" placeholder="输入CSESIDX">
856
+ </div>
857
+ <div class="form-group">
858
+ <label class="form-label" for="newUserAgent">User Agent</label>
859
+ <input type="text" class="form-input" id="newUserAgent" placeholder="输入User Agent">
860
+ </div>
861
+ </div>
862
+ <div class="modal-footer">
863
+ <button class="btn btn-outline" onclick="closeModal('addAccountModal')">取消</button>
864
+ <button class="btn btn-primary" onclick="saveNewAccount()">保存</button>
865
+ </div>
866
+ </div>
867
+ </div>
868
+ <!-- 编辑账号模态框 -->
869
+ <div class="modal" id="editAccountModal">
870
+ <div class="modal-content">
871
+ <div class="modal-header">
872
+ <h3>编辑账号</h3>
873
+ <button class="modal-close" onclick="closeModal('editAccountModal')" title="关闭">&times;</button>
874
+ </div>
875
+ <div class="modal-body">
876
+ <input type="hidden" id="editAccountId">
877
+ <div class="form-group">
878
+ <label class="form-label" for="editTeamId">Team ID</label>
879
+ <input type="text" class="form-input" id="editTeamId" placeholder="输入Team ID">
880
+ </div>
881
+ <div class="form-group">
882
+ <label class="form-label" for="editSecureCses">Cookie中的__Secure-C_SES</label>
883
+ <textarea class="form-textarea" id="editSecureCses" placeholder="输入Secure C Ses" rows="3"></textarea>
884
+ </div>
885
+ <div class="form-group">
886
+ <label class="form-label" for="editHostCoses">Cookie中的__Host-C_OSES</label>
887
+ <textarea class="form-textarea" id="editHostCoses" placeholder="输入Host C Oses" rows="3"></textarea>
888
+ </div>
889
+ <div class="form-group">
890
+ <label class="form-label" for="editCsesidx">CSESIDX</label>
891
+ <input type="text" class="form-input" id="editCsesidx" placeholder="输入CSESIDX">
892
+ </div>
893
+ <div class="form-group">
894
+ <label class="form-label" for="editUserAgent">User Agent</label>
895
+ <input type="text" class="form-input" id="editUserAgent" placeholder="输入User Agent">
896
+ </div>
897
+ </div>
898
+ <div class="modal-footer">
899
+ <button class="btn btn-outline" onclick="closeModal('editAccountModal')">取消</button>
900
+ <button class="btn btn-primary" onclick="updateAccount()">保存</button>
901
+ </div>
902
+ </div>
903
+ </div>
904
+
905
+ <!-- 刷新Cookie模态框 -->
906
+ <div class="modal" id="refreshCookieModal">
907
+ <div class="modal-content">
908
+ <div class="modal-header">
909
+ <h3>刷新账号Cookie</h3>
910
+ <button class="modal-close" onclick="closeModal('refreshCookieModal')" title="关闭">&times;</button>
911
+ </div>
912
+ <div class="modal-body">
913
+ <input type="hidden" id="refreshAccountId">
914
+ <p class="text-muted" style="margin-bottom: 16px;">请输入新的Cookie值来刷新账号认证信息。刷新后将清除JWT缓存。</p>
915
+ <div class="form-group">
916
+ <label class="form-label" for="refreshSecureCses">Cookie中的__Secure-C_SES <span style="color: var(--danger);">*</span></label>
917
+ <textarea class="form-textarea" id="refreshSecureCses" placeholder="输入新的__Secure-C_SES值" rows="3"></textarea>
918
+ </div>
919
+ <div class="form-group">
920
+ <label class="form-label" for="refreshHostCoses">Cookie中的__Host-C_OSES <span style="color: var(--danger);">*</span></label>
921
+ <textarea class="form-textarea" id="refreshHostCoses" placeholder="输入新的__Host-C_OSES值" rows="3"></textarea>
922
+ </div>
923
+ <div class="form-group">
924
+ <label class="form-label" for="refreshCsesidx">CSESIDX (可选)</label>
925
+ <input type="text" class="form-input" id="refreshCsesidx" placeholder="输入CSESIDX值">
926
+ </div>
927
+ <div class="form-group">
928
+ <label class="form-label">从JSON粘贴 (可选)</label>
929
+ <textarea class="form-textarea" id="refreshCookieJson" placeholder="粘贴Cookie JSON数据" rows="3"></textarea>
930
+ <button class="btn btn-outline" style="margin-top: 8px;" onclick="pasteRefreshCookieJson()">📋 粘贴并解析</button>
931
+ </div>
932
+ </div>
933
+ <div class="modal-footer">
934
+ <button class="btn btn-outline" onclick="closeModal('refreshCookieModal')">取消</button>
935
+ <button class="btn btn-primary" onclick="refreshAccountCookie()">刷新Cookie</button>
936
+ </div>
937
+ </div>
938
+ </div>
939
+
940
+ <!-- 添加模型模态框 -->
941
+ <div class="modal" id="addModelModal">
942
+ <div class="modal-content">
943
+ <div class="modal-header">
944
+ <h3>添加模型</h3>
945
+ <button class="modal-close" onclick="closeModal('addModelModal')" title="关闭">&times;</button>
946
+ </div>
947
+ <div class="modal-body">
948
+ <div class="form-row">
949
+ <div class="form-group">
950
+ <label class="form-label" for="newModelId">模型ID</label>
951
+ <input type="text" class="form-input" id="newModelId" placeholder="如: gemini-pro">
952
+ </div>
953
+ <div class="form-group">
954
+ <label class="form-label" for="newModelName">模型名称</label>
955
+ <input type="text" class="form-input" id="newModelName" placeholder="如: Gemini Pro">
956
+ </div>
957
+ </div>
958
+ <div class="form-group">
959
+ <label class="form-label" for="newModelDesc">描述</label>
960
+ <input type="text" class="form-input" id="newModelDesc" placeholder="模型描述">
961
+ </div>
962
+ <div class="form-row">
963
+ <div class="form-group">
964
+ <label class="form-label" for="newContextLength">上下文长度</label>
965
+ <input type="number" class="form-input" id="newContextLength" value="32768">
966
+ </div>
967
+ <div class="form-group">
968
+ <label class="form-label" for="newMaxTokens">最大Token</label>
969
+ <input type="number" class="form-input" id="newMaxTokens" value="8192">
970
+ </div>
971
+ </div>
972
+ </div>
973
+ <div class="modal-footer">
974
+ <button class="btn btn-outline" onclick="closeModal('addModelModal')">取消</button>
975
+ <button class="btn btn-primary" onclick="saveNewModel()">保存</button>
976
+ </div>
977
+ </div>
978
+ </div>
979
+
980
+ <!-- 登录模态框 -->
981
+ <div class="modal" id="loginModal">
982
+ <div class="modal-content">
983
+ <div class="modal-header">
984
+ <h3>管理员登录</h3>
985
+ <button class="modal-close" onclick="closeModal('loginModal')" title="关闭">&times;</button>
986
+ </div>
987
+ <div class="modal-body">
988
+ <div class="form-group">
989
+ <label class="form-label" for="loginPassword">后台密码</label>
990
+ <input type="password" class="form-input" id="loginPassword" placeholder="输入后台密码">
991
+ </div>
992
+ <p class="text-muted" style="font-size: 12px;">首次登录将设置当前密码为后台密码。</p>
993
+ </div>
994
+ <div class="modal-footer">
995
+ <button class="btn btn-outline" onclick="closeModal('loginModal')">取消</button>
996
+ <button class="btn btn-primary" onclick="submitLogin()">登录</button>
997
+ </div>
998
+ </div>
999
+ </div>
1000
+
1001
+ <!-- 编辑模型模态框 -->
1002
+ <div class="modal" id="editModelModal">
1003
+ <div class="modal-content">
1004
+ <div class="modal-header">
1005
+ <h3>编辑模型</h3>
1006
+ <button class="modal-close" onclick="closeModal('editModelModal')" title="关闭">&times;</button>
1007
+ </div>
1008
+ <div class="modal-body">
1009
+ <input type="hidden" id="editModelOriginalId">
1010
+ <div class="form-row">
1011
+ <div class="form-group">
1012
+ <label class="form-label" for="editModelId">模型ID</label>
1013
+ <input type="text" class="form-input" id="editModelId" placeholder="如: gemini-pro" readonly style="background-color: var(--bg-tertiary); cursor: not-allowed;">
1014
+ </div>
1015
+ <div class="form-group">
1016
+ <label class="form-label" for="editModelName">模型名称</label>
1017
+ <input type="text" class="form-input" id="editModelName" placeholder="如: Gemini Pro">
1018
+ </div>
1019
+ </div>
1020
+ <div class="form-group">
1021
+ <label class="form-label" for="editModelDesc">描述</label>
1022
+ <input type="text" class="form-input" id="editModelDesc" placeholder="模型描述">
1023
+ </div>
1024
+ <div class="form-row">
1025
+ <div class="form-group">
1026
+ <label class="form-label" for="editContextLength">上下文长度</label>
1027
+ <input type="number" class="form-input" id="editContextLength">
1028
+ </div>
1029
+ <div class="form-group">
1030
+ <label class="form-label" for="editMaxTokens">最大Token</label>
1031
+ <input type="number" class="form-input" id="editMaxTokens">
1032
+ </div>
1033
+ </div>
1034
+ </div>
1035
+ <div class="modal-footer">
1036
+ <button class="btn btn-outline" onclick="closeModal('editModelModal')">取消</button>
1037
+ <button class="btn btn-primary" onclick="updateModel()">保存</button>
1038
+ </div>
1039
+ </div>
1040
+ </div>
1041
+
1042
+
1043
+ <!-- Toast通知 -->
1044
+ <div id="toastContainer" class="toast-container">
1045
+ <!-- Toasts will be injected here by JS -->
1046
+ </div>
1047
+ <div class="toast" id="toast"></div>
1048
+
1049
+ <script>
1050
+ // [OPTIMIZATION] 1. 脚本微调以适应新的图标
1051
+ function updateThemeIcon(theme) {
1052
+ const iconContainer = document.getElementById('themeIconContainer');
1053
+ if (iconContainer) {
1054
+ const iconId = theme === 'dark' ? 'icon-sun' : 'icon-moon';
1055
+ iconContainer.innerHTML = `<svg class="icon"><use xlink:href="#${iconId}"></use></svg>`;
1056
+ }
1057
+ }
1058
+
1059
+ // [OPTIMIZATION] 2. 改进Toast通知
1060
+ let toastTimeout;
1061
+ function showToast(message, type = 'info') {
1062
+ const toast = document.getElementById('toast');
1063
+ if (!toast) return;
1064
+
1065
+ let icon = '';
1066
+ let borderType = type; // 'success', 'error', 'info'
1067
+ switch(type) {
1068
+ case 'success':
1069
+ icon = '<svg class="icon" style="color: var(--success);"><use xlink:href="#icon-check"></use></svg>';
1070
+ break;
1071
+ case 'error':
1072
+ icon = '<svg class="icon" style="color: var(--danger);"><use xlink:href="#icon-x"></use></svg>';
1073
+ break;
1074
+ default:
1075
+ icon = '<svg class="icon" style="color: var(--primary);"><use xlink:href="#icon-server"></use></svg>';
1076
+ borderType = 'primary';
1077
+ break;
1078
+ }
1079
+
1080
+ toast.innerHTML = `${icon} <span class="toast-message">${message}</span>`;
1081
+ toast.className = `toast show`;
1082
+ toast.style.borderLeft = `4px solid var(--${borderType})`;
1083
+
1084
+ clearTimeout(toastTimeout);
1085
+ toastTimeout = setTimeout(() => {
1086
+ toast.classList.remove('show');
1087
+ }, 3500);
1088
+ }
1089
+
1090
+ // =======================================================
1091
+ // [FULL SCRIPT] 以下是完整的、未删减的功能性 JavaScript 代码
1092
+ // =======================================================
1093
+
1094
+ // API 基础 URL
1095
+ const API_BASE = '.';
1096
+
1097
+ // 全局数据缓存
1098
+ let accountsData = [];
1099
+ let modelsData = [];
1100
+ let configData = {};
1101
+ let currentEditAccountId = null;
1102
+ let currentEditModelId = null;
1103
+ const ADMIN_TOKEN_KEY = 'admin_token';
1104
+ let tokensData = [];
1105
+
1106
+ // --- 初始化 ---
1107
+ document.addEventListener('DOMContentLoaded', () => {
1108
+ initTheme();
1109
+ loadAllData();
1110
+ setInterval(checkServerStatus, 30000); // 每30秒检查一次服务状态
1111
+ updateLoginButton();
1112
+ });
1113
+
1114
+ // --- 核心加载与渲染 ---
1115
+ async function loadAllData() {
1116
+ await Promise.all([
1117
+ loadAccounts(),
1118
+ loadModels(),
1119
+ loadConfig(),
1120
+ checkServerStatus(),
1121
+ loadLogLevel(),
1122
+ loadTokens()
1123
+ ]);
1124
+ }
1125
+
1126
+ function getAuthHeaders() {
1127
+ const token = localStorage.getItem(ADMIN_TOKEN_KEY);
1128
+ return token ? { 'X-Admin-Token': token } : {};
1129
+ }
1130
+
1131
+ function updateLoginButton() {
1132
+ const token = localStorage.getItem(ADMIN_TOKEN_KEY);
1133
+ const btn = document.getElementById('loginButton');
1134
+ if (!btn) return;
1135
+ if (token) {
1136
+ btn.textContent = '注销';
1137
+ btn.disabled = false;
1138
+ btn.classList.remove('btn-disabled');
1139
+ btn.title = '注销登录';
1140
+ btn.onclick = logoutAdmin;
1141
+ } else {
1142
+ btn.textContent = '登录';
1143
+ btn.disabled = false;
1144
+ btn.classList.remove('btn-disabled');
1145
+ btn.title = '管理员登录';
1146
+ btn.onclick = showLoginModal;
1147
+ }
1148
+ }
1149
+
1150
+ async function apiFetch(url, options = {}) {
1151
+ const headers = Object.assign({}, options.headers || {}, getAuthHeaders());
1152
+ const res = await fetch(url, { ...options, headers });
1153
+ if (res.status === 401 || res.status === 403) {
1154
+ showLoginModal();
1155
+ updateLoginButton();
1156
+ throw new Error('需要登录');
1157
+ }
1158
+ return res;
1159
+ }
1160
+
1161
+ // --- 主题控制 ---
1162
+ function initTheme() {
1163
+ const savedTheme = localStorage.getItem('theme') || 'light';
1164
+ document.documentElement.setAttribute('data-theme', savedTheme);
1165
+ updateThemeIcon(savedTheme);
1166
+ }
1167
+
1168
+ function toggleTheme() {
1169
+ const current = document.documentElement.getAttribute('data-theme');
1170
+ const newTheme = current === 'dark' ? 'light' : 'dark';
1171
+ document.documentElement.setAttribute('data-theme', newTheme);
1172
+ localStorage.setItem('theme', newTheme);
1173
+ updateThemeIcon(newTheme);
1174
+ }
1175
+
1176
+ // --- 标签页控制 ---
1177
+ function switchTab(tabName) {
1178
+ document.querySelectorAll('.tab').forEach(btn => btn.classList.remove('active'));
1179
+ document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active'));
1180
+
1181
+ const tabBtn = document.querySelector(`[onclick="switchTab('${tabName}')"]`);
1182
+ const tabContent = document.getElementById(tabName);
1183
+
1184
+ if (tabBtn) tabBtn.classList.add('active');
1185
+ if (tabContent) tabContent.classList.add('active');
1186
+ }
1187
+
1188
+ // --- 状态检查 ---
1189
+ async function checkServerStatus() {
1190
+ const indicator = document.getElementById('serviceStatus');
1191
+ if (!indicator) return;
1192
+ try {
1193
+ const res = await apiFetch(`${API_BASE}/api/status`);
1194
+ console.log('Server Status Response:', res);
1195
+ if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
1196
+ const data = await res.json();
1197
+ indicator.textContent = '服务运行中';
1198
+ indicator.classList.remove('offline');
1199
+ indicator.title = '服务连接正常 - ' + new Date().toLocaleString();
1200
+ } catch (e) {
1201
+ indicator.textContent = '服务离线';
1202
+ indicator.classList.add('offline');
1203
+ indicator.title = '无法连接到后端服务';
1204
+ }
1205
+ }
1206
+
1207
+ // --- 账号管理 (Accounts) ---
1208
+ async function loadAccounts() {
1209
+ try {
1210
+ const res = await apiFetch(`${API_BASE}/api/accounts`);
1211
+ const data = await res.json();
1212
+ accountsData = data.accounts || [];
1213
+ document.getElementById('currentIndex').textContent = data.current_index || 0;
1214
+ renderAccounts();
1215
+ updateAccountStats();
1216
+ } catch (e) {
1217
+ showToast('加载账号列表失败: ' + e.message, 'error');
1218
+ }
1219
+ }
1220
+
1221
+ function renderAccounts() {
1222
+ const tbody = document.getElementById('accountsTableBody');
1223
+ if (!tbody) return;
1224
+
1225
+ if (accountsData.length === 0) {
1226
+ tbody.innerHTML = `<tr><td colspan="6" class="empty-state">
1227
+ <div class="empty-state-icon"><svg class="icon"><use xlink:href="#icon-users"></use></svg></div>
1228
+ <h3>暂无账号</h3><p>点击 "添加账号" 按钮来创建一个。</p>
1229
+ </td></tr>`;
1230
+ return;
1231
+ }
1232
+
1233
+ tbody.innerHTML = accountsData.map((acc, index) => `
1234
+ <tr>
1235
+ <td>${index + 1}</td>
1236
+ <td><code>${acc.team_id || '-'}</code></td>
1237
+ <td><code>${acc.csesidx || '-'}</code></td>
1238
+ <td title="${acc.user_agent}">${acc.user_agent ? acc.user_agent.substring(0, 30) + '...' : '-'}</td>
1239
+ <td>
1240
+ <span class="badge ${acc.available ? 'badge-success' : 'badge-danger'}">${acc.available ? '可用' : '不可用'}</span>
1241
+ ${renderNextRefresh(acc)}
1242
+ </td>
1243
+ <td style="white-space: nowrap;">
1244
+ <button class="btn btn-sm ${acc.enabled !== false ? 'btn-warning' : 'btn-success'} btn-icon" onclick="toggleAccount(${acc.id})" title="${acc.enabled !== false ? '停用' : '启用'}"><svg class="icon" style="width:16px; height:16px;"><use xlink:href="#icon-${acc.enabled !== false ? 'pause' : 'play'}"></use></svg></button>
1245
+ <button class="btn btn-sm btn-outline btn-icon" onclick="testAccount(${acc.id})" title="测试连接"><svg class="icon" style="width:16px; height:16px;"><use xlink:href="#icon-zap"></use></svg></button>
1246
+ <button class="btn btn-sm btn-outline btn-icon" onclick="showRefreshCookieModal(${acc.id})" title="刷新Cookie"><svg class="icon" style="width:16px; height:16px;"><use xlink:href="#icon-refresh"></use></svg></button>
1247
+ <button class="btn btn-sm btn-outline btn-icon" onclick="showEditAccountModal(${acc.id})" title="编辑"><svg class="icon" style="width:16px; height:16px;"><use xlink:href="#icon-settings"></use></svg></button>
1248
+ <button class="btn btn-sm btn-danger btn-icon" onclick="deleteAccount(${acc.id})" title="删除"><svg class="icon" style="width:16px; height:16px;"><use xlink:href="#icon-x"></use></svg></button>
1249
+ </td>
1250
+ </tr>
1251
+ `).join('');
1252
+ }
1253
+
1254
+ function updateAccountStats() {
1255
+ document.getElementById('totalAccounts').textContent = accountsData.length;
1256
+ document.getElementById('availableAccounts').textContent = accountsData.filter(a => a.available).length;
1257
+ document.getElementById('unavailableAccounts').textContent = accountsData.length - accountsData.filter(a => a.available).length;
1258
+ }
1259
+
1260
+ function renderNextRefresh(acc) {
1261
+ if (!acc || !acc.cooldown_until) return '';
1262
+ const now = Date.now();
1263
+ const ts = acc.cooldown_until * 1000;
1264
+ if (ts <= now) return '';
1265
+ const next = new Date(ts);
1266
+ const remaining = Math.max(0, ts - now);
1267
+ const minutes = Math.floor(remaining / 60000);
1268
+ const label = minutes >= 60
1269
+ ? `${Math.floor(minutes / 60)}小时${minutes % 60}分`
1270
+ : `${minutes}分`;
1271
+ return `<span class="cooldown-hint">下次恢复: ${next.toLocaleString()}(约${label})</span>`;
1272
+ }
1273
+
1274
+ function showAddAccountModal() {
1275
+ openModal('addAccountModal');
1276
+ }
1277
+
1278
+ function showEditAccountModal(id) {
1279
+ const acc = accountsData.find(a => a.id === id);
1280
+ if (!acc) return;
1281
+
1282
+ document.getElementById('editAccountId').value = id;
1283
+ document.getElementById('editTeamId').value = acc.team_id || '';
1284
+ document.getElementById('editSecureCses').value = acc.secure_c_ses || '';
1285
+ document.getElementById('editHostCoses').value = acc.host_c_oses || '';
1286
+ document.getElementById('editCsesidx').value = acc.csesidx || '';
1287
+ document.getElementById('editUserAgent').value = acc.user_agent ? acc.user_agent.replace('...', '') : '';
1288
+
1289
+ openModal('editAccountModal');
1290
+ }
1291
+
1292
+ async function updateAccount() {
1293
+ const id = document.getElementById('editAccountId').value;
1294
+ const account = {};
1295
+
1296
+ const teamId = document.getElementById('editTeamId').value;
1297
+ const secureCses = document.getElementById('editSecureCses').value;
1298
+ const hostCoses = document.getElementById('editHostCoses').value;
1299
+ const csesidx = document.getElementById('editCsesidx').value;
1300
+ const userAgent = document.getElementById('editUserAgent').value;
1301
+
1302
+ if (teamId) account.team_id = teamId;
1303
+ if (secureCses) account.secure_c_ses = secureCses;
1304
+ if (hostCoses) account.host_c_oses = hostCoses;
1305
+ if (csesidx) account.csesidx = csesidx;
1306
+ if (userAgent) account.user_agent = userAgent;
1307
+
1308
+ try {
1309
+ const res = await apiFetch(`${API_BASE}/api/accounts/${id}`, {
1310
+ method: 'PUT',
1311
+ headers: { 'Content-Type': 'application/json' },
1312
+ body: JSON.stringify(account)
1313
+ });
1314
+ const data = await res.json();
1315
+
1316
+ if (data.success) {
1317
+ showToast('账号更新成功', 'success');
1318
+ closeModal('editAccountModal');
1319
+ loadAccounts();
1320
+ } else {
1321
+ showToast('更新失败: ' + (data.error || '未知错误'), 'error');
1322
+ }
1323
+ } catch (e) {
1324
+ showToast('更新失败: ' + e.message, 'error');
1325
+ }
1326
+ }
1327
+
1328
+ async function saveNewAccount() {
1329
+ const teamId = document.getElementById('newTeamId').value;
1330
+ const secureCses = document.getElementById('newSecureCses').value;
1331
+ const hostCoses = document.getElementById('newHostCoses').value;
1332
+ const csesidx = document.getElementById('newCsesidx').value;
1333
+ const userAgent = document.getElementById('newUserAgent').value;
1334
+
1335
+ try {
1336
+ const res = await apiFetch(`${API_BASE}/api/accounts`, {
1337
+ method: 'POST',
1338
+ headers: { 'Content-Type': 'application/json' },
1339
+ body: JSON.stringify({
1340
+ team_id: teamId,
1341
+ "secure_c_ses": secureCses,
1342
+ "host_c_oses": hostCoses,
1343
+ "csesidx": csesidx,
1344
+ "user_agent": userAgent })
1345
+ });
1346
+ const data = await res.json();
1347
+ if (!res.ok || data.error) throw new Error(data.error || data.detail || '添加失败');
1348
+ showToast('账号添加成功!', 'success');
1349
+ closeModal('addAccountModal');
1350
+ loadAccounts();
1351
+ } catch (e) {
1352
+ showToast('添加失败: ' + e.message, 'error');
1353
+ }
1354
+ }
1355
+
1356
+ function parseAccountJson(text) {
1357
+ const textarea = document.getElementById('newAccountJson');
1358
+ const raw = (typeof text === 'string' ? text : textarea.value || '').trim();
1359
+ if (!raw) {
1360
+ showToast('请先粘贴账号JSON', 'warning');
1361
+ return;
1362
+ }
1363
+ let acc;
1364
+ try {
1365
+ const parsed = JSON.parse(raw);
1366
+ acc = Array.isArray(parsed) ? parsed[0] : parsed;
1367
+ if (!acc || typeof acc !== 'object') throw new Error('格式不正确');
1368
+ } catch (err) {
1369
+ showToast('解析失败: ' + err.message, 'error');
1370
+ return;
1371
+ }
1372
+
1373
+ document.getElementById('newTeamId').value = acc.team_id || '';
1374
+ document.getElementById('newSecureCses').value = acc.secure_c_ses || '';
1375
+ document.getElementById('newHostCoses').value = acc.host_c_oses || '';
1376
+ document.getElementById('newCsesidx').value = acc.csesidx || '';
1377
+ document.getElementById('newUserAgent').value = acc.user_agent || '';
1378
+ showToast('已填充账号信息', 'success');
1379
+ }
1380
+
1381
+ async function pasteAccountJson() {
1382
+ try {
1383
+ const text = await navigator.clipboard.readText();
1384
+ document.getElementById('newAccountJson').value = text;
1385
+ parseAccountJson(text);
1386
+ } catch (e) {
1387
+ showToast('无法读取剪贴板: ' + e.message, 'error');
1388
+ }
1389
+ }
1390
+
1391
+ async function deleteAccount(id) {
1392
+ if (!confirm('确定要删除这个账号吗?')) return;
1393
+ try {
1394
+ const res = await apiFetch(`${API_BASE}/api/accounts/${id}`, { method: 'DELETE' });
1395
+ if (!res.ok) throw new Error((await res.json()).detail);
1396
+ showToast('账号删除成功!', 'success');
1397
+ loadAccounts();
1398
+ } catch (e) {
1399
+ showToast('删除失败: ' + e.message, 'error');
1400
+ }
1401
+ }
1402
+
1403
+ async function testAccount(id) {
1404
+ showToast(`正在测试账号ID: ${id}...`, 'info');
1405
+ try {
1406
+ const res = await apiFetch(`${API_BASE}/api/accounts/${id}/test`);
1407
+ const data = await res.json();
1408
+ if (res.ok && data.success) {
1409
+ showToast(`账号 ${id} 测试成功!`, 'success');
1410
+ } else {
1411
+ throw new Error(data.detail || '未知错误');
1412
+ }
1413
+ loadAccounts();
1414
+ } catch (e) {
1415
+ showToast(`账号 ${id} 测试失败: ${e.message}`, 'error');
1416
+ }
1417
+ }
1418
+
1419
+ async function toggleAccount(id) {
1420
+ const acc = accountsData.find(a => a.id === id);
1421
+ const action = acc && acc.enabled !== false ? '停用' : '启用';
1422
+ try {
1423
+ const res = await apiFetch(`${API_BASE}/api/accounts/${id}/toggle`, {
1424
+ method: 'POST',
1425
+ headers: { 'Content-Type': 'application/json' }
1426
+ });
1427
+ const data = await res.json();
1428
+ if (res.ok && data.success) {
1429
+ showToast(`账号 ${id} ${action}成功!`, 'success');
1430
+ loadAccounts();
1431
+ } else {
1432
+ throw new Error(data.error || data.detail || '未知错误');
1433
+ }
1434
+ } catch (e) {
1435
+ showToast(`账号 ${id} ${action}失败: ${e.message}`, 'error');
1436
+ }
1437
+ }
1438
+
1439
+ /**
1440
+ * 显示刷新Cookie的模态框
1441
+ * @param {number} id - 账号ID
1442
+ */
1443
+ function showRefreshCookieModal(id) {
1444
+ const acc = accountsData.find(a => a.id === id);
1445
+ if (!acc) {
1446
+ showToast('账号不存在', 'error');
1447
+ return;
1448
+ }
1449
+
1450
+ document.getElementById('refreshAccountId').value = id;
1451
+ document.getElementById('refreshSecureCses').value = '';
1452
+ document.getElementById('refreshHostCoses').value = '';
1453
+ document.getElementById('refreshCsesidx').value = '';
1454
+ document.getElementById('refreshCookieJson').value = '';
1455
+
1456
+ openModal('refreshCookieModal');
1457
+ }
1458
+
1459
+ /**
1460
+ * 从JSON解析并填充刷新Cookie表单
1461
+ * @param {string} text - JSON字符串
1462
+ */
1463
+ function parseRefreshCookieJson(text) {
1464
+ const textarea = document.getElementById('refreshCookieJson');
1465
+ const raw = (typeof text === 'string' ? text : textarea.value || '').trim();
1466
+ if (!raw) {
1467
+ showToast('请先粘贴Cookie JSON', 'warning');
1468
+ return;
1469
+ }
1470
+ let acc;
1471
+ try {
1472
+ const parsed = JSON.parse(raw);
1473
+ acc = Array.isArray(parsed) ? parsed[0] : parsed;
1474
+ if (!acc || typeof acc !== 'object') throw new Error('格式不正确');
1475
+ } catch (err) {
1476
+ showToast('解析失败: ' + err.message, 'error');
1477
+ return;
1478
+ }
1479
+
1480
+ document.getElementById('refreshSecureCses').value = acc.secure_c_ses || '';
1481
+ document.getElementById('refreshHostCoses').value = acc.host_c_oses || '';
1482
+ document.getElementById('refreshCsesidx').value = acc.csesidx || '';
1483
+ showToast('已填充Cookie信息', 'success');
1484
+ }
1485
+
1486
+ /**
1487
+ * 从剪贴板粘贴并解析刷新Cookie JSON
1488
+ */
1489
+ async function pasteRefreshCookieJson() {
1490
+ try {
1491
+ const text = await navigator.clipboard.readText();
1492
+ document.getElementById('refreshCookieJson').value = text;
1493
+ parseRefreshCookieJson(text);
1494
+ } catch (e) {
1495
+ showToast('无法读取剪贴板: ' + e.message, 'error');
1496
+ }
1497
+ }
1498
+
1499
+ /**
1500
+ * 刷新账号Cookie
1501
+ * 调用后端API更新账号的Cookie信息
1502
+ */
1503
+ async function refreshAccountCookie() {
1504
+ const id = document.getElementById('refreshAccountId').value;
1505
+ const secureCses = document.getElementById('refreshSecureCses').value.trim();
1506
+ const hostCoses = document.getElementById('refreshHostCoses').value.trim();
1507
+ const csesidx = document.getElementById('refreshCsesidx').value.trim();
1508
+
1509
+ // 验证必填字段
1510
+ if (!secureCses || !hostCoses) {
1511
+ showToast('secure_c_ses 和 host_c_oses 为必填项', 'warning');
1512
+ return;
1513
+ }
1514
+
1515
+ try {
1516
+ const res = await apiFetch(`${API_BASE}/api/accounts/${id}/refresh-cookie`, {
1517
+ method: 'POST',
1518
+ headers: { 'Content-Type': 'application/json' },
1519
+ body: JSON.stringify({
1520
+ secure_c_ses: secureCses,
1521
+ host_c_oses: hostCoses,
1522
+ csesidx: csesidx || undefined
1523
+ })
1524
+ });
1525
+ const data = await res.json();
1526
+
1527
+ if (res.ok && data.success) {
1528
+ showToast('Cookie刷新成功!', 'success');
1529
+ closeModal('refreshCookieModal');
1530
+ loadAccounts();
1531
+ } else {
1532
+ throw new Error(data.error || data.detail || '未知错误');
1533
+ }
1534
+ } catch (e) {
1535
+ showToast('Cookie刷新失败: ' + e.message, 'error');
1536
+ }
1537
+ }
1538
+
1539
+ // --- 模型管理 (Models) ---
1540
+ async function loadModels() {
1541
+ try {
1542
+ const res = await apiFetch(`${API_BASE}/api/models`);
1543
+ const data = await res.json();
1544
+ modelsData = data.models || [];
1545
+ renderModels();
1546
+ } catch (e) {
1547
+ showToast('加载模型列表失败: ' + e.message, 'error');
1548
+ }
1549
+ }
1550
+
1551
+ function escapeHtml(str) {
1552
+ if (!str) return '';
1553
+ return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#039;');
1554
+ }
1555
+
1556
+ function renderModels() {
1557
+ const tbody = document.getElementById('modelsTableBody');
1558
+ if (!tbody) return;
1559
+ if (modelsData.length === 0) {
1560
+ tbody.innerHTML = `<tr><td colspan="7" class="empty-state">
1561
+ <div class="empty-state-icon"><svg class="icon"><use xlink:href="#icon-robot"></use></svg></div>
1562
+ <h3>暂无模型</h3><p>点击 "添加模型" 按钮来创建一个。</p>
1563
+ </td></tr>`;
1564
+ return;
1565
+ }
1566
+ tbody.innerHTML = modelsData.map((model, index) => {
1567
+ const safeId = escapeHtml(model.id);
1568
+ const safeName = escapeHtml(model.name);
1569
+ const safeDesc = escapeHtml(model.description);
1570
+ return `
1571
+ <tr>
1572
+ <td><code>${safeId}</code></td>
1573
+ <td>${safeName}</td>
1574
+ <td title="${safeDesc}">${model.description ? safeDesc.substring(0, 40) + '...' : ''}</td>
1575
+ <td>${model.context_length}</td>
1576
+ <td>${model.max_tokens}</td>
1577
+ <td><span class="badge ${model.is_public ? 'badge-success' : 'badge-warning'}">${model.is_public ? '公共' : '私有'}</span></td>
1578
+ <td>
1579
+ <button class="btn btn-sm btn-outline btn-icon" onclick="showEditModelModalByIndex(${index})" title="编辑">✏️</button>
1580
+ <button class="btn btn-sm btn-danger btn-icon" onclick="deleteModelByIndex(${index})" title="删除">🗑️</button>
1581
+ </td>
1582
+ </tr>
1583
+ `;
1584
+ }).join('');
1585
+ }
1586
+
1587
+ function showAddModelModal() {
1588
+ openModal('addModelModal');
1589
+ }
1590
+
1591
+ function showEditModelModalByIndex(index) {
1592
+ const model = modelsData[index];
1593
+ if (!model) return;
1594
+
1595
+ document.getElementById('editModelOriginalId').value = model.id;
1596
+ document.getElementById('editModelId').value = model.id;
1597
+ document.getElementById('editModelName').value = model.name || '';
1598
+ document.getElementById('editModelDesc').value = model.description || '';
1599
+ document.getElementById('editContextLength').value = model.context_length || '';
1600
+ document.getElementById('editMaxTokens').value = model.max_tokens || '';
1601
+
1602
+ openModal('editModelModal');
1603
+ }
1604
+
1605
+ async function updateModel() {
1606
+ const originalId = document.getElementById('editModelOriginalId').value;
1607
+ const model = {
1608
+ name: document.getElementById('editModelName').value,
1609
+ description: document.getElementById('editModelDesc').value,
1610
+ context_length: parseInt(document.getElementById('editContextLength').value) || 32000,
1611
+ max_tokens: parseInt(document.getElementById('editMaxTokens').value) || 8096
1612
+ };
1613
+
1614
+ try {
1615
+ const res = await apiFetch(`${API_BASE}/api/models/${encodeURIComponent(originalId)}`, {
1616
+ method: 'PUT',
1617
+ headers: { 'Content-Type': 'application/json' },
1618
+ body: JSON.stringify(model)
1619
+ });
1620
+ const data = await res.json();
1621
+
1622
+ if (data.success) {
1623
+ showToast('模型更新成功', 'success');
1624
+ closeModal('editModelModal');
1625
+ loadModels();
1626
+ } else {
1627
+ showToast('更新失败: ' + (data.error || '未知错误'), 'error');
1628
+ }
1629
+ } catch (e) {
1630
+ showToast('更新失败: ' + e.message, 'error');
1631
+ }
1632
+ }
1633
+
1634
+ /**
1635
+ * 保存新模型
1636
+ * 从添加模型模态框获取数据并调用API创建新模型
1637
+ */
1638
+ async function saveNewModel() {
1639
+ const modelId = document.getElementById('newModelId').value.trim();
1640
+ const modelName = document.getElementById('newModelName').value.trim();
1641
+ const modelDesc = document.getElementById('newModelDesc').value.trim();
1642
+ const contextLength = parseInt(document.getElementById('newContextLength').value) || 32000;
1643
+ const maxTokens = parseInt(document.getElementById('newMaxTokens').value) || 8096;
1644
+
1645
+ // 验证必填字段
1646
+ if (!modelId) {
1647
+ showToast('请输入模型ID', 'warning');
1648
+ return;
1649
+ }
1650
+ if (!modelName) {
1651
+ showToast('请输入模型名称', 'warning');
1652
+ return;
1653
+ }
1654
+
1655
+ const model = {
1656
+ id: modelId,
1657
+ name: modelName,
1658
+ description: modelDesc,
1659
+ context_length: contextLength,
1660
+ max_tokens: maxTokens
1661
+ };
1662
+
1663
+ try {
1664
+ const res = await apiFetch(`${API_BASE}/api/models`, {
1665
+ method: 'POST',
1666
+ headers: { 'Content-Type': 'application/json' },
1667
+ body: JSON.stringify(model)
1668
+ });
1669
+ const data = await res.json();
1670
+
1671
+ if (res.ok && (data.success || !data.error)) {
1672
+ showToast('模型添加成功', 'success');
1673
+ closeModal('addModelModal');
1674
+ // 清空表单
1675
+ document.getElementById('newModelId').value = '';
1676
+ document.getElementById('newModelName').value = '';
1677
+ document.getElementById('newModelDesc').value = '';
1678
+ document.getElementById('newContextLength').value = '';
1679
+ document.getElementById('newMaxTokens').value = '';
1680
+ loadModels();
1681
+ } else {
1682
+ throw new Error(data.error || '添加失败');
1683
+ }
1684
+ } catch (e) {
1685
+ showToast('添加模型失败: ' + e.message, 'error');
1686
+ }
1687
+ }
1688
+
1689
+ /**
1690
+ * 删除模型
1691
+ * @param {string} id - 模型ID
1692
+ */
1693
+ async function deleteModelByIndex(index) {
1694
+ const model = modelsData[index];
1695
+ if (!model) return;
1696
+ const id = model.id;
1697
+ if (!confirm(`确定要删除模型 "${id}" 吗?此操作不可恢复。`)) {
1698
+ return;
1699
+ }
1700
+
1701
+ try {
1702
+ const res = await apiFetch(`${API_BASE}/api/models/${encodeURIComponent(id)}`, {
1703
+ method: 'DELETE'
1704
+ });
1705
+ const data = await res.json();
1706
+
1707
+ if (res.ok && (data.success || !data.error)) {
1708
+ showToast('模型删除成功', 'success');
1709
+ loadModels();
1710
+ } else {
1711
+ throw new Error(data.error || '删除失败');
1712
+ }
1713
+ } catch (e) {
1714
+ showToast('删除模型失败: ' + e.message, 'error');
1715
+ }
1716
+ }
1717
+
1718
+ // --- 系统设置 (Settings) ---
1719
+ async function loadConfig() {
1720
+ try {
1721
+ const res = await apiFetch(`${API_BASE}/api/config`);
1722
+ configData = await res.json();
1723
+ document.getElementById('proxyUrl').value = configData.proxy || '';
1724
+ const imageModeSelect = document.getElementById('imageOutputMode');
1725
+ if (imageModeSelect) {
1726
+ const mode = (configData.image_output_mode || 'url');
1727
+ imageModeSelect.value = mode === 'base64' ? 'base64' : 'url';
1728
+ }
1729
+ document.getElementById('configJson').value = JSON.stringify(configData, null, 2);
1730
+ } catch (e) {
1731
+ showToast('加载配置失败: ' + e.message, 'error');
1732
+ }
1733
+ }
1734
+
1735
+ async function loadLogLevel() {
1736
+ try {
1737
+ const res = await apiFetch(`${API_BASE}/api/logging`);
1738
+ const data = await res.json();
1739
+ const select = document.getElementById('logLevelSelect');
1740
+ if (select && data.level) {
1741
+ select.value = data.level;
1742
+ }
1743
+ } catch (e) {
1744
+ console.warn('日志级别加载失败', e);
1745
+ }
1746
+ }
1747
+
1748
+ async function updateLogLevel(level) {
1749
+ try {
1750
+ const res = await apiFetch(`${API_BASE}/api/logging`, {
1751
+ method: 'POST',
1752
+ headers: { 'Content-Type': 'application/json' },
1753
+ body: JSON.stringify({ level })
1754
+ });
1755
+ const data = await res.json();
1756
+ if (!res.ok || data.error) {
1757
+ throw new Error(data.error || '设置失败');
1758
+ }
1759
+ showToast(`日志级别已切换为 ${data.level}`, 'success');
1760
+ } catch (e) {
1761
+ showToast('日志级别设置失败: ' + e.message, 'error');
1762
+ }
1763
+ }
1764
+
1765
+ // --- Token 管理 ---
1766
+ async function loadTokens() {
1767
+ try {
1768
+ const res = await apiFetch(`${API_BASE}/api/tokens`);
1769
+ const data = await res.json();
1770
+ tokensData = data.tokens || [];
1771
+ renderTokens();
1772
+ } catch (e) {
1773
+ showToast('加载 Token 失败: ' + e.message, 'error');
1774
+ }
1775
+ }
1776
+
1777
+ function renderTokens() {
1778
+ const tbody = document.getElementById('tokensTableBody');
1779
+ if (!tbody) return;
1780
+ if (!tokensData.length) {
1781
+ tbody.innerHTML = `<tr><td colspan="2" class="empty-state">暂无 Token</td></tr>`;
1782
+ return;
1783
+ }
1784
+ tbody.innerHTML = tokensData.map(token => `
1785
+ <tr>
1786
+ <td><code>${token}</code></td>
1787
+ <td style="white-space: nowrap;">
1788
+ <button class="btn btn-outline btn-sm" data-token="${token}" onclick="copyToken(this.dataset.token)" title="复制Token">复制</button>
1789
+ <button class="btn btn-danger btn-sm" data-token="${token}" onclick="deleteToken(this.dataset.token)" title="删除Token">删除</button>
1790
+ </td>
1791
+ </tr>
1792
+ `).join('');
1793
+ }
1794
+
1795
+ async function addToken() {
1796
+ const manual = document.getElementById('manualToken').value.trim();
1797
+ try {
1798
+ const res = await apiFetch(`${API_BASE}/api/tokens`, {
1799
+ method: 'POST',
1800
+ headers: { 'Content-Type': 'application/json' },
1801
+ body: JSON.stringify(manual ? { token: manual } : {})
1802
+ });
1803
+ const data = await res.json();
1804
+ if (!res.ok || data.error) throw new Error(data.error || '创建失败');
1805
+ document.getElementById('manualToken').value = data.token;
1806
+ showToast('Token 创建成功', 'success');
1807
+ loadTokens();
1808
+ } catch (e) {
1809
+ showToast('创建 Token 失败: ' + e.message, 'error');
1810
+ }
1811
+ }
1812
+
1813
+ function generateToken() {
1814
+ if (window.crypto && crypto.randomUUID) {
1815
+ document.getElementById('manualToken').value = crypto.randomUUID().replace(/-/g, '');
1816
+ } else {
1817
+ document.getElementById('manualToken').value = Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2);
1818
+ }
1819
+ }
1820
+
1821
+ async function deleteToken(token) {
1822
+ if (!confirm('确定删除该 Token 吗?')) return;
1823
+ try {
1824
+ const res = await apiFetch(`${API_BASE}/api/tokens/${token}`, { method: 'DELETE' });
1825
+ const data = await res.json();
1826
+ if (!res.ok || data.error) throw new Error(data.error || '删除失败');
1827
+ showToast('Token 删除成功', 'success');
1828
+ loadTokens();
1829
+ } catch (e) {
1830
+ showToast('删除 Token 失败: ' + e.message, 'error');
1831
+ }
1832
+ }
1833
+
1834
+ function copyToken(token) {
1835
+ if (!token) {
1836
+ showToast('无效的 Token', 'warning');
1837
+ return;
1838
+ }
1839
+ if (navigator.clipboard && navigator.clipboard.writeText) {
1840
+ navigator.clipboard.writeText(token).then(() => {
1841
+ showToast('已复制', 'success');
1842
+ }).catch(() => {
1843
+ fallbackCopy(token);
1844
+ });
1845
+ } else {
1846
+ fallbackCopy(token);
1847
+ }
1848
+ }
1849
+
1850
+ function fallbackCopy(text) {
1851
+ try {
1852
+ const textarea = document.createElement('textarea');
1853
+ textarea.value = text;
1854
+ document.body.appendChild(textarea);
1855
+ textarea.select();
1856
+ document.execCommand('copy');
1857
+ document.body.removeChild(textarea);
1858
+ showToast('已复制', 'success');
1859
+ } catch (err) {
1860
+ showToast('复制失败', 'error');
1861
+ }
1862
+ }
1863
+
1864
+ function logoutAdmin() {
1865
+ localStorage.removeItem(ADMIN_TOKEN_KEY);
1866
+ document.cookie = 'admin_token=; Max-Age=0; path=/';
1867
+ showToast('已注销', 'success');
1868
+ updateLoginButton();
1869
+ }
1870
+
1871
+ function showLoginModal() {
1872
+ document.getElementById('loginPassword').value = '';
1873
+ openModal('loginModal');
1874
+ }
1875
+
1876
+ async function submitLogin() {
1877
+ const pwd = document.getElementById('loginPassword').value;
1878
+ if (!pwd) {
1879
+ showToast('请输入密码', 'warning');
1880
+ return;
1881
+ }
1882
+ try {
1883
+ const res = await fetch(`${API_BASE}/api/auth/login`, {
1884
+ method: 'POST',
1885
+ headers: { 'Content-Type': 'application/json' },
1886
+ body: JSON.stringify({ password: pwd })
1887
+ });
1888
+ const data = await res.json();
1889
+ if (!res.ok || data.error) {
1890
+ throw new Error(data.error || '登录失败');
1891
+ }
1892
+ localStorage.setItem(ADMIN_TOKEN_KEY, data.token);
1893
+ showToast('登录成功', 'success');
1894
+ closeModal('loginModal');
1895
+ loadAllData();
1896
+ updateLoginButton();
1897
+ } catch (e) {
1898
+ showToast('登录失败: ' + e.message, 'error');
1899
+ }
1900
+ }
1901
+
1902
+ async function saveSettings() {
1903
+ const proxyUrl = document.getElementById('proxyUrl').value;
1904
+ const imageModeSelect = document.getElementById('imageOutputMode');
1905
+ const imageOutputMode = imageModeSelect ? imageModeSelect.value : 'url';
1906
+ try {
1907
+ const res = await apiFetch(`${API_BASE}/api/config`, {
1908
+ method: 'PUT',
1909
+ headers: { 'Content-Type': 'application/json' },
1910
+ body: JSON.stringify({ proxy: proxyUrl, image_output_mode: imageOutputMode })
1911
+ });
1912
+ if (!res.ok) throw new Error((await res.json()).detail);
1913
+ showToast('设置保存成功!', 'success');
1914
+ loadConfig();
1915
+ } catch (e) {
1916
+ showToast('保存失败: ' + e.message, 'error');
1917
+ }
1918
+ }
1919
+
1920
+ async function testProxy() {
1921
+ const proxyUrl = document.getElementById('proxyUrl').value;
1922
+ const proxyStatus = document.getElementById('proxyStatus');
1923
+ proxyStatus.textContent = '测试中...';
1924
+ proxyStatus.style.color = 'var(--text-muted)';
1925
+ try {
1926
+ const res = await apiFetch(`${API_BASE}/api/proxy/test`, {
1927
+ method: 'POST',
1928
+ headers: { 'Content-Type': 'application/json' },
1929
+ body: JSON.stringify({ proxy: proxyUrl })
1930
+ });
1931
+ const data = await res.json();
1932
+ if (res.ok && data.success) {
1933
+ proxyStatus.textContent = `测试成功! (${data.delay_ms}ms)`;
1934
+ proxyStatus.style.color = 'var(--success)';
1935
+ } else {
1936
+ throw new Error(data.detail);
1937
+ }
1938
+ } catch (e) {
1939
+ proxyStatus.textContent = `测试失败: ${e.message}`;
1940
+ proxyStatus.style.color = 'var(--danger)';
1941
+ }
1942
+ }
1943
+
1944
+ function refreshConfig() {
1945
+ loadConfig();
1946
+ showToast('配置已刷新', 'info');
1947
+ }
1948
+
1949
+ function downloadConfig() {
1950
+ const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(configData, null, 2));
1951
+ const downloadAnchorNode = document.createElement('a');
1952
+ downloadAnchorNode.setAttribute("href", dataStr);
1953
+ downloadAnchorNode.setAttribute("download", "business_gemini_session.json");
1954
+ document.body.appendChild(downloadAnchorNode);
1955
+ downloadAnchorNode.click();
1956
+ downloadAnchorNode.remove();
1957
+ showToast('配置文件已开始下载', 'success');
1958
+ }
1959
+
1960
+ function uploadConfig() {
1961
+ document.getElementById('configFileInput').click();
1962
+ }
1963
+
1964
+ function handleConfigUpload(event) {
1965
+ const file = event.target.files[0];
1966
+ if (!file) return;
1967
+ const reader = new FileReader();
1968
+ reader.onload = async (e) => {
1969
+ try {
1970
+ const newConfig = JSON.parse(e.target.result);
1971
+ const res = await apiFetch(`${API_BASE}/api/config/import`, {
1972
+ method: 'POST',
1973
+ headers: { 'Content-Type': 'application/json' },
1974
+ body: JSON.stringify(newConfig)
1975
+ });
1976
+ if (!res.ok) throw new Error((await res.json()).detail);
1977
+ showToast('配置导入成功!', 'success');
1978
+ loadAllData();
1979
+ } catch (err) {
1980
+ showToast('导入失败: ' + err.message, 'error');
1981
+ }
1982
+ };
1983
+ reader.readAsText(file);
1984
+ }
1985
+
1986
+ // --- 模态框控制 ---
1987
+ function openModal(modalId) {
1988
+ const modal = document.getElementById(modalId);
1989
+ if (modal) modal.classList.add('show');
1990
+ }
1991
+
1992
+ function closeModal(modalId) {
1993
+ const modal = document.getElementById(modalId);
1994
+ if (modal) modal.classList.remove('show');
1995
+ }
1996
+
1997
+ document.querySelectorAll('.modal').forEach(modal => {
1998
+ modal.addEventListener('click', (e) => {
1999
+ if (e.target.classList.contains('modal')) {
2000
+ closeModal(modal.id);
2001
+ }
2002
+ });
2003
+ });
2004
+ </script>
2005
+
2006
+ </body>
2007
+ </html>