feat: 初始化智能物联网设备管理系统前后端基础项目
完成项目整体结构搭建,包含: 1. 前端Vue3+TS+Vite+Antd项目基础配置与核心依赖 2. 后端MidwayJS+TypeORM+JWT权限认证框架 3. 完整的用户、角色、权限、日志数据库表结构 4. 核心业务模块API与基础服务实现 5. 全局样式、路由、状态管理配置
This commit is contained in:
commit
3d7eb12103
89 files changed
+16085
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { Middleware } from '@midwayjs/core';
|
||||
import { Context, NextFunction } from '@midwayjs/koa';
|
||||
|
||||
@Middleware()
|
||||
export class ErrorMiddleware {
|
||||
static getName(): string {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
resolve() {
|
||||
return async (ctx: Context, next: NextFunction) => {
|
||||
try {
|
||||
await next();
|
||||
} catch (err: any) {
|
||||
console.error('全局错误捕获:', err);
|
||||
|
||||
const status = err.status || 500;
|
||||
const message = err.message || '服务器内部错误';
|
||||
|
||||
ctx.status = status;
|
||||
ctx.body = {
|
||||
code: status,
|
||||
message: message,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ignore(ctx: Context): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user