shensuming commited on
Commit
b699cce
·
verified ·
1 Parent(s): eb321c2

Update admin.html

Browse files
Files changed (1) hide show
  1. admin.html +41 -1
admin.html CHANGED
@@ -204,6 +204,7 @@
204
  const data = await res.json();
205
  currentUsers = data.users;
206
  renderTable();
 
207
  updateSortUI();
208
  showToast('作战数据加载成功', 'success');
209
  } catch (e) {}
@@ -239,7 +240,46 @@
239
  if (!emails) { showToast('没有可复制的邮箱', 'error'); return; }
240
  navigator.clipboard.writeText(emails).then(() => showToast('已复制全部邮箱到剪贴板', 'success'));
241
  }
242
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  async function exportCSV() {
244
  const token = document.getElementById('adminToken').value;
245
  if (!token) {
 
204
  const data = await res.json();
205
  currentUsers = data.users;
206
  renderTable();
207
+ loadBouncedEmails();
208
  updateSortUI();
209
  showToast('作战数据加载成功', 'success');
210
  } catch (e) {}
 
240
  if (!emails) { showToast('没有可复制的邮箱', 'error'); return; }
241
  navigator.clipboard.writeText(emails).then(() => showToast('已复制全部邮箱到剪贴板', 'success'));
242
  }
243
+
244
+ async function loadBouncedEmails() {
245
+ const token = document.getElementById('adminToken').value;
246
+ if (!token) return;
247
+ try {
248
+ const res = await fetch('/api/admin/bounced_emails', { headers: { 'X-Admin-Token': token } });
249
+ const data = await res.json();
250
+ window.bouncedData = data.emails || [];
251
+ document.getElementById('bouncedTotal').textContent = `(${window.bouncedData.length} 条)`;
252
+ renderBouncedTable(window.bouncedData);
253
+ } catch(e) {}
254
+ }
255
+ function renderBouncedTable(emails) {
256
+ const tbody = document.getElementById('bouncedTableBody');
257
+ tbody.innerHTML = emails.map(e => `
258
+ <tr class="hover:bg-slate-50">
259
+ <td class="p-3 text-sm font-mono text-slate-700">${e.email}</td>
260
+ <td class="p-3 text-xs text-slate-500">${e.created_at ? new Date(e.created_at).toLocaleString('zh-CN') : '-'}</td>
261
+ <td class="p-3 text-right">
262
+ <button onclick="deleteBounced('${e.email}')" class="text-red-500 hover:text-red-700 text-xs font-semibold">删除</button>
263
+ </td>
264
+ </tr>
265
+ `).join('');
266
+ }
267
+ function filterBouncedTable() {
268
+ const kw = document.getElementById('bouncedSearch').value.toLowerCase();
269
+ renderBouncedTable((window.bouncedData || []).filter(e => e.email.toLowerCase().includes(kw)));
270
+ }
271
+ async function deleteBounced(email) {
272
+ if (!confirm(`确定从退信库中删除 ${email} 吗?`)) return;
273
+ const token = document.getElementById('adminToken').value;
274
+ await fetch(`/api/admin/bounced_emails?email=${encodeURIComponent(email)}`, { method: 'DELETE', headers: { 'X-Admin-Token': token } });
275
+ loadBouncedEmails();
276
+ }
277
+ function exportBouncedCsv() {
278
+ const csv = '邮箱,退信时间\n' + (window.bouncedData || []).map(e => `${e.email},${e.created_at || ''}`).join('\n');
279
+ const blob = new Blob(['\uFEFF' + csv], { type: 'text/csv;charset=utf-8;' });
280
+ const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = `bounced_emails_${new Date().toISOString().slice(0,10)}.csv`; a.click();
281
+ }
282
+
283
  async function exportCSV() {
284
  const token = document.getElementById('adminToken').value;
285
  if (!token) {