File size: 20,333 Bytes
3c2af29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8">
  <link rel="icon" type="image/x-icon" href="data:image/x-icon;,">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Token 信息管理</title>
  <!-- 引入共享样式 -->
  <link rel="stylesheet" href="/static/shared-styles.css">
  <script src="/static/shared.js"></script>
  <style>
    .token-container {
      display: grid;
      gap: var(--spacing);
    }

    .token-section {
      background: var(--card-background);
      padding: var(--spacing);
      border-radius: var(--border-radius);
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .shortcuts {
      margin-top: var(--spacing);
      padding: 12px;
      background: var(--disabled-bg);
      border-radius: 4px;
      font-size: 14px;
      color: var(--text-secondary);
    }

    kbd {
      background: var(--card-background);
      border-radius: 3px;
      border: 1px solid var(--border-color);
      padding: 1px 4px;
      font-size: 12px;
      color: var(--text-primary);
    }

    .token-table {
      width: 100%;
      border-collapse: collapse;
      margin: 8px 0;
      background: var(--card-background);
    }

    .token-table th,
    .token-table td {
      padding: 8px;
      text-align: left;
      border-bottom: 1px solid var(--border-color);
    }

    .token-table th {
      background: var(--disabled-bg);
      font-weight: 500;
      color: var(--text-primary);
    }

    .token-list-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .token-list-header button {
      padding: 4px 12px;
      font-size: 14px;
    }

    /* Token表格样式优化 */
    .token-table td {
      max-width: 200px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: var(--text-primary);
    }

    .token-table tr:hover {
      background: var(--primary-color-alpha);
    }

    .token-table tr:hover td {
      white-space: normal;
      word-break: break-all;
    }

    /* 操作按钮样式 */
    .action-cell {
      width: 160px;
      /* 增加宽度以容纳两个按钮 */
      text-align: center !important;
    }

    .action-cell button {
      padding: 2px 8px;
      font-size: 12px;
      white-space: nowrap;
      margin: 0 2px;
      /* 添加按钮间距 */
    }

    /* 提示框样式 */
    .modal {
      display: none;
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: var(--card-background);
      padding: 20px;
      border-radius: var(--border-radius);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
      z-index: 1000;
      width: 90%;
      max-width: 500px;
      color: var(--text-primary);
    }

    .modal-backdrop {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.5);
      z-index: 999;
    }

    .modal-header {
      margin-bottom: 15px;
      border-bottom: 1px solid var(--border-color);
      padding-bottom: 10px;
    }

    .modal-header h3 {
      margin: 0;
      color: var(--text-primary);
    }

    .modal-footer {
      margin-top: 15px;
      padding-top: 15px;
      border-top: 1px solid var(--border-color);
      text-align: right;
    }

    /* 复选框容器样式 */
    .checkbox-container {
      margin: 8px 0;
    }

    .checkbox-container label {
      display: inline;
      margin-left: 8px;
      color: var(--text-primary);
    }

    /* 帮助文本样式 */
    .help-text {
      color: var(--text-secondary);
    }

    @media (prefers-color-scheme: dark) {
      .modal {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
      }

      .token-table tr:hover {
        background: rgba(144, 202, 249, 0.1);
        /* --primary-color in dark mode */
      }
    }

    /* Key结果样式 */
    .key-result {
      background: var(--card-background);
      padding: var(--spacing);
      border-radius: var(--border-radius);
      border: 1px solid var(--border-color);
      margin-top: var(--spacing);
      position: relative;
      cursor: pointer;
      transition: all var(--transition-fast);
    }

    .key-result:hover {
      background: var(--primary-color-alpha);
      border-color: var(--primary-color);
    }

    .key-result:active {
      transform: translateY(1px);
    }

    .key-content {
      overflow-x: auto;
      white-space: nowrap;
      scrollbar-width: thin;
      /* Firefox */
      -ms-overflow-style: none;
      /* IE and Edge */
    }

    /* Webkit浏览器的滚动条样式 */
    .key-content::-webkit-scrollbar {
      height: 6px;
    }

    .key-content::-webkit-scrollbar-track {
      background: var(--disabled-bg);
      border-radius: 3px;
    }

    .key-content::-webkit-scrollbar-thumb {
      background: var(--border-color);
      border-radius: 3px;
    }

    .key-content::-webkit-scrollbar-thumb:hover {
      background: var(--text-secondary);
    }

    @media (prefers-color-scheme: dark) {
      .key-content::-webkit-scrollbar-track {
        background: var(--card-background);
      }

      .key-content::-webkit-scrollbar-thumb {
        background: var(--text-secondary);
      }

      .key-content::-webkit-scrollbar-thumb:hover {
        background: var(--text-primary);
      }
    }

    .model-list {
      max-height: 150px;
      overflow-y: auto;
      padding: 8px;
      border: 1px solid var(--border-color);
      border-radius: 4px;
      margin-top: 8px;
      background: var(--card-background);
    }

    .model-item {
      display: flex;
      align-items: center;
      margin-bottom: 4px;
    }

    .model-item input[type="checkbox"] {
      margin-right: 8px;
    }

    /* 确认对话框的额外样式 */
    #confirmModal {
      max-width: 400px;
    }

    #confirmModal .modal-content {
      margin: 20px 0;
      text-align: center;
    }

    #confirmModal .modal-footer button {
      min-width: 80px;
      margin-left: 10px;
    }
  </style>
