youbiaokachi commited on
Commit
7d46840
·
verified ·
1 Parent(s): 871097d

Upload 3 files

Browse files
Files changed (1) hide show
  1. templates/manager.html +42 -17
templates/manager.html CHANGED
@@ -198,6 +198,8 @@
198
  border: 1px solid var(--border-color);
199
  border-radius: 8px;
200
  font-size: 16px;
 
 
201
  }
202
 
203
  #addTokenBtn,
@@ -487,7 +489,7 @@
487
  <div class="token-input-container">
488
  <h3>添加 SSO Token</h3>
489
  <div class="token-input-section">
490
- <input type="text" id="tokenInput" placeholder="输入新的 SSO Token">
491
  <button id="addTokenBtn">添加 Token</button>
492
  </div>
493
  </div>
@@ -760,23 +762,46 @@
760
 
761
  document.getElementById('addTokenBtn').addEventListener('click', async () => {
762
  const tokenInput = document.getElementById('tokenInput');
763
- const newToken = tokenInput.value.trim();
764
- if (newToken) {
765
- try {
766
- const response = await fetch('/manager/api/add', {
767
- method: 'POST',
768
- headers: { 'Content-Type': 'application/json' },
769
- body: JSON.stringify({ sso: newToken })
770
- });
771
- if (response.ok) {
772
- tokenInput.value = '';
773
- await fetchTokenMap();
774
- showNotification('Token 添加成功');
775
- } else {
776
- showNotification('添加 Token 失败');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
777
  }
778
- } catch (error) {
779
- showNotification('添加 Token 出错');
 
 
 
 
 
 
 
 
 
780
  }
781
  }
782
  });
 
198
  border: 1px solid var(--border-color);
199
  border-radius: 8px;
200
  font-size: 16px;
201
+ font-family: 'Inter', sans-serif;
202
+ resize: vertical;
203
  }
204
 
205
  #addTokenBtn,
 
489
  <div class="token-input-container">
490
  <h3>添加 SSO Token</h3>
491
  <div class="token-input-section">
492
+ <textarea id="tokenInput" placeholder="输入新的 SSO Token(每行一个)" rows="4"></textarea>
493
  <button id="addTokenBtn">添加 Token</button>
494
  </div>
495
  </div>
 
762
 
763
  document.getElementById('addTokenBtn').addEventListener('click', async () => {
764
  const tokenInput = document.getElementById('tokenInput');
765
+ const tokenText = tokenInput.value.trim();
766
+ if (tokenText) {
767
+ const tokens = tokenText.split('\n')
768
+ .map(token => token.trim())
769
+ .filter(token => token.length > 0);
770
+
771
+ if (tokens.length === 0) {
772
+ showNotification('请输入至少一个有效的 Token');
773
+ return;
774
+ }
775
+
776
+ let successCount = 0;
777
+ let failCount = 0;
778
+
779
+ for (const newToken of tokens) {
780
+ try {
781
+ const response = await fetch('/manager/api/add', {
782
+ method: 'POST',
783
+ headers: { 'Content-Type': 'application/json' },
784
+ body: JSON.stringify({ sso: newToken })
785
+ });
786
+ if (response.ok) {
787
+ successCount++;
788
+ } else {
789
+ failCount++;
790
+ }
791
+ } catch (error) {
792
+ failCount++;
793
  }
794
+ }
795
+
796
+ tokenInput.value = '';
797
+ await fetchTokenMap();
798
+
799
+ if (successCount > 0 && failCount === 0) {
800
+ showNotification(`成功添加 ${successCount} 个 Token`);
801
+ } else if (successCount > 0 && failCount > 0) {
802
+ showNotification(`成功添加 ${successCount} 个,失败 ${failCount} 个 Token`);
803
+ } else {
804
+ showNotification(`添加失败,共 ${failCount} 个 Token 失败`);
805
  }
806
  }
807
  });