From c1e54d9457bde8c0fc09b3e711449a3fbcc6eacb Mon Sep 17 00:00:00 2001 From: root Date: Fri, 27 Feb 2026 18:01:32 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=E5=B7=B2=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=E7=9A=84=E6=97=A7=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DEV_REVERSE_PROXY_SETUP.md | 219 ----- GIT_WORKFLOW.md | 171 ---- IMPLEMENTATION_PLAN.md | 601 ------------ PROJECT.md | 356 ------- PROJECT_ISSUES.md | 941 ------------------- REVERSE_PROXY_SETUP.md | 142 --- backend/app/controller/TestController.php | 109 --- backend/test_data.php | 529 ----------- frontend/src/pages/approval/quick-action.tsx | 34 +- frontend/src/pages/debug-feishu.tsx | 11 +- nginx/x-server-api.conf | 9 + 11 files changed, 33 insertions(+), 3089 deletions(-) delete mode 100644 DEV_REVERSE_PROXY_SETUP.md delete mode 100644 GIT_WORKFLOW.md delete mode 100644 IMPLEMENTATION_PLAN.md delete mode 100644 PROJECT.md delete mode 100644 PROJECT_ISSUES.md delete mode 100644 REVERSE_PROXY_SETUP.md delete mode 100644 backend/app/controller/TestController.php delete mode 100644 backend/test_data.php diff --git a/DEV_REVERSE_PROXY_SETUP.md b/DEV_REVERSE_PROXY_SETUP.md deleted file mode 100644 index 4761143..0000000 --- a/DEV_REVERSE_PROXY_SETUP.md +++ /dev/null @@ -1,219 +0,0 @@ -# 开发环境反向代理配置指南 - -本指南用于配置开发环境的 OpenResty 和 frpc,以便将本地 API 暴露到公网调试飞书登录。 - -## 前提条件 - -- 已安装并运行 OpenResty -- 已安装并运行 frpc -- Docker 中运行的后端服务 (localhost:8787) - -## 配置步骤 - -### 1. OpenResty 配置 - -在你的 OpenResty 配置目录中创建以下配置文件: - -```nginx -# /usr/local/openresty/nginx/conf/conf.d/x-server-api.conf - -server { - listen 8080; # 本地开发端口,避免与 80 端口冲突 - server_name api.x-server.local; - - # API 反向代理 - location /api/ { - proxy_pass http://127.0.0.1:8787/api/; - proxy_http_version 1.1; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - # CORS 配置(飞书请求需要) - add_header Access-Control-Allow-Origin *; - add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS'; - add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,X-Tenant-Key'; - - if ($request_method = 'OPTIONS') { - return 204; - } - - proxy_connect_timeout 60s; - proxy_send_timeout 60s; - proxy_read_timeout 60s; - } - - # 健康检查 - location /health { - return 200 "OK\n"; - add_header Content-Type text/plain; - } -} -``` - -重载配置: -```bash -sudo openresty -s reload -# 或 -sudo systemctl reload openresty -``` - -### 2. frpc 配置 - -配置 frpc 将本地 OpenResty 服务暴露到公网: - -```ini -# ~/.frpc.ini 或 /etc/frp/frpc.ini - -[common] -server_addr = your-frp-server.com # 你的 frp 服务器地址 -server_port = 7000 -token = your-token - -[x-server-api] -type = http -local_ip = 127.0.0.1 -local_port = 8080 # OpenResty 监听端口 -custom_domains = api-dev.x-server.your-domain.com # 开发环境域名 - -# 可选:启用加密和压缩 -use_encryption = true -use_compression = true -``` - -启动 frpc: -```bash -frpc -c ~/.frpc.ini -``` - -### 3. 本地 hosts 配置 - -在本地开发时配置 hosts: - -```bash -# /etc/hosts -127.0.0.1 api.x-server.local -``` - -### 4. 飞书应用配置 - -在飞书开放平台配置开发环境回调 URL: - -``` -https://api-dev.x-server.your-domain.com/api/v1/auth/feishu-login -``` - -## 验证配置 - -### 1. 本地测试 -```bash -# 直接访问后端 -curl http://localhost:8787/api/v1/user/info - -# 通过 OpenResty 访问 -curl http://localhost:8080/api/v1/user/info - -# 通过本地域名访问 -curl http://api.x-server.local/api/v1/user/info -``` - -### 2. 公网测试 -```bash -# 通过 frps 域名访问 -curl https://api-dev.x-server.your-domain.com/api/v1/user/info -``` - -### 3. 飞书调试 -1. 在飞书开放平台创建测试应用 -2. 配置回调 URL 为开发环境域名 -3. 使用飞书 APP ID 和 APP SECRET 进行测试 -4. 检查后端日志查看请求详情 - -## 开发与生产环境区分 - -### 开发环境(使用 frpc) -- 域名:`api-dev.x-server.your-domain.com` -- 使用 frpc 暴露本地服务 -- CORS 允许所有来源 -- 详细日志输出 - -### 生产环境(不使用 frpc) -- 域名:`api.x-server.com` -- 直接部署到服务器 -- CORS 严格限制 -- 日志级别调整 - -## 故障排查 - -### OpenResty 无法访问后端 -1. 检查 Docker 容器是否运行:`docker ps` -2. 检查端口是否正确:`docker ps | grep 8787` -3. 检查网络连通性:`curl http://127.0.0.1:8787` - -### frpc 连接失败 -1. 检查 frp 服务器是否可访问 -2. 检查 token 是否正确 -3. 查看 frpc 日志:`frpc -c ~/.frpc.ini` - -### 飞书回调失败 -1. 检查域名 DNS 解析是否指向 frp 服务器 -2. 检查 frp 服务器是否配置了域名白名单 -3. 检查后端日志是否收到请求 -4. 验证 CORS 配置是否正确 - -## 安全建议 - -1. **开发环境使用独立的域名和 token** -2. **定期更新 frp token** -3. **不要在代码中硬编码生产环境配置** -4. **使用环境变量管理敏感信息** -5. **生产环境部署前移除 frpc 配置** - -## 常用命令 - -```bash -# 查看 Docker 容器日志 -docker logs x-server-backend -f - -# 重启后端服务 -docker compose restart backend - -# 重载 OpenResty 配置 -sudo openresty -s reload - -# 查看 frpc 状态 -frpc status -c ~/.frpc.ini - -# 测试 API 连通性 -curl -v http://localhost:8787/api/v1/user/info -``` - -## 环境变量配置 - -创建 `.env.development` 文件用于开发环境: - -```env -# 后端配置 -DB_HOST=mysql -DB_PORT=3306 -DB_DATABASE=x_server_mobile -DB_USERNAME=root -DB_PASSWORD=mysql_xEsdPa - -# Redis 配置 -REDIS_HOST=redis -REDIS_PORT=6379 - -# 飞书配置(开发环境) -FEISHU_APP_ID=cli_xxxxxxxxxxxxx -FEISHU_APP_SECRET=xxxxxxxxxxxxxxxxxxxx -FEISHU_ENCRYPT_KEY=xxxxxxxxxxxxxxxxxxxx -FEISHU_VERIFICATION_TOKEN=xxxxxxxxxxxxxxxxxxxx - -# API 配置 -API_BASE_URL=http://localhost:8787 -PUBLIC_API_URL=https://api-dev.x-server.your-domain.com -``` - -生产环境使用 `.env.production` 文件,移除 frpc 相关配置。 diff --git a/GIT_WORKFLOW.md b/GIT_WORKFLOW.md deleted file mode 100644 index e36db9a..0000000 --- a/GIT_WORKFLOW.md +++ /dev/null @@ -1,171 +0,0 @@ -# Git 工作流 - -## 分支策略 - -采用 Git Flow 简化版工作流: - -### 主要分支 - -| 分支 | 用途 | 说明 | -|------|------|------| -| `master` | 生产环境 | 保持稳定,只接受从 develop 合并的代码 | -| `develop` | 开发环境 | 主开发分支,包含最新的开发功能 | -| `feature/*` | 功能分支 | 从 develop 分支,开发完成后合并回 develop | -| `hotfix/*` | 热修复分支 | 从 master 分支,修复后合并到 master 和 develop | - -## 分支命名规范 - -### 功能分支 -``` -feature/功能名称 -例如:feature/i18n-support -``` - -### 热修复分支 -``` -hotfix/问题描述 -例如:hotfix/login-error -``` - -## 工作流程 - -### 1. 开发新功能 - -```bash -# 从 develop 创建功能分支 -git checkout develop -git pull origin develop -git checkout -b feature/your-feature-name - -# 开发并提交 -git add . -git commit -m "feat: add your feature" - -# 推送到远程 -git push -u origin feature/your-feature-name - -# 完成后合并到 develop -git checkout develop -git merge feature/your-feature-name -git push origin develop - -# 删除功能分支(可选) -git branch -d feature/your-feature-name -``` - -### 2. 修复紧急问题 - -```bash -# 从 master 创建热修复分支 -git checkout master -git pull origin master -git checkout -b hotfix/your-fix-name - -# 修复并提交 -git add . -git commit -m "fix: describe the fix" - -# 推送到远程 -git push -u origin hotfix/your-fix-name - -# 合并到 master 和 develop -git checkout master -git merge hotfix/your-fix-name -git push origin master - -git checkout develop -git merge hotfix/your-fix-name -git push origin develop -``` - -### 3. 发布到生产 - -```bash -# 将 develop 合并到 master -git checkout master -git merge develop -git push origin master - -# 打标签 -git tag -a v1.0.0 -m "Release version 1.0.0" -git push origin v1.0.0 -``` - -## 提交信息规范 - -使用 Conventional Commits 规范: - -| 类型 | 说明 | 示例 | -|------|------|------| -| `feat` | 新功能 | `feat: add user login` | -| `fix` | 修复bug | `fix: correct i18n loading` | -| `docs` | 文档变更 | `docs: update README` | -| `style` | 代码格式 | `style: format code` | -| `refactor` | 重构 | `refactor: simplify API` | -| `test` | 测试 | `test: add unit tests` | -| `chore` | 构建/工具 | `chore: update dependencies` | - -格式: -``` -(): - - - -