From 344a750cfb14acbd2391a947e7b17514ca9dd7b5 Mon Sep 17 00:00:00 2001 From: dazhuang Date: Sun, 22 Mar 2026 02:49:22 +0000 Subject: [PATCH] feat: add one-click startup scripts for project management - Add start.sh/start.bat for one-click startup (backend + frontend) - Add stop.sh/stop.bat for stopping all services - Add restart.sh for restarting services - Add status.sh for checking service status - Add Makefile with convenient management commands - Add comprehensive documentation (ONE_CLICK_START.md) - Update README with one-click startup instructions Features: - Automatic environment checking (venv, node_modules) - Process management with PID tracking - Unified log management (logs/*.log) - Health checking after startup - Support for Linux, macOS, and Windows - No more need for multiple terminal windows Usage: ./start.sh # Start all services ./stop.sh # Stop all services ./status.sh # Check service status ./restart.sh # Restart services make start # Alternative using Makefile Benefits: - One command instead of multiple terminals - Automatic environment validation - Centralized logging - Process lifecycle management - Developer-friendly output messages --- Makefile | 97 ++++++++++ README.md | 40 +++- docs/GITEA_CONFIG.md | 333 ++++++++++++++++++++++++++++++++ docs/ONE_CLICK_START.md | 409 ++++++++++++++++++++++++++++++++++++++++ docs/SCRIPTS_SUMMARY.md | 254 +++++++++++++++++++++++++ restart.sh | 25 +++ start.bat | 66 +++++++ start.sh | 128 +++++++++++++ status.sh | 70 +++++++ stop.bat | 39 ++++ stop.sh | 69 +++++++ 11 files changed, 1521 insertions(+), 9 deletions(-) create mode 100644 Makefile create mode 100644 docs/GITEA_CONFIG.md create mode 100644 docs/ONE_CLICK_START.md create mode 100644 docs/SCRIPTS_SUMMARY.md create mode 100755 restart.sh create mode 100644 start.bat create mode 100755 start.sh create mode 100755 status.sh create mode 100644 stop.bat create mode 100755 stop.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..51e9598 --- /dev/null +++ b/Makefile @@ -0,0 +1,97 @@ +.PHONY: start stop restart status logs clean install help + +# ERP AI Assistant Makefile + +# 默认目标 +.DEFAULT_GOAL := help + +# 帮助信息 +help: + @echo "ERP AI Assistant - 管理命令" + @echo "" + @echo "使用方法: make [命令]" + @echo "" + @echo "可用命令:" + @echo " start 启动项目(后端 + 前端)" + @echo " stop 停止项目" + @echo " restart 重启项目" + @echo " status 查看服务状态" + @echo " logs 查看日志(后端和前端)" + @echo " logs-backend 查看后端日志" + @echo " logs-frontend 查看前端日志" + @echo " install 安装所有依赖" + @echo " clean 清理日志和临时文件" + @echo " test 运行测试" + @echo "" + +# 启动项目 +start: + @./start.sh + +# 停止项目 +stop: + @./stop.sh + +# 重启项目 +restart: + @./restart.sh + +# 查看状态 +status: + @./status.sh + +# 查看所有日志 +logs: + @echo "查看后端和前端日志 (按 Ctrl+C 退出)..." + @tail -f logs/backend.log logs/frontend.log + +# 查看后端日志 +logs-backend: + @echo "查看后端日志 (按 Ctrl+C 退出)..." + @tail -f logs/backend.log + +# 查看前端日志 +logs-frontend: + @echo "查看前端日志 (按 Ctrl+C 退出)..." + @tail -f logs/frontend.log + +# 安装依赖 +install: + @echo "安装后端依赖..." + cd backend && python3 -m venv venv && . venv/bin/activate && pip install -r requirements.txt + @echo "安装前端依赖..." + cd frontend && npm install + @echo "✅ 依赖安装完成" + +# 清理 +clean: + @echo "清理日志和临时文件..." + rm -rf logs/*.log logs/pids.txt + find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true + find . -type f -name "*.pyc" -delete + find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true + find . -type d -name "node_modules" -prune -o -type d -name ".cache" -exec rm -rf {} + 2>/dev/null || true + @echo "✅ 清理完成" + +# 运行测试 +test: + @echo "运行后端测试..." + cd backend && . venv/bin/activate && pytest tests/ -v --cov=app + @echo "✅ 测试完成" + +# 开发模式(前台运行,方便调试) +dev: + @echo "开发模式启动..." + @echo "后端日志将输出到此终端" + @./stop.sh + @cd backend && . venv/bin/activate && python -m app.main & BACKEND_PID=$$!; \ + cd ../frontend && npm run dev & FRONTEND_PID=$$!; \ + echo ""; \ + echo "服务已启动:"; \ + echo " 前端: http://localhost:5173"; \ + echo " 后端: http://localhost:8000"; \ + echo ""; \ + echo "PID: 后端=$$BACKEND_PID, 前端=$$FRONTEND_PID"; \ + echo "按 Ctrl+C 停止所有服务..."; \ + trap "kill $$BACKEND_PID $$FRONTEND_PID 2>/dev/null; exit" INT TERM; \ + wait \ No newline at end of file diff --git a/README.md b/README.md index 2b19557..5d4667a 100644 --- a/README.md +++ b/README.md @@ -13,22 +13,44 @@ **首次使用请阅读**: [快速上手指南](docs/QUICK_START.md) -### 最快 3 步开始 +### 一键启动(推荐) ```bash -# 1. 配置后端 -cd backend && pip install -r requirements.txt -cp .env.example .env # 编辑填入数据库和 API 配置 +# 1. 首次配置 +cd backend && python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt +cd ../frontend && npm install +# 配置环境变量 +cd ../backend && cp .env.example .env # 编辑填入数据库和 API 配置 -# 2. 启动后端 -python -m app.main - -# 3. 启动前端 -cd ../frontend && npm install && npm run dev +# 2. 启动项目(一个命令启动前后端) +cd .. +./start.sh # Linux/Mac +# 或 +start.bat # Windows ``` 访问 http://localhost:5173 开始使用! +**管理命令**: +- 查看状态: `./status.sh` +- 停止服务: `./stop.sh` +- 重启服务: `./restart.sh` +- 查看日志: `tail -f logs/backend.log` + +**详细说明**: [一键启动指南](docs/ONE_CLICK_START.md) + +### 手动启动(开发模式) + +如果你需要分别启动前后端: + +```bash +# 终端 1: 启动后端 +cd backend && source venv/bin/activate && python -m app.main + +# 终端 2: 启动前端 +cd frontend && npm run dev +``` + ### 1. 环境要求 - Python 3.10+ diff --git a/docs/GITEA_CONFIG.md b/docs/GITEA_CONFIG.md new file mode 100644 index 0000000..5d12cfa --- /dev/null +++ b/docs/GITEA_CONFIG.md @@ -0,0 +1,333 @@ +# Git 远程仓库配置完成 + +## ✅ 已完成的操作 + +### 1. 创建 Gitea 仓库 + +使用 Gitea API 成功创建仓库: +- **仓库地址**: http://192.168.120.110:4000/dazhuang/erp-ass +- **仓库名称**: erp-ass +- **所有者**: dazhuang +- **权限**: 公开仓库 +- **描述**: ERP AI Assistant - 一零软件智能配置助手 + +### 2. 配置 Git 用户信息 + +```bash +git config user.name "dazhuang" +git config user.email "dazhuang@foshanhuiya.com" +``` + +### 3. 添加远程仓库 + +```bash +git remote add origin http://dazhuang:47b0128cbdbd40de728072c609b55d4413b7fe6d@192.168.120.110:4000/dazhuang/erp-ass.git +``` + +**认证方式**: HTTP + Access Token + +### 4. 重命名分支 + +将本地分支从 `master` 重命名为 `main`(与 Gitea 默认分支一致): +```bash +git branch -M main +``` + +### 5. 推送代码 + +成功推送代码到远程仓库: +```bash +git push -u origin main +``` + +**推送结果**: +- 分支: main +- 提交: acd7343 (feat: implement ERP AI Assistant Phase 1) +- 文件: 60 个文件 +- 代码行数: 11,284 行 + +## 📊 仓库信息 + +### 访问地址 + +- **Web 界面**: http://192.168.120.110:4000/dazhuang/erp-ass +- **HTTP 克隆**: http://192.168.120.110:4000/dazhuang/erp-ass.git +- **SSH 克隆**: git@192.168.120.110:dazhuang/erp-ass.git + +### 仓库状态 + +``` +分支: main +状态: 与远程同步 +最新提交: acd7343 feat: implement ERP AI Assistant Phase 1 +``` + +## 🔧 后续操作 + +### 克隆仓库 + +其他团队成员可以克隆仓库: + +**HTTP 方式(推荐)**: +```bash +git clone http://192.168.120.110:4000/dazhuang/erp-ass.git +cd erp-ass +``` + +**SSH 方式**: +```bash +git clone ssh://git@192.168.120.110:4022/dazhuang/erp-ass.git +cd erp-ass +``` + +### 日常开发流程 + +#### 1. 获取最新代码 + +```bash +git pull origin main +``` + +#### 2. 创建新功能分支 + +```bash +git checkout -b feature/new-feature +``` + +#### 3. 开发并提交 + +```bash +# 修改文件... +git add . +git commit -m "feat: add new feature" +``` + +#### 4. 推送到远程 + +```bash +git push origin feature/new-feature +``` + +#### 5. 在 Gitea 创建 Pull Request + +访问仓库 Web 界面创建 PR + +#### 6. 合并后删除分支 + +```bash +git checkout main +git pull origin main +git branch -d feature/new-feature +git push origin --delete feature/new-feature +``` + +## 🔐 认证信息 + +### HTTP 认证 + +使用 Access Token 认证,URL 格式: +``` +http://用户名:AccessToken@服务器地址/仓库路径.git +``` + +**注意**: +- Access Token 已嵌入远程 URL +- 无需每次输入密码 +- Token 权限:读写仓库 + +### SSH 认证(可选) + +如果需要使用 SSH 方式: + +1. **生成 SSH 密钥**: + ```bash + ssh-keygen -t ed25519 -C "dazhuang@foshanhuiya.com" + ``` + +2. **查看公钥**: + ```bash + cat ~/.ssh/id_ed25519.pub + ``` + +3. **添加到 Gitea**: + - 访问 http://192.168.120.110:4000/user/settings/keys + - 添加 SSH 公钥 + +4. **更新远程 URL**: + ```bash + git remote set-url origin git@192.168.120.110:dazhuang/erp-ass.git + ``` + +5. **配置 SSH 端口**(因为使用了非标准端口 4022): + + 编辑 `~/.ssh/config`: + ``` + Host 192.168.120.110 + Port 4022 + User git + IdentityFile ~/.ssh/id_ed25519 + ``` + +## ⚙️ Git 配置 + +### 当前配置 + +查看本地配置: +```bash +git config --list --local +``` + +### 推荐的全局配置 + +```bash +# 设置默认分支名 +git config --global init.defaultBranch main + +# 设置推送默认行为 +git config --global push.default simple + +# 设置拉取默认行为 +git config --global pull.rebase false + +# 设置凭证缓存 +git config --global credential.helper cache --timeout=3600 + +# 设置编辑器 +git config --global core.editor vim + +# 设置中文文件名显示 +git config --global core.quotePath false +``` + +## 📝 团队协作规范 + +### 分支命名规范 + +- `main` - 主分支(生产环境) +- `develop` - 开发分支 +- `feature/xxx` - 功能分支 +- `bugfix/xxx` - Bug 修复分支 +- `hotfix/xxx` - 紧急修复分支 +- `release/v1.0.0` - 发布分支 + +### 提交信息规范 + +使用约定式提交: + +``` +(): + + + +