优化: 大文件拆分+代码分割+按需加载+console清理+any类型替换
- Money.tsx (2260行→54行): 拆分为 money/ 子目录4个组件, React.lazy二级分割 - AIAssistant.tsx (2038行→63行): 拆分为 ai-assistant/ 子目录6个组件, React.lazy二级分割 - xlsx改为动态导入, OvertimeTab从345KB降至12.7KB - api-services.ts: 请求参数 any→Record<string,unknown> - 移除前端3处console.log残留 - 后端console替换为pino logger - 前后端未使用import/变量清理 - Zod schema验证: termination/platform/special-status/work-process - 新增 leave.routes.ts, acceptance-test.routes.ts - UI组件: PageGuide, QueryError, Stepper
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { AuthRequest } from './auth'
|
||||
import prisma from '../lib/prisma'
|
||||
import logger from '../lib/logger'
|
||||
|
||||
export async function auditLog(
|
||||
req: AuthRequest,
|
||||
@@ -22,6 +23,6 @@ export async function auditLog(
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('Audit log error:', err)
|
||||
logger.error({ err, action, entity, entityId }, 'Audit log error')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Request, Response, NextFunction } from 'express'
|
||||
import { ZodError } from 'zod'
|
||||
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'
|
||||
import { AppError } from '../lib/AppError'
|
||||
import logger from '../lib/logger'
|
||||
|
||||
export function errorHandler(err: unknown, _req: Request, res: Response, _next: NextFunction) {
|
||||
if (err instanceof AppError) {
|
||||
@@ -55,7 +56,7 @@ export function errorHandler(err: unknown, _req: Request, res: Response, _next:
|
||||
})
|
||||
}
|
||||
|
||||
console.error('Unhandled error:', err)
|
||||
logger.error({ err }, 'Unhandled error')
|
||||
return res.status(500).json({
|
||||
success: false,
|
||||
error: { code: 'INTERNAL_ERROR', message: '服务器内部错误' },
|
||||
|
||||
Reference in New Issue
Block a user