'init'
This commit is contained in:
44
static/js/common.js
Normal file
44
static/js/common.js
Normal file
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user