讓 PPT AiderHeal 背景派工
All checks were successful
CD Pipeline / deploy (push) Successful in 1m5s

This commit is contained in:
OoO
2026-05-19 00:30:24 +08:00
parent 5908d1bdca
commit 02682c81ed
5 changed files with 81 additions and 23 deletions

View File

@@ -573,23 +573,45 @@
}
};
window.triggerAiderHeal = async function triggerAiderHeal(pptxFilename, errorMsg) {
window.triggerAiderHeal = async function triggerAiderHeal(pptxFilename, errorMsg, triggerButton) {
if (!confirm(`觸發 AiderHeal 自動修復?\n\n檔案:${pptxFilename}\n錯誤:${(errorMsg || '').substring(0, 200)}`)) return;
const statusNode = document.querySelector('[data-ppt-auto-status]');
const originalHtml = triggerButton ? triggerButton.innerHTML : '';
if (triggerButton) {
triggerButton.disabled = true;
triggerButton.innerHTML = '<i class="fas fa-spinner fa-spin me-1"></i>派工中';
}
if (statusNode) {
statusNode.classList.add('is-working');
statusNode.textContent = `${pptxFilename || 'PPT'} 正在排入 AiderHeal 背景修復。`;
}
try {
const response = await postJson('/observability/ppt_audit/trigger_aider_heal', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ pptx_filename: pptxFilename, error_msg: errorMsg || '' })
body: JSON.stringify({ pptx_filename: pptxFilename, issue_summary: errorMsg || '' })
});
const data = await response.json();
if (data.ok) {
alert(`✅ AiderHeal 已派出\n動作:${data.action || '—'}\n訊息:${data.message || ''}`);
} else {
alert(`${data.error || data.message || '觸發失敗'}`);
if (!response.ok || !data.ok) {
throw new Error(data.error || data.message || '觸發失敗');
}
if (triggerButton) {
triggerButton.innerHTML = '<i class="fas fa-check me-1"></i>已排入';
}
if (statusNode) {
statusNode.classList.remove('is-working');
statusNode.textContent = data.message || 'AiderHeal 已排入背景執行,完成後會由 Telegram/Gitea/CD 結果回報。';
}
} catch (error) {
console.warn('ppt_audit_trigger_aider_heal_failed', error);
alert('操作暫時無法完成,請稍後再試或查看系統日誌。');
if (triggerButton) {
triggerButton.disabled = false;
triggerButton.innerHTML = originalHtml;
}
if (statusNode) {
statusNode.classList.remove('is-working');
statusNode.textContent = 'AiderHeal 派工失敗,請稍後再試或查看系統日誌。';
}
}
};
@@ -666,7 +688,7 @@
if (button.dataset.bound === '1') return;
button.dataset.bound = '1';
button.addEventListener('click', () => {
window.triggerAiderHeal(button.dataset.pptFilename || '', button.dataset.pptError || '');
window.triggerAiderHeal(button.dataset.pptFilename || '', button.dataset.pptError || '', button);
});
});