AstroResearch/docs/contributing.md

61 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AstroResearch Contributing Guide / 参与贡献
我们欢迎社区共同参与 AstroResearch 的开发与优化。以下是关于本地开发调试、代码规范和测试的说明。
---
## 1. 开发者本地环境搭建 (Developer Setup)
### 后端开发环境 (Rust)
1. 准备 Rust 工具链 (Edition 2021)。
2. 安装 SQLx CLI可选用于生成迁移文件
```bash
cargo install sqlx-cli --no-default-features --features sqlite
```
3. 启动开发模式下的 Rust 服务:
```bash
cargo run
```
### 前端开发环境 (React + TypeScript)
1. 进入 `dashboard` 目录,安装依赖:
```bash
cd dashboard
npm install
```
2. 启动开发服务器(支持 HMR 热更新及 API 请求代理转发):
```bash
npm run dev
```
---
## 2. 编码规范 (Coding Style Guidelines)
### Rust 规范 (Backend)
- 遵循 Rust 官方标准样式,提交前必须执行 `cargo fmt``cargo clippy`
- 注释和系统日志建议统一使用中文,便于开发者追踪和阅读。
- API handers 中的异常信息请使用 `anyhow``thiserror` 进行结构化抛出。
### React & TypeScript 规范 (Frontend)
- 严格遵循 `React 18/19` 函数式组件写法,使用 React Hooks 维护状态。
- 为保证生产编译成功,务必开启类型安全限制(如在导入纯类型时显式使用 `import type { ... }`)。
- CSS 层面使用 Tailwind CSS 统一的磨砂玻璃体 (Glassmorphism) 及响应式布局,所有间距、颜色严格使用 CSS 变量控制以支持主题切换。
---
## 3. 测试与验证 (Testing)
### 运行后端单元测试
系统为各个下载、解析、词典分词、接口提取等模块设计了健全的测试。运行测试命令:
```bash
cargo test
```
### 运行前端校验
```bash
cd dashboard
npm run build # 运行 TypeScript 类型检查及 Vite 打包编译
```
确保无编译 Error 或 Warn 警告后方可提交 PR。