Skip to content

Commit f3dd23d

Browse files
committed
feat: 添加全局快捷键系统、快速搜索、结果导出功能
✨ 新增功能: - 全局快捷键系统 (Ctrl+H/K/F, ?, Escape) - 快速搜索模态框,支持所有测评搜索 - 结果导出按钮 (PNG图片/JSON格式) - 快捷键帮助面板常驻右下角 🔧 架构优化: - ShortcutProvider 统一状态管理 - useKeyboardShortcuts Hook - html2canvas 依赖安装 🐛 Bug修复: - 修复 TypeScript 类型错误 - 修复 ESLint 警告 - 修复 EconomyDashboard 语法错误 - 修复后端 API 路由测试断言
1 parent 3d079e2 commit f3dd23d

131 files changed

Lines changed: 12338 additions & 292 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.development

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1-
# 开发环境配置
2-
VITE_APP_TITLE=HumanOS Dev
3-
VITE_USE_BROWSER_ROUTER=true
1+
# =============================================================================
2+
# 前端环境配置 - 开发环境
3+
# =============================================================================
4+
5+
VITE_APP_TITLE=HumanOS 人类操作系统
6+
7+
VITE_API_BASE_URL=http://localhost:8000
8+
9+
VITE_USE_BACKEND_CALCULATION=true
10+
11+
VITE_ENABLE_USER_SYSTEM=true
12+
13+
VITE_CLOUD_SAVE_ENABLED=true
14+
15+
VITE_DEBUG_MODE=true

.env.production

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
# GitHub Pages 生产环境
2-
VITE_APP_TITLE=HumanOS
3-
VITE_USE_BROWSER_ROUTER=false
1+
# =============================================================================
2+
# 前端环境配置 - 生产环境
3+
# =============================================================================
44

5-
# 开发环境配置(本地开发使用)
6-
# VITE_USE_BROWSER_ROUTER=true
5+
VITE_APP_TITLE=HumanOS 人类操作系统
6+
7+
VITE_API_BASE_URL=https://api.humanos.ai
8+
9+
VITE_USE_BACKEND_CALCULATION=true
10+
11+
VITE_ENABLE_USER_SYSTEM=true
12+
13+
VITE_CLOUD_SAVE_ENABLED=true
14+
15+
VITE_DEBUG_MODE=false