</head>

<body>
  <h1>Token 信息管理</h1>

  <div class="container">
    <div class="form-group">
      <label>认证令牌:</label>
      <input type="password" id="authToken" placeholder="输入 AUTH_TOKEN">
    </div>
  </div>

  <div class="token-container">
    <div class="token-section">
      <h3>Token 管理</h3>
      <div class="button-group">
        <button onclick="getTokenInfo()">获取当前配置</button>
        <button onclick="reloadTokens()" class="secondary">重载Token</button>
        <button onclick="addTokens()" class="secondary">添加Token</button>
        <button onclick="deleteTokens()" class="danger">删除Token</button>
      </div>

      <div class="form-group">
        <label>Token 操作:</label>
        <textarea id="tokenInput" placeholder="每行一个 token"></textarea>
        <div class="help-text">添加模式: 输入要添加的token,每行一个
          删除模式: 输入要删除的token,每行一个</div>
      </div>

      <div class="form-group">
        <div class="token-list-header">
          <label>当前Token列表:</label>
          <button onclick="copyTokenList()" class="secondary">复制列表</button>
        </div>
        <table class="token-table">
          <thead>
            <tr>
              <th>Token</th>
              <th>Checksum</th>
              <th>邮箱</th>
              <th>会员类型</th>
              <th>Premium用量</th>
              <th>试用剩余</th>
              <th class="action-cell">操作</th>
            </tr>
          </thead>
          <tbody id="tokenTableBody">
          </tbody>
        </table>
      </div>

      <div class="shortcuts">
        快捷键: <kbd>Ctrl</kbd> + <kbd>Enter</kbd> 执行当前操作
      </div>
    </div>
  </div>

  <div id="message"></div>

  <!-- 动态key生成对话框 -->
  <div class="modal-backdrop" id="keyModal-backdrop" onclick="closeKeyModal()"></div>
  <div class="modal" id="keyModal">
    <div class="modal-header">
      <h3>生成动态Key</h3>
    </div>
    <div class="form-group">
      <label>图片处理能力:</label>
      <select id="disableVision">
        <option value="">跟随全局</option>
        <option value="true">禁用</option>
        <option value="false">启用</option>
      </select>
    </div>
    <div class="form-group">
      <label>慢速池:</label>
      <select id="enableSlowPool">
        <option value="">跟随全局</option>
        <option value="true">启用</option>
        <option value="false">禁用</option>
      </select>
    </div>
    <div class="form-group">
      <label>使用量检查模型规则:</label>
      <select id="usageCheckType" onchange="toggleModelList()">
        <option value="">跟随全局</option>
        <option value="default">默认</option>
        <option value="disabled">禁用</option>
        <option value="all">所有</option>
        <option value="custom">自定义</option>
      </select>
      <div id="modelListContainer" class="model-list" style="display: none;">
        <!-- 模型列表将通过 JavaScript 动态填充 -->
      </div>
    </div>
    <div class="form-group">
      <label>包含网络引用:</label>
      <select id="includeWebReferences">
        <option value="">跟随全局</option>
        <option value="true">启用</option>
        <option value="false">禁用</option>
      </select>
    </div>
    <div class="key-result" id="keyResult" style="display: none;" onclick="copyGeneratedKey()">
      <div class="key-content" id="keyContent"></div>
    </div>
    <div class="modal-footer">
      <button onclick="closeKeyModal()" class="secondary">取消</button>
      <button onclick="generateKey()" class="primary">生成</button>
    </div>
  </div>

  <!-- 添加确认对话框 -->
  <div class="modal-backdrop" id="confirmModal-backdrop"></div>
  <div class="modal" id="confirmModal">
    <div class="modal-header">
      <h3>确认删除</h3>
    </div>
    <div class="modal-content">
      <p>确定要删除这个token吗?</p>
    </div>
    <div class="modal-footer">
      <button onclick="closeConfirmModal()" class="secondary">取消</button>
      <button onclick="confirmDelete()" class="danger">删除</button>
    </div>
  </div>

  <script>
    async function getTokenInfo() {
      const data = await makeAuthenticatedRequest('/tokens/get');
      if (data) {
        const tableBody = document.getElementById('tokenTableBody');
        tableBody.innerHTML = data.tokens.map(t => {
          const profile = t.profile || {};
          const user = profile.user || {};
          const stripe = profile.stripe || {};
          const usage = profile.usage || {};
          const premium = usage.premium || {};

          return `<tr><td title="${t.token}">${t.token}</td><td title="${t.checksum}">${t.checksum}</td><td>${user.email || '-'}</td><td>${formatMembershipType(stripe.membership_type)}</td><td>${premium.requests || 0}/${premium.max_requests || '∞'}</td><td>${stripe.days_remaining_on_trial > 0 ? `${stripe.days_remaining_on_trial}天` : '-'}</td><td class="action-cell"><button onclick="showKeyModal('${t.token}','${t.checksum}')" class="secondary">生成Key</button><button onclick="deleteToken('${t.token}')" class="danger">删除</button></td></tr>`;
        }).join('');
        showGlobalMessage('配置获取成功');
      }
    }

    function copyTokenList() {
      const tableBody = document.getElementById('tokenTableBody');
      const rows = tableBody.getElementsByTagName('tr');
      const tokenList = Array.from(rows).map(row => {
        const token = row.cells[0].textContent;
        const checksum = row.cells[1].textContent;
        return `${token},${checksum}`;
      }).join('\n');

      navigator.clipboard.writeText(tokenList).then(() => {
        showGlobalMessage('Token列表已复制到剪贴板');
      }).catch(err => {
        showGlobalMessage('复制失败: ' + err, true);
      });
    }

    async function reloadTokens() {
      const data = await makeAuthenticatedRequest('/tokens/reload');
      if (data) {
        showGlobalMessage(`Token重载成功: ${data.message}`);
        getTokenInfo(); // 刷新当前配置
      }
    }

    async function addTokens() {
      const tokensInput = document.getElementById('tokenInput').value;

      if (!tokensInput) {
        showGlobalMessage('请输入要添加的Token', true);
        return;
      }

      // 处理输入的tokens,跳过空行和注释,解析token和checksum
      const tokenList = tokensInput.split('\n')
        .map(line => line.trim())
        .filter(line => line && !line.startsWith('#'))
        .map(line => {
          const parts = line.includes(',') ? line.split(',') : [line];
          return {
            token: parts[0].trim(),
            checksum: parts[1]?.trim() || null
          };
        });

      if (tokenList.length === 0) {
        showGlobalMessage('没有有效的Token输入', true);
        return;
      }

      const data = await makeAuthenticatedRequest('/tokens/add', {
        body: JSON.stringify(tokenList)
      });

      if (data) {
        showGlobalMessage(`添加成功: ${data.message}`);
        document.getElementById('tokenInput').value = '';
        getTokenInfo(); // 刷新当前配置
      }
    }

    async function deleteTokens() {
      const tokensToDelete = document.getElementById('tokenInput').value;

      if (!tokensToDelete) {
        showGlobalMessage('请输入要删除的Token', true);
        return;
      }

      const tokens = tokensToDelete.trim().split('\n').filter(t => t);

      const data = await makeAuthenticatedRequest('/tokens/delete', {
        body: JSON.stringify({
          tokens: tokens,
          expectation: 'detailed'
        })
      });

      if (data) {
        let message = '删除操作完成\n';
        if (data.failed_tokens?.length) {
          message += `\n未找到的Token: ${data.failed_tokens.join('\n')}`;
        }
        if (data.updated_tokens?.length) {
          message += `\n剩余Token: ${data.updated_tokens.join('\n')}`;
        }
        showGlobalMessage(message, timeout = 30000);
        document.getElementById('tokenInput').value = '';
        getTokenInfo();
      }
    }

    // 添加删除单个token的函数
    let tokenToDelete = null;

    function showConfirmModal(token) {
      tokenToDelete = token;
      const modal = document.getElementById('confirmModal');
      const backdrop = document.getElementById('confirmModal-backdrop');
      modal.style.display = 'block';
      backdrop.style.display = 'block';
    }

    function closeConfirmModal() {
      const modal = document.getElementById('confirmModal');
      const backdrop = document.getElementById('confirmModal-backdrop');
      modal.style.display = 'none';
      backdrop.style.display = 'none';
      tokenToDelete = null;
    }

    async function confirmDelete() {
      if (!tokenToDelete) return;

      const data = await makeAuthenticatedRequest('/tokens/delete', {
        body: JSON.stringify({
          tokens: [tokenToDelete],
          expectation: 'detailed'
        })
      });

      if (data) {
        showGlobalMessage('Token删除成功');
        getTokenInfo();
      }

      closeConfirmModal();
    }

    // 修改deleteToken函数
    function deleteToken(token) {
      showConfirmModal(token);
    }

    // 动态key相关函数
    let availableModels = [];
    let currentToken = '';
    let currentChecksum = '';

    async function getModels() {
      try {
        const response = await fetch('/v1/models');
        const data = await response.json();
        availableModels = data.data.map(model => model.id);
        updateModelList();
      } catch (error) {
        showGlobalMessage('获取模型列表失败', true);
      }
    }

    function updateModelList() {
      const container = document.getElementById('modelListContainer');
      container.innerHTML = availableModels.map(model => `<div class="model-item"><input type="checkbox" id="model_${model}" value="${model}"><label for="model_${model}">${model}</label></div>`).join('');
    }

    function toggleModelList() {
      const type = document.getElementById('usageCheckType').value;
      const container = document.getElementById('modelListContainer');
      container.style.display = type === 'custom' ? 'block' : 'none';
    }

    function showKeyModal(token, checksum) {
      currentToken = token;
      currentChecksum = checksum;

      const modal = document.getElementById('keyModal');
      const backdrop = document.getElementById('keyModal-backdrop');

      modal.style.display = 'block';
      backdrop.style.display = 'block';
      document.getElementById('keyResult').style.display = 'none';

      // 添加点击事件处理
      modal.addEventListener('click', function (event) {
        event.stopPropagation();  // 防止点击modal内部时触发backdrop的点击事件
      });

      // 重置所有选项
      document.getElementById('disableVision').value = '';
      document.getElementById('enableSlowPool').value = '';
      document.getElementById('usageCheckType').value = '';
      document.getElementById('modelListContainer').style.display = 'none';
      document.getElementById('includeWebReferences').value = '';
    }

    function closeKeyModal() {
      document.getElementById('keyModal').style.display = 'none';
      document.getElementById('keyModal-backdrop').style.display = 'none';
    }

    function parseBooleanFromString(value, defaultValue) {
      if (value === '') return defaultValue;
      return value === 'true';
    }

    async function generateKey() {
      const type = document.getElementById('usageCheckType').value;
      let modelIds = '';
      if (type === 'custom') {
        modelIds = Array.from(document.querySelectorAll('#modelListContainer input:checked'))
          .map(input => input.value)
          .join(',');
      }

      const payload = {
        auth_token: `${currentToken},${currentChecksum}`,
        disable_vision: parseBooleanFromString(document.getElementById('disableVision').value, undefined),
        enable_slow_pool: parseBooleanFromString(document.getElementById('enableSlowPool').value, undefined),
        usage_check_models: type ? {
          type: type,
          model_ids: type === 'custom' ? modelIds : undefined
        } : undefined,
        include_web_references: parseBooleanFromString(document.getElementById('includeWebReferences').value, undefined)
      };

      const data = await makeAuthenticatedRequest('/build-key', {
        body: JSON.stringify(payload)
      });

      if (data && data.key) {
        const keyResult = document.getElementById('keyResult');
        const keyContent = document.getElementById('keyContent');
        keyContent.textContent = data.key;
        keyResult.style.display = 'block';
        showGlobalMessage('动态Key已生成,点击复制');
      }
    }

    function copyGeneratedKey(event) {
      // 防止触发滚动条点击事件
      if (event && event.target.classList.contains('key-content') && event.offsetX > event.target.clientWidth) {
        return;
      }

      const keyContent = document.getElementById('keyContent').textContent;
      navigator.clipboard.writeText(keyContent).then(() => {
        showGlobalMessage('Key已复制到剪贴板');
      }).catch(() => {
        showGlobalMessage('复制失败', true);
      });
    }

    // 快捷键支持
    document.addEventListener('keydown', function (e) {
      if (e.ctrlKey && e.key === 'Enter') {
        e.preventDefault();
        const activeElement = document.activeElement;
        if (activeElement.id === 'tokenInput') {
          // 根据当前焦点确定操作
          const action = document.querySelector('.button-group button.active');
          if (action) {
            action.click();
          }
        }
      }
    });

    // 初始化 token 处理
    initializeTokenHandling('authToken');

    // 页面加载完成后获取当前配置和模型列表
    document.addEventListener('DOMContentLoaded', () => {
      getModels();
      getTokenInfo();
    });
  </script>
</body>

</html>