|
| 1 | +# Contributing to ChatCrystal |
| 2 | + |
| 3 | +感谢你对 ChatCrystal 的关注!我们欢迎任何形式的贡献。 |
| 4 | +Thanks for your interest in ChatCrystal! We welcome contributions of all kinds. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## 目录 / Table of Contents |
| 9 | + |
| 10 | +- [开始之前 / Before You Start](#开始之前--before-you-start) |
| 11 | +- [开发环境 / Development Setup](#开发环境--development-setup) |
| 12 | +- [项目结构 / Project Structure](#项目结构--project-structure) |
| 13 | +- [开发流程 / Development Workflow](#开发流程--development-workflow) |
| 14 | +- [提交规范 / Commit Convention](#提交规范--commit-convention) |
| 15 | +- [Pull Request 流程 / Pull Request Process](#pull-request-流程--pull-request-process) |
| 16 | +- [报告 Bug / Reporting Bugs](#报告-bug--reporting-bugs) |
| 17 | +- [功能建议 / Feature Requests](#功能建议--feature-requests) |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## 开始之前 / Before You Start |
| 22 | + |
| 23 | +- 请先阅读 [Code of Conduct](CODE_OF_CONDUCT.md) / Please read our [Code of Conduct](CODE_OF_CONDUCT.md) |
| 24 | +- 对于重大变更,请先开 Issue 讨论 / For major changes, please open an Issue first to discuss |
| 25 | +- 确保你的 Node.js 版本 >= 20 / Make sure you have Node.js >= 20 |
| 26 | + |
| 27 | +## 开发环境 / Development Setup |
| 28 | + |
| 29 | +```bash |
| 30 | +# 1. Fork 并克隆仓库 / Fork and clone the repo |
| 31 | +git clone https://github.com/<your-username>/ChatCrystal.git |
| 32 | +cd ChatCrystal |
| 33 | + |
| 34 | +# 2. 安装依赖 / Install dependencies |
| 35 | +npm install |
| 36 | + |
| 37 | +# 3. 启动开发服务器(前端 + 后端)/ Start dev server (frontend + backend) |
| 38 | +npm run dev |
| 39 | +``` |
| 40 | + |
| 41 | +启动后: |
| 42 | +- 后端 API: `http://localhost:3721` |
| 43 | +- 前端页面: `http://localhost:13721` |
| 44 | + |
| 45 | +After starting: |
| 46 | +- Backend API: `http://localhost:3721` |
| 47 | +- Frontend: `http://localhost:13721` |
| 48 | + |
| 49 | +### 代码检查 / Linting |
| 50 | + |
| 51 | +```bash |
| 52 | +npm run lint # 检查 / Check |
| 53 | +npm run lint:fix # 自动修复 / Auto-fix |
| 54 | +``` |
| 55 | + |
| 56 | +## 项目结构 / Project Structure |
| 57 | + |
| 58 | +``` |
| 59 | +ChatCrystal/ |
| 60 | +├── shared/ # 共享类型 (无构建步骤) / Shared types (no build step) |
| 61 | +├── server/ # Fastify 后端 / Fastify backend |
| 62 | +├── client/ # React 前端 (Vite + Tailwind CSS) / React frontend |
| 63 | +├── electron/ # Electron 桌面应用 / Electron desktop app |
| 64 | +└── scripts/ # 发布与工具脚本 / Release & utility scripts |
| 65 | +``` |
| 66 | + |
| 67 | +## 开发流程 / Development Workflow |
| 68 | + |
| 69 | +1. 从 `main` 创建你的分支 / Create a branch from `main` |
| 70 | + ```bash |
| 71 | + git checkout -b feat/your-feature |
| 72 | + ``` |
| 73 | +2. 进行修改并确保 lint 通过 / Make changes and ensure lint passes |
| 74 | +3. 提交你的更改 / Commit your changes(见下方提交规范 / see commit convention below) |
| 75 | +4. 推送到你的 Fork / Push to your fork |
| 76 | +5. 创建 Pull Request / Open a Pull Request |
| 77 | + |
| 78 | +## 提交规范 / Commit Convention |
| 79 | + |
| 80 | +使用 [Conventional Commits](https://www.conventionalcommits.org/) 格式: |
| 81 | +Use [Conventional Commits](https://www.conventionalcommits.org/) format: |
| 82 | + |
| 83 | +``` |
| 84 | +<type>(<scope>): <description> |
| 85 | +``` |
| 86 | + |
| 87 | +常用 type / Common types: |
| 88 | +| type | 说明 / Description | |
| 89 | +|------|-------------------| |
| 90 | +| `feat` | 新功能 / New feature | |
| 91 | +| `fix` | Bug 修复 / Bug fix | |
| 92 | +| `docs` | 文档变更 / Documentation | |
| 93 | +| `refactor` | 重构(不改变行为)/ Refactoring (no behavior change) | |
| 94 | +| `style` | 代码格式 / Code style (formatting, etc.) | |
| 95 | +| `test` | 测试 / Tests | |
| 96 | +| `chore` | 构建/工具变更 / Build or tooling changes | |
| 97 | + |
| 98 | +常用 scope / Common scopes: |
| 99 | +`client`, `server`, `shared`, `electron`, `cli`, `docs`, `ci` |
| 100 | + |
| 101 | +示例 / Examples: |
| 102 | +``` |
| 103 | +feat(client): add dark mode toggle |
| 104 | +fix(server): handle empty conversation parsing |
| 105 | +docs: update README installation steps |
| 106 | +``` |
| 107 | + |
| 108 | +## Pull Request 流程 / Pull Request Process |
| 109 | + |
| 110 | +1. 确保 PR 描述清晰,说明做了什么以及为什么 / Ensure PR description explains what and why |
| 111 | +2. 关联相关 Issue(如有)/ Link related Issues (if any) |
| 112 | +3. 确保 CI 检查通过 / Ensure CI checks pass |
| 113 | +4. 等待维护者审核 / Wait for maintainer review |
| 114 | +5. 根据反馈进行修改 / Address review feedback |
| 115 | + |
| 116 | +### PR 标题格式 / PR Title Format |
| 117 | + |
| 118 | +与提交规范一致 / Same as commit convention: |
| 119 | +``` |
| 120 | +feat(client): add dark mode toggle |
| 121 | +``` |
| 122 | + |
| 123 | +## 报告 Bug / Reporting Bugs |
| 124 | + |
| 125 | +使用 [Bug Report](https://github.com/ZengLiangYi/ChatCrystal/issues/new?template=bug_report.yml) 模板,包含: |
| 126 | +Use the [Bug Report](https://github.com/ZengLiangYi/ChatCrystal/issues/new?template=bug_report.yml) template, including: |
| 127 | + |
| 128 | +- 清晰的复现步骤 / Clear steps to reproduce |
| 129 | +- 期望与实际行为 / Expected vs actual behavior |
| 130 | +- 版本与运行环境 / Version and environment |
| 131 | +- 相关日志或截图 / Relevant logs or screenshots |
| 132 | + |
| 133 | +## 功能建议 / Feature Requests |
| 134 | + |
| 135 | +使用 [Feature Request](https://github.com/ZengLiangYi/ChatCrystal/issues/new?template=feature_request.yml) 模板。 |
| 136 | +Use the [Feature Request](https://github.com/ZengLiangYi/ChatCrystal/issues/new?template=feature_request.yml) template. |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +如有疑问,请在 [Discussions](https://github.com/ZengLiangYi/ChatCrystal/discussions) 中提问。 |
| 141 | +If you have questions, feel free to ask in [Discussions](https://github.com/ZengLiangYi/ChatCrystal/discussions). |
0 commit comments