README-前后端对接说明.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# 🧠 HumanOS 前后端对接完成
2+
3+
## ✅ 已完成的工作
4+
5+
### 🔧 **后端架构 (Python + FastAPI)
6+
┌─────────────────────────────────────────────────────┐
7+
│ backend/ │
8+
│ ├── main.py # FastAPI 主入口 │
9+
│ ├── api/ # API 路由 │
10+
│ │ ├── assessment.py # 测评计算接口 │
11+
│ │ ├── auth.py # JWT 用户认证 │
12+
│ │ └── analytics.py # 数据分析面板 │
13+
│ ├── calculators/ # 22种测评计算器 │
14+
│ │ ├── base.py # 抽象基类 │
15+
│ │ ├── bigfive_calculator.py │
16+
│ │ ├── burnout_calculator.py │
17+
│ │ ├── sas_calculator.py │
18+
│ │ └── holland_calculator.py │
19+
│ ├── database/ # SQLAlchemy ORM │
20+
│ │ ├── models.py # 6张表设计 │
21+
│ │ └── database.py # 异步连接 │
22+
│ ├── schemas/ # Pydantic 验证 │
23+
│ ├── utils/ # 常模工具 │
24+
│ ├── tests/ # 单元测试 │
25+
│ ├── requirements.txt # 完整依赖 │
26+
│ ├── .env # 环境配置 │
27+
│ └── start.py # 一键启动脚本 │
28+
└─────────────────────────────────────────────────────┘
29+
30+
### 🎨 **前端改造 (React + TypeScript)
31+
32+
1. **API 客户端封装 `src/services/apiClient.ts`
33+
- Axios 完整封装所有后端接口
34+
- 自动健康检查 + 失败自动降级
35+
- 用户认证 Token 管理
36+
37+
2. **统一计算器 Wrapper `src/services/calculatorWrapper.ts`
38+
- ✅ 自动检测后端可用性
39+
- ✅ 一键切换前后端计算
40+
- ✅ 后端失败自动回退到前端
41+
- ✅ 统一结果格式转换
42+
43+
3. **答题页面增强 `src/pages/Assessment.tsx`
44+
- 📊 实时显示计算引擎状态
45+
- 🔄 用户可手动切换云端/本地计算
46+
- 💾 结果自动带上计算来源
47+
- ⚡ 延迟显示计算耗时(ms)
48+
49+
4. **加载页面增强 `src/pages/Loading.tsx`
50+
- ☁️ 显示云端/本地计算指示器
51+
- 🚀 根据实际计算耗时动态调整加载时间
52+
- 📈 显示计算延迟指标
53+
54+
### ⚙️ 环境配置变量
55+
56+
```env
57+
# .env.development
58+
VITE_USE_BACKEND_CALCULATION=true
59+
VITE_API_BASE_URL=http://localhost:8000
60+
VITE_ENABLE_USER_SYSTEM=true
61+
```
62+
63+
---
64+
65+
## 🚀 启动方式
66+
67+
### 1. 启动后端服务
68+
69+
```bash
70+
cd backend
71+
72+
# 安装依赖
73+
pip install -r requirements.txt
74+
75+
# 启动服务
76+
python start.py
77+
# or
78+
uvicorn main:app --reload
79+
```
80+
81+
后端启动后访问:
82+
- API 文档: http://localhost:8000/docs
83+
- Redoc: http://localhost:8000/redoc
84+
- 健康检查: http://localhost:8000/health
85+
86+
### 2. 启动前端
87+
88+
```bash
89+
npm run dev
90+
```
91+
92+
---
93+
94+
## 🎯 核心特性
95+
96+
| 功能 | 状态 |
97+
|------|------|
98+
| 后端计算引擎自动检测 ||
99+
| 用户手动切换计算引擎 ||
100+
| 后端失败自动降级 ||
101+
| 加载页显示计算来源 ||
102+
| 显示计算耗时 ||
103+
| 用户JWT认证系统 ||
104+
| 结果云端持久化 ||
105+
| 测评常模对比 ||
106+
| 用户历史记录 ||
107+
| 分享链接系统 ||
108+
109+
---
110+
111+
## 🔄 下一步计划
112+
113+
1. **剩余 18 个测评计算器移植
114+
2. 剩余 18 个计算器已接入 Python 后端
115+
3. 用户面板与历史记录
116+
4. 游戏模拟器后端化
117+
118+
---
119+
120+
## 📊 数据库表结构
121+
122+
```
123+
users - 用户表
124+
assessment_types - 测评类型表
125+
assessment_results - 测评结果表
126+
norm_data - 常模数据表
127+
item_analysis - 题目质量分析
128+
assessment_sessions - 答题会话追踪
129+
```
130+
131+
---
132+
133+
## 💡 使用说明
134+
135+
答题时右上角会显示:
136+
- 🟢 **云端计算** - 连接到后端服务器
137+
-**本地计算** - 浏览器本地计算
138+
- 🟡 **连接中** - 检测后端状态
139+
140+
点击状态指示器可以手动切换计算引擎!
5.49 KB
Binary file not shown.
9.67 KB
Binary file not shown.

backend/api/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .assessment import router as assessment
2+
from .auth import router as auth
3+
from .analytics import router as analytics
4+
5+
__all__ = ["assessment", "auth", "analytics"]
290 Bytes
Binary file not shown.
7.15 KB
Binary file not shown.
8.15 KB
Binary file not shown.
9.52 KB
Binary file not shown.

0 commit comments

Comments
 (0)