Files
ai_mip/static/js/common.js
2026-01-13 18:59:26 +08:00

45 lines
1.3 KiB
JavaScript

const API_BASE = 'http://127.0.0.1:5000';
// 显示Toast提示
function showToast(message, type = 'info') {
const toast = document.createElement('div');
toast.className = `toast toast-${type}`;
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.remove();
}, 3000);
}
// 获取调度器状态
async function getSchedulerStatus() {
try {
const response = await fetch(`${API_BASE}/api/scheduler/status`);
const data = await response.json();
if (data.success) {
const isRunning = data.data.status === 'running';
const indicator = document.getElementById('statusIndicator');
const text = document.getElementById('statusText');
if (indicator && text) {
indicator.style.background = isRunning ? '#52c41a' : '#ff4d4f';
text.textContent = isRunning ? '调度器运行中' : '调度器已停止';
}
}
} catch (error) {
console.error('获取调度器状态失败:', error);
}
}
// 页面加载时初始化
document.addEventListener('DOMContentLoaded', () => {
getSchedulerStatus();
// 定时刷新状态
setInterval(() => {
getSchedulerStatus();
}, 5000);
});