Browse Source

docs: add local development guide

Y7000\张扬阳 2 weeks ago
parent
commit
edb5a47858
1 changed files with 70 additions and 0 deletions
  1. 70 0
      README.md

+ 70 - 0
README.md

@@ -0,0 +1,70 @@
+# 企业知识库开发说明
+
+## 本地运行
+
+开发时需要两个进程:
+
+```bash
+npm run dev
+npm run worker:media
+```
+
+- `npm run dev` 启动 Next.js 页面和 API。
+- `npm run worker:media` 消费 BullMQ 队列并调用 FFmpeg 生成 HLS。
+- 如果只启动 `npm run dev`,视频可以上传,但会停在 `pending` 或 `processing`,直到 worker 启动。
+
+默认访问地址:
+
+```text
+http://127.0.0.1:3000/login
+```
+
+默认开发账号来自 seed 数据:
+
+```text
+admin@ekb.com
+hashed_password_here
+```
+
+## 构建和开发服务
+
+`next build` 和 `next typegen` 会改写 `.next` 目录。不要在已有 `npm run dev` 进程运行期间执行构建后继续使用旧 dev server;构建或类型检查后请重启开发服务。
+
+推荐顺序:
+
+```bash
+npm run typecheck
+npm run build
+npm run dev
+```
+
+## 媒体测试
+
+媒体测试依赖:
+
+- PostgreSQL
+- Redis
+- MinIO
+- FFmpeg
+- 项目根目录的 `test_sample.mp4`
+
+常用验证命令:
+
+```bash
+npm run test:upload
+npm run test:media-pipeline
+npm run test:media-status
+npm run test:media-list
+npm run test:media-permission
+npm run test:media-delete
+```
+
+测试会尽量清理自己创建的媒体记录、资源记录、原始 MinIO 对象和 HLS 输出。不要用这些测试脚本验证需要长期保留的人工上传文件。
+
+如果本地库里已经有旧测试残留,可以运行:
+
+```bash
+npm run test:cleanup
+```
+
+该脚本只清理使用测试前缀创建的数据,例如 `e2e-*`、`media-list-*`、`media-status-*`、`admin-flow-*@ekb.com` 和 `/permission-admin/*`。