fix: 优化登录项

This commit is contained in:
丹尼尔
2026-03-15 19:17:12 +08:00
parent 9f0e2a2db2
commit 3b3fac1cee
6 changed files with 316 additions and 8 deletions

View File

@@ -282,7 +282,8 @@
const tab = document.querySelector('.mgmt-tab[data-panel="' + panelId + '"]');
if (tab) tab.classList.add('active');
if (panelId === 'panel-greeting') loadCustomerTagsForGreeting();
if (panelId === 'panel-ai-reply') { loadAiReplyConfig(); loadAiReplyStatus(); loadCallbackStatus(); }
if (panelId === 'panel-push') loadPushTasks();
if (panelId === 'panel-ai-reply') { loadAiReplyConfig(); loadAiReplyStatus(); }
}
function _parseWxidLines(ta) {
@@ -590,6 +591,21 @@
} catch (e) { $('push-group-list').innerHTML = '<p class="small-label">加载失败</p>'; }
}
async function loadPushTasks() {
const key = $('key').value.trim();
const el = $('push-task-list');
if (!el) return;
if (!key) { el.innerHTML = '<p class="small-label">请先登录。</p>'; return; }
try {
const data = await callApi('/api/push-tasks?key=' + encodeURIComponent(key) + '&limit=100');
const list = data.items || [];
el.innerHTML = list.length
? '<table class="mgmt-table"><thead><tr><th>时间</th><th>群组</th><th>状态</th><th>内容摘要</th></tr></thead><tbody>'
+ list.map(t => '<tr><td>' + escapeHtml((t.created_at || t.send_at || '-').toString().slice(0, 19)) + '</td><td>' + escapeHtml((t.group_id || '-').toString().slice(0, 12)) + '</td><td>' + escapeHtml((t.status || 'pending').toString()) + '</td><td>' + escapeHtml((t.content || '').toString().slice(0, 40)) + (t.content && t.content.length > 40 ? '…' : '') + '</td></tr>').join('') + '</tbody></table>'
: '<p class="small-label">暂无推送任务记录。</p>';
} catch (e) { el.innerHTML = '<p class="small-label">加载失败: ' + escapeHtml(e.message) + '</p>'; }
}
function fillPushSelects() {
const key = $('key').value.trim();
if (!key) return;
@@ -874,6 +890,7 @@
const items = wxids.map(wxid => ({ to_user_name: wxid, content }));
await callApi('/api/send-batch', { method: 'POST', body: JSON.stringify({ key, items }) });
await callApi('/api/push-tasks', { method: 'POST', body: JSON.stringify({ key, product_tag_id: tagId || '', group_id: groupId, content }) });
loadPushTasks();
alert('已推送至 ' + items.length + ' 人');
$('push-content').value = '';
} catch (e) { alert(e.message); }
@@ -943,6 +960,7 @@
loadGreetingTasks();
loadProductTags();
loadPushGroups();
loadPushTasks();
(function wsStatusCheck() {
let wasConnected = false;