feat: 完善项目架构和功能

- 修复路由配置,实现根路径自动重定向到/project
- 新增Gitea OAuth认证系统和相关组件
- 完善日志系统实现,包含pino日志工具和中间件
- 重构页面结构,分离项目管理和环境管理页面
- 新增CORS、Session等关键中间件
- 优化前端请求封装和类型定义
- 修复TypeScript类型错误和参数传递问题
This commit is contained in:
2025-09-04 23:19:52 +08:00
parent d178df54da
commit ef473d6084
34 changed files with 1022 additions and 196 deletions

View File

@@ -1,7 +1,9 @@
import { Router } from './router.ts';
import { ResponseTime } from './responseTime.ts';
import { Exception } from './exception.ts';
import { BodyParser } from './body-parser.ts';
import { Session } from './session.ts';
import { CORS } from './cors.ts';
import { HttpLogger } from './logger.ts';
import type Koa from 'koa';
/**
@@ -9,17 +11,19 @@ import type Koa from 'koa';
* @param app Koa
*/
export function initMiddlewares(app: Koa) {
// 日志中间件需要最早注册,记录所有请求
new HttpLogger().apply(app);
// 全局异常处理中间件必须最先注册
const exception = new Exception();
exception.apply(app);
new Exception().apply(app);
// Session 中间件需要在请求体解析之前注册
new Session().apply(app);
// 请求体解析中间件
const bodyParser = new BodyParser();
bodyParser.apply(app);
new BodyParser().apply(app);
const responseTime = new ResponseTime();
responseTime.apply(app);
new CORS().apply(app);
const router = new Router();
router.apply(app);
new Router().apply(app);
}