refactor: 统一代码风格并迁移至 ESLint 新配置

style(backend): 格式化模型文件代码
style(frontend): 调整组件代码格式
chore: 删除旧 ESLint 配置并添加新配置
refactor(backend): 重构模型定义语法
style: 统一箭头函数和对象属性简写
This commit is contained in:
zhang1106
2026-03-27 19:12:16 +08:00
parent 6a8d4144ff
commit 63f0cb570e
166 changed files with 15483 additions and 11170 deletions
+30 -22
View File
@@ -4,7 +4,7 @@ const checkDatabase = async () => {
const result = {
status: 'ok',
type: dbDialect,
message: '数据库连接正常'
message: '数据库连接正常',
};
try {
@@ -35,19 +35,19 @@ const checkCriticalConfig = () => {
checks.push({
key: 'JWT_SECRET',
status: 'error',
message: 'JWT_SECRET 未配置'
message: 'JWT_SECRET 未配置',
});
} else if (jwtSecret.length < 32) {
checks.push({
key: 'JWT_SECRET',
status: 'warning',
message: 'JWT_SECRET 长度不足,建议至少 32 字符'
message: 'JWT_SECRET 长度不足,建议至少 32 字符',
});
} else {
checks.push({
key: 'JWT_SECRET',
status: 'ok',
message: 'JWT_SECRET 已配置'
message: 'JWT_SECRET 已配置',
});
}
@@ -55,14 +55,14 @@ const checkCriticalConfig = () => {
checks.push({
key: 'PORT',
status: port ? 'ok' : 'warning',
message: port ? `服务端口: ${port}` : '使用默认端口 8000'
message: port ? `服务端口: ${port}` : '使用默认端口 8000',
});
const dbType = process.env.DB_TYPE || 'sqlite';
checks.push({
key: 'DB_TYPE',
status: 'ok',
message: `数据库类型: ${dbType}`
message: `数据库类型: ${dbType}`,
});
if (dbType === 'mysql') {
@@ -72,7 +72,7 @@ const checkCriticalConfig = () => {
checks.push({
key: 'MYSQL_CONFIG',
status: 'warning',
message: 'MySQL 配置不完整'
message: 'MySQL 配置不完整',
});
}
}
@@ -85,7 +85,7 @@ const checkCriticalConfig = () => {
return {
status: overallStatus,
checks
checks,
};
};
@@ -93,17 +93,25 @@ const getSystemInfo = () => {
const memUsage = process.memoryUsage();
const uptime = process.uptime();
const formatUptime = (seconds) => {
const formatUptime = seconds => {
const days = Math.floor(seconds / 86400);
const hours = Math.floor((seconds % 86400) / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const secs = Math.floor(seconds % 60);
const parts = [];
if (days > 0) parts.push(`${days}`);
if (hours > 0) parts.push(`${hours}小时`);
if (minutes > 0) parts.push(`${minutes}分钟`);
if (secs > 0 || parts.length === 0) parts.push(`${secs}`);
if (days > 0) {
parts.push(`${days}`);
}
if (hours > 0) {
parts.push(`${hours}小时`);
}
if (minutes > 0) {
parts.push(`${minutes}分钟`);
}
if (secs > 0 || parts.length === 0) {
parts.push(`${secs}`);
}
return parts.join(' ');
};
@@ -112,13 +120,13 @@ const getSystemInfo = () => {
nodeVersion: process.version,
platform: process.platform,
memory: {
heapUsed: Math.round(memUsage.heapUsed / 1024 / 1024 * 100) / 100,
heapTotal: Math.round(memUsage.heapTotal / 1024 / 1024 * 100) / 100,
rss: Math.round(memUsage.rss / 1024 / 1024 * 100) / 100,
unit: 'MB'
heapUsed: Math.round((memUsage.heapUsed / 1024 / 1024) * 100) / 100,
heapTotal: Math.round((memUsage.heapTotal / 1024 / 1024) * 100) / 100,
rss: Math.round((memUsage.rss / 1024 / 1024) * 100) / 100,
unit: 'MB',
},
uptime: formatUptime(uptime),
uptimeSeconds: Math.round(uptime)
uptimeSeconds: Math.round(uptime),
};
};
@@ -129,7 +137,7 @@ const performHealthCheck = async () => {
const allChecks = [
{ name: 'database', ...dbCheck },
{ name: 'config', ...configCheck }
{ name: 'config', ...configCheck },
];
const overallStatus = allChecks.every(c => c.status === 'ok')
@@ -143,10 +151,10 @@ const performHealthCheck = async () => {
timestamp: new Date().toISOString(),
service: {
name: 'IDC设备管理系统',
version: '1.0.0'
version: '1.0.0',
},
checks: allChecks,
system: systemInfo
system: systemInfo,
};
};
@@ -154,5 +162,5 @@ module.exports = {
performHealthCheck,
checkDatabase,
checkCriticalConfig,
getSystemInfo
getSystemInfo,
};