feat(admin): 添加系统健康检测功能
新增管理员健康检测面板,可检测以下配置项: - 安全配置:JWT密钥、CORS、HTTPS、管理员账号、登录防爆破 - 服务状态:SMTP邮件、数据库连接、存储目录 - 运行配置:反向代理支持、Node环境 修改文件: - backend/auth.js: 新增 isJwtSecretSecure() 函数 - backend/server.js: 新增 /api/admin/health-check API - frontend/app.js: 新增健康检测数据和方法 - frontend/app.html: 新增健康检测UI界面 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -148,6 +148,15 @@ createApp({
|
||||
}
|
||||
},
|
||||
|
||||
// 健康检测
|
||||
healthCheck: {
|
||||
loading: false,
|
||||
lastCheck: null,
|
||||
overallStatus: null, // healthy, warning, critical
|
||||
summary: { total: 0, pass: 0, warning: 0, fail: 0, info: 0 },
|
||||
checks: []
|
||||
},
|
||||
|
||||
// Toast通知
|
||||
toasts: [],
|
||||
toastIdCounter: 0,
|
||||
@@ -2041,10 +2050,11 @@ handleDragLeave(e) {
|
||||
this.loadShares();
|
||||
break;
|
||||
case 'admin':
|
||||
// 切换到管理后台时,重新加载用户列表
|
||||
// 切换到管理后台时,重新加载用户列表和健康检测
|
||||
if (this.user && this.user.is_admin) {
|
||||
this.loadUsers();
|
||||
this.loadServerStorageStats();
|
||||
this.loadHealthCheck();
|
||||
}
|
||||
break;
|
||||
case 'settings':
|
||||
@@ -2260,6 +2270,67 @@ handleDragLeave(e) {
|
||||
}
|
||||
},
|
||||
|
||||
// ===== 健康检测 =====
|
||||
|
||||
async loadHealthCheck() {
|
||||
this.healthCheck.loading = true;
|
||||
try {
|
||||
const response = await axios.get(`${this.apiBase}/api/admin/health-check`, {
|
||||
headers: { Authorization: `Bearer ${this.token}` }
|
||||
});
|
||||
|
||||
if (response.data.success) {
|
||||
this.healthCheck.overallStatus = response.data.overallStatus;
|
||||
this.healthCheck.summary = response.data.summary;
|
||||
this.healthCheck.checks = response.data.checks;
|
||||
this.healthCheck.lastCheck = response.data.timestamp;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('健康检测失败:', error);
|
||||
this.showToast('error', '错误', '健康检测失败');
|
||||
} finally {
|
||||
this.healthCheck.loading = false;
|
||||
}
|
||||
},
|
||||
|
||||
getHealthStatusColor(status) {
|
||||
const colors = {
|
||||
pass: 'bg-green-100 text-green-800',
|
||||
warning: 'bg-yellow-100 text-yellow-800',
|
||||
fail: 'bg-red-100 text-red-800',
|
||||
info: 'bg-blue-100 text-blue-800'
|
||||
};
|
||||
return colors[status] || 'bg-gray-100 text-gray-800';
|
||||
},
|
||||
|
||||
getHealthStatusIcon(status) {
|
||||
const icons = {
|
||||
pass: '✓',
|
||||
warning: '⚠',
|
||||
fail: '✗',
|
||||
info: 'ℹ'
|
||||
};
|
||||
return icons[status] || '?';
|
||||
},
|
||||
|
||||
getOverallStatusColor(status) {
|
||||
const colors = {
|
||||
healthy: 'text-green-600',
|
||||
warning: 'text-yellow-600',
|
||||
critical: 'text-red-600'
|
||||
};
|
||||
return colors[status] || 'text-gray-600';
|
||||
},
|
||||
|
||||
getOverallStatusText(status) {
|
||||
const texts = {
|
||||
healthy: '系统健康',
|
||||
warning: '存在警告',
|
||||
critical: '存在问题'
|
||||
};
|
||||
return texts[status] || '未知';
|
||||
},
|
||||
|
||||
// ===== 上传工具管理 =====
|
||||
|
||||
// 检测上传工具是否存在
|
||||
|
||||
Reference in New Issue
Block a user