diff --git a/BILLING_FEATURES.md b/BILLING_FEATURES.md
new file mode 100644
index 0000000..18709b5
--- /dev/null
+++ b/BILLING_FEATURES.md
@@ -0,0 +1,130 @@
+# 移动端计费功能实现总结
+
+## 已实现的功能
+
+### 1. 计费系统核心功能 (`src/types/billing.ts`)
+- ✅ 用户类型定义:个人用户和企业用户
+- ✅ 通话类型:语音通话和视频通话
+- ✅ 翻译类型:文本翻译、手语翻译、人工翻译
+- ✅ 计费规则配置
+- ✅ 用户账户信息管理
+- ✅ 预约信息结构
+- ✅ 翻译员信息管理
+- ✅ 通话记录和充值记录
+
+### 2. 计费服务 (`src/services/billingService.ts`)
+- ✅ 单例模式的计费服务类
+- ✅ 根据用户类型设置不同的计费规则
+- ✅ 通话费用计算(基于通话类型、翻译类型、时长、翻译员费率)
+- ✅ 余额检查和扣费功能
+- ✅ 低余额警告
+- ✅ 账户充值功能
+- ✅ 金额格式化显示
+
+### 3. 预约服务 (`src/services/appointmentService.ts`)
+- ✅ 预约管理服务
+- ✅ 翻译员管理和可用性检查
+- ✅ 预约创建、查询、更新、取消
+- ✅ 时间冲突检查
+- ✅ 按日期和月份筛选预约
+- ✅ 模拟数据初始化
+
+### 4. 移动端首页更新 (`src/pages/mobile/Home.tsx`)
+- ✅ 用户账户余额显示
+- ✅ 账户类型显示
+- ✅ 快捷操作按钮(语音通话、视频通话、预约通话、账户充值)
+- ✅ 即将到来的预约预览
+- ✅ 最近活动记录(包含费用信息)
+- ✅ 美观的卡片式布局
+
+### 5. 移动端通话页面 (`src/pages/mobile/Call.tsx`)
+- ✅ 支持语音和视频通话选择
+- ✅ 翻译类型选择(文本、手语、人工翻译)
+- ✅ 实时费用计算和显示
+- ✅ 账户余额监控
+- ✅ 通话时长计时
+- ✅ 翻译员选择(人工翻译时)
+- ✅ 翻译历史记录
+- ✅ 自动扣费功能
+
+### 6. 移动端充值页面 (`src/pages/mobile/Recharge.tsx`)
+- ✅ 预设充值金额选择
+- ✅ 自定义充值金额输入
+- ✅ 充值赠送金额计算
+- ✅ 多种支付方式支持
+- ✅ 充值历史记录查看
+- ✅ 账户余额实时显示
+- ✅ 充值成功后余额更新
+
+### 7. 移动端预约页面 (`src/pages/mobile/Appointment.tsx`)
+- ✅ 通话类型选择(语音/视频)
+- ✅ 翻译类型选择
+- ✅ 日期和时间选择(未来7天)
+- ✅ 语言对选择
+- ✅ 翻译员选择(基于语言和日期可用性)
+- ✅ 预估费用计算
+- ✅ 余额充足性检查
+- ✅ 预约创建和确认
+
+### 8. 移动端设置页面 (`src/pages/mobile/Settings.tsx`)
+- ✅ 用户信息展示(账户类型、余额)
+- ✅ 账户管理功能
+- ✅ 通话设置选项
+- ✅ 翻译设置选项
+- ✅ 通知设置管理
+- ✅ 帮助和反馈入口
+- ✅ 退出登录功能
+
+### 9. 路由配置更新 (`src/routes/index.tsx`)
+- ✅ 新增充值页面路由 `/mobile/recharge`
+- ✅ 新增预约页面路由 `/mobile/appointment`
+- ✅ 移动端路由完整配置
+
+## 核心计费逻辑
+
+### 费率配置
+- **语音通话 + 文本翻译**: ¥0.50/分钟
+- **视频通话 + 手语翻译**: ¥1.00/分钟
+- **视频通话 + 人工翻译**: ¥2.00/分钟 + 翻译员费率
+
+### 用户类型差异
+- **个人用户**: 使用标准费率
+- **企业用户**: 可配置专属费率和信用额度
+
+### 余额管理
+- 低余额警告:不足5分钟通话费用时提醒
+- 最低余额限制:不足1分钟通话费用时禁止通话
+- 自动扣费:通话结束后自动从账户余额扣除费用
+
+### 充值优惠
+- 充值金额越大,赠送比例越高
+- 支持多种支付方式(微信、支付宝、银行卡等)
+
+## 技术特性
+
+- 🎯 **TypeScript 类型安全**: 完整的类型定义确保代码质量
+- 🏗️ **单例模式**: 服务类使用单例模式确保数据一致性
+- 💾 **模拟数据**: 完整的模拟数据支持开发和测试
+- 🎨 **响应式设计**: 适配移动端的美观界面
+- ⚡ **实时计算**: 费用和余额实时更新
+- 🔒 **余额保护**: 多重余额检查防止超支
+
+## 使用流程
+
+1. **用户注册/登录** → 获得初始账户和余额
+2. **查看余额** → 在首页或设置页面查看当前余额
+3. **充值账户** → 选择金额和支付方式进行充值
+4. **预约通话** → 选择时间、类型、翻译员创建预约
+5. **开始通话** → 选择通话类型和翻译方式
+6. **实时计费** → 通话过程中显示累计费用
+7. **自动扣费** → 通话结束后自动从余额扣除费用
+8. **查看记录** → 在首页查看通话历史和费用记录
+
+## 下一步开发建议
+
+1. **后端集成**: 连接真实的后端API替换模拟数据
+2. **支付集成**: 集成真实的支付网关
+3. **推送通知**: 实现余额不足和预约提醒
+4. **数据持久化**: 实现本地数据存储
+5. **错误处理**: 完善网络错误和支付失败处理
+6. **单元测试**: 为核心计费逻辑添加测试用例
\ No newline at end of file
diff --git a/TWILIO_TEST_GUIDE.md b/TWILIO_TEST_GUIDE.md
new file mode 100644
index 0000000..4362696
--- /dev/null
+++ b/TWILIO_TEST_GUIDE.md
@@ -0,0 +1,247 @@
+# Twilio 视频通话服务完整测试指南
+
+## 🚀 快速开始
+
+### 1. 环境准备
+
+#### 后端服务器
+```bash
+# 进入服务器目录
+cd server
+
+# 安装依赖
+npm install
+
+# 启动服务器
+npm start
+```
+
+服务器将在 `http://localhost:3001` 启动
+
+#### 前端应用
+```bash
+# 在项目根目录
+npm install
+
+# 启动开发服务器
+npm run dev
+```
+
+前端应用将在 `http://localhost:5173` 启动
+
+### 2. Twilio 配置
+
+在 `server/index.js` 中更新您的 Twilio 凭证:
+
+```javascript
+const TWILIO_CONFIG = {
+ accountSid: 'YOUR_TWILIO_ACCOUNT_SID',
+ apiKey: 'YOUR_TWILIO_API_KEY',
+ apiSecret: 'YOUR_TWILIO_API_SECRET',
+};
+```
+
+或者设置环境变量:
+```bash
+export TWILIO_ACCOUNT_SID=your_account_sid
+export TWILIO_API_KEY=your_api_key
+export TWILIO_API_SECRET=your_api_secret
+```
+
+## 🧪 测试步骤
+
+### 步骤 1: 后端 API 测试
+
+#### 1.1 健康检查
+```bash
+curl http://localhost:3001/health
+```
+
+预期响应:
+```json
+{
+ "status": "ok",
+ "timestamp": "2024-01-01T00:00:00.000Z",
+ "service": "Twilio Token Server"
+}
+```
+
+#### 1.2 获取访问令牌
+```bash
+curl -X POST http://localhost:3001/api/twilio/token \
+ -H "Content-Type: application/json" \
+ -d '{
+ "identity": "test-user",
+ "roomName": "test-room"
+ }'
+```
+
+预期响应:
+```json
+{
+ "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0...",
+ "identity": "test-user",
+ "roomName": "test-room"
+}
+```
+
+### 步骤 2: 前端功能测试
+
+#### 2.1 访问视频通话页面
+1. 打开浏览器访问 `http://localhost:5173`
+2. 导航到视频通话相关页面
+3. 查看设备检测是否正常工作
+
+#### 2.2 设备测试面板
+访问 `/device-test` 页面进行设备测试:
+
+1. **摄像头测试**
+ - 点击"测试摄像头"按钮
+ - 确认能看到视频预览
+ - 检查视频质量
+
+2. **麦克风测试**
+ - 点击"测试麦克风"按钮
+ - 说话并观察音频指示器
+ - 确认音频输入正常
+
+3. **扬声器测试**
+ - 点击"测试扬声器"按钮
+ - 确认能听到测试音频
+
+#### 2.3 视频通话测试
+
+1. **创建房间**
+ - 输入房间名称
+ - 输入用户身份
+ - 点击"加入房间"
+
+2. **多用户测试**
+ - 在另一个浏览器标签页或设备上
+ - 使用不同的用户身份加入同一房间
+ - 测试双向视频通话
+
+## 📱 设备兼容性测试
+
+### 桌面浏览器
+- ✅ Chrome (推荐)
+- ✅ Firefox
+- ✅ Safari
+- ⚠️ Edge (部分功能)
+
+### 移动设备
+- ✅ iOS Safari
+- ✅ Android Chrome
+- ⚠️ 其他移动浏览器
+
+### 测试检查清单
+
+#### 基础功能
+- [ ] 摄像头权限请求
+- [ ] 麦克风权限请求
+- [ ] 视频预览显示
+- [ ] 音频输入检测
+- [ ] 房间创建和加入
+
+#### 视频通话功能
+- [ ] 本地视频显示
+- [ ] 远程视频接收
+- [ ] 音频双向通信
+- [ ] 视频质量自适应
+- [ ] 网络断线重连
+
+#### 用户界面
+- [ ] 控制按钮响应
+- [ ] 设备切换功能
+- [ ] 全屏模式
+- [ ] 静音/取消静音
+- [ ] 视频开启/关闭
+
+## 🐛 常见问题排查
+
+### 问题 1: 无法获取访问令牌
+**症状**: API 返回 500 错误
+**解决方案**:
+1. 检查 Twilio 凭证是否正确
+2. 确认网络连接正常
+3. 查看服务器日志
+
+### 问题 2: 摄像头/麦克风权限被拒绝
+**症状**: 浏览器显示权限被阻止
+**解决方案**:
+1. 在浏览器设置中允许摄像头和麦克风权限
+2. 使用 HTTPS 连接(生产环境)
+3. 刷新页面重新请求权限
+
+### 问题 3: 视频通话连接失败
+**症状**: 无法看到远程视频
+**解决方案**:
+1. 检查防火墙设置
+2. 确认 STUN/TURN 服务器配置
+3. 测试网络连接质量
+
+### 问题 4: 音频质量差或有回音
+**症状**: 音频断断续续或有回音
+**解决方案**:
+1. 使用耳机减少回音
+2. 调整麦克风音量
+3. 检查网络带宽
+
+## 📊 性能监控
+
+### 关键指标
+- **连接建立时间**: < 3 秒
+- **视频延迟**: < 200ms
+- **音频延迟**: < 150ms
+- **丢包率**: < 1%
+
+### 监控工具
+1. 浏览器开发者工具
+2. Twilio Insights Dashboard
+3. 网络质量检测
+
+## 🔧 高级配置
+
+### 视频质量设置
+```javascript
+const videoConfig = {
+ width: { ideal: 1280 },
+ height: { ideal: 720 },
+ frameRate: { ideal: 30 }
+};
+```
+
+### 音频设置
+```javascript
+const audioConfig = {
+ echoCancellation: true,
+ noiseSuppression: true,
+ autoGainControl: true
+};
+```
+
+## 📞 技术支持
+
+如果遇到问题,请:
+1. 查看浏览器控制台错误信息
+2. 检查服务器日志
+3. 参考 Twilio 官方文档
+4. 联系技术支持团队
+
+## 🚀 生产环境部署
+
+### 安全考虑
+1. 使用 HTTPS
+2. 实施用户认证
+3. 设置访问令牌过期时间
+4. 配置 CORS 策略
+
+### 性能优化
+1. 使用 CDN 加速
+2. 启用 gzip 压缩
+3. 配置负载均衡
+4. 监控服务器性能
+
+---
+
+**注意**: 这是一个测试环境配置,生产环境需要额外的安全和性能优化措施。
\ No newline at end of file
diff --git a/Twilioapp-admin/package-lock.json b/Twilioapp-admin/package-lock.json
index dbf046a..6b3dde4 100644
--- a/Twilioapp-admin/package-lock.json
+++ b/Twilioapp-admin/package-lock.json
@@ -8,6 +8,7 @@
"name": "twilioapp-admin",
"version": "0.1.0",
"dependencies": {
+ "@ant-design/icons": "^6.0.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
@@ -23,6 +24,7 @@
"react-dom": "^18.2.0",
"react-router-dom": "^6.4.0",
"react-scripts": "5.0.1",
+ "recharts": "^3.0.2",
"twilio": "^5.7.1",
"twilio-video": "^2.31.0",
"typescript": "^4.7.4",
@@ -112,15 +114,14 @@
}
},
"node_modules/@ant-design/icons": {
- "version": "5.6.1",
- "resolved": "https://registry.npmjs.org/@ant-design/icons/-/icons-5.6.1.tgz",
- "integrity": "sha512-0/xS39c91WjPAZOWsvi1//zjx6kAp4kxWwctR6kuU6p133w8RU0D2dSCvZC19uQyharg/sAvYxGYWl01BbZZfg==",
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/@ant-design/icons/-/icons-6.0.0.tgz",
+ "integrity": "sha512-o0aCCAlHc1o4CQcapAwWzHeaW2x9F49g7P3IDtvtNXgHowtRWYb7kiubt8sQPFvfVIVU/jLw2hzeSlNt0FU+Uw==",
"dependencies": {
- "@ant-design/colors": "^7.0.0",
+ "@ant-design/colors": "^8.0.0",
"@ant-design/icons-svg": "^4.4.0",
- "@babel/runtime": "^7.24.8",
- "classnames": "^2.2.6",
- "rc-util": "^5.31.1"
+ "@rc-component/util": "^1.2.1",
+ "classnames": "^2.2.6"
},
"engines": {
"node": ">=8"
@@ -135,6 +136,22 @@
"resolved": "https://registry.npmjs.org/@ant-design/icons-svg/-/icons-svg-4.4.2.tgz",
"integrity": "sha512-vHbT+zJEVzllwP+CM+ul7reTEfBR0vgxFe7+lREAsAA7YGsYpboiq2sQNeQeRvh09GfQgs/GyFEvZpJ9cLXpXA=="
},
+ "node_modules/@ant-design/icons/node_modules/@ant-design/colors": {
+ "version": "8.0.0",
+ "resolved": "https://registry.npmjs.org/@ant-design/colors/-/colors-8.0.0.tgz",
+ "integrity": "sha512-6YzkKCw30EI/E9kHOIXsQDHmMvTllT8STzjMb4K2qzit33RW2pqCJP0sk+hidBntXxE+Vz4n1+RvCTfBw6OErw==",
+ "dependencies": {
+ "@ant-design/fast-color": "^3.0.0"
+ }
+ },
+ "node_modules/@ant-design/icons/node_modules/@ant-design/fast-color": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/@ant-design/fast-color/-/fast-color-3.0.0.tgz",
+ "integrity": "sha512-eqvpP7xEDm2S7dUzl5srEQCBTXZMmY3ekf97zI+M2DHOYyKdJGH0qua0JACHTqbkRnD/KHFQP9J1uMJ/XWVzzA==",
+ "engines": {
+ "node": ">=8.x"
+ }
+ },
"node_modules/@ant-design/react-slick": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@ant-design/react-slick/-/react-slick-1.1.2.tgz",
@@ -3141,6 +3158,57 @@
"react-dom": ">=16.9.0"
}
},
+ "node_modules/@rc-component/util": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/@rc-component/util/-/util-1.2.1.tgz",
+ "integrity": "sha512-AUVu6jO+lWjQnUOOECwu8iR0EdElQgWW5NBv5vP/Uf9dWbAX3udhMutRlkVXjuac2E40ghkFy+ve00mc/3Fymg==",
+ "dependencies": {
+ "react-is": "^18.2.0"
+ },
+ "peerDependencies": {
+ "react": ">=18.0.0",
+ "react-dom": ">=18.0.0"
+ }
+ },
+ "node_modules/@rc-component/util/node_modules/react-is": {
+ "version": "18.3.1",
+ "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
+ "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg=="
+ },
+ "node_modules/@reduxjs/toolkit": {
+ "version": "2.8.2",
+ "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-2.8.2.tgz",
+ "integrity": "sha512-MYlOhQ0sLdw4ud48FoC5w0dH9VfWQjtCjreKwYTT3l+r427qYC5Y8PihNutepr8XrNaBUDQo9khWUwQxZaqt5A==",
+ "dependencies": {
+ "@standard-schema/spec": "^1.0.0",
+ "@standard-schema/utils": "^0.3.0",
+ "immer": "^10.0.3",
+ "redux": "^5.0.1",
+ "redux-thunk": "^3.1.0",
+ "reselect": "^5.1.0"
+ },
+ "peerDependencies": {
+ "react": "^16.9.0 || ^17.0.0 || ^18 || ^19",
+ "react-redux": "^7.2.1 || ^8.1.3 || ^9.0.0"
+ },
+ "peerDependenciesMeta": {
+ "react": {
+ "optional": true
+ },
+ "react-redux": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@reduxjs/toolkit/node_modules/immer": {
+ "version": "10.1.1",
+ "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz",
+ "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/immer"
+ }
+ },
"node_modules/@remix-run/router": {
"version": "1.23.0",
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.23.0.tgz",
@@ -3254,6 +3322,16 @@
"@sinonjs/commons": "^1.7.0"
}
},
+ "node_modules/@standard-schema/spec": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz",
+ "integrity": "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA=="
+ },
+ "node_modules/@standard-schema/utils": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/@standard-schema/utils/-/utils-0.3.0.tgz",
+ "integrity": "sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g=="
+ },
"node_modules/@surma/rollup-plugin-off-main-thread": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz",
@@ -3814,6 +3892,60 @@
"@types/node": "*"
}
},
+ "node_modules/@types/d3-array": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/@types/d3-array/-/d3-array-3.2.1.tgz",
+ "integrity": "sha512-Y2Jn2idRrLzUfAKV2LyRImR+y4oa2AntrgID95SHJxuMUrkNXmanDSed71sRNZysveJVt1hLLemQZIady0FpEg=="
+ },
+ "node_modules/@types/d3-color": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/@types/d3-color/-/d3-color-3.1.3.tgz",
+ "integrity": "sha512-iO90scth9WAbmgv7ogoq57O9YpKmFBbmoEoCHDB2xMBY0+/KVrqAaCDyCE16dUspeOvIxFFRI+0sEtqDqy2b4A=="
+ },
+ "node_modules/@types/d3-ease": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@types/d3-ease/-/d3-ease-3.0.2.tgz",
+ "integrity": "sha512-NcV1JjO5oDzoK26oMzbILE6HW7uVXOHLQvHshBUW4UMdZGfiY6v5BeQwh9a9tCzv+CeefZQHJt5SRgK154RtiA=="
+ },
+ "node_modules/@types/d3-interpolate": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/@types/d3-interpolate/-/d3-interpolate-3.0.4.tgz",
+ "integrity": "sha512-mgLPETlrpVV1YRJIglr4Ez47g7Yxjl1lj7YKsiMCb27VJH9W8NVM6Bb9d8kkpG/uAQS5AmbA48q2IAolKKo1MA==",
+ "dependencies": {
+ "@types/d3-color": "*"
+ }
+ },
+ "node_modules/@types/d3-path": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/@types/d3-path/-/d3-path-3.1.1.tgz",
+ "integrity": "sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg=="
+ },
+ "node_modules/@types/d3-scale": {
+ "version": "4.0.9",
+ "resolved": "https://registry.npmjs.org/@types/d3-scale/-/d3-scale-4.0.9.tgz",
+ "integrity": "sha512-dLmtwB8zkAeO/juAMfnV+sItKjlsw2lKdZVVy6LRr0cBmegxSABiLEpGVmSJJ8O08i4+sGR6qQtb6WtuwJdvVw==",
+ "dependencies": {
+ "@types/d3-time": "*"
+ }
+ },
+ "node_modules/@types/d3-shape": {
+ "version": "3.1.7",
+ "resolved": "https://registry.npmjs.org/@types/d3-shape/-/d3-shape-3.1.7.tgz",
+ "integrity": "sha512-VLvUQ33C+3J+8p+Daf+nYSOsjB4GXp19/S/aGo60m9h1v6XaxjiT82lKVWJCfzhtuZ3yD7i/TPeC/fuKLLOSmg==",
+ "dependencies": {
+ "@types/d3-path": "*"
+ }
+ },
+ "node_modules/@types/d3-time": {
+ "version": "3.0.4",
+ "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.4.tgz",
+ "integrity": "sha512-yuzZug1nkAAaBlBBikKZTgzCeA+k1uy4ZFwWANOfKw5z5LRhV0gNA7gNkKm7HoK+HRN0wX3EkxGk0fpbWhmB7g=="
+ },
+ "node_modules/@types/d3-timer": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/@types/d3-timer/-/d3-timer-3.0.2.tgz",
+ "integrity": "sha512-Ps3T8E8dZDam6fUyNiMkekK3XUsaUEik+idO9/YjPtfj2qruF8tFBXS7XhtE4iIXBLxhmLjP3SXpLhVf21I9Lw=="
+ },
"node_modules/@types/eslint": {
"version": "8.56.12",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.12.tgz",
@@ -4082,6 +4214,11 @@
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw=="
},
+ "node_modules/@types/use-sync-external-store": {
+ "version": "0.0.6",
+ "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.6.tgz",
+ "integrity": "sha512-zFDAD+tlpf2r4asuHEj0XH6pY6i0g5NeAHPn+15wk3BV6JA69eERFXC1gyGThDkVa1zCyKr5jox1+2LbV/AMLg=="
+ },
"node_modules/@types/ws": {
"version": "8.18.1",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz",
@@ -4752,6 +4889,25 @@
"react-dom": ">=16.9.0"
}
},
+ "node_modules/antd/node_modules/@ant-design/icons": {
+ "version": "5.6.1",
+ "resolved": "https://registry.npmjs.org/@ant-design/icons/-/icons-5.6.1.tgz",
+ "integrity": "sha512-0/xS39c91WjPAZOWsvi1//zjx6kAp4kxWwctR6kuU6p133w8RU0D2dSCvZC19uQyharg/sAvYxGYWl01BbZZfg==",
+ "dependencies": {
+ "@ant-design/colors": "^7.0.0",
+ "@ant-design/icons-svg": "^4.4.0",
+ "@babel/runtime": "^7.24.8",
+ "classnames": "^2.2.6",
+ "rc-util": "^5.31.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "peerDependencies": {
+ "react": ">=16.0.0",
+ "react-dom": ">=16.0.0"
+ }
+ },
"node_modules/any-promise": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
@@ -5782,6 +5938,14 @@
"wrap-ansi": "^7.0.0"
}
},
+ "node_modules/clsx": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
+ "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/co": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
@@ -6468,6 +6632,116 @@
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz",
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="
},
+ "node_modules/d3-array": {
+ "version": "3.2.4",
+ "resolved": "https://registry.npmjs.org/d3-array/-/d3-array-3.2.4.tgz",
+ "integrity": "sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==",
+ "dependencies": {
+ "internmap": "1 - 2"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-color": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-color/-/d3-color-3.1.0.tgz",
+ "integrity": "sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-ease": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-ease/-/d3-ease-3.0.1.tgz",
+ "integrity": "sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-format": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-format/-/d3-format-3.1.0.tgz",
+ "integrity": "sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA==",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-interpolate": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-interpolate/-/d3-interpolate-3.0.1.tgz",
+ "integrity": "sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==",
+ "dependencies": {
+ "d3-color": "1 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-path": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-path/-/d3-path-3.1.0.tgz",
+ "integrity": "sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==",
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-scale": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/d3-scale/-/d3-scale-4.0.2.tgz",
+ "integrity": "sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==",
+ "dependencies": {
+ "d3-array": "2.10.0 - 3",
+ "d3-format": "1 - 3",
+ "d3-interpolate": "1.2.0 - 3",
+ "d3-time": "2.1.1 - 3",
+ "d3-time-format": "2 - 4"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-shape": {
+ "version": "3.2.0",
+ "resolved": "https://registry.npmjs.org/d3-shape/-/d3-shape-3.2.0.tgz",
+ "integrity": "sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==",
+ "dependencies": {
+ "d3-path": "^3.1.0"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-time": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/d3-time/-/d3-time-3.1.0.tgz",
+ "integrity": "sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==",
+ "dependencies": {
+ "d3-array": "2 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-time-format": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/d3-time-format/-/d3-time-format-4.1.0.tgz",
+ "integrity": "sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==",
+ "dependencies": {
+ "d3-time": "1 - 3"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/d3-timer": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/d3-timer/-/d3-timer-3.0.1.tgz",
+ "integrity": "sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==",
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/damerau-levenshtein": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz",
@@ -6560,6 +6834,11 @@
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.5.0.tgz",
"integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw=="
},
+ "node_modules/decimal.js-light": {
+ "version": "2.5.1",
+ "resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz",
+ "integrity": "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg=="
+ },
"node_modules/dedent": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz",
@@ -7205,6 +7484,11 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/es-toolkit": {
+ "version": "1.39.5",
+ "resolved": "https://registry.npmjs.org/es-toolkit/-/es-toolkit-1.39.5.tgz",
+ "integrity": "sha512-z9V0qU4lx1TBXDNFWfAASWk6RNU6c6+TJBKE+FLIg8u0XJ6Yw58Hi0yX8ftEouj6p1QARRlXLFfHbIli93BdQQ=="
+ },
"node_modules/escalade": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz",
@@ -9220,6 +9504,14 @@
"node": ">= 0.4"
}
},
+ "node_modules/internmap": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz",
+ "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==",
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/ipaddr.js": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz",
@@ -14298,6 +14590,28 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w=="
},
+ "node_modules/react-redux": {
+ "version": "9.2.0",
+ "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-9.2.0.tgz",
+ "integrity": "sha512-ROY9fvHhwOD9ySfrF0wmvu//bKCQ6AeZZq1nJNtbDC+kk5DuSuNX/n6YWYF/SYy7bSba4D4FSz8DJeKY/S/r+g==",
+ "dependencies": {
+ "@types/use-sync-external-store": "^0.0.6",
+ "use-sync-external-store": "^1.4.0"
+ },
+ "peerDependencies": {
+ "@types/react": "^18.2.25 || ^19",
+ "react": "^18.0 || ^19",
+ "redux": "^5.0.0"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "redux": {
+ "optional": true
+ }
+ }
+ },
"node_modules/react-refresh": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz",
@@ -14440,6 +14754,46 @@
"node": ">=8.10.0"
}
},
+ "node_modules/recharts": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/recharts/-/recharts-3.0.2.tgz",
+ "integrity": "sha512-eDc3ile9qJU9Dp/EekSthQPhAVPG48/uM47jk+PF7VBQngxeW3cwQpPHb/GHC1uqwyCRWXcIrDzuHRVrnRryoQ==",
+ "dependencies": {
+ "@reduxjs/toolkit": "1.x.x || 2.x.x",
+ "clsx": "^2.1.1",
+ "decimal.js-light": "^2.5.1",
+ "es-toolkit": "^1.39.3",
+ "eventemitter3": "^5.0.1",
+ "immer": "^10.1.1",
+ "react-redux": "8.x.x || 9.x.x",
+ "reselect": "5.1.1",
+ "tiny-invariant": "^1.3.3",
+ "use-sync-external-store": "^1.2.2",
+ "victory-vendor": "^37.0.2"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "peerDependencies": {
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
+ "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
+ "react-is": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
+ }
+ },
+ "node_modules/recharts/node_modules/eventemitter3": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz",
+ "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA=="
+ },
+ "node_modules/recharts/node_modules/immer": {
+ "version": "10.1.1",
+ "resolved": "https://registry.npmjs.org/immer/-/immer-10.1.1.tgz",
+ "integrity": "sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==",
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/immer"
+ }
+ },
"node_modules/recursive-readdir": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.3.tgz",
@@ -14463,6 +14817,19 @@
"node": ">=8"
}
},
+ "node_modules/redux": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/redux/-/redux-5.0.1.tgz",
+ "integrity": "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w=="
+ },
+ "node_modules/redux-thunk": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-3.1.0.tgz",
+ "integrity": "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw==",
+ "peerDependencies": {
+ "redux": "^5.0.0"
+ }
+ },
"node_modules/reflect.getprototypeof": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz",
@@ -14613,6 +14980,11 @@
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
},
+ "node_modules/reselect": {
+ "version": "5.1.1",
+ "resolved": "https://registry.npmjs.org/reselect/-/reselect-5.1.1.tgz",
+ "integrity": "sha512-K/BG6eIky/SBpzfHZv/dd+9JBFiS4SWV7FIujVyJRux6e45+73RaUHXLmIR1f7WOMaQ0U1km6qwklRQxpJJY0w=="
+ },
"node_modules/resize-observer-polyfill": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
@@ -16367,6 +16739,11 @@
"resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz",
"integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA=="
},
+ "node_modules/tiny-invariant": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",
+ "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg=="
+ },
"node_modules/tmpl": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
@@ -16890,6 +17267,14 @@
"requires-port": "^1.0.0"
}
},
+ "node_modules/use-sync-external-store": {
+ "version": "1.5.0",
+ "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.5.0.tgz",
+ "integrity": "sha512-Rb46I4cGGVBmjamjphe8L/UnvJD+uPPtTkNvX5mZgqdbavhI4EbgIWJiIHXJ8bc/i9EQGPRh4DwEURJ552Do0A==",
+ "peerDependencies": {
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
+ }
+ },
"node_modules/util": {
"version": "0.12.5",
"resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz",
@@ -16968,6 +17353,27 @@
"node": ">= 0.8"
}
},
+ "node_modules/victory-vendor": {
+ "version": "37.3.6",
+ "resolved": "https://registry.npmjs.org/victory-vendor/-/victory-vendor-37.3.6.tgz",
+ "integrity": "sha512-SbPDPdDBYp+5MJHhBCAyI7wKM3d5ivekigc2Dk2s7pgbZ9wIgIBYGVw4zGHBml/qTFbexrofXW6Gu4noGxrOwQ==",
+ "dependencies": {
+ "@types/d3-array": "^3.0.3",
+ "@types/d3-ease": "^3.0.0",
+ "@types/d3-interpolate": "^3.0.1",
+ "@types/d3-scale": "^4.0.2",
+ "@types/d3-shape": "^3.1.0",
+ "@types/d3-time": "^3.0.0",
+ "@types/d3-timer": "^3.0.0",
+ "d3-array": "^3.1.6",
+ "d3-ease": "^3.0.1",
+ "d3-interpolate": "^3.0.1",
+ "d3-scale": "^4.0.2",
+ "d3-shape": "^3.1.0",
+ "d3-time": "^3.0.0",
+ "d3-timer": "^3.0.1"
+ }
+ },
"node_modules/w3c-hr-time": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz",
diff --git a/Twilioapp-admin/package.json b/Twilioapp-admin/package.json
index 4c9aa6b..d76423f 100644
--- a/Twilioapp-admin/package.json
+++ b/Twilioapp-admin/package.json
@@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
+ "@ant-design/icons": "^6.0.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
@@ -18,6 +19,7 @@
"react-dom": "^18.2.0",
"react-router-dom": "^6.4.0",
"react-scripts": "5.0.1",
+ "recharts": "^3.0.2",
"twilio": "^5.7.1",
"twilio-video": "^2.31.0",
"typescript": "^4.7.4",
diff --git a/Twilioapp-admin/src/App.tsx b/Twilioapp-admin/src/App.tsx
index 48daf03..2e34898 100644
--- a/Twilioapp-admin/src/App.tsx
+++ b/Twilioapp-admin/src/App.tsx
@@ -9,7 +9,10 @@ import {
UserOutlined,
TeamOutlined,
DollarOutlined,
- SettingOutlined
+ SettingOutlined,
+ WalletOutlined,
+ BarChartOutlined,
+ CalculatorOutlined
} from '@ant-design/icons';
import zhCN from 'antd/locale/zh_CN';
import 'antd/dist/reset.css';
@@ -28,6 +31,11 @@ import TranslatorList from './pages/Translators/TranslatorList';
import PaymentList from './pages/Payments/PaymentList';
import SystemSettings from './pages/Settings/SystemSettings';
+// 导入计费管理页面
+import BillingRules from './pages/Billing/BillingRules';
+import UserAccounts from './pages/Billing/UserAccounts';
+import BillingStats from './pages/Billing/BillingStats';
+
const { Header, Sider, Content } = Layout;
const { Title } = Typography;
@@ -58,6 +66,15 @@ const AppContent: React.FC = () => {
case 'payments':
navigate('/payments');
break;
+ case 'billing-rules':
+ navigate('/billing/rules');
+ break;
+ case 'user-accounts':
+ navigate('/billing/accounts');
+ break;
+ case 'billing-stats':
+ navigate('/billing/stats');
+ break;
case 'settings':
navigate('/settings');
break;
@@ -97,6 +114,28 @@ const AppContent: React.FC = () => {
icon: ,
label: '译员管理',
},
+ {
+ key: 'billing',
+ icon: ,
+ label: '计费管理',
+ children: [
+ {
+ key: 'billing-rules',
+ icon: ,
+ label: '计费规则',
+ },
+ {
+ key: 'user-accounts',
+ icon: ,
+ label: '用户账户',
+ },
+ {
+ key: 'billing-stats',
+ icon: ,
+ label: '计费统计',
+ },
+ ],
+ },
{
key: 'payments',
icon: ,
@@ -156,20 +195,28 @@ const AppContent: React.FC = () => {
background: '#f0f2f5',
minHeight: 'calc(100vh - 64px)'
}}>
-
- } />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
-
+
+
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+
+ {/* 计费管理路由 */}
+ } />
+ } />
+ } />
+
+ } />
+ } />
+
+
diff --git a/Twilioapp-admin/src/pages/Billing/BillingRules.tsx b/Twilioapp-admin/src/pages/Billing/BillingRules.tsx
new file mode 100644
index 0000000..724948f
--- /dev/null
+++ b/Twilioapp-admin/src/pages/Billing/BillingRules.tsx
@@ -0,0 +1,338 @@
+import React, { useState, useEffect } from 'react';
+import {
+ Table,
+ Button,
+ Modal,
+ Form,
+ Input,
+ Select,
+ Switch,
+ InputNumber,
+ Space,
+ Popconfirm,
+ message,
+ Card,
+ Row,
+ Col,
+ Statistic,
+} from 'antd';
+import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
+import { BillingRule, CallType, TranslationType, UserType } from '../../types/billing';
+import billingService from '../../services/billingService';
+
+const { Option } = Select;
+
+const BillingRules: React.FC = () => {
+ const [rules, setRules] = useState([]);
+ const [loading, setLoading] = useState(false);
+ const [modalVisible, setModalVisible] = useState(false);
+ const [editingRule, setEditingRule] = useState(null);
+ const [form] = Form.useForm();
+
+ useEffect(() => {
+ fetchRules();
+ }, []);
+
+ const fetchRules = async () => {
+ setLoading(true);
+ try {
+ const rulesData = await billingService.getBillingRules();
+ setRules(rulesData);
+ } catch (error) {
+ message.error('获取计费规则失败');
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const handleAdd = () => {
+ setEditingRule(null);
+ form.resetFields();
+ setModalVisible(true);
+ };
+
+ const handleEdit = (rule: BillingRule) => {
+ setEditingRule(rule);
+ form.setFieldsValue(rule);
+ setModalVisible(true);
+ };
+
+ const handleDelete = async (id: string) => {
+ try {
+ await billingService.deleteBillingRule(id);
+ message.success('删除成功');
+ fetchRules();
+ } catch (error) {
+ message.error('删除失败');
+ }
+ };
+
+ const handleSubmit = async (values: any) => {
+ try {
+ if (editingRule) {
+ await billingService.updateBillingRule(editingRule.id, values);
+ message.success('更新成功');
+ } else {
+ await billingService.createBillingRule(values);
+ message.success('创建成功');
+ }
+ setModalVisible(false);
+ fetchRules();
+ } catch (error) {
+ message.error(editingRule ? '更新失败' : '创建失败');
+ }
+ };
+
+ const columns = [
+ {
+ title: '规则名称',
+ dataIndex: 'name',
+ key: 'name',
+ },
+ {
+ title: '通话类型',
+ dataIndex: 'callType',
+ key: 'callType',
+ render: (type: CallType) => {
+ const typeMap = {
+ [CallType.VOICE]: '语音通话',
+ [CallType.VIDEO]: '视频通话',
+ };
+ return typeMap[type];
+ },
+ },
+ {
+ title: '翻译类型',
+ dataIndex: 'translationType',
+ key: 'translationType',
+ render: (type: TranslationType) => {
+ const typeMap = {
+ [TranslationType.TEXT]: '文字翻译',
+ [TranslationType.SIGN_LANGUAGE]: '手语翻译',
+ [TranslationType.HUMAN_INTERPRETER]: '真人翻译',
+ };
+ return typeMap[type];
+ },
+ },
+ {
+ title: '用户类型',
+ dataIndex: 'userType',
+ key: 'userType',
+ render: (type: UserType) => {
+ const typeMap = {
+ [UserType.INDIVIDUAL]: '普通用户',
+ [UserType.ENTERPRISE]: '企业用户',
+ };
+ return typeMap[type];
+ },
+ },
+ {
+ title: '每分钟价格',
+ dataIndex: 'pricePerMinute',
+ key: 'pricePerMinute',
+ render: (price: number) => `¥${(price / 100).toFixed(2)}`,
+ },
+ {
+ title: '最低收费',
+ dataIndex: 'minimumCharge',
+ key: 'minimumCharge',
+ render: (charge: number) => `¥${(charge / 100).toFixed(2)}`,
+ },
+ {
+ title: '状态',
+ dataIndex: 'isActive',
+ key: 'isActive',
+ render: (isActive: boolean) => (
+
+ {isActive ? '启用' : '禁用'}
+
+ ),
+ },
+ {
+ title: '操作',
+ key: 'action',
+ render: (_: any, record: BillingRule) => (
+
+ }
+ onClick={() => handleEdit(record)}
+ >
+ 编辑
+
+ handleDelete(record.id)}
+ okText="确定"
+ cancelText="取消"
+ >
+ }>
+ 删除
+
+
+
+ ),
+ },
+ ];
+
+ const activeRules = rules.filter(rule => rule.isActive);
+ const inactiveRules = rules.filter(rule => !rule.isActive);
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
} onClick={handleAdd}>
+ 新增规则
+
+ }
+ >
+
`共 ${total} 条记录`,
+ }}
+ />
+
+
+ setModalVisible(false)}
+ footer={null}
+ width={600}
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default BillingRules;
\ No newline at end of file
diff --git a/Twilioapp-admin/src/pages/Billing/BillingStats.tsx b/Twilioapp-admin/src/pages/Billing/BillingStats.tsx
new file mode 100644
index 0000000..554a8fa
--- /dev/null
+++ b/Twilioapp-admin/src/pages/Billing/BillingStats.tsx
@@ -0,0 +1,293 @@
+import React, { useState, useEffect } from 'react';
+import {
+ Card,
+ Row,
+ Col,
+ Statistic,
+ Table,
+ DatePicker,
+ Select,
+ Space,
+ Button,
+} from 'antd';
+import {
+ LineChart,
+ Line,
+ AreaChart,
+ Area,
+ BarChart,
+ Bar,
+ PieChart,
+ Pie,
+ Cell,
+ XAxis,
+ YAxis,
+ CartesianGrid,
+ Tooltip,
+ Legend,
+ ResponsiveContainer,
+} from 'recharts';
+import { BillingStats as BillingStatsType } from '../../types/billing';
+import billingService from '../../services/billingService';
+
+const { RangePicker } = DatePicker;
+const { Option } = Select;
+
+const BillingStats: React.FC = () => {
+ const [stats, setStats] = useState(null);
+ const [loading, setLoading] = useState(false);
+ const [dateRange, setDateRange] = useState<[any, any] | null>(null);
+
+ useEffect(() => {
+ fetchStats();
+ }, [dateRange]);
+
+ const fetchStats = async () => {
+ setLoading(true);
+ try {
+ const startDate = dateRange?.[0]?.toDate();
+ const endDate = dateRange?.[1]?.toDate();
+ const statsData = await billingService.getBillingStats(startDate, endDate);
+ setStats(statsData);
+ } catch (error) {
+ console.error('获取统计数据失败:', error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ if (!stats) {
+ return 加载中...
;
+ }
+
+ // 饼图颜色配置
+ const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042', '#8884D8'];
+
+ // 服务统计表格列
+ const serviceColumns = [
+ {
+ title: '服务类型',
+ dataIndex: 'type',
+ key: 'type',
+ },
+ {
+ title: '使用次数',
+ dataIndex: 'count',
+ key: 'count',
+ },
+ {
+ title: '收入金额',
+ dataIndex: 'revenue',
+ key: 'revenue',
+ render: (revenue: number) => `¥${(revenue / 100).toFixed(2)}`,
+ },
+ {
+ title: '平均单价',
+ key: 'avgPrice',
+ render: (_: any, record: any) =>
+ `¥${((record.revenue / record.count) / 100).toFixed(2)}`,
+ },
+ ];
+
+ return (
+
+ {/* 筛选条件 */}
+
+
+ 时间范围:
+
+
+
+
+
+ {/* 核心指标 */}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* 图表区域 */}
+
+ {/* 收入趋势图 */}
+
+
+
+
+
+
+ `¥${(value / 100).toFixed(0)}`} />
+ [`¥${(value / 100).toFixed(2)}`, '收入']}
+ />
+
+
+
+
+
+
+ {/* 服务类型分布 */}
+
+
+
+
+ `${type} ${(percent * 100).toFixed(0)}%`}
+ outerRadius={80}
+ fill="#8884d8"
+ dataKey="count"
+ >
+ {stats.topServices.map((entry, index) => (
+ |
+ ))}
+
+
+
+
+
+
+
+
+
+ {/* 服务收入对比 */}
+
+
+
+
+
+
+ `¥${(value / 100).toFixed(0)}`} />
+ [`¥${(value / 100).toFixed(2)}`, '收入']}
+ />
+
+
+
+
+
+
+ {/* 服务使用次数对比 */}
+
+
+
+
+
+
+
+ [value, '次数']} />
+
+
+
+
+
+
+
+ {/* 详细数据表格 */}
+
+
+
+
+ );
+};
+
+export default BillingStats;
\ No newline at end of file
diff --git a/Twilioapp-admin/src/pages/Billing/UserAccounts.tsx b/Twilioapp-admin/src/pages/Billing/UserAccounts.tsx
new file mode 100644
index 0000000..793a868
--- /dev/null
+++ b/Twilioapp-admin/src/pages/Billing/UserAccounts.tsx
@@ -0,0 +1,318 @@
+import React, { useState, useEffect } from 'react';
+import {
+ Table,
+ Button,
+ Modal,
+ Form,
+ Input,
+ InputNumber,
+ Space,
+ message,
+ Card,
+ Row,
+ Col,
+ Statistic,
+ Tag,
+ Tabs,
+} from 'antd';
+import { WalletOutlined, PlusOutlined, MinusOutlined, StopOutlined } from '@ant-design/icons';
+import { UserAccount, UserType, RechargeRecord, ConsumptionRecord } from '../../types/billing';
+import billingService from '../../services/billingService';
+
+const { TabPane } = Tabs;
+
+const UserAccounts: React.FC = () => {
+ const [accounts, setAccounts] = useState([]);
+ const [rechargeRecords, setRechargeRecords] = useState([]);
+ const [consumptionRecords, setConsumptionRecords] = useState([]);
+ const [loading, setLoading] = useState(false);
+ const [modalVisible, setModalVisible] = useState(false);
+ const [modalType, setModalType] = useState<'recharge' | 'deduct' | 'freeze' | 'unfreeze'>('recharge');
+ const [selectedAccount, setSelectedAccount] = useState(null);
+ const [form] = Form.useForm();
+
+ useEffect(() => {
+ fetchAccounts();
+ fetchRechargeRecords();
+ fetchConsumptionRecords();
+ }, []);
+
+ const fetchAccounts = async () => {
+ setLoading(true);
+ try {
+ const { accounts: accountsData } = await billingService.getUserAccounts();
+ setAccounts(accountsData);
+ } catch (error) {
+ message.error('获取用户账户失败');
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const fetchRechargeRecords = async () => {
+ try {
+ const { records } = await billingService.getRechargeRecords();
+ setRechargeRecords(records);
+ } catch (error) {
+ message.error('获取充值记录失败');
+ }
+ };
+
+ const fetchConsumptionRecords = async () => {
+ try {
+ const { records } = await billingService.getConsumptionRecords();
+ setConsumptionRecords(records);
+ } catch (error) {
+ message.error('获取消费记录失败');
+ }
+ };
+
+ const handleBalanceOperation = (account: UserAccount, type: 'recharge' | 'deduct' | 'freeze' | 'unfreeze') => {
+ setSelectedAccount(account);
+ setModalType(type);
+ form.resetFields();
+ setModalVisible(true);
+ };
+
+ const handleSubmit = async (values: any) => {
+ if (!selectedAccount) return;
+
+ try {
+ const { amount, reason } = values;
+
+ switch (modalType) {
+ case 'recharge':
+ await billingService.updateUserBalance(selectedAccount.userId, amount, reason || '管理员充值');
+ message.success('充值成功');
+ break;
+ case 'deduct':
+ await billingService.updateUserBalance(selectedAccount.userId, -amount, reason || '管理员扣费');
+ message.success('扣费成功');
+ break;
+ case 'freeze':
+ await billingService.freezeUserBalance(selectedAccount.userId, amount);
+ message.success('冻结成功');
+ break;
+ case 'unfreeze':
+ await billingService.unfreezeUserBalance(selectedAccount.userId, amount);
+ message.success('解冻成功');
+ break;
+ }
+
+ setModalVisible(false);
+ fetchAccounts();
+ } catch (error: any) {
+ message.error(error.message || '操作失败');
+ }
+ };
+
+ const accountColumns = [
+ {
+ title: '用户ID',
+ dataIndex: 'userId',
+ key: 'userId',
+ },
+ {
+ title: '用户类型',
+ dataIndex: 'userType',
+ key: 'userType',
+ render: (type: UserType) => {
+ const typeMap = {
+ [UserType.INDIVIDUAL]: { text: '普通用户', color: 'blue' },
+ [UserType.ENTERPRISE]: { text: '企业用户', color: 'gold' },
+ };
+ const config = typeMap[type];
+ return {config.text};
+ },
+ },
+ {
+ title: '账户余额',
+ dataIndex: 'balance',
+ key: 'balance',
+ render: (balance: number) => (
+ 0 ? '#52c41a' : '#ff4d4f' }}>
+ ¥{(balance / 100).toFixed(2)}
+
+ ),
+ },
+ {
+ title: '冻结余额',
+ dataIndex: 'frozenBalance',
+ key: 'frozenBalance',
+ render: (balance: number) => `¥${(balance / 100).toFixed(2)}`,
+ },
+ {
+ title: '累计充值',
+ dataIndex: 'totalRecharge',
+ key: 'totalRecharge',
+ render: (amount: number) => `¥${(amount / 100).toFixed(2)}`,
+ },
+ {
+ title: '累计消费',
+ dataIndex: 'totalConsumption',
+ key: 'totalConsumption',
+ render: (amount: number) => `¥${(amount / 100).toFixed(2)}`,
+ },
+ {
+ title: '操作',
+ key: 'action',
+ render: (_: any, record: UserAccount) => (
+
+ }
+ onClick={() => handleBalanceOperation(record, 'recharge')}
+ >
+ 充值
+
+ }
+ onClick={() => handleBalanceOperation(record, 'deduct')}
+ >
+ 扣费
+
+ }
+ onClick={() => handleBalanceOperation(record, 'freeze')}
+ >
+ 冻结
+
+
+ ),
+ },
+ ];
+
+ const totalBalance = accounts.reduce((sum, account) => sum + account.balance, 0);
+ const totalFrozenBalance = accounts.reduce((sum, account) => sum + account.frozenBalance, 0);
+
+ const getModalTitle = () => {
+ const titles = {
+ recharge: '用户充值',
+ deduct: '用户扣费',
+ freeze: '冻结余额',
+ unfreeze: '解冻余额',
+ };
+ return titles[modalType];
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `共 ${total} 条记录`,
+ }}
+ />
+
+
+
+
+ setModalVisible(false)}
+ footer={null}
+ width={500}
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+ {(modalType === 'recharge' || modalType === 'deduct') && (
+
+
+
+ )}
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default UserAccounts;
\ No newline at end of file
diff --git a/Twilioapp-admin/src/pages/Billing/index.ts b/Twilioapp-admin/src/pages/Billing/index.ts
new file mode 100644
index 0000000..73b373f
--- /dev/null
+++ b/Twilioapp-admin/src/pages/Billing/index.ts
@@ -0,0 +1,3 @@
+export { default as BillingRules } from './BillingRules';
+export { default as UserAccounts } from './UserAccounts';
+export { default as BillingStats } from './BillingStats';
\ No newline at end of file
diff --git a/Twilioapp-admin/src/services/billingService.ts b/Twilioapp-admin/src/services/billingService.ts
new file mode 100644
index 0000000..5417bbb
--- /dev/null
+++ b/Twilioapp-admin/src/services/billingService.ts
@@ -0,0 +1,440 @@
+import {
+ BillingRule,
+ UserAccount,
+ CallRecord,
+ RechargeRecord,
+ ConsumptionRecord,
+ BillingStats,
+ CallType,
+ TranslationType,
+ UserType,
+ BILLING_CONFIG,
+} from '../types/billing';
+
+class BillingService {
+ private static instance: BillingService;
+
+ public static getInstance(): BillingService {
+ if (!BillingService.instance) {
+ BillingService.instance = new BillingService();
+ }
+ return BillingService.instance;
+ }
+
+ // 计费规则管理
+ async getBillingRules(): Promise {
+ // TODO: 替换为实际API调用
+ return [
+ {
+ id: '1',
+ name: '语音文字翻译',
+ callType: CallType.VOICE,
+ translationType: TranslationType.TEXT,
+ pricePerMinute: 50,
+ minimumCharge: 50,
+ userType: UserType.INDIVIDUAL,
+ isActive: true,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ },
+ {
+ id: '2',
+ name: '视频手语翻译',
+ callType: CallType.VIDEO,
+ translationType: TranslationType.SIGN_LANGUAGE,
+ pricePerMinute: 100,
+ minimumCharge: 100,
+ userType: UserType.INDIVIDUAL,
+ isActive: true,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ },
+ {
+ id: '3',
+ name: '视频真人翻译',
+ callType: CallType.VIDEO,
+ translationType: TranslationType.HUMAN_INTERPRETER,
+ pricePerMinute: 200,
+ minimumCharge: 200,
+ userType: UserType.INDIVIDUAL,
+ isActive: true,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ },
+ ];
+ }
+
+ async createBillingRule(rule: Omit): Promise {
+ // TODO: 替换为实际API调用
+ const newRule: BillingRule = {
+ ...rule,
+ id: Date.now().toString(),
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ };
+ return newRule;
+ }
+
+ async updateBillingRule(id: string, updates: Partial): Promise {
+ // TODO: 替换为实际API调用
+ const existingRule = await this.getBillingRuleById(id);
+ return {
+ ...existingRule,
+ ...updates,
+ updatedAt: new Date(),
+ };
+ }
+
+ async deleteBillingRule(id: string): Promise {
+ // TODO: 替换为实际API调用
+ console.log('删除计费规则:', id);
+ }
+
+ async getBillingRuleById(id: string): Promise {
+ // TODO: 替换为实际API调用
+ const rules = await this.getBillingRules();
+ const rule = rules.find(r => r.id === id);
+ if (!rule) {
+ throw new Error('计费规则未找到');
+ }
+ return rule;
+ }
+
+ // 用户账户管理
+ async getUserAccounts(page: number = 1, pageSize: number = 10): Promise<{
+ accounts: UserAccount[];
+ total: number;
+ }> {
+ // TODO: 替换为实际API调用
+ const mockAccounts: UserAccount[] = [
+ {
+ id: '1',
+ userId: 'user1',
+ userType: UserType.INDIVIDUAL,
+ balance: 5000,
+ frozenBalance: 0,
+ totalRecharge: 10000,
+ totalConsumption: 5000,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ },
+ {
+ id: '2',
+ userId: 'user2',
+ userType: UserType.ENTERPRISE,
+ balance: 50000,
+ frozenBalance: 5000,
+ creditLimit: 100000,
+ totalRecharge: 100000,
+ totalConsumption: 50000,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ },
+ ];
+
+ return {
+ accounts: mockAccounts,
+ total: mockAccounts.length,
+ };
+ }
+
+ async getUserAccountById(userId: string): Promise {
+ // TODO: 替换为实际API调用
+ const { accounts } = await this.getUserAccounts();
+ const account = accounts.find(a => a.userId === userId);
+ if (!account) {
+ throw new Error('用户账户未找到');
+ }
+ return account;
+ }
+
+ async updateUserBalance(userId: string, amount: number, reason: string): Promise {
+ // TODO: 替换为实际API调用
+ const account = await this.getUserAccountById(userId);
+ account.balance += amount;
+ account.updatedAt = new Date();
+
+ // 记录消费记录
+ if (amount !== 0) {
+ await this.createConsumptionRecord({
+ userId,
+ relatedType: 'call',
+ relatedId: 'admin-adjustment',
+ amount: Math.abs(amount),
+ balanceBefore: account.balance - amount,
+ balanceAfter: account.balance,
+ description: reason,
+ });
+ }
+
+ return account;
+ }
+
+ async freezeUserBalance(userId: string, amount: number): Promise {
+ // TODO: 替换为实际API调用
+ const account = await this.getUserAccountById(userId);
+ if (account.balance < amount) {
+ throw new Error('余额不足');
+ }
+ account.balance -= amount;
+ account.frozenBalance += amount;
+ account.updatedAt = new Date();
+ return account;
+ }
+
+ async unfreezeUserBalance(userId: string, amount: number): Promise {
+ // TODO: 替换为实际API调用
+ const account = await this.getUserAccountById(userId);
+ if (account.frozenBalance < amount) {
+ throw new Error('冻结余额不足');
+ }
+ account.frozenBalance -= amount;
+ account.balance += amount;
+ account.updatedAt = new Date();
+ return account;
+ }
+
+ // 通话记录管理
+ async getCallRecords(
+ page: number = 1,
+ pageSize: number = 10,
+ filters?: {
+ userId?: string;
+ status?: string;
+ startDate?: Date;
+ endDate?: Date;
+ }
+ ): Promise<{
+ records: CallRecord[];
+ total: number;
+ }> {
+ // TODO: 替换为实际API调用
+ const mockRecords: CallRecord[] = [
+ {
+ id: '1',
+ userId: 'user1',
+ callType: CallType.VOICE,
+ translationType: TranslationType.TEXT,
+ startTime: new Date(Date.now() - 3600000),
+ endTime: new Date(),
+ duration: 60,
+ cost: 3000,
+ status: 'completed',
+ billingDetails: {
+ baseRate: 50,
+ totalMinutes: 60,
+ totalCost: 3000,
+ },
+ createdAt: new Date(),
+ qualityScore: 4.5,
+ userRating: 5,
+ userFeedback: '翻译质量很好',
+ },
+ ];
+
+ return {
+ records: mockRecords,
+ total: mockRecords.length,
+ };
+ }
+
+ async getCallRecordById(id: string): Promise {
+ // TODO: 替换为实际API调用
+ const { records } = await this.getCallRecords();
+ const record = records.find(r => r.id === id);
+ if (!record) {
+ throw new Error('通话记录未找到');
+ }
+ return record;
+ }
+
+ // 充值记录管理
+ async getRechargeRecords(
+ page: number = 1,
+ pageSize: number = 10,
+ filters?: {
+ userId?: string;
+ status?: string;
+ startDate?: Date;
+ endDate?: Date;
+ }
+ ): Promise<{
+ records: RechargeRecord[];
+ total: number;
+ }> {
+ // TODO: 替换为实际API调用
+ const mockRecords: RechargeRecord[] = [
+ {
+ id: '1',
+ userId: 'user1',
+ amount: 10000,
+ bonus: 500,
+ paymentMethod: 'wechat',
+ status: 'completed',
+ transactionId: 'tx_123456',
+ createdAt: new Date(),
+ completedAt: new Date(),
+ },
+ ];
+
+ return {
+ records: mockRecords,
+ total: mockRecords.length,
+ };
+ }
+
+ async processRecharge(
+ userId: string,
+ amount: number,
+ paymentMethod: string,
+ transactionId: string
+ ): Promise {
+ // TODO: 替换为实际API调用
+ const bonus = this.calculateRechargeBonus(amount);
+
+ const record: RechargeRecord = {
+ id: Date.now().toString(),
+ userId,
+ amount,
+ bonus,
+ paymentMethod,
+ status: 'completed',
+ transactionId,
+ createdAt: new Date(),
+ completedAt: new Date(),
+ };
+
+ // 更新用户余额
+ await this.updateUserBalance(userId, amount + bonus, `充值 ${amount/100}元,赠送 ${bonus/100}元`);
+
+ return record;
+ }
+
+ // 消费记录管理
+ async getConsumptionRecords(
+ page: number = 1,
+ pageSize: number = 10,
+ filters?: {
+ userId?: string;
+ relatedType?: string;
+ startDate?: Date;
+ endDate?: Date;
+ }
+ ): Promise<{
+ records: ConsumptionRecord[];
+ total: number;
+ }> {
+ // TODO: 替换为实际API调用
+ const mockRecords: ConsumptionRecord[] = [
+ {
+ id: '1',
+ userId: 'user1',
+ relatedType: 'call',
+ relatedId: 'call_123',
+ amount: 3000,
+ balanceBefore: 8000,
+ balanceAfter: 5000,
+ description: '语音文字翻译通话费用',
+ createdAt: new Date(),
+ },
+ ];
+
+ return {
+ records: mockRecords,
+ total: mockRecords.length,
+ };
+ }
+
+ async createConsumptionRecord(
+ record: Omit
+ ): Promise {
+ // TODO: 替换为实际API调用
+ return {
+ ...record,
+ id: Date.now().toString(),
+ createdAt: new Date(),
+ };
+ }
+
+ // 统计数据
+ async getBillingStats(
+ startDate?: Date,
+ endDate?: Date
+ ): Promise {
+ // TODO: 替换为实际API调用
+ return {
+ totalRevenue: 1000000, // 10000元
+ totalUsers: 1500,
+ activeUsers: 800,
+ totalCalls: 5000,
+ totalAppointments: 1200,
+ averageCallDuration: 45,
+ averageCallCost: 2000, // 20元
+ topServices: [
+ { type: '语音文字翻译', count: 3000, revenue: 600000 },
+ { type: '视频手语翻译', count: 1500, revenue: 300000 },
+ { type: '视频真人翻译', count: 500, revenue: 100000 },
+ ],
+ revenueByDate: [
+ { date: '2024-01-01', revenue: 50000 },
+ { date: '2024-01-02', revenue: 60000 },
+ { date: '2024-01-03', revenue: 55000 },
+ ],
+ };
+ }
+
+ // 工具方法
+ private calculateRechargeBonus(amount: number): number {
+ for (const rule of BILLING_CONFIG.RECHARGE_BONUS_RULES) {
+ if (amount >= rule.minAmount) {
+ return Math.floor(amount * rule.bonusPercentage / 100);
+ }
+ }
+ return 0;
+ }
+
+ // 计算通话费用
+ calculateCallCost(
+ callType: CallType,
+ translationType: TranslationType,
+ duration: number,
+ userType: UserType = UserType.INDIVIDUAL
+ ): number {
+ // TODO: 根据计费规则计算实际费用
+ const baseRate = BILLING_CONFIG.DEFAULT_RATES[callType]?.[translationType] || 100;
+ return Math.max(baseRate, baseRate * Math.ceil(duration));
+ }
+
+ // 检查用户余额是否充足
+ async checkUserBalance(userId: string, requiredAmount: number): Promise {
+ const account = await this.getUserAccountById(userId);
+ return account.balance >= requiredAmount;
+ }
+
+ // 扣费
+ async deductBalance(
+ userId: string,
+ amount: number,
+ relatedType: 'call' | 'appointment' | 'document',
+ relatedId: string,
+ description: string
+ ): Promise {
+ const account = await this.getUserAccountById(userId);
+ if (account.balance < amount) {
+ throw new Error('余额不足');
+ }
+
+ await this.updateUserBalance(userId, -amount, description);
+ await this.createConsumptionRecord({
+ userId,
+ relatedType,
+ relatedId,
+ amount,
+ balanceBefore: account.balance,
+ balanceAfter: account.balance - amount,
+ description,
+ });
+ }
+}
+
+export default BillingService.getInstance();
\ No newline at end of file
diff --git a/Twilioapp-admin/src/types/billing.ts b/Twilioapp-admin/src/types/billing.ts
new file mode 100644
index 0000000..ab14d22
--- /dev/null
+++ b/Twilioapp-admin/src/types/billing.ts
@@ -0,0 +1,189 @@
+// 用户类型
+export enum UserType {
+ INDIVIDUAL = 'individual', // 普通用户
+ ENTERPRISE = 'enterprise', // 企业用户
+}
+
+// 通话类型
+export enum CallType {
+ VOICE = 'voice', // 语音通话
+ VIDEO = 'video', // 视频通话
+}
+
+// 翻译类型
+export enum TranslationType {
+ TEXT = 'text', // 文字翻译
+ SIGN_LANGUAGE = 'sign_language', // 手语翻译
+ HUMAN_INTERPRETER = 'human_interpreter', // 真人翻译
+}
+
+// 计费规则
+export interface BillingRule {
+ id: string;
+ name: string;
+ callType: CallType;
+ translationType: TranslationType;
+ pricePerMinute: number; // 每分钟价格(分)
+ minimumCharge: number; // 最低收费(分)
+ userType: UserType;
+ isActive: boolean; // 是否启用
+ createdAt: Date;
+ updatedAt: Date;
+}
+
+// 用户账户信息
+export interface UserAccount {
+ id: string;
+ userId: string;
+ userType: UserType;
+ balance: number; // 余额(分)
+ frozenBalance: number; // 冻结余额(分)
+ enterpriseContractId?: string; // 企业合同ID
+ creditLimit?: number; // 信用额度(分)
+ totalRecharge: number; // 累计充值(分)
+ totalConsumption: number; // 累计消费(分)
+ createdAt: Date;
+ updatedAt: Date;
+}
+
+// 预约信息
+export interface Appointment {
+ id: string;
+ userId: string;
+ title: string;
+ description?: string;
+ scheduledTime: Date;
+ duration: number; // 预计时长(分钟)
+ callType: CallType;
+ translationType: TranslationType;
+ interpreterIds?: string[]; // 翻译员ID列表
+ estimatedCost: number; // 预估费用(分)
+ actualCost?: number; // 实际费用(分)
+ status: 'scheduled' | 'confirmed' | 'in_progress' | 'completed' | 'cancelled';
+ createdAt: Date;
+ updatedAt: Date;
+ // 管理员字段
+ adminNotes?: string;
+ cancelReason?: string;
+}
+
+// 翻译员信息
+export interface Interpreter {
+ id: string;
+ name: string;
+ avatar?: string;
+ languages: string[]; // 支持的语言
+ specialties: string[]; // 专业领域
+ rating: number; // 评分
+ pricePerMinute: number; // 每分钟价格(分)
+ availability: {
+ [key: string]: boolean; // 日期可用性
+ };
+ isOnline: boolean;
+ totalCalls: number; // 总通话次数
+ totalEarnings: number; // 总收入(分)
+ status: 'active' | 'inactive' | 'suspended';
+ createdAt: Date;
+ updatedAt: Date;
+}
+
+// 通话记录
+export interface CallRecord {
+ id: string;
+ userId: string;
+ appointmentId?: string;
+ callType: CallType;
+ translationType: TranslationType;
+ interpreterIds?: string[];
+ startTime: Date;
+ endTime?: Date;
+ duration: number; // 实际时长(分钟)
+ cost: number; // 实际费用(分)
+ status: 'in_progress' | 'completed' | 'failed';
+ billingDetails: {
+ baseRate: number;
+ interpreterRate?: number;
+ totalMinutes: number;
+ totalCost: number;
+ };
+ createdAt: Date;
+ // 管理员字段
+ adminNotes?: string;
+ qualityScore?: number;
+ userRating?: number;
+ userFeedback?: string;
+}
+
+// 充值记录
+export interface RechargeRecord {
+ id: string;
+ userId: string;
+ amount: number; // 充值金额(分)
+ bonus: number; // 赠送金额(分)
+ paymentMethod: string;
+ status: 'pending' | 'completed' | 'failed';
+ transactionId?: string;
+ createdAt: Date;
+ completedAt?: Date;
+ // 管理员字段
+ adminNotes?: string;
+ refundAmount?: number;
+ refundReason?: string;
+}
+
+// 消费记录
+export interface ConsumptionRecord {
+ id: string;
+ userId: string;
+ relatedType: 'call' | 'appointment' | 'document';
+ relatedId: string;
+ amount: number; // 消费金额(分)
+ balanceBefore: number; // 消费前余额(分)
+ balanceAfter: number; // 消费后余额(分)
+ description: string;
+ createdAt: Date;
+}
+
+// 计费统计
+export interface BillingStats {
+ totalRevenue: number; // 总收入(分)
+ totalUsers: number; // 总用户数
+ activeUsers: number; // 活跃用户数
+ totalCalls: number; // 总通话数
+ totalAppointments: number; // 总预约数
+ averageCallDuration: number; // 平均通话时长(分钟)
+ averageCallCost: number; // 平均通话费用(分)
+ topServices: Array<{
+ type: string;
+ count: number;
+ revenue: number;
+ }>;
+ revenueByDate: Array<{
+ date: string;
+ revenue: number;
+ }>;
+}
+
+// 计费配置
+export const BILLING_CONFIG = {
+ // 默认计费规则
+ DEFAULT_RATES: {
+ [CallType.VOICE]: {
+ [TranslationType.TEXT]: 50, // 0.5元/分钟
+ },
+ [CallType.VIDEO]: {
+ [TranslationType.SIGN_LANGUAGE]: 100, // 1元/分钟
+ [TranslationType.HUMAN_INTERPRETER]: 200, // 2元/分钟
+ },
+ } as Record>>,
+ // 低余额警告阈值(5分钟费用)
+ LOW_BALANCE_THRESHOLD_MINUTES: 5,
+ // 最低余额阈值(1分钟费用)
+ MINIMUM_BALANCE_THRESHOLD_MINUTES: 1,
+ // 充值赠送规则
+ RECHARGE_BONUS_RULES: [
+ { minAmount: 10000, bonusPercentage: 5 }, // 100元以上送5%
+ { minAmount: 20000, bonusPercentage: 10 }, // 200元以上送10%
+ { minAmount: 50000, bonusPercentage: 15 }, // 500元以上送15%
+ ],
+};
\ No newline at end of file
diff --git a/server/index.js b/server/index.js
new file mode 100644
index 0000000..e1fad2d
--- /dev/null
+++ b/server/index.js
@@ -0,0 +1,99 @@
+const express = require('express');
+const cors = require('cors');
+const jwt = require('jsonwebtoken');
+const { AccessToken } = require('twilio').jwt;
+const { VideoGrant } = AccessToken;
+
+const app = express();
+const PORT = 3001;
+
+// 中间件
+app.use(cors());
+app.use(express.json());
+
+// Twilio 配置 - 请替换为您的实际凭证
+const TWILIO_CONFIG = {
+ accountSid: process.env.TWILIO_ACCOUNT_SID || 'AC_YOUR_ACCOUNT_SID',
+ apiKey: process.env.TWILIO_API_KEY || 'SK3b25e00e6914162a7cf829cffc415cb3',
+ apiSecret: process.env.TWILIO_API_SECRET || 'PpGH298dlRgMSeGrexUjw1flczTVIw9H',
+};
+
+// 生成 Twilio Access Token
+app.post('/api/twilio/token', (req, res) => {
+ try {
+ const { identity, roomName } = req.body;
+
+ if (!identity || !roomName) {
+ return res.status(400).json({
+ error: 'Identity and roomName are required'
+ });
+ }
+
+ // 创建 Access Token
+ const token = new AccessToken(
+ TWILIO_CONFIG.accountSid,
+ TWILIO_CONFIG.apiKey,
+ TWILIO_CONFIG.apiSecret,
+ { identity: identity }
+ );
+
+ // 创建 Video Grant
+ const videoGrant = new VideoGrant({
+ room: roomName
+ });
+
+ // 将 grant 添加到 token
+ token.addGrant(videoGrant);
+
+ // 生成 JWT token
+ const jwtToken = token.toJwt();
+
+ console.log(`Generated token for identity: ${identity}, room: ${roomName}`);
+
+ res.json({
+ token: jwtToken,
+ identity: identity,
+ roomName: roomName
+ });
+
+ } catch (error) {
+ console.error('Token generation error:', error);
+ res.status(500).json({
+ error: 'Failed to generate token',
+ details: error.message
+ });
+ }
+});
+
+// 健康检查端点
+app.get('/health', (req, res) => {
+ res.json({
+ status: 'ok',
+ timestamp: new Date().toISOString(),
+ service: 'Twilio Token Server'
+ });
+});
+
+// 获取房间信息(模拟)
+app.get('/api/twilio/rooms', (req, res) => {
+ res.json({
+ rooms: [
+ { name: 'test-room', participants: 0 },
+ { name: 'demo-room', participants: 2 },
+ ]
+ });
+});
+
+// 启动服务器
+app.listen(PORT, () => {
+ console.log(`🚀 Twilio Token Server running on http://localhost:${PORT}`);
+ console.log(`📋 Health check: http://localhost:${PORT}/health`);
+ console.log(`🎥 Token endpoint: http://localhost:${PORT}/api/twilio/token`);
+ console.log('');
+ console.log('⚠️ 请确保已设置正确的 Twilio 凭证:');
+ console.log(` TWILIO_ACCOUNT_SID: ${TWILIO_CONFIG.accountSid}`);
+ console.log(` TWILIO_API_KEY: ${TWILIO_CONFIG.apiKey}`);
+ console.log(` TWILIO_API_SECRET: ${TWILIO_CONFIG.apiSecret.substring(0, 4)}...`);
+});
+
+module.exports = app;
\ No newline at end of file
diff --git a/server/package-lock.json b/server/package-lock.json
new file mode 100644
index 0000000..67d889b
--- /dev/null
+++ b/server/package-lock.json
@@ -0,0 +1,1446 @@
+{
+ "name": "twilio-token-server",
+ "version": "1.0.0",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "twilio-token-server",
+ "version": "1.0.0",
+ "license": "MIT",
+ "dependencies": {
+ "cors": "^2.8.5",
+ "express": "^4.18.2",
+ "jsonwebtoken": "^9.0.2",
+ "twilio": "^4.19.0"
+ },
+ "devDependencies": {
+ "nodemon": "^3.0.2"
+ }
+ },
+ "node_modules/accepts": {
+ "version": "1.3.8",
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
+ "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
+ "dependencies": {
+ "mime-types": "~2.1.34",
+ "negotiator": "0.6.3"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/agent-base": {
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
+ "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
+ "dependencies": {
+ "debug": "4"
+ },
+ "engines": {
+ "node": ">= 6.0.0"
+ }
+ },
+ "node_modules/agent-base/node_modules/debug": {
+ "version": "4.4.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
+ "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
+ "dependencies": {
+ "ms": "^2.1.3"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/agent-base/node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
+ },
+ "node_modules/anymatch": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
+ "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
+ "dev": true,
+ "dependencies": {
+ "normalize-path": "^3.0.0",
+ "picomatch": "^2.0.4"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/array-flatten": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
+ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
+ },
+ "node_modules/asynckit": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
+ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
+ },
+ "node_modules/axios": {
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/axios/-/axios-1.10.0.tgz",
+ "integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==",
+ "dependencies": {
+ "follow-redirects": "^1.15.6",
+ "form-data": "^4.0.0",
+ "proxy-from-env": "^1.1.0"
+ }
+ },
+ "node_modules/balanced-match": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
+ "dev": true
+ },
+ "node_modules/binary-extensions": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
+ "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
+ "dev": true,
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/body-parser": {
+ "version": "1.20.3",
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
+ "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
+ "dependencies": {
+ "bytes": "3.1.2",
+ "content-type": "~1.0.5",
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "destroy": "1.2.0",
+ "http-errors": "2.0.0",
+ "iconv-lite": "0.4.24",
+ "on-finished": "2.4.1",
+ "qs": "6.13.0",
+ "raw-body": "2.5.2",
+ "type-is": "~1.6.18",
+ "unpipe": "1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8",
+ "npm": "1.2.8000 || >= 1.4.16"
+ }
+ },
+ "node_modules/brace-expansion": {
+ "version": "1.1.12",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
+ "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
+ "dev": true,
+ "dependencies": {
+ "balanced-match": "^1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "node_modules/braces": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
+ "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
+ "dev": true,
+ "dependencies": {
+ "fill-range": "^7.1.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/buffer-equal-constant-time": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
+ "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
+ },
+ "node_modules/bytes": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
+ "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/call-bind-apply-helpers": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
+ "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/call-bound": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
+ "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.2",
+ "get-intrinsic": "^1.3.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/chokidar": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
+ "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
+ "dev": true,
+ "dependencies": {
+ "anymatch": "~3.1.2",
+ "braces": "~3.0.2",
+ "glob-parent": "~5.1.2",
+ "is-binary-path": "~2.1.0",
+ "is-glob": "~4.0.1",
+ "normalize-path": "~3.0.0",
+ "readdirp": "~3.6.0"
+ },
+ "engines": {
+ "node": ">= 8.10.0"
+ },
+ "funding": {
+ "url": "https://paulmillr.com/funding/"
+ },
+ "optionalDependencies": {
+ "fsevents": "~2.3.2"
+ }
+ },
+ "node_modules/combined-stream": {
+ "version": "1.0.8",
+ "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
+ "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
+ "dependencies": {
+ "delayed-stream": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/concat-map": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
+ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
+ "dev": true
+ },
+ "node_modules/content-disposition": {
+ "version": "0.5.4",
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
+ "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
+ "dependencies": {
+ "safe-buffer": "5.2.1"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/content-type": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
+ "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie": {
+ "version": "0.7.1",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
+ "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie-signature": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
+ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
+ },
+ "node_modules/cors": {
+ "version": "2.8.5",
+ "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
+ "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
+ "dependencies": {
+ "object-assign": "^4",
+ "vary": "^1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/dayjs": {
+ "version": "1.11.13",
+ "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.13.tgz",
+ "integrity": "sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg=="
+ },
+ "node_modules/debug": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "dependencies": {
+ "ms": "2.0.0"
+ }
+ },
+ "node_modules/delayed-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
+ "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
+ "node_modules/depd": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
+ "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/destroy": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
+ "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
+ "engines": {
+ "node": ">= 0.8",
+ "npm": "1.2.8000 || >= 1.4.16"
+ }
+ },
+ "node_modules/dunder-proto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.1",
+ "es-errors": "^1.3.0",
+ "gopd": "^1.2.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/ecdsa-sig-formatter": {
+ "version": "1.0.11",
+ "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
+ "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
+ "dependencies": {
+ "safe-buffer": "^5.0.1"
+ }
+ },
+ "node_modules/ee-first": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
+ },
+ "node_modules/encodeurl": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
+ "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/es-define-property": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/es-errors": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/es-object-atoms": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
+ "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
+ "dependencies": {
+ "es-errors": "^1.3.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/es-set-tostringtag": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
+ "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.6",
+ "has-tostringtag": "^1.0.2",
+ "hasown": "^2.0.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/escape-html": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
+ },
+ "node_modules/etag": {
+ "version": "1.8.1",
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/express": {
+ "version": "4.21.2",
+ "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
+ "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
+ "dependencies": {
+ "accepts": "~1.3.8",
+ "array-flatten": "1.1.1",
+ "body-parser": "1.20.3",
+ "content-disposition": "0.5.4",
+ "content-type": "~1.0.4",
+ "cookie": "0.7.1",
+ "cookie-signature": "1.0.6",
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "finalhandler": "1.3.1",
+ "fresh": "0.5.2",
+ "http-errors": "2.0.0",
+ "merge-descriptors": "1.0.3",
+ "methods": "~1.1.2",
+ "on-finished": "2.4.1",
+ "parseurl": "~1.3.3",
+ "path-to-regexp": "0.1.12",
+ "proxy-addr": "~2.0.7",
+ "qs": "6.13.0",
+ "range-parser": "~1.2.1",
+ "safe-buffer": "5.2.1",
+ "send": "0.19.0",
+ "serve-static": "1.16.2",
+ "setprototypeof": "1.2.0",
+ "statuses": "2.0.1",
+ "type-is": "~1.6.18",
+ "utils-merge": "1.0.1",
+ "vary": "~1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.10.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/express"
+ }
+ },
+ "node_modules/fill-range": {
+ "version": "7.1.1",
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
+ "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
+ "dev": true,
+ "dependencies": {
+ "to-regex-range": "^5.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/finalhandler": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
+ "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
+ "dependencies": {
+ "debug": "2.6.9",
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "on-finished": "2.4.1",
+ "parseurl": "~1.3.3",
+ "statuses": "2.0.1",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/follow-redirects": {
+ "version": "1.15.9",
+ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
+ "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://github.com/sponsors/RubenVerborgh"
+ }
+ ],
+ "engines": {
+ "node": ">=4.0"
+ },
+ "peerDependenciesMeta": {
+ "debug": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/form-data": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.3.tgz",
+ "integrity": "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==",
+ "dependencies": {
+ "asynckit": "^0.4.0",
+ "combined-stream": "^1.0.8",
+ "es-set-tostringtag": "^2.1.0",
+ "hasown": "^2.0.2",
+ "mime-types": "^2.1.12"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/forwarded": {
+ "version": "0.2.0",
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
+ "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/fresh": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
+ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/fsevents": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
+ "dev": true,
+ "hasInstallScript": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
+ }
+ },
+ "node_modules/function-bind": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/get-intrinsic": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.2",
+ "es-define-property": "^1.0.1",
+ "es-errors": "^1.3.0",
+ "es-object-atoms": "^1.1.1",
+ "function-bind": "^1.1.2",
+ "get-proto": "^1.0.1",
+ "gopd": "^1.2.0",
+ "has-symbols": "^1.1.0",
+ "hasown": "^2.0.2",
+ "math-intrinsics": "^1.1.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/get-proto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
+ "dependencies": {
+ "dunder-proto": "^1.0.1",
+ "es-object-atoms": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/glob-parent": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
+ "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
+ "dev": true,
+ "dependencies": {
+ "is-glob": "^4.0.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/gopd": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/has-flag": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
+ "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
+ "dev": true,
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/has-symbols": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/has-tostringtag": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
+ "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
+ "dependencies": {
+ "has-symbols": "^1.0.3"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/hasown": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
+ "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
+ "dependencies": {
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/http-errors": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
+ "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
+ "dependencies": {
+ "depd": "2.0.0",
+ "inherits": "2.0.4",
+ "setprototypeof": "1.2.0",
+ "statuses": "2.0.1",
+ "toidentifier": "1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/https-proxy-agent": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
+ "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
+ "dependencies": {
+ "agent-base": "6",
+ "debug": "4"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/https-proxy-agent/node_modules/debug": {
+ "version": "4.4.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
+ "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
+ "dependencies": {
+ "ms": "^2.1.3"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/https-proxy-agent/node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
+ },
+ "node_modules/iconv-lite": {
+ "version": "0.4.24",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
+ "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
+ "dependencies": {
+ "safer-buffer": ">= 2.1.2 < 3"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/ignore-by-default": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
+ "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
+ "dev": true
+ },
+ "node_modules/inherits": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
+ },
+ "node_modules/ipaddr.js": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
+ "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/is-binary-path": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
+ "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
+ "dev": true,
+ "dependencies": {
+ "binary-extensions": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/is-extglob": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
+ "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/is-glob": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
+ "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
+ "dev": true,
+ "dependencies": {
+ "is-extglob": "^2.1.1"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/is-number": {
+ "version": "7.0.0",
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.12.0"
+ }
+ },
+ "node_modules/jsonwebtoken": {
+ "version": "9.0.2",
+ "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz",
+ "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==",
+ "dependencies": {
+ "jws": "^3.2.2",
+ "lodash.includes": "^4.3.0",
+ "lodash.isboolean": "^3.0.3",
+ "lodash.isinteger": "^4.0.4",
+ "lodash.isnumber": "^3.0.3",
+ "lodash.isplainobject": "^4.0.6",
+ "lodash.isstring": "^4.0.1",
+ "lodash.once": "^4.0.0",
+ "ms": "^2.1.1",
+ "semver": "^7.5.4"
+ },
+ "engines": {
+ "node": ">=12",
+ "npm": ">=6"
+ }
+ },
+ "node_modules/jsonwebtoken/node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
+ },
+ "node_modules/jwa": {
+ "version": "1.4.2",
+ "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.2.tgz",
+ "integrity": "sha512-eeH5JO+21J78qMvTIDdBXidBd6nG2kZjg5Ohz/1fpa28Z4CcsWUzJ1ZZyFq/3z3N17aZy+ZuBoHljASbL1WfOw==",
+ "dependencies": {
+ "buffer-equal-constant-time": "^1.0.1",
+ "ecdsa-sig-formatter": "1.0.11",
+ "safe-buffer": "^5.0.1"
+ }
+ },
+ "node_modules/jws": {
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
+ "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
+ "dependencies": {
+ "jwa": "^1.4.1",
+ "safe-buffer": "^5.0.1"
+ }
+ },
+ "node_modules/lodash.includes": {
+ "version": "4.3.0",
+ "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
+ "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="
+ },
+ "node_modules/lodash.isboolean": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
+ "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="
+ },
+ "node_modules/lodash.isinteger": {
+ "version": "4.0.4",
+ "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
+ "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="
+ },
+ "node_modules/lodash.isnumber": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
+ "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="
+ },
+ "node_modules/lodash.isplainobject": {
+ "version": "4.0.6",
+ "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
+ "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="
+ },
+ "node_modules/lodash.isstring": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
+ "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="
+ },
+ "node_modules/lodash.once": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
+ "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
+ },
+ "node_modules/math-intrinsics": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/media-typer": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+ "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/merge-descriptors": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
+ "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/methods": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
+ "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
+ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
+ "bin": {
+ "mime": "cli.js"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/mime-db": {
+ "version": "1.52.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime-types": {
+ "version": "2.1.35",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+ "dependencies": {
+ "mime-db": "1.52.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/minimatch": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
+ "dev": true,
+ "dependencies": {
+ "brace-expansion": "^1.1.7"
+ },
+ "engines": {
+ "node": "*"
+ }
+ },
+ "node_modules/ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
+ },
+ "node_modules/negotiator": {
+ "version": "0.6.3",
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
+ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/nodemon": {
+ "version": "3.1.10",
+ "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.10.tgz",
+ "integrity": "sha512-WDjw3pJ0/0jMFmyNDp3gvY2YizjLmmOUQo6DEBY+JgdvW/yQ9mEeSw6H5ythl5Ny2ytb7f9C2nIbjSxMNzbJXw==",
+ "dev": true,
+ "dependencies": {
+ "chokidar": "^3.5.2",
+ "debug": "^4",
+ "ignore-by-default": "^1.0.1",
+ "minimatch": "^3.1.2",
+ "pstree.remy": "^1.1.8",
+ "semver": "^7.5.3",
+ "simple-update-notifier": "^2.0.0",
+ "supports-color": "^5.5.0",
+ "touch": "^3.1.0",
+ "undefsafe": "^2.0.5"
+ },
+ "bin": {
+ "nodemon": "bin/nodemon.js"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/nodemon"
+ }
+ },
+ "node_modules/nodemon/node_modules/debug": {
+ "version": "4.4.1",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz",
+ "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==",
+ "dev": true,
+ "dependencies": {
+ "ms": "^2.1.3"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/nodemon/node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
+ "dev": true
+ },
+ "node_modules/normalize-path": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/object-inspect": {
+ "version": "1.13.4",
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
+ "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/on-finished": {
+ "version": "2.4.1",
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
+ "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
+ "dependencies": {
+ "ee-first": "1.1.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/parseurl": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
+ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/path-to-regexp": {
+ "version": "0.1.12",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
+ "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ=="
+ },
+ "node_modules/picomatch": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
+ "dev": true,
+ "engines": {
+ "node": ">=8.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
+ "node_modules/proxy-addr": {
+ "version": "2.0.7",
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
+ "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
+ "dependencies": {
+ "forwarded": "0.2.0",
+ "ipaddr.js": "1.9.1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/proxy-from-env": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
+ "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
+ },
+ "node_modules/pstree.remy": {
+ "version": "1.1.8",
+ "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
+ "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
+ "dev": true
+ },
+ "node_modules/qs": {
+ "version": "6.13.0",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
+ "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
+ "dependencies": {
+ "side-channel": "^1.0.6"
+ },
+ "engines": {
+ "node": ">=0.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/querystringify": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
+ "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
+ },
+ "node_modules/range-parser": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
+ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/raw-body": {
+ "version": "2.5.2",
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
+ "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
+ "dependencies": {
+ "bytes": "3.1.2",
+ "http-errors": "2.0.0",
+ "iconv-lite": "0.4.24",
+ "unpipe": "1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/readdirp": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
+ "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
+ "dev": true,
+ "dependencies": {
+ "picomatch": "^2.2.1"
+ },
+ "engines": {
+ "node": ">=8.10.0"
+ }
+ },
+ "node_modules/requires-port": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
+ "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
+ },
+ "node_modules/safe-buffer": {
+ "version": "5.2.1",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ]
+ },
+ "node_modules/safer-buffer": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
+ },
+ "node_modules/scmp": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/scmp/-/scmp-2.1.0.tgz",
+ "integrity": "sha512-o/mRQGk9Rcer/jEEw/yw4mwo3EU/NvYvp577/Btqrym9Qy5/MdWGBqipbALgd2lrdWTJ5/gqDusxfnQBxOxT2Q=="
+ },
+ "node_modules/semver": {
+ "version": "7.7.2",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
+ "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
+ "bin": {
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/send": {
+ "version": "0.19.0",
+ "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
+ "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
+ "dependencies": {
+ "debug": "2.6.9",
+ "depd": "2.0.0",
+ "destroy": "1.2.0",
+ "encodeurl": "~1.0.2",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "fresh": "0.5.2",
+ "http-errors": "2.0.0",
+ "mime": "1.6.0",
+ "ms": "2.1.3",
+ "on-finished": "2.4.1",
+ "range-parser": "~1.2.1",
+ "statuses": "2.0.1"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/send/node_modules/encodeurl": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
+ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/send/node_modules/ms": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
+ },
+ "node_modules/serve-static": {
+ "version": "1.16.2",
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
+ "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
+ "dependencies": {
+ "encodeurl": "~2.0.0",
+ "escape-html": "~1.0.3",
+ "parseurl": "~1.3.3",
+ "send": "0.19.0"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/setprototypeof": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
+ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
+ },
+ "node_modules/side-channel": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
+ "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "object-inspect": "^1.13.3",
+ "side-channel-list": "^1.0.0",
+ "side-channel-map": "^1.0.1",
+ "side-channel-weakmap": "^1.0.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/side-channel-list": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
+ "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "object-inspect": "^1.13.3"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/side-channel-map": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
+ "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
+ "dependencies": {
+ "call-bound": "^1.0.2",
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.5",
+ "object-inspect": "^1.13.3"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/side-channel-weakmap": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
+ "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
+ "dependencies": {
+ "call-bound": "^1.0.2",
+ "es-errors": "^1.3.0",
+ "get-intrinsic": "^1.2.5",
+ "object-inspect": "^1.13.3",
+ "side-channel-map": "^1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/simple-update-notifier": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz",
+ "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==",
+ "dev": true,
+ "dependencies": {
+ "semver": "^7.5.3"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/statuses": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
+ "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/supports-color": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
+ "dev": true,
+ "dependencies": {
+ "has-flag": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/to-regex-range": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
+ "dev": true,
+ "dependencies": {
+ "is-number": "^7.0.0"
+ },
+ "engines": {
+ "node": ">=8.0"
+ }
+ },
+ "node_modules/toidentifier": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
+ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
+ "engines": {
+ "node": ">=0.6"
+ }
+ },
+ "node_modules/touch": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz",
+ "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==",
+ "dev": true,
+ "bin": {
+ "nodetouch": "bin/nodetouch.js"
+ }
+ },
+ "node_modules/twilio": {
+ "version": "4.23.0",
+ "resolved": "https://registry.npmjs.org/twilio/-/twilio-4.23.0.tgz",
+ "integrity": "sha512-LdNBQfOe0dY2oJH2sAsrxazpgfFQo5yXGxe96QA8UWB5uu+433PrUbkv8gQ5RmrRCqUTPQ0aOrIyAdBr1aB03Q==",
+ "dependencies": {
+ "axios": "^1.6.0",
+ "dayjs": "^1.11.9",
+ "https-proxy-agent": "^5.0.0",
+ "jsonwebtoken": "^9.0.0",
+ "qs": "^6.9.4",
+ "scmp": "^2.1.0",
+ "url-parse": "^1.5.9",
+ "xmlbuilder": "^13.0.2"
+ },
+ "engines": {
+ "node": ">=14.0"
+ }
+ },
+ "node_modules/type-is": {
+ "version": "1.6.18",
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
+ "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
+ "dependencies": {
+ "media-typer": "0.3.0",
+ "mime-types": "~2.1.24"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/undefsafe": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
+ "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
+ "dev": true
+ },
+ "node_modules/unpipe": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/url-parse": {
+ "version": "1.5.10",
+ "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
+ "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
+ "dependencies": {
+ "querystringify": "^2.1.1",
+ "requires-port": "^1.0.0"
+ }
+ },
+ "node_modules/utils-merge": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
+ "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
+ "engines": {
+ "node": ">= 0.4.0"
+ }
+ },
+ "node_modules/vary": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/xmlbuilder": {
+ "version": "13.0.2",
+ "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-13.0.2.tgz",
+ "integrity": "sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ==",
+ "engines": {
+ "node": ">=6.0"
+ }
+ }
+ }
+}
diff --git a/server/package.json b/server/package.json
new file mode 100644
index 0000000..917c03b
--- /dev/null
+++ b/server/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "twilio-token-server",
+ "version": "1.0.0",
+ "description": "Twilio Video Token Server for TranslatePro",
+ "main": "index.js",
+ "scripts": {
+ "start": "node index.js",
+ "dev": "nodemon index.js",
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "dependencies": {
+ "express": "^4.18.2",
+ "cors": "^2.8.5",
+ "jsonwebtoken": "^9.0.2",
+ "twilio": "^4.19.0"
+ },
+ "devDependencies": {
+ "nodemon": "^3.0.2"
+ },
+ "keywords": [
+ "twilio",
+ "video",
+ "token",
+ "server"
+ ],
+ "author": "TranslatePro Team",
+ "license": "MIT"
+}
\ No newline at end of file
diff --git a/src/App.tsx b/src/App.tsx
index 0eb1b20..58aa3f8 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,8 +1,10 @@
+import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import { ConfigProvider, App as AntdApp } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import { AppProvider } from '@/store';
import AppRoutes from '@/routes';
+import DeviceTestPanel from '@/components/DeviceTestPanel';
import '@/styles/global.css';
// Ant Design 主题配置
@@ -25,7 +27,7 @@ const theme = {
},
};
-const App = () => {
+const App: React.FC = () => {
return (
{
+
diff --git a/src/components/DeviceRedirect.tsx b/src/components/DeviceRedirect.tsx
new file mode 100644
index 0000000..cc4e97d
--- /dev/null
+++ b/src/components/DeviceRedirect.tsx
@@ -0,0 +1,48 @@
+import { FC, useEffect } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { getRecommendedRoute } from '@/utils/deviceDetection';
+
+const DeviceRedirect: FC = () => {
+ const navigate = useNavigate();
+
+ useEffect(() => {
+ const recommendedRoute = getRecommendedRoute();
+ navigate(recommendedRoute, { replace: true });
+ }, [navigate]);
+
+ // 显示加载状态
+ return (
+
+
+ 🔄
+
+
+ 正在为您准备最佳体验...
+
+
+
+
+ );
+};
+
+export default DeviceRedirect;
\ No newline at end of file
diff --git a/src/components/DeviceTestPanel.tsx b/src/components/DeviceTestPanel.tsx
new file mode 100644
index 0000000..fc0af96
--- /dev/null
+++ b/src/components/DeviceTestPanel.tsx
@@ -0,0 +1,145 @@
+import { FC, useState } from 'react';
+import { useNavigate } from 'react-router-dom';
+
+const DeviceTestPanel: FC = () => {
+ const navigate = useNavigate();
+ const [isVisible, setIsVisible] = useState(false);
+
+ const testRoutes = [
+ { path: '/mobile/home', label: '移动端首页', icon: '📱' },
+ { path: '/mobile/call', label: '移动端通话', icon: '📞' },
+ { path: '/mobile/documents', label: '移动端文档', icon: '📄' },
+ { path: '/mobile/settings', label: '移动端设置', icon: '⚙️' },
+ { path: '/dashboard', label: '管理后台', icon: '💻' },
+ ];
+
+ const styles = {
+ toggle: {
+ position: 'fixed' as const,
+ top: '20px',
+ right: '20px',
+ zIndex: 9999,
+ padding: '8px 12px',
+ backgroundColor: '#1890ff',
+ color: 'white',
+ border: 'none',
+ borderRadius: '6px',
+ cursor: 'pointer',
+ fontSize: '12px',
+ fontWeight: '600' as const,
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)',
+ },
+ panel: {
+ position: 'fixed' as const,
+ top: '60px',
+ right: '20px',
+ zIndex: 9998,
+ backgroundColor: 'white',
+ borderRadius: '8px',
+ padding: '16px',
+ boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
+ minWidth: '200px',
+ border: '1px solid #e8e8e8',
+ },
+ title: {
+ fontSize: '14px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '12px',
+ textAlign: 'center' as const,
+ },
+ routeButton: {
+ display: 'flex',
+ alignItems: 'center',
+ width: '100%',
+ padding: '8px 12px',
+ marginBottom: '4px',
+ backgroundColor: 'transparent',
+ border: '1px solid #e8e8e8',
+ borderRadius: '4px',
+ cursor: 'pointer',
+ fontSize: '12px',
+ transition: 'all 0.2s ease',
+ },
+ routeIcon: {
+ marginRight: '8px',
+ fontSize: '14px',
+ },
+ deviceInfo: {
+ marginTop: '12px',
+ padding: '8px',
+ backgroundColor: '#f5f5f5',
+ borderRadius: '4px',
+ fontSize: '11px',
+ color: '#666',
+ },
+ };
+
+ const getCurrentDeviceInfo = () => {
+ const width = window.innerWidth;
+ const height = window.innerHeight;
+ const userAgent = navigator.userAgent;
+ const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent);
+
+ return {
+ width,
+ height,
+ userAgent: userAgent.substring(0, 50) + '...',
+ isMobile,
+ };
+ };
+
+ const deviceInfo = getCurrentDeviceInfo();
+
+ if (process.env.NODE_ENV === 'production') {
+ return null; // 生产环境不显示测试面板
+ }
+
+ return (
+ <>
+
+
+ {isVisible && (
+
+
🧪 设备测试面板
+
+ {testRoutes.map((route) => (
+
+ ))}
+
+
+
设备信息:
+
尺寸: {deviceInfo.width} x {deviceInfo.height}
+
移动设备: {deviceInfo.isMobile ? '是' : '否'}
+
UA: {deviceInfo.userAgent}
+
+
+ )}
+ >
+ );
+};
+
+export default DeviceTestPanel;
\ No newline at end of file
diff --git a/src/components/MobileLayout.tsx b/src/components/MobileLayout.tsx
new file mode 100644
index 0000000..7452d5d
--- /dev/null
+++ b/src/components/MobileLayout.tsx
@@ -0,0 +1,99 @@
+import { FC, ReactNode, useEffect, useState } from 'react';
+import { Outlet } from 'react-router-dom';
+import MobileNavigation from './MobileNavigation';
+
+interface MobileLayoutProps {
+ children?: ReactNode;
+}
+
+const MobileLayout: FC = ({ children }) => {
+ const [isMobile, setIsMobile] = useState(false);
+
+ useEffect(() => {
+ const checkMobile = () => {
+ const userAgent = navigator.userAgent;
+ const mobileKeywords = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
+ const isMobileDevice = mobileKeywords.test(userAgent);
+ const isSmallScreen = window.innerWidth <= 768;
+ setIsMobile(isMobileDevice || isSmallScreen);
+ };
+
+ checkMobile();
+ window.addEventListener('resize', checkMobile);
+
+ return () => window.removeEventListener('resize', checkMobile);
+ }, []);
+
+ const styles = {
+ container: {
+ display: 'flex',
+ flexDirection: 'column' as const,
+ height: '100vh',
+ backgroundColor: '#f5f5f5',
+ overflow: 'hidden',
+ },
+ content: {
+ flex: 1,
+ overflow: 'auto',
+ paddingBottom: isMobile ? '80px' : '0',
+ position: 'relative' as const,
+ },
+ mobileHeader: {
+ backgroundColor: '#1890ff',
+ color: 'white',
+ padding: '12px 16px',
+ textAlign: 'center' as const,
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ boxShadow: '0 2px 4px rgba(0, 0, 0, 0.1)',
+ },
+ };
+
+ if (!isMobile) {
+ // 如果不是移动设备,显示提示信息
+ return (
+
+
+
📱 移动端应用
+
+ 此应用专为移动设备设计。请在手机或平板电脑上访问,或调整浏览器窗口大小至移动设备尺寸。
+
+
+ 您也可以使用浏览器的开发者工具切换到移动设备视图。
+
+
+
+ );
+ }
+
+ return (
+
+
+ Twilio 翻译应用
+
+
+
+ {children || }
+
+
+
+
+ );
+};
+
+export default MobileLayout;
\ No newline at end of file
diff --git a/src/components/MobileNavigation.tsx b/src/components/MobileNavigation.tsx
index f9f9d6a..65481d9 100644
--- a/src/components/MobileNavigation.tsx
+++ b/src/components/MobileNavigation.tsx
@@ -8,10 +8,10 @@ interface NavItem {
}
const navItems: NavItem[] = [
- { path: '/mobile/home', label: '首页', icon: '🏠' },
- { path: '/mobile/call', label: '通话', icon: '📞' },
- { path: '/mobile/documents', label: '文档', icon: '📄' },
- { path: '/mobile/settings', label: '我的', icon: '👤' },
+ { path: '/home', label: '首页', icon: '🏠' },
+ { path: '/call', label: '通话', icon: '📞' },
+ { path: '/documents', label: '文档', icon: '📄' },
+ { path: '/settings', label: '我的', icon: '👤' },
];
const MobileNavigation: FC = () => {
@@ -22,6 +22,60 @@ const MobileNavigation: FC = () => {
navigate(path);
};
+ const styles = {
+ container: {
+ display: 'flex',
+ flexDirection: 'row' as const,
+ backgroundColor: '#fff',
+ borderTop: '1px solid #e0e0e0',
+ padding: '8px 4px',
+ justifyContent: 'space-around',
+ alignItems: 'center',
+ position: 'absolute' as const,
+ bottom: 0,
+ left: 0,
+ right: 0,
+ height: '80px',
+ boxShadow: '0 -2px 4px rgba(0, 0, 0, 0.1)',
+ zIndex: 1000,
+ },
+ navItem: {
+ flex: 1,
+ display: 'flex',
+ flexDirection: 'column' as const,
+ alignItems: 'center',
+ justifyContent: 'center',
+ padding: '8px 4px',
+ borderRadius: '8px',
+ border: 'none',
+ backgroundColor: 'transparent',
+ cursor: 'pointer',
+ transition: 'all 0.2s ease',
+ },
+ activeNavItem: {
+ backgroundColor: '#f0f8ff',
+ },
+ icon: {
+ fontSize: '20px',
+ marginBottom: '4px',
+ opacity: 0.6,
+ transition: 'opacity 0.2s ease',
+ },
+ activeIcon: {
+ opacity: 1,
+ },
+ label: {
+ fontSize: '12px',
+ color: '#666',
+ textAlign: 'center' as const,
+ transition: 'color 0.2s ease',
+ },
+ activeLabel: {
+ color: '#1890ff',
+ fontWeight: '600' as const,
+ },
+ };
+
return (
{navItems.map((item) => {
@@ -54,58 +108,4 @@ const MobileNavigation: FC = () => {
);
};
-const styles = {
- container: {
- display: 'flex',
- flexDirection: 'row' as const,
- backgroundColor: '#fff',
- borderTop: '1px solid #e0e0e0',
- padding: '8px 4px',
- justifyContent: 'space-around',
- alignItems: 'center',
- position: 'absolute' as const,
- bottom: 0,
- left: 0,
- right: 0,
- height: '80px',
- boxShadow: '0 -2px 4px rgba(0, 0, 0, 0.1)',
- zIndex: 1000,
- },
- navItem: {
- flex: 1,
- display: 'flex',
- flexDirection: 'column' as const,
- alignItems: 'center',
- justifyContent: 'center',
- padding: '8px 4px',
- borderRadius: '8px',
- border: 'none',
- backgroundColor: 'transparent',
- cursor: 'pointer',
- transition: 'all 0.2s ease',
- },
- activeNavItem: {
- backgroundColor: '#f0f8ff',
- },
- icon: {
- fontSize: '20px',
- marginBottom: '4px',
- opacity: 0.6,
- transition: 'opacity 0.2s ease',
- },
- activeIcon: {
- opacity: 1,
- },
- label: {
- fontSize: '12px',
- color: '#666',
- textAlign: 'center' as const,
- transition: 'color 0.2s ease',
- },
- activeLabel: {
- color: '#1890ff',
- fontWeight: '600' as const,
- },
-};
-
export default MobileNavigation;
\ No newline at end of file
diff --git a/src/components/MobileNavigation.web.tsx b/src/components/MobileNavigation.web.tsx
index ca755ff..b7edd62 100644
--- a/src/components/MobileNavigation.web.tsx
+++ b/src/components/MobileNavigation.web.tsx
@@ -8,10 +8,10 @@ interface NavItem {
}
const navItems: NavItem[] = [
- { path: '/mobile/home', label: '首页', icon: '🏠' },
- { path: '/mobile/call', label: '通话', icon: '📞' },
- { path: '/mobile/documents', label: '文档', icon: '📄' },
- { path: '/mobile/settings', label: '我的', icon: '👤' },
+ { path: '/home', label: '首页', icon: '🏠' },
+ { path: '/call', label: '通话', icon: '📞' },
+ { path: '/documents', label: '文档', icon: '📄' },
+ { path: '/settings', label: '我的', icon: '👤' },
];
const MobileNavigation: FC = () => {
diff --git a/src/components/VideoCall/VideoCall.tsx b/src/components/VideoCall/VideoCall.tsx
index 850d058..ec4b1c9 100644
--- a/src/components/VideoCall/VideoCall.tsx
+++ b/src/components/VideoCall/VideoCall.tsx
@@ -1,22 +1,29 @@
import React, { useState, useEffect, useRef } from 'react';
-import { Button, Card, Row, Col, Space, Typography, message } from 'antd';
+import { Button, Card, Row, Col, Space, Typography, message, Badge, Statistic } from 'antd';
import {
PhoneOutlined,
VideoCameraOutlined,
AudioOutlined,
AudioMutedOutlined,
VideoCameraAddOutlined,
- StopOutlined
+ StopOutlined,
+ WalletOutlined,
+ ClockCircleOutlined
} from '@ant-design/icons';
import { Room, RemoteParticipant, LocalParticipant } from 'twilio-video';
import { twilioService, VideoCallOptions, ParticipantInfo } from '../../services/twilioService';
+import { BillingService } from '../../services/billingService';
+import { CallType, TranslationType, UserAccount, UserType } from '../../types/billing';
const { Title, Text } = Typography;
interface VideoCallProps {
roomName: string;
identity: string;
+ callType?: CallType;
+ translationType?: TranslationType;
onLeave?: () => void;
+ onBillingUpdate?: (cost: number, duration: number) => void;
}
interface ParticipantVideoProps {
@@ -92,17 +99,167 @@ const ParticipantVideo: React.FC
= ({ participant, isLoca
);
};
-export const VideoCall: React.FC = ({ roomName, identity, onLeave }) => {
+export const VideoCall: React.FC = ({
+ roomName,
+ identity,
+ callType = CallType.VIDEO,
+ translationType = TranslationType.SIGN_LANGUAGE,
+ onLeave,
+ onBillingUpdate
+}) => {
const [room, setRoom] = useState(null);
const [participants, setParticipants] = useState([]);
const [isConnecting, setIsConnecting] = useState(false);
const [isConnected, setIsConnected] = useState(false);
const [audioEnabled, setAudioEnabled] = useState(true);
const [videoEnabled, setVideoEnabled] = useState(true);
+
+ // 计费相关状态
+ const [userAccount, setUserAccount] = useState(null);
+ const [callDuration, setCallDuration] = useState(0);
+ const [currentCost, setCurrentCost] = useState(0);
+ const [billingService] = useState(() => BillingService.getInstance());
+ const [lastBillingMinute, setLastBillingMinute] = useState(0);
+
+ const callStartTime = useRef(null);
+ const durationInterval = useRef(null);
+ const billingInterval = useRef(null);
+
+ // 初始化用户账户信息
+ useEffect(() => {
+ const initUserAccount = async () => {
+ try {
+ // 模拟用户账户数据
+ const mockAccount: UserAccount = {
+ id: 'user-123',
+ userType: UserType.INDIVIDUAL,
+ balance: 10000, // 100元
+ };
+ billingService.setUserAccount(mockAccount);
+ setUserAccount(mockAccount);
+ } catch (error) {
+ console.error('获取用户账户失败:', error);
+ message.error('获取用户账户信息失败');
+ }
+ };
+
+ initUserAccount();
+ }, [billingService]);
+
+ // 检查余额是否足够
+ const checkBalance = () => {
+ if (!userAccount) return false;
+
+ const balanceCheck = billingService.checkBalance(callType, translationType, 1);
+ if (!balanceCheck.sufficient) {
+ message.error(`余额不足,需要至少 ¥${(balanceCheck.requiredAmount / 100).toFixed(2)} 才能开始通话`);
+ return false;
+ }
+
+ const shouldWarn = billingService.shouldShowLowBalanceWarning(callType, translationType);
+ if (shouldWarn) {
+ message.warning('账户余额较低,请及时充值');
+ }
+
+ return true;
+ };
+
+ // 开始计费
+ const startBilling = () => {
+ callStartTime.current = new Date();
+
+ // 每秒更新通话时长
+ durationInterval.current = setInterval(() => {
+ if (callStartTime.current) {
+ const duration = Math.floor((Date.now() - callStartTime.current.getTime()) / 1000);
+ setCallDuration(duration);
+ }
+ }, 1000);
+
+ // 每分钟进行计费
+ billingInterval.current = setInterval(() => {
+ if (callStartTime.current) {
+ const currentMinute = Math.floor((Date.now() - callStartTime.current.getTime()) / 60000);
+ if (currentMinute > lastBillingMinute) {
+ performBilling(currentMinute);
+ setLastBillingMinute(currentMinute);
+ }
+ }
+ }, 60000); // 每分钟检查一次
+ };
+
+ // 执行计费
+ const performBilling = async (minute: number) => {
+ if (!userAccount) return;
+
+ try {
+ const cost = billingService.calculateCallCost(callType, translationType, 1);
+ const newTotalCost = currentCost + cost;
+
+ // 检查余额是否足够继续通话
+ const balanceCheck = billingService.checkBalance(callType, translationType, 1);
+ if (!balanceCheck.sufficient) {
+ message.error('余额不足,通话即将结束');
+ setTimeout(() => {
+ handleForceDisconnect();
+ }, 30000); // 30秒后强制断开
+ return;
+ }
+
+ // 扣费
+ const deductSuccess = billingService.deductBalance(cost);
+ if (deductSuccess) {
+ setCurrentCost(newTotalCost);
+ const updatedAccount = billingService.getUserAccount();
+ setUserAccount(updatedAccount);
+
+ // 通知父组件计费更新
+ onBillingUpdate?.(newTotalCost, callDuration);
+
+ const shouldWarn = billingService.shouldShowLowBalanceWarning(callType, translationType);
+ if (shouldWarn) {
+ message.warning('账户余额较低,请及时充值');
+ }
+ } else {
+ message.error('扣费失败,通话即将结束');
+ handleForceDisconnect();
+ }
+ } catch (error) {
+ console.error('计费失败:', error);
+ message.error('计费系统异常');
+ }
+ };
+
+ // 强制断开连接(余额不足)
+ const handleForceDisconnect = () => {
+ message.error('余额不足,通话已结束');
+ leaveRoom();
+ };
+
+ // 停止计费
+ const stopBilling = () => {
+ if (durationInterval.current) {
+ clearInterval(durationInterval.current);
+ durationInterval.current = null;
+ }
+
+ if (billingInterval.current) {
+ clearInterval(billingInterval.current);
+ billingInterval.current = null;
+ }
+
+ callStartTime.current = null;
+ setLastBillingMinute(0);
+ };
const connectToRoom = async () => {
if (isConnecting) return;
+ // 检查余额
+ if (!checkBalance()) {
+ return;
+ }
+
setIsConnecting(true);
try {
const options: VideoCallOptions = {
@@ -117,6 +274,7 @@ export const VideoCall: React.FC = ({ roomName, identity, onLeav
setIsConnected(true);
setupRoomEventListeners(connectedRoom);
+ startBilling(); // 开始计费
message.success('成功连接到视频通话');
} catch (error) {
@@ -146,6 +304,7 @@ export const VideoCall: React.FC = ({ roomName, identity, onLeav
setIsConnected(false);
setRoom(null);
setParticipants([]);
+ stopBilling(); // 停止计费
message.info('已断开视频通话连接');
});
@@ -157,6 +316,7 @@ export const VideoCall: React.FC = ({ roomName, identity, onLeav
setIsConnected(false);
setRoom(null);
setParticipants([]);
+ stopBilling(); // 停止计费
onLeave?.();
};
@@ -170,22 +330,64 @@ export const VideoCall: React.FC = ({ roomName, identity, onLeav
setVideoEnabled(newVideoState);
};
+ const formatDuration = (seconds: number): string => {
+ const mins = Math.floor(seconds / 60);
+ const secs = seconds % 60;
+ return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
+ };
+
+ const formatCost = (cents: number): string => {
+ return (cents / 100).toFixed(2);
+ };
+
useEffect(() => {
return () => {
twilioService.disconnect();
+ stopBilling();
};
}, []);
if (!isConnected) {
return (
-
+
视频通话
房间: {roomName}
身份: {identity}
+
+
通话类型: {callType === CallType.VIDEO ? '视频通话' : '语音通话'}
+
+
翻译类型: {translationType === TranslationType.SIGN_LANGUAGE ? '手语翻译' : translationType === TranslationType.TEXT ? '文字翻译' : '真人翻译'}
+ {/* 用户账户信息 */}
+ {userAccount && (
+
+
+
+
+
+
+
+
+
+
+ )}
+
@@ -217,6 +419,7 @@ export const VideoCall: React.FC = ({ roomName, identity, onLeav
loading={isConnecting}
onClick={connectToRoom}
style={{ width: '100%' }}
+ disabled={!userAccount}
>
{isConnecting ? '连接中...' : '加入通话'}
@@ -230,9 +433,32 @@ export const VideoCall: React.FC = ({ roomName, identity, onLeav
-
-
视频通话 - {roomName}
-
参与者: {participants.length}
+ {/* 通话信息和计费状态 */}
+
+
+
+ 视频通话 - {roomName}
+ 参与者: {participants.length}
+
+
+
+
+
+ {formatDuration(callDuration)}
+
+
+
+
+
+ ¥{formatCost(currentCost)}
+ {userAccount && (
+
+ (余额: ¥{formatCost(userAccount.balance)})
+
+ )}
+
+
+
@@ -256,37 +482,39 @@ export const VideoCall: React.FC = ({ roomName, identity, onLeav
-
-
-
- : }
- onClick={toggleAudio}
- />
-
-
- }
- onClick={toggleVideo}
- />
-
-
- }
- onClick={leaveRoom}
- />
-
-
+ {/* 控制按钮 */}
+
+
+ : }
+ onClick={toggleAudio}
+ size="large"
+ >
+ {audioEnabled ? '静音' : '取消静音'}
+
+
+ }
+ onClick={toggleVideo}
+ size="large"
+ >
+ {videoEnabled ? '关闭视频' : '开启视频'}
+
+
+ }
+ onClick={leaveRoom}
+ size="large"
+ >
+ 结束通话
+
+
diff --git a/src/components/VideoCallTest.tsx b/src/components/VideoCallTest.tsx
new file mode 100644
index 0000000..929635e
--- /dev/null
+++ b/src/components/VideoCallTest.tsx
@@ -0,0 +1,349 @@
+import React, { useState, useEffect, useRef } from 'react';
+import { Button, Card, Input, Space, Typography, message, Row, Col, Badge, Divider } from 'antd';
+import {
+ PhoneOutlined,
+ VideoCameraOutlined,
+ AudioOutlined,
+ AudioMutedOutlined,
+ VideoCameraAddOutlined,
+ StopOutlined,
+ UserOutlined,
+ HomeOutlined,
+ WifiOutlined
+} from '@ant-design/icons';
+import { Room, RemoteParticipant, LocalParticipant } from 'twilio-video';
+import { TwilioService, VideoCallOptions, ParticipantInfo } from '../services/twilioService';
+
+const { Title, Text } = Typography;
+
+const VideoCallTest: React.FC = () => {
+ const [twilioService] = useState(() => new TwilioService());
+ const [room, setRoom] = useState
(null);
+ const [participants, setParticipants] = useState([]);
+ const [isConnecting, setIsConnecting] = useState(false);
+ const [isConnected, setIsConnected] = useState(false);
+ const [audioEnabled, setAudioEnabled] = useState(true);
+ const [videoEnabled, setVideoEnabled] = useState(true);
+
+ // 表单状态
+ const [roomName, setRoomName] = useState('test-room');
+ const [identity, setIdentity] = useState('user-' + Math.floor(Math.random() * 1000));
+
+ // 视频引用
+ const localVideoRef = useRef(null);
+ const remoteVideoRef = useRef(null);
+
+ // 连接到房间
+ const connectToRoom = async () => {
+ if (isConnecting || !roomName || !identity) {
+ message.warning('请填写房间名称和用户身份');
+ return;
+ }
+
+ setIsConnecting(true);
+ try {
+ const options: VideoCallOptions = {
+ roomName,
+ identity,
+ audio: audioEnabled,
+ video: videoEnabled,
+ };
+
+ console.log('连接参数:', options);
+ const connectedRoom = await twilioService.connectToRoom(options);
+ setRoom(connectedRoom);
+ setIsConnected(true);
+
+ setupRoomEventListeners(connectedRoom);
+
+ message.success(`成功连接到房间: ${roomName}`);
+ } catch (error: any) {
+ console.error('连接失败:', error);
+ message.error(`连接失败: ${error.message}`);
+ } finally {
+ setIsConnecting(false);
+ }
+ };
+
+ // 设置房间事件监听器
+ const setupRoomEventListeners = (room: Room) => {
+ const updateParticipants = () => {
+ const participantList = twilioService.getParticipants();
+ setParticipants(participantList);
+ console.log('参与者更新:', participantList);
+ };
+
+ // 参与者连接
+ room.on('participantConnected', (participant: RemoteParticipant) => {
+ console.log(`参与者加入: ${participant.identity}`);
+ message.info(`${participant.identity} 加入了通话`);
+ updateParticipants();
+
+ // 监听远程视频轨道
+ participant.on('trackSubscribed', (track) => {
+ if (track.kind === 'video' && remoteVideoRef.current) {
+ track.attach(remoteVideoRef.current);
+ }
+ });
+ });
+
+ // 参与者断开
+ room.on('participantDisconnected', (participant: RemoteParticipant) => {
+ console.log(`参与者离开: ${participant.identity}`);
+ message.info(`${participant.identity} 离开了通话`);
+ updateParticipants();
+ });
+
+ // 房间断开
+ room.on('disconnected', () => {
+ console.log('房间连接断开');
+ setIsConnected(false);
+ setRoom(null);
+ setParticipants([]);
+ message.info('已断开视频通话连接');
+ });
+
+ // 本地视频轨道
+ const localParticipant = room.localParticipant;
+ if (localParticipant && localVideoRef.current) {
+ localParticipant.videoTracks.forEach((publication) => {
+ if (publication.track) {
+ publication.track.attach(localVideoRef.current!);
+ }
+ });
+ }
+
+ updateParticipants();
+ };
+
+ // 离开房间
+ const leaveRoom = () => {
+ if (room) {
+ twilioService.disconnect();
+ setIsConnected(false);
+ setRoom(null);
+ setParticipants([]);
+ message.info('已离开视频通话');
+ }
+ };
+
+ // 切换音频
+ const toggleAudio = () => {
+ const newAudioEnabled = twilioService.toggleAudio();
+ setAudioEnabled(newAudioEnabled);
+ message.info(newAudioEnabled ? '音频已开启' : '音频已关闭');
+ };
+
+ // 切换视频
+ const toggleVideo = () => {
+ const newVideoEnabled = twilioService.toggleVideo();
+ setVideoEnabled(newVideoEnabled);
+ message.info(newVideoEnabled ? '视频已开启' : '视频已关闭');
+ };
+
+ // 测试服务器连接
+ const testServerConnection = async () => {
+ try {
+ const response = await fetch('http://localhost:3001/health');
+ const data = await response.json();
+ message.success('Token服务器连接正常');
+ console.log('服务器状态:', data);
+ } catch (error) {
+ message.error('Token服务器连接失败,请确保服务器已启动');
+ console.error('服务器连接错误:', error);
+ }
+ };
+
+ useEffect(() => {
+ // 组件挂载时测试服务器连接
+ testServerConnection();
+
+ return () => {
+ // 组件卸载时清理连接
+ if (room) {
+ twilioService.disconnect();
+ }
+ };
+ }, []);
+
+ const styles = {
+ container: {
+ padding: '20px',
+ maxWidth: '1200px',
+ margin: '0 auto',
+ },
+ videoContainer: {
+ display: 'flex',
+ gap: '16px',
+ marginBottom: '20px',
+ },
+ videoCard: {
+ flex: 1,
+ minHeight: '300px',
+ },
+ video: {
+ width: '100%',
+ height: '250px',
+ backgroundColor: '#000',
+ borderRadius: '8px',
+ },
+ controlPanel: {
+ marginBottom: '20px',
+ },
+ participantList: {
+ marginTop: '20px',
+ },
+ statusBadge: {
+ marginBottom: '10px',
+ }
+ };
+
+ return (
+
+
🎥 Twilio 视频通话测试
+
+ {/* 连接状态 */}
+
+
+ }
+ onClick={testServerConnection}
+ >
+ 测试服务器
+
+
+
+ {/* 视频区域 */}
+
+
+
+
+
+
+
+
+
+ {/* 控制面板 */}
+
+
+
+
+ setRoomName(e.target.value)}
+ prefix={}
+ disabled={isConnected}
+ />
+ setIdentity(e.target.value)}
+ prefix={}
+ disabled={isConnected}
+ />
+
+
+
+
+ {!isConnected ? (
+ }
+ loading={isConnecting}
+ onClick={connectToRoom}
+ size="large"
+ >
+ {isConnecting ? '连接中...' : '加入通话'}
+
+ ) : (
+ <>
+ }
+ onClick={leaveRoom}
+ size="large"
+ >
+ 离开通话
+
+ : }
+ onClick={toggleAudio}
+ >
+ {audioEnabled ? '关闭音频' : '开启音频'}
+
+ }
+ onClick={toggleVideo}
+ >
+ {videoEnabled ? '关闭视频' : '开启视频'}
+
+ >
+ )}
+
+
+
+
+
+ {/* 参与者列表 */}
+ {participants.length > 0 && (
+
+
+ {participants.map((participant) => (
+
+
+
+
+
+ {participant.identity}
+
+
+ {participant.isLocal ? '本地' : '远程'} |
+ 音频: {participant.audioEnabled ? '开' : '关'} |
+ 视频: {participant.videoEnabled ? '开' : '关'}
+
+
+
+
+
+ ))}
+
+
+ )}
+
+
+
+ {/* 使用说明 */}
+
+
+ 测试步骤:
+ 1. 确保Token服务器已启动(端口3001)
+ 2. 填写房间名称和用户身份
+ 3. 点击"加入通话"按钮
+ 4. 在另一个浏览器标签页中使用相同房间名称测试多人通话
+ 5. 使用音频/视频控制按钮测试功能
+
+
+
+ );
+};
+
+export default VideoCallTest;
\ No newline at end of file
diff --git a/src/pages/mobile/Appointment.tsx b/src/pages/mobile/Appointment.tsx
new file mode 100644
index 0000000..4fc3de8
--- /dev/null
+++ b/src/pages/mobile/Appointment.tsx
@@ -0,0 +1,580 @@
+import { FC, useState, useEffect } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { AppointmentService } from '../../services/appointmentService';
+import { BillingService } from '../../services/billingService';
+import {
+ Appointment,
+ Interpreter,
+ CallType,
+ TranslationType,
+ UserAccount
+} from '../../types/billing';
+
+const MobileAppointment: FC = () => {
+ const navigate = useNavigate();
+ const appointmentService = AppointmentService.getInstance();
+ const billingService = BillingService.getInstance();
+
+ const [userAccount, setUserAccount] = useState(null);
+ const [selectedDate, setSelectedDate] = useState('');
+ const [selectedTime, setSelectedTime] = useState('');
+ const [callType, setCallType] = useState(CallType.VOICE);
+ const [translationType, setTranslationType] = useState(TranslationType.TEXT);
+ const [selectedLanguages, setSelectedLanguages] = useState({
+ from: 'zh-CN',
+ to: 'en-US',
+ });
+ const [selectedInterpreter, setSelectedInterpreter] = useState(null);
+ const [availableInterpreters, setAvailableInterpreters] = useState([]);
+ const [description, setDescription] = useState('');
+ const [estimatedCost, setEstimatedCost] = useState(0);
+ const [isSubmitting, setIsSubmitting] = useState(false);
+
+ const languages = [
+ { code: 'zh-CN', name: '中文', flag: '🇨🇳' },
+ { code: 'en-US', name: 'English', flag: '🇺🇸' },
+ { code: 'ja-JP', name: '日本語', flag: '🇯🇵' },
+ { code: 'ko-KR', name: '한국어', flag: '🇰🇷' },
+ { code: 'es-ES', name: 'Español', flag: '🇪🇸' },
+ { code: 'fr-FR', name: 'Français', flag: '🇫🇷' },
+ { code: 'de-DE', name: 'Deutsch', flag: '🇩🇪' },
+ ];
+
+ // 生成可选时间段
+ const timeSlots = [
+ '09:00', '09:30', '10:00', '10:30', '11:00', '11:30',
+ '14:00', '14:30', '15:00', '15:30', '16:00', '16:30',
+ '17:00', '17:30', '18:00', '18:30', '19:00', '19:30',
+ '20:00', '20:30', '21:00'
+ ];
+
+ // 生成未来7天的日期选项
+ const getDateOptions = () => {
+ const dates = [];
+ for (let i = 0; i < 7; i++) {
+ const date = new Date();
+ date.setDate(date.getDate() + i);
+ dates.push({
+ value: date.toISOString().split('T')[0],
+ label: i === 0 ? '今天' : i === 1 ? '明天' :
+ `${date.getMonth() + 1}月${date.getDate()}日`,
+ weekday: date.toLocaleDateString('zh-CN', { weekday: 'short' })
+ });
+ }
+ return dates;
+ };
+
+ useEffect(() => {
+ const account = billingService.getUserAccount();
+ setUserAccount(account);
+ }, []);
+
+ useEffect(() => {
+ if (selectedDate) {
+ const date = new Date(selectedDate);
+ const interpreters = appointmentService.getAvailableInterpreters(
+ date,
+ [selectedLanguages.from, selectedLanguages.to]
+ );
+ setAvailableInterpreters(interpreters);
+ }
+ }, [selectedDate, selectedLanguages]);
+
+ useEffect(() => {
+ // 计算预估费用
+ if (callType && translationType && userAccount) {
+ const interpreterRate = selectedInterpreter?.pricePerMinute;
+ const baseCost = billingService.calculateCallCost(
+ callType,
+ translationType,
+ 30, // 假设30分钟
+ interpreterRate
+ );
+ setEstimatedCost(baseCost);
+ }
+ }, [callType, translationType, selectedInterpreter, userAccount]);
+
+ useEffect(() => {
+ // 根据通话类型设置默认翻译类型
+ if (callType === CallType.VIDEO) {
+ setTranslationType(TranslationType.SIGN_LANGUAGE);
+ } else {
+ setTranslationType(TranslationType.TEXT);
+ }
+ }, [callType]);
+
+ const formatCurrency = (cents: number) => {
+ return (cents / 100).toFixed(2);
+ };
+
+ const handleSubmit = async () => {
+ if (!selectedDate || !selectedTime || !callType || !translationType) {
+ alert('请完善预约信息');
+ return;
+ }
+
+ if (!userAccount || userAccount.balance < estimatedCost) {
+ alert('账户余额不足,请先充值');
+ navigate('/mobile/recharge');
+ return;
+ }
+
+ setIsSubmitting(true);
+
+ try {
+ // 构建预约数据
+ const appointmentData = {
+ userId: 'user_1', // 实际应该从用户状态获取
+ title: `${callType === CallType.VOICE ? '语音' : '视频'}通话预约`,
+ description: `${translationType === TranslationType.TEXT ? '文本翻译' :
+ translationType === TranslationType.SIGN_LANGUAGE ? '手语翻译' : '人工翻译'}`,
+ scheduledTime: new Date(`${selectedDate}T${selectedTime}`),
+ duration: 60, // 默认60分钟
+ callType,
+ translationType,
+ interpreterIds: selectedInterpreter ? [selectedInterpreter.id] : undefined,
+ estimatedCost,
+ status: 'scheduled' as const,
+ };
+
+ // 创建预约
+ const appointment = appointmentService.createAppointment(appointmentData);
+
+ alert('预约创建成功!');
+ navigate('/mobile/home');
+ } catch (error) {
+ console.error('创建预约失败:', error);
+ alert('创建预约失败,请重试');
+ } finally {
+ setIsSubmitting(false);
+ }
+ };
+
+ const styles = {
+ container: {
+ padding: '16px',
+ backgroundColor: '#f5f5f5',
+ minHeight: '100vh',
+ },
+ header: {
+ display: 'flex',
+ alignItems: 'center',
+ marginBottom: '20px',
+ },
+ backButton: {
+ background: 'none',
+ border: 'none',
+ fontSize: '24px',
+ cursor: 'pointer',
+ marginRight: '12px',
+ },
+ title: {
+ fontSize: '20px',
+ fontWeight: '600' as const,
+ color: '#333',
+ },
+ section: {
+ backgroundColor: 'white',
+ borderRadius: '16px',
+ padding: '20px',
+ marginBottom: '20px',
+ boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)',
+ },
+ sectionTitle: {
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '16px',
+ },
+ callTypeSelector: {
+ display: 'flex',
+ gap: '12px',
+ marginBottom: '16px',
+ },
+ callTypeButton: (active: boolean) => ({
+ flex: 1,
+ padding: '16px',
+ borderRadius: '12px',
+ border: active ? '2px solid #1890ff' : '2px solid #f0f0f0',
+ backgroundColor: active ? '#e6f7ff' : 'white',
+ color: active ? '#1890ff' : '#666',
+ fontSize: '16px',
+ fontWeight: '500' as const,
+ cursor: 'pointer',
+ textAlign: 'center' as const,
+ }),
+ dateGrid: {
+ display: 'grid',
+ gridTemplateColumns: 'repeat(2, 1fr)',
+ gap: '12px',
+ marginBottom: '16px',
+ },
+ dateOption: (selected: boolean) => ({
+ padding: '16px',
+ borderRadius: '12px',
+ border: selected ? '2px solid #1890ff' : '2px solid #f0f0f0',
+ backgroundColor: selected ? '#e6f7ff' : 'white',
+ cursor: 'pointer',
+ textAlign: 'center' as const,
+ }),
+ dateLabel: {
+ fontSize: '16px',
+ fontWeight: '500' as const,
+ color: '#333',
+ marginBottom: '4px',
+ },
+ dateWeekday: {
+ fontSize: '12px',
+ color: '#999',
+ },
+ timeGrid: {
+ display: 'grid',
+ gridTemplateColumns: 'repeat(3, 1fr)',
+ gap: '8px',
+ },
+ timeSlot: (selected: boolean, available: boolean) => ({
+ padding: '12px 8px',
+ borderRadius: '8px',
+ border: selected ? '2px solid #1890ff' : '1px solid #d9d9d9',
+ backgroundColor: selected ? '#e6f7ff' : available ? 'white' : '#f5f5f5',
+ color: selected ? '#1890ff' : available ? '#333' : '#999',
+ fontSize: '14px',
+ textAlign: 'center' as const,
+ cursor: available ? 'pointer' : 'not-allowed',
+ }),
+ languageRow: {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ marginBottom: '16px',
+ },
+ languageSelect: {
+ flex: 1,
+ padding: '12px',
+ borderRadius: '8px',
+ border: '1px solid #d9d9d9',
+ backgroundColor: 'white',
+ fontSize: '14px',
+ },
+ swapButton: {
+ margin: '0 12px',
+ padding: '8px',
+ borderRadius: '20px',
+ border: 'none',
+ backgroundColor: '#f0f8ff',
+ cursor: 'pointer',
+ fontSize: '16px',
+ },
+ translationTypeSelector: {
+ display: 'flex',
+ flexDirection: 'column' as const,
+ gap: '12px',
+ marginBottom: '16px',
+ },
+ translationTypeButton: (active: boolean) => ({
+ padding: '16px',
+ borderRadius: '12px',
+ border: active ? '2px solid #1890ff' : '1px solid #d9d9d9',
+ backgroundColor: active ? '#e6f7ff' : 'white',
+ color: active ? '#1890ff' : '#666',
+ fontSize: '14px',
+ cursor: 'pointer',
+ textAlign: 'left' as const,
+ }),
+ interpreterList: {
+ marginTop: '16px',
+ },
+ interpreterItem: (selected: boolean) => ({
+ display: 'flex',
+ alignItems: 'center',
+ padding: '16px',
+ borderRadius: '12px',
+ border: selected ? '2px solid #1890ff' : '1px solid #d9d9d9',
+ backgroundColor: selected ? '#e6f7ff' : 'white',
+ marginBottom: '12px',
+ cursor: 'pointer',
+ }),
+ interpreterAvatar: {
+ fontSize: '32px',
+ marginRight: '16px',
+ },
+ interpreterInfo: {
+ flex: 1,
+ },
+ interpreterName: {
+ fontSize: '16px',
+ fontWeight: '500' as const,
+ color: '#333',
+ marginBottom: '4px',
+ },
+ interpreterDetails: {
+ fontSize: '12px',
+ color: '#666',
+ marginBottom: '4px',
+ },
+ interpreterRate: {
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ color: '#fa8c16',
+ },
+ descriptionInput: {
+ width: '100%',
+ minHeight: '80px',
+ padding: '12px',
+ borderRadius: '8px',
+ border: '1px solid #d9d9d9',
+ fontSize: '14px',
+ resize: 'vertical' as const,
+ },
+ costSummary: {
+ backgroundColor: '#f8f9fa',
+ borderRadius: '12px',
+ padding: '16px',
+ marginBottom: '20px',
+ },
+ costRow: {
+ display: 'flex',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ marginBottom: '8px',
+ },
+ costLabel: {
+ fontSize: '14px',
+ color: '#666',
+ },
+ costValue: {
+ fontSize: '16px',
+ fontWeight: '600' as const,
+ color: '#1890ff',
+ },
+ submitButton: {
+ width: '100%',
+ padding: '16px',
+ borderRadius: '12px',
+ border: 'none',
+ backgroundColor: selectedDate && selectedTime && !isSubmitting ? '#1890ff' : '#d9d9d9',
+ color: 'white',
+ fontSize: '16px',
+ fontWeight: '600' as const,
+ cursor: selectedDate && selectedTime && !isSubmitting ? 'pointer' : 'not-allowed',
+ },
+ };
+
+ return (
+
+ {/* 头部 */}
+
+
+
预约通话
+
+
+ {/* 通话类型选择 */}
+
+
选择通话类型
+
+
+
+
+
+
+ {/* 日期选择 */}
+
+
选择日期
+
+ {getDateOptions().map((date) => (
+
setSelectedDate(date.value)}
+ >
+
{date.label}
+
{date.weekday}
+
+ ))}
+
+
+
+ {/* 时间选择 */}
+ {selectedDate && (
+
+
选择时间
+
+ {timeSlots.map((time) => {
+ const isAvailable = appointmentService.isTimeSlotAvailable(
+ new Date(`${selectedDate}T${time}:00`),
+ 30
+ );
+ return (
+
+ );
+ })}
+
+
+ )}
+
+ {/* 语言选择 */}
+
+
选择语言
+
+
+
+
+
+
+
+
+
+ {/* 翻译服务选择 */}
+
+
选择翻译服务
+
+ {callType === CallType.VOICE && (
+
+ )}
+
+ {callType === CallType.VIDEO && (
+ <>
+
+
+
+ >
+ )}
+
+
+ {/* 翻译员选择 */}
+ {translationType === TranslationType.HUMAN_INTERPRETER && (
+
+
选择翻译员
+ {availableInterpreters.map((interpreter) => (
+
setSelectedInterpreter(interpreter)}
+ >
+
{interpreter.avatar}
+
+
{interpreter.name}
+
+ {interpreter.languages.join(', ')} | ⭐ {interpreter.rating} | {interpreter.specialties.join(', ')}
+
+
+ ¥{formatCurrency(interpreter.pricePerMinute)}/分钟
+
+
+
+ ))}
+
+ )}
+
+
+ {/* 备注信息 */}
+
+
+ {/* 费用预估 */}
+ {estimatedCost > 0 && (
+
+
+ 预估费用(30分钟)
+ ¥{formatCurrency(estimatedCost)}
+
+
+ 当前余额
+
+ ¥{userAccount ? formatCurrency(userAccount.balance) : '0.00'}
+
+
+
+ )}
+
+ {/* 提交按钮 */}
+
+
+ );
+};
+
+export default MobileAppointment;
\ No newline at end of file
diff --git a/src/pages/mobile/Call.tsx b/src/pages/mobile/Call.tsx
new file mode 100644
index 0000000..b3bf993
--- /dev/null
+++ b/src/pages/mobile/Call.tsx
@@ -0,0 +1,698 @@
+import { FC, useState, useEffect, useRef } from 'react';
+import { useNavigate, useLocation } from 'react-router-dom';
+import { BillingService } from '../../services/billingService';
+import { AppointmentService } from '../../services/appointmentService';
+import {
+ UserAccount,
+ CallType,
+ TranslationType,
+ Interpreter,
+ BillingRule
+} from '../../types/billing';
+
+const MobileCall: FC = () => {
+ const navigate = useNavigate();
+ const location = useLocation();
+ const billingService = BillingService.getInstance();
+ const appointmentService = AppointmentService.getInstance();
+
+ // 从URL参数获取通话类型
+ const urlParams = new URLSearchParams(location.search);
+ const initialCallType = urlParams.get('type') === 'video' ? CallType.VIDEO : CallType.VOICE;
+
+ // 状态管理
+ const [callType, setCallType] = useState(initialCallType);
+ const [translationType, setTranslationType] = useState(
+ callType === CallType.VIDEO ? TranslationType.SIGN_LANGUAGE : TranslationType.TEXT
+ );
+ const [isConnected, setIsConnected] = useState(false);
+ const [callDuration, setCallDuration] = useState(0);
+ const [currentCost, setCurrentCost] = useState(0);
+ const [userAccount, setUserAccount] = useState(null);
+ const [selectedInterpreter, setSelectedInterpreter] = useState(null);
+ const [availableInterpreters, setAvailableInterpreters] = useState([]);
+ const [billingRule, setBillingRule] = useState(null);
+ const [showLowBalanceWarning, setShowLowBalanceWarning] = useState(false);
+ const [selectedLanguages, setSelectedLanguages] = useState({
+ from: 'zh-CN',
+ to: 'en-US',
+ });
+
+ // 计费相关
+ const [lastBillingMinute, setLastBillingMinute] = useState(0);
+ const billingIntervalRef = useRef(null);
+
+ // 翻译历史
+ const [translationHistory, setTranslationHistory] = useState([
+ {
+ time: '14:23:15',
+ original: '你好,很高兴见到你',
+ translated: 'Hello, nice to meet you',
+ speaker: 'you'
+ },
+ {
+ time: '14:23:18',
+ original: 'Nice to meet you too!',
+ translated: '我也很高兴见到你!',
+ speaker: 'other'
+ },
+ ]);
+
+ const languages = [
+ { code: 'zh-CN', name: '中文', flag: '🇨🇳' },
+ { code: 'en-US', name: 'English', flag: '🇺🇸' },
+ { code: 'ja-JP', name: '日本語', flag: '🇯🇵' },
+ { code: 'ko-KR', name: '한국어', flag: '🇰🇷' },
+ { code: 'es-ES', name: 'Español', flag: '🇪🇸' },
+ { code: 'fr-FR', name: 'Français', flag: '🇫🇷' },
+ { code: 'de-DE', name: 'Deutsch', flag: '🇩🇪' },
+ ];
+
+ useEffect(() => {
+ // 获取用户账户信息
+ const account = billingService.getUserAccount();
+ setUserAccount(account);
+
+ // 获取计费规则
+ if (account) {
+ const rule = billingService.getBillingRule(callType, translationType, account.userType);
+ setBillingRule(rule);
+ }
+
+ // 获取可用翻译员
+ if (translationType === TranslationType.HUMAN_INTERPRETER) {
+ const interpreters = appointmentService.getAvailableInterpreters(
+ new Date(),
+ [selectedLanguages.from, selectedLanguages.to]
+ );
+ setAvailableInterpreters(interpreters);
+ }
+ }, [callType, translationType, selectedLanguages]);
+
+ useEffect(() => {
+ let interval: NodeJS.Timeout;
+ if (isConnected) {
+ interval = setInterval(() => {
+ setCallDuration(prev => {
+ const newDuration = prev + 1;
+ const currentMinute = Math.ceil(newDuration / 60);
+
+ // 计算当前费用
+ if (billingRule && userAccount) {
+ const interpreterRate = selectedInterpreter?.pricePerMinute;
+ const cost = billingService.calculateCallCost(
+ callType,
+ translationType,
+ newDuration / 60,
+ interpreterRate
+ );
+ setCurrentCost(cost);
+
+ // 每分钟开始时扣费
+ if (currentMinute > lastBillingMinute) {
+ const minuteCost = billingService.calculateCallCost(
+ callType,
+ translationType,
+ 1,
+ interpreterRate
+ );
+
+ if (billingService.deductBalance(minuteCost)) {
+ setLastBillingMinute(currentMinute);
+ setUserAccount(billingService.getUserAccount());
+ } else {
+ // 余额不足,断开通话
+ handleDisconnect();
+ alert('余额不足,通话已断开');
+ }
+ }
+
+ // 检查低余额警告
+ if (billingService.shouldShowLowBalanceWarning(callType, translationType, interpreterRate)) {
+ setShowLowBalanceWarning(true);
+ }
+ }
+
+ return newDuration;
+ });
+ }, 1000);
+ }
+ return () => clearInterval(interval);
+ }, [isConnected, billingRule, userAccount, selectedInterpreter, lastBillingMinute]);
+
+ const formatDuration = (seconds: number) => {
+ const mins = Math.floor(seconds / 60);
+ const secs = seconds % 60;
+ return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
+ };
+
+ const formatCost = (cents: number) => {
+ return (cents / 100).toFixed(2);
+ };
+
+ const handleConnect = () => {
+ if (!userAccount || !billingRule) {
+ alert('账户信息或计费规则未加载');
+ return;
+ }
+
+ const interpreterRate = selectedInterpreter?.pricePerMinute;
+ const balanceCheck = billingService.checkBalance(callType, translationType, 1, interpreterRate);
+
+ if (!balanceCheck.sufficient) {
+ alert(`余额不足,需要至少 ¥${formatCost(balanceCheck.requiredAmount)} 才能开始通话`);
+ navigate('/mobile/recharge');
+ return;
+ }
+
+ setIsConnected(true);
+ setCallDuration(0);
+ setCurrentCost(0);
+ setLastBillingMinute(0);
+ };
+
+ const handleDisconnect = () => {
+ setIsConnected(false);
+ if (billingIntervalRef.current) {
+ clearInterval(billingIntervalRef.current);
+ }
+ };
+
+ const handleCallTypeChange = (newCallType: CallType) => {
+ if (isConnected) {
+ alert('通话进行中无法切换类型');
+ return;
+ }
+
+ setCallType(newCallType);
+ // 根据通话类型设置默认翻译类型
+ if (newCallType === CallType.VIDEO) {
+ setTranslationType(TranslationType.SIGN_LANGUAGE);
+ } else {
+ setTranslationType(TranslationType.TEXT);
+ }
+ };
+
+ const handleTranslationTypeChange = (newTranslationType: TranslationType) => {
+ if (isConnected) {
+ alert('通话进行中无法切换翻译类型');
+ return;
+ }
+ setTranslationType(newTranslationType);
+ };
+
+ const handleInterpreterSelect = (interpreter: Interpreter) => {
+ if (isConnected) {
+ alert('通话进行中无法切换翻译员');
+ return;
+ }
+ setSelectedInterpreter(interpreter);
+ };
+
+ const swapLanguages = () => {
+ setSelectedLanguages({
+ from: selectedLanguages.to,
+ to: selectedLanguages.from,
+ });
+ };
+
+ const styles = {
+ container: {
+ padding: '16px',
+ backgroundColor: '#f5f5f5',
+ minHeight: '100vh',
+ display: 'flex',
+ flexDirection: 'column' as const,
+ },
+ header: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '16px',
+ marginBottom: '16px',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ callTypeSelector: {
+ display: 'flex',
+ gap: '8px',
+ marginBottom: '16px',
+ },
+ callTypeButton: (active: boolean) => ({
+ flex: 1,
+ padding: '12px',
+ borderRadius: '8px',
+ border: 'none',
+ backgroundColor: active ? '#1890ff' : '#f0f0f0',
+ color: active ? 'white' : '#666',
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ cursor: 'pointer',
+ }),
+ statusRow: {
+ display: 'flex',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ marginBottom: '12px',
+ },
+ statusIndicator: {
+ display: 'flex',
+ alignItems: 'center',
+ },
+ statusDot: {
+ width: '12px',
+ height: '12px',
+ borderRadius: '6px',
+ backgroundColor: isConnected ? '#52c41a' : '#d9d9d9',
+ marginRight: '8px',
+ },
+ statusText: {
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ color: isConnected ? '#52c41a' : '#666',
+ },
+ costInfo: {
+ textAlign: 'right' as const,
+ },
+ duration: {
+ fontSize: '20px',
+ fontWeight: '600' as const,
+ color: '#1890ff',
+ textAlign: 'center' as const,
+ marginBottom: '8px',
+ },
+ currentCost: {
+ fontSize: '16px',
+ fontWeight: '500' as const,
+ color: '#fa8c16',
+ textAlign: 'center' as const,
+ },
+ billingInfo: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '16px',
+ marginBottom: '16px',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ billingTitle: {
+ fontSize: '16px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '12px',
+ },
+ translationTypeSelector: {
+ display: 'flex',
+ flexDirection: 'column' as const,
+ gap: '8px',
+ marginBottom: '16px',
+ },
+ translationTypeButton: (active: boolean) => ({
+ padding: '12px',
+ borderRadius: '8px',
+ border: active ? '2px solid #1890ff' : '1px solid #d9d9d9',
+ backgroundColor: active ? '#e6f7ff' : 'white',
+ color: active ? '#1890ff' : '#666',
+ fontSize: '14px',
+ cursor: 'pointer',
+ textAlign: 'left' as const,
+ }),
+ rateInfo: {
+ fontSize: '14px',
+ color: '#666',
+ marginBottom: '8px',
+ },
+ interpreterSelector: {
+ marginTop: '12px',
+ },
+ interpreterItem: (selected: boolean) => ({
+ display: 'flex',
+ alignItems: 'center',
+ padding: '12px',
+ borderRadius: '8px',
+ border: selected ? '2px solid #1890ff' : '1px solid #d9d9d9',
+ backgroundColor: selected ? '#e6f7ff' : 'white',
+ marginBottom: '8px',
+ cursor: 'pointer',
+ }),
+ interpreterInfo: {
+ marginLeft: '12px',
+ flex: 1,
+ },
+ interpreterName: {
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ color: '#333',
+ },
+ interpreterDetails: {
+ fontSize: '12px',
+ color: '#666',
+ },
+ interpreterRate: {
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ color: '#fa8c16',
+ },
+ languageSelector: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '16px',
+ marginBottom: '16px',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ languageRow: {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ marginBottom: '12px',
+ },
+ languageSelect: {
+ flex: 1,
+ padding: '12px',
+ borderRadius: '8px',
+ border: '1px solid #d9d9d9',
+ backgroundColor: 'white',
+ fontSize: '14px',
+ },
+ swapButton: {
+ margin: '0 12px',
+ padding: '8px',
+ borderRadius: '20px',
+ border: 'none',
+ backgroundColor: '#f0f8ff',
+ cursor: 'pointer',
+ fontSize: '16px',
+ },
+ controlButtons: {
+ display: 'flex',
+ justifyContent: 'center',
+ gap: '20px',
+ marginBottom: '24px',
+ },
+ controlButton: {
+ width: '80px',
+ height: '80px',
+ borderRadius: '40px',
+ border: 'none',
+ cursor: 'pointer',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ fontSize: '32px',
+ boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
+ transition: 'transform 0.2s ease',
+ },
+ connectButton: {
+ backgroundColor: isConnected ? '#ff4d4f' : '#52c41a',
+ },
+ translationContainer: {
+ flex: 1,
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '16px',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ translationTitle: {
+ fontSize: '16px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '16px',
+ },
+ translationItem: {
+ marginBottom: '16px',
+ padding: '12px',
+ borderRadius: '8px',
+ backgroundColor: '#f8f9fa',
+ },
+ translationTime: {
+ fontSize: '12px',
+ color: '#999',
+ marginBottom: '4px',
+ },
+ translationText: {
+ fontSize: '14px',
+ lineHeight: '1.4',
+ marginBottom: '4px',
+ },
+ originalText: {
+ color: '#333',
+ fontWeight: '500' as const,
+ },
+ translatedText: {
+ color: '#1890ff',
+ },
+ speakerTag: {
+ fontSize: '12px',
+ color: '#666',
+ fontStyle: 'italic' as const,
+ },
+ warningModal: {
+ position: 'fixed' as const,
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ zIndex: 1000,
+ },
+ warningContent: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '24px',
+ margin: '20px',
+ textAlign: 'center' as const,
+ },
+ warningTitle: {
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ color: '#fa8c16',
+ marginBottom: '12px',
+ },
+ warningText: {
+ fontSize: '14px',
+ color: '#666',
+ marginBottom: '20px',
+ },
+ warningButtons: {
+ display: 'flex',
+ gap: '12px',
+ justifyContent: 'center',
+ },
+ warningButton: (primary: boolean) => ({
+ padding: '8px 16px',
+ borderRadius: '6px',
+ border: 'none',
+ backgroundColor: primary ? '#1890ff' : '#f0f0f0',
+ color: primary ? 'white' : '#666',
+ fontSize: '14px',
+ cursor: 'pointer',
+ }),
+ };
+
+ return (
+
+ {/* 通话类型选择 */}
+
+
+
+
+
+
+
+
+
+
+ {isConnected ? '通话中' : '未连接'}
+
+
+
+
{formatDuration(callDuration)}
+
¥{formatCost(currentCost)}
+
+
+
+
+ {/* 计费信息 */}
+
+
翻译服务选择
+
+
+ {callType === CallType.VOICE && (
+
+ )}
+
+ {callType === CallType.VIDEO && (
+ <>
+
+
+
+ >
+ )}
+
+
+ {/* 翻译员选择 */}
+ {translationType === TranslationType.HUMAN_INTERPRETER && (
+
+
选择翻译员
+ {availableInterpreters.map((interpreter) => (
+
handleInterpreterSelect(interpreter)}
+ >
+
{interpreter.avatar}
+
+
{interpreter.name}
+
+ {interpreter.languages.join(', ')} | ⭐ {interpreter.rating}
+
+
+
+ ¥{formatCost(interpreter.pricePerMinute)}/分钟
+
+
+ ))}
+
+ )}
+
+
+ {/* 语言选择器 */}
+
+
+
+
+
+
+
+
+
+
+ {/* 控制按钮 */}
+
+
+
+
+ {/* 翻译历史 */}
+
+
+ {translationType === TranslationType.TEXT ? '实时翻译' :
+ translationType === TranslationType.SIGN_LANGUAGE ? '手语翻译' : '翻译员服务'}
+
+ {translationHistory.map((item, index) => (
+
+
{item.time}
+
+ {item.original}
+
+
+ {item.translated}
+
+
+ {item.speaker === 'you' ? '您' : '对方'}
+
+
+ ))}
+
+
+ {/* 低余额警告 */}
+ {showLowBalanceWarning && (
+
+
+
⚠️ 余额不足警告
+
+ 您的账户余额即将不足,可能无法维持通话超过5分钟。
+ 建议立即充值以避免通话中断。
+
+
+
+
+
+
+
+ )}
+
+ );
+};
+
+export default MobileCall;
\ No newline at end of file
diff --git a/src/pages/mobile/Documents.tsx b/src/pages/mobile/Documents.tsx
new file mode 100644
index 0000000..161bc1b
--- /dev/null
+++ b/src/pages/mobile/Documents.tsx
@@ -0,0 +1,407 @@
+import { FC, useState } from 'react';
+
+interface Document {
+ id: string;
+ name: string;
+ size: string;
+ status: 'uploading' | 'processing' | 'completed' | 'failed';
+ progress: number;
+ originalLanguage: string;
+ targetLanguage: string;
+ uploadTime: string;
+}
+
+const MobileDocuments: FC = () => {
+ const [documents, setDocuments] = useState([
+ {
+ id: '1',
+ name: '商业合同.pdf',
+ size: '2.3 MB',
+ status: 'completed',
+ progress: 100,
+ originalLanguage: 'zh-CN',
+ targetLanguage: 'en-US',
+ uploadTime: '2024-01-15 14:30',
+ },
+ {
+ id: '2',
+ name: '技术文档.docx',
+ size: '1.8 MB',
+ status: 'processing',
+ progress: 65,
+ originalLanguage: 'en-US',
+ targetLanguage: 'zh-CN',
+ uploadTime: '2024-01-15 15:20',
+ },
+ ]);
+
+ const [selectedLanguages, setSelectedLanguages] = useState({
+ from: 'zh-CN',
+ to: 'en-US',
+ });
+
+ const languages = [
+ { code: 'zh-CN', name: '中文', flag: '🇨🇳' },
+ { code: 'en-US', name: 'English', flag: '🇺🇸' },
+ { code: 'ja-JP', name: '日本語', flag: '🇯🇵' },
+ { code: 'ko-KR', name: '한국어', flag: '🇰🇷' },
+ { code: 'es-ES', name: 'Español', flag: '🇪🇸' },
+ { code: 'fr-FR', name: 'Français', flag: '🇫🇷' },
+ { code: 'de-DE', name: 'Deutsch', flag: '🇩🇪' },
+ ];
+
+ const handleFileUpload = (event: React.ChangeEvent) => {
+ const files = event.target.files;
+ if (files && files.length > 0) {
+ const file = files[0];
+ const newDocument: Document = {
+ id: Date.now().toString(),
+ name: file.name,
+ size: `${(file.size / 1024 / 1024).toFixed(1)} MB`,
+ status: 'uploading',
+ progress: 0,
+ originalLanguage: selectedLanguages.from,
+ targetLanguage: selectedLanguages.to,
+ uploadTime: new Date().toLocaleString('zh-CN'),
+ };
+
+ setDocuments(prev => [newDocument, ...prev]);
+
+ // 模拟上传进度
+ simulateUpload(newDocument.id);
+ }
+ };
+
+ const simulateUpload = (docId: string) => {
+ let progress = 0;
+ const interval = setInterval(() => {
+ progress += Math.random() * 15;
+ if (progress >= 100) {
+ progress = 100;
+ setDocuments(prev => prev.map(doc =>
+ doc.id === docId
+ ? { ...doc, status: 'processing', progress: 0 }
+ : doc
+ ));
+ clearInterval(interval);
+ simulateProcessing(docId);
+ } else {
+ setDocuments(prev => prev.map(doc =>
+ doc.id === docId
+ ? { ...doc, progress: Math.floor(progress) }
+ : doc
+ ));
+ }
+ }, 200);
+ };
+
+ const simulateProcessing = (docId: string) => {
+ let progress = 0;
+ const interval = setInterval(() => {
+ progress += Math.random() * 10;
+ if (progress >= 100) {
+ progress = 100;
+ setDocuments(prev => prev.map(doc =>
+ doc.id === docId
+ ? { ...doc, status: 'completed', progress: 100 }
+ : doc
+ ));
+ clearInterval(interval);
+ } else {
+ setDocuments(prev => prev.map(doc =>
+ doc.id === docId
+ ? { ...doc, progress: Math.floor(progress) }
+ : doc
+ ));
+ }
+ }, 300);
+ };
+
+ const getStatusText = (status: Document['status']) => {
+ switch (status) {
+ case 'uploading': return '上传中';
+ case 'processing': return '翻译中';
+ case 'completed': return '已完成';
+ case 'failed': return '失败';
+ default: return '';
+ }
+ };
+
+ const getStatusColor = (status: Document['status']) => {
+ switch (status) {
+ case 'uploading': return '#1890ff';
+ case 'processing': return '#fa8c16';
+ case 'completed': return '#52c41a';
+ case 'failed': return '#ff4d4f';
+ default: return '#666';
+ }
+ };
+
+ const swapLanguages = () => {
+ setSelectedLanguages({
+ from: selectedLanguages.to,
+ to: selectedLanguages.from,
+ });
+ };
+
+ const styles = {
+ container: {
+ padding: '16px',
+ backgroundColor: '#f5f5f5',
+ minHeight: '100%',
+ },
+ uploadSection: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '20px',
+ marginBottom: '20px',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ uploadTitle: {
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '16px',
+ textAlign: 'center' as const,
+ },
+ languageSelector: {
+ marginBottom: '20px',
+ },
+ languageRow: {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ marginBottom: '12px',
+ },
+ languageSelect: {
+ flex: 1,
+ padding: '12px',
+ borderRadius: '8px',
+ border: '1px solid #d9d9d9',
+ backgroundColor: 'white',
+ fontSize: '14px',
+ },
+ swapButton: {
+ margin: '0 12px',
+ padding: '8px',
+ borderRadius: '20px',
+ border: 'none',
+ backgroundColor: '#f0f8ff',
+ cursor: 'pointer',
+ fontSize: '16px',
+ },
+ uploadArea: {
+ border: '2px dashed #d9d9d9',
+ borderRadius: '8px',
+ padding: '40px 20px',
+ textAlign: 'center' as const,
+ backgroundColor: '#fafafa',
+ cursor: 'pointer',
+ transition: 'border-color 0.3s ease',
+ },
+ uploadIcon: {
+ fontSize: '48px',
+ marginBottom: '12px',
+ color: '#1890ff',
+ },
+ uploadText: {
+ fontSize: '16px',
+ color: '#666',
+ marginBottom: '8px',
+ },
+ uploadSubtext: {
+ fontSize: '14px',
+ color: '#999',
+ },
+ hiddenInput: {
+ display: 'none',
+ },
+ documentsSection: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '16px',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ sectionTitle: {
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '16px',
+ },
+ documentItem: {
+ display: 'flex',
+ alignItems: 'center',
+ padding: '16px',
+ borderRadius: '8px',
+ backgroundColor: '#f8f9fa',
+ marginBottom: '12px',
+ },
+ documentIcon: {
+ fontSize: '24px',
+ marginRight: '12px',
+ },
+ documentInfo: {
+ flex: 1,
+ },
+ documentName: {
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ color: '#333',
+ marginBottom: '4px',
+ },
+ documentDetails: {
+ fontSize: '12px',
+ color: '#666',
+ marginBottom: '4px',
+ },
+ documentLanguages: {
+ fontSize: '12px',
+ color: '#1890ff',
+ },
+ documentStatus: {
+ textAlign: 'right' as const,
+ },
+ statusText: {
+ fontSize: '12px',
+ fontWeight: '500' as const,
+ marginBottom: '4px',
+ },
+ progressBar: {
+ width: '60px',
+ height: '4px',
+ backgroundColor: '#f0f0f0',
+ borderRadius: '2px',
+ overflow: 'hidden',
+ },
+ progressFill: {
+ height: '100%',
+ backgroundColor: '#1890ff',
+ transition: 'width 0.3s ease',
+ },
+ actionButton: {
+ padding: '4px 8px',
+ borderRadius: '4px',
+ border: 'none',
+ backgroundColor: '#1890ff',
+ color: 'white',
+ fontSize: '12px',
+ cursor: 'pointer',
+ marginTop: '4px',
+ },
+ };
+
+ return (
+
+ {/* 上传区域 */}
+
+
📄 文档翻译
+
+ {/* 语言选择 */}
+
+
+
+
+
+
+
+
+
+
+ {/* 上传区域 */}
+
+
+
+ {/* 文档列表 */}
+
+
我的文档
+
+ {documents.length === 0 ? (
+
+ 暂无文档,请上传您的第一个文档
+
+ ) : (
+ documents.map((doc) => (
+
+
+ {doc.name.endsWith('.pdf') ? '📄' : '📝'}
+
+
+
+
{doc.name}
+
+ {doc.size} • {doc.uploadTime}
+
+
+ {languages.find(l => l.code === doc.originalLanguage)?.flag} → {' '}
+ {languages.find(l => l.code === doc.targetLanguage)?.flag}
+
+
+
+
+
+ {getStatusText(doc.status)}
+
+
+ {doc.status !== 'completed' && (
+
+ )}
+
+ {doc.status === 'completed' && (
+
+ )}
+
+
+ ))
+ )}
+
+
+ );
+};
+
+export default MobileDocuments;
\ No newline at end of file
diff --git a/src/pages/mobile/Home.tsx b/src/pages/mobile/Home.tsx
new file mode 100644
index 0000000..aef8896
--- /dev/null
+++ b/src/pages/mobile/Home.tsx
@@ -0,0 +1,388 @@
+import { FC, useState, useEffect } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { BillingService } from '../../services/billingService';
+import { AppointmentService } from '../../services/appointmentService';
+import { UserType, UserAccount, Appointment } from '../../types/billing';
+
+const MobileHome: FC = () => {
+ const navigate = useNavigate();
+ const [userAccount, setUserAccount] = useState(null);
+ const [upcomingAppointments, setUpcomingAppointments] = useState([]);
+ const billingService = BillingService.getInstance();
+ const appointmentService = AppointmentService.getInstance();
+
+ useEffect(() => {
+ // 模拟用户账户数据
+ const mockAccount: UserAccount = {
+ id: 'user_1',
+ userType: UserType.INDIVIDUAL,
+ balance: 5000, // 50元
+ };
+
+ billingService.setUserAccount(mockAccount);
+ setUserAccount(mockAccount);
+
+ // 获取即将到来的预约
+ const appointments = appointmentService.getUpcomingAppointments('user_1', 3);
+ setUpcomingAppointments(appointments);
+ }, []);
+
+ const quickActions = [
+ {
+ id: 1,
+ title: '语音通话',
+ description: '发起实时语音翻译通话',
+ icon: '📞',
+ color: '#52c41a',
+ action: () => navigate('/mobile/call?type=voice'),
+ },
+ {
+ id: 2,
+ title: '视频通话',
+ description: '发起视频通话和手语翻译',
+ icon: '📹',
+ color: '#1890ff',
+ action: () => navigate('/mobile/call?type=video'),
+ },
+ {
+ id: 3,
+ title: '预约通话',
+ description: '预约专业翻译员服务',
+ icon: '📅',
+ color: '#722ed1',
+ action: () => navigate('/mobile/appointment'),
+ },
+ {
+ id: 4,
+ title: '充值',
+ description: '账户余额充值',
+ icon: '💰',
+ color: '#fa8c16',
+ action: () => navigate('/mobile/recharge'),
+ },
+ ];
+
+ const recentActivities = [
+ {
+ id: 1,
+ type: 'call',
+ title: '与 John Smith 的通话',
+ time: '2小时前',
+ status: '已完成',
+ cost: '¥15.50',
+ },
+ {
+ id: 2,
+ type: 'appointment',
+ title: '商务会议翻译',
+ time: '明天 14:00',
+ status: '已预约',
+ cost: '¥180.00',
+ },
+ {
+ id: 3,
+ type: 'call',
+ title: '医疗咨询翻译',
+ time: '2天前',
+ status: '已完成',
+ cost: '¥32.00',
+ },
+ ];
+
+ const formatBalance = (balance: number) => {
+ return (balance / 100).toFixed(2);
+ };
+
+ const getActivityIcon = (type: string) => {
+ switch (type) {
+ case 'call': return '📞';
+ case 'appointment': return '📅';
+ case 'recharge': return '💰';
+ default: return '📋';
+ }
+ };
+
+ const getStatusColor = (status: string) => {
+ switch (status) {
+ case '已完成': return '#52c41a';
+ case '已预约': return '#1890ff';
+ case '进行中': return '#fa8c16';
+ case '已取消': return '#ff4d4f';
+ default: return '#666';
+ }
+ };
+
+ const styles = {
+ container: {
+ padding: '16px',
+ backgroundColor: '#f5f5f5',
+ minHeight: '100%',
+ },
+ balanceCard: {
+ backgroundColor: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
+ background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
+ borderRadius: '16px',
+ padding: '20px',
+ marginBottom: '20px',
+ color: 'white',
+ boxShadow: '0 4px 12px rgba(102, 126, 234, 0.3)',
+ },
+ balanceTitle: {
+ fontSize: '14px',
+ opacity: 0.9,
+ marginBottom: '8px',
+ },
+ balanceAmount: {
+ fontSize: '32px',
+ fontWeight: '700' as const,
+ marginBottom: '4px',
+ },
+ balanceSubtitle: {
+ fontSize: '12px',
+ opacity: 0.8,
+ },
+ userTypeTag: {
+ position: 'absolute' as const,
+ top: '16px',
+ right: '16px',
+ backgroundColor: 'rgba(255, 255, 255, 0.2)',
+ padding: '4px 8px',
+ borderRadius: '12px',
+ fontSize: '12px',
+ fontWeight: '500' as const,
+ },
+ welcomeCard: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '20px',
+ marginBottom: '20px',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ welcomeTitle: {
+ fontSize: '24px',
+ fontWeight: '600' as const,
+ color: '#1890ff',
+ marginBottom: '8px',
+ },
+ welcomeSubtitle: {
+ fontSize: '16px',
+ color: '#666',
+ marginBottom: '0',
+ },
+ sectionTitle: {
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '16px',
+ marginTop: '24px',
+ },
+ quickActionsGrid: {
+ display: 'grid',
+ gridTemplateColumns: 'repeat(2, 1fr)',
+ gap: '12px',
+ marginBottom: '24px',
+ },
+ actionCard: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '16px',
+ textAlign: 'center' as const,
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ border: 'none',
+ cursor: 'pointer',
+ transition: 'transform 0.2s ease, box-shadow 0.2s ease',
+ position: 'relative' as const,
+ },
+ actionIcon: {
+ fontSize: '32px',
+ marginBottom: '8px',
+ display: 'block',
+ },
+ actionTitle: {
+ fontSize: '14px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '4px',
+ },
+ actionDescription: {
+ fontSize: '12px',
+ color: '#666',
+ lineHeight: '1.4',
+ },
+ appointmentPreview: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '16px',
+ marginBottom: '20px',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ appointmentTitle: {
+ fontSize: '16px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '12px',
+ },
+ appointmentItem: {
+ display: 'flex',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ padding: '8px 0',
+ borderBottom: '1px solid #f0f0f0',
+ },
+ appointmentInfo: {
+ flex: 1,
+ },
+ appointmentName: {
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ color: '#333',
+ marginBottom: '2px',
+ },
+ appointmentTime: {
+ fontSize: '12px',
+ color: '#666',
+ },
+ appointmentStatus: {
+ fontSize: '12px',
+ padding: '2px 8px',
+ borderRadius: '10px',
+ backgroundColor: '#e6f7ff',
+ color: '#1890ff',
+ },
+ activityList: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ padding: '16px',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ activityItem: {
+ display: 'flex',
+ alignItems: 'center',
+ padding: '12px 0',
+ borderBottom: '1px solid #f0f0f0',
+ },
+ activityIcon: {
+ width: '40px',
+ height: '40px',
+ borderRadius: '20px',
+ backgroundColor: '#f0f8ff',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ marginRight: '12px',
+ fontSize: '18px',
+ },
+ activityContent: {
+ flex: 1,
+ },
+ activityTitle: {
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ color: '#333',
+ marginBottom: '4px',
+ },
+ activityTime: {
+ fontSize: '12px',
+ color: '#999',
+ },
+ activityRight: {
+ textAlign: 'right' as const,
+ },
+ activityStatus: {
+ fontSize: '12px',
+ fontWeight: '500' as const,
+ marginBottom: '4px',
+ },
+ activityCost: {
+ fontSize: '14px',
+ fontWeight: '600' as const,
+ color: '#333',
+ },
+ };
+
+ const handleActionPress = (action: () => void) => {
+ action();
+ };
+
+ return (
+
+ {/* 余额卡片 */}
+ {userAccount && (
+
+
+ {userAccount.userType === UserType.INDIVIDUAL ? '个人用户' : '企业用户'}
+
+
账户余额
+
¥{formatBalance(userAccount.balance)}
+
可用于通话和翻译服务
+
+ )}
+
+ {/* 快捷操作 */}
+
快捷操作
+
+ {quickActions.map((action) => (
+
+ ))}
+
+
+ {/* 即将到来的预约 */}
+ {upcomingAppointments.length > 0 && (
+
+
即将到来的预约
+ {upcomingAppointments.map((appointment) => (
+
+
+
{appointment.title}
+
+ {appointment.scheduledTime.toLocaleDateString()} {appointment.scheduledTime.toLocaleTimeString()}
+
+
+
{appointment.status}
+
+ ))}
+
+ )}
+
+ {/* 最近活动 */}
+
最近活动
+
+ {recentActivities.map((activity) => (
+
+
+ {getActivityIcon(activity.type)}
+
+
+
{activity.title}
+
{activity.time}
+
+
+
+ {activity.status}
+
+
{activity.cost}
+
+
+ ))}
+
+
+ );
+};
+
+export default MobileHome;
\ No newline at end of file
diff --git a/src/pages/mobile/Recharge.tsx b/src/pages/mobile/Recharge.tsx
new file mode 100644
index 0000000..ce70e92
--- /dev/null
+++ b/src/pages/mobile/Recharge.tsx
@@ -0,0 +1,497 @@
+import { FC, useState, useEffect } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { BillingService } from '../../services/billingService';
+import { UserAccount, UserType, RechargeRecord } from '../../types/billing';
+
+const MobileRecharge: FC = () => {
+ const navigate = useNavigate();
+ const billingService = BillingService.getInstance();
+
+ const [userAccount, setUserAccount] = useState(null);
+ const [selectedAmount, setSelectedAmount] = useState(0);
+ const [customAmount, setCustomAmount] = useState('');
+ const [selectedPayment, setSelectedPayment] = useState<'wechat' | 'alipay' | 'card'>('wechat');
+ const [rechargeHistory, setRechargeHistory] = useState([]);
+ const [isProcessing, setIsProcessing] = useState(false);
+
+ // 预设充值金额(分)
+ const presetAmounts = [
+ { value: 5000, label: '¥50', bonus: 0, popular: false },
+ { value: 10000, label: '¥100', bonus: 500, popular: true },
+ { value: 20000, label: '¥200', bonus: 1500, popular: false },
+ { value: 50000, label: '¥500', bonus: 5000, popular: false },
+ { value: 100000, label: '¥1000', bonus: 15000, popular: false },
+ ];
+
+ const paymentMethods = [
+ { id: 'wechat', name: '微信支付', icon: '💚', color: '#07c160' },
+ { id: 'alipay', name: '支付宝', icon: '💙', color: '#1677ff' },
+ { id: 'card', name: '银行卡', icon: '💳', color: '#722ed1' },
+ ];
+
+ useEffect(() => {
+ const account = billingService.getUserAccount();
+ setUserAccount(account);
+
+ // 模拟充值历史
+ const mockHistory: RechargeRecord[] = [
+ {
+ id: '1',
+ userId: account?.id || '1',
+ amount: 10000,
+ bonus: 500,
+ paymentMethod: 'wechat',
+ status: 'completed',
+ createdAt: new Date(Date.now() - 86400000), // 1天前
+ },
+ {
+ id: '2',
+ userId: account?.id || '1',
+ amount: 5000,
+ bonus: 0,
+ paymentMethod: 'alipay',
+ status: 'completed',
+ createdAt: new Date(Date.now() - 7 * 86400000), // 7天前
+ },
+ ];
+ setRechargeHistory(mockHistory);
+ }, []);
+
+ const formatCurrency = (cents: number) => {
+ return (cents / 100).toFixed(2);
+ };
+
+ const handleAmountSelect = (amount: number) => {
+ setSelectedAmount(amount);
+ setCustomAmount('');
+ };
+
+ const handleCustomAmountChange = (value: string) => {
+ const numValue = parseFloat(value);
+ if (!isNaN(numValue) && numValue > 0) {
+ setSelectedAmount(Math.round(numValue * 100));
+ setCustomAmount(value);
+ } else {
+ setSelectedAmount(0);
+ setCustomAmount(value);
+ }
+ };
+
+ const getBonus = (amount: number) => {
+ const preset = presetAmounts.find(p => p.value === amount);
+ return preset?.bonus || 0;
+ };
+
+ const getTotalAmount = () => {
+ return selectedAmount + getBonus(selectedAmount);
+ };
+
+ const handleRecharge = async () => {
+ if (selectedAmount < 100) { // 最低1元
+ alert('充值金额不能少于1元');
+ return;
+ }
+
+ if (!userAccount) {
+ alert('用户账户信息未加载');
+ return;
+ }
+
+ setIsProcessing(true);
+
+ try {
+ // 模拟支付处理
+ await new Promise(resolve => setTimeout(resolve, 2000));
+
+ // 执行充值
+ const success = billingService.rechargeAccount(selectedAmount);
+
+ if (success) {
+ // 更新用户账户
+ setUserAccount(billingService.getUserAccount());
+
+ // 添加充值记录
+ const newRecord: RechargeRecord = {
+ id: Date.now().toString(),
+ userId: userAccount.id,
+ amount: selectedAmount,
+ bonus: getBonus(selectedAmount),
+ paymentMethod: selectedPayment,
+ status: 'completed',
+ createdAt: new Date(),
+ };
+ setRechargeHistory(prev => [newRecord, ...prev]);
+
+ alert(`充值成功!到账金额:¥${formatCurrency(getTotalAmount())}`);
+ setSelectedAmount(0);
+ setCustomAmount('');
+ } else {
+ alert('充值失败,请重试');
+ }
+ } catch (error) {
+ alert('充值失败,请重试');
+ } finally {
+ setIsProcessing(false);
+ }
+ };
+
+ const getStatusColor = (status: string) => {
+ switch (status) {
+ case 'completed':
+ return '#52c41a';
+ case 'pending':
+ return '#fa8c16';
+ case 'failed':
+ return '#ff4d4f';
+ default:
+ return '#d9d9d9';
+ }
+ };
+
+ const getStatusText = (status: string) => {
+ switch (status) {
+ case 'completed':
+ return '成功';
+ case 'pending':
+ return '处理中';
+ case 'failed':
+ return '失败';
+ default:
+ return '未知';
+ }
+ };
+
+ const styles = {
+ container: {
+ padding: '16px',
+ backgroundColor: '#f5f5f5',
+ minHeight: '100vh',
+ },
+ header: {
+ display: 'flex',
+ alignItems: 'center',
+ marginBottom: '20px',
+ },
+ backButton: {
+ background: 'none',
+ border: 'none',
+ fontSize: '24px',
+ cursor: 'pointer',
+ marginRight: '12px',
+ },
+ title: {
+ fontSize: '20px',
+ fontWeight: '600' as const,
+ color: '#333',
+ },
+ balanceCard: {
+ backgroundColor: 'white',
+ borderRadius: '16px',
+ padding: '20px',
+ marginBottom: '20px',
+ textAlign: 'center' as const,
+ boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)',
+ },
+ balanceLabel: {
+ fontSize: '14px',
+ color: '#666',
+ marginBottom: '8px',
+ },
+ balanceAmount: {
+ fontSize: '32px',
+ fontWeight: '700' as const,
+ color: '#1890ff',
+ marginBottom: '8px',
+ },
+ userType: {
+ fontSize: '12px',
+ color: '#999',
+ backgroundColor: '#f0f8ff',
+ padding: '4px 12px',
+ borderRadius: '12px',
+ display: 'inline-block',
+ },
+ section: {
+ backgroundColor: 'white',
+ borderRadius: '16px',
+ padding: '20px',
+ marginBottom: '20px',
+ boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)',
+ },
+ sectionTitle: {
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '16px',
+ },
+ amountGrid: {
+ display: 'grid',
+ gridTemplateColumns: 'repeat(2, 1fr)',
+ gap: '12px',
+ marginBottom: '16px',
+ },
+ amountCard: (selected: boolean, popular: boolean) => ({
+ padding: '16px',
+ borderRadius: '12px',
+ border: selected ? '2px solid #1890ff' : '2px solid transparent',
+ backgroundColor: selected ? '#e6f7ff' : '#fafafa',
+ cursor: 'pointer',
+ textAlign: 'center' as const,
+ position: 'relative' as const,
+ ...(popular && {
+ borderColor: '#fa8c16',
+ backgroundColor: '#fff7e6',
+ }),
+ }),
+ popularBadge: {
+ position: 'absolute' as const,
+ top: '-8px',
+ right: '-8px',
+ backgroundColor: '#fa8c16',
+ color: 'white',
+ fontSize: '10px',
+ padding: '2px 6px',
+ borderRadius: '8px',
+ fontWeight: '500' as const,
+ },
+ amountValue: {
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '4px',
+ },
+ bonusText: {
+ fontSize: '12px',
+ color: '#52c41a',
+ fontWeight: '500' as const,
+ },
+ customAmountInput: {
+ width: '100%',
+ padding: '12px',
+ borderRadius: '8px',
+ border: '1px solid #d9d9d9',
+ fontSize: '16px',
+ marginBottom: '16px',
+ },
+ paymentMethods: {
+ display: 'flex',
+ gap: '12px',
+ marginBottom: '20px',
+ },
+ paymentMethod: (selected: boolean, color: string) => ({
+ flex: 1,
+ padding: '16px',
+ borderRadius: '12px',
+ border: selected ? `2px solid ${color}` : '2px solid #f0f0f0',
+ backgroundColor: selected ? `${color}10` : 'white',
+ cursor: 'pointer',
+ textAlign: 'center' as const,
+ }),
+ paymentIcon: {
+ fontSize: '24px',
+ marginBottom: '8px',
+ },
+ paymentName: {
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ color: '#333',
+ },
+ summaryCard: {
+ backgroundColor: '#f8f9fa',
+ borderRadius: '12px',
+ padding: '16px',
+ marginBottom: '20px',
+ },
+ summaryRow: {
+ display: 'flex',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ marginBottom: '8px',
+ },
+ summaryLabel: {
+ fontSize: '14px',
+ color: '#666',
+ },
+ summaryValue: {
+ fontSize: '14px',
+ fontWeight: '500' as const,
+ color: '#333',
+ },
+ totalRow: {
+ borderTop: '1px solid #e8e8e8',
+ paddingTop: '8px',
+ marginTop: '8px',
+ },
+ totalValue: {
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ color: '#1890ff',
+ },
+ rechargeButton: {
+ width: '100%',
+ padding: '16px',
+ borderRadius: '12px',
+ border: 'none',
+ backgroundColor: selectedAmount > 0 && !isProcessing ? '#1890ff' : '#d9d9d9',
+ color: 'white',
+ fontSize: '16px',
+ fontWeight: '600' as const,
+ cursor: selectedAmount > 0 && !isProcessing ? 'pointer' : 'not-allowed',
+ marginBottom: '20px',
+ },
+ historyItem: {
+ display: 'flex',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ padding: '16px 0',
+ borderBottom: '1px solid #f0f0f0',
+ },
+ historyLeft: {
+ flex: 1,
+ },
+ historyAmount: {
+ fontSize: '16px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '4px',
+ },
+ historyDate: {
+ fontSize: '12px',
+ color: '#999',
+ },
+ historyStatus: (status: string) => ({
+ fontSize: '12px',
+ fontWeight: '500' as const,
+ color: getStatusColor(status),
+ backgroundColor: `${getStatusColor(status)}15`,
+ padding: '2px 8px',
+ borderRadius: '8px',
+ }),
+ };
+
+ return (
+
+ {/* 头部 */}
+
+
+
账户充值
+
+
+ {/* 余额显示 */}
+
+
当前余额
+
+ ¥{userAccount ? formatCurrency(userAccount.balance) : '0.00'}
+
+
+ {userAccount?.userType === UserType.ENTERPRISE ? '企业用户' : '个人用户'}
+
+
+
+ {/* 充值金额选择 */}
+
+
选择充值金额
+
+ {presetAmounts.map((amount) => (
+
handleAmountSelect(amount.value)}
+ >
+ {amount.popular &&
推荐
}
+
{amount.label}
+ {amount.bonus > 0 && (
+
+ 送¥{formatCurrency(amount.bonus)}
+
+ )}
+
+ ))}
+
+
+
handleCustomAmountChange(e.target.value)}
+ />
+
+
+ {/* 支付方式 */}
+
+
选择支付方式
+
+ {paymentMethods.map((method) => (
+
setSelectedPayment(method.id as any)}
+ >
+
{method.icon}
+
{method.name}
+
+ ))}
+
+
+
+ {/* 费用明细 */}
+ {selectedAmount > 0 && (
+
+
+ 充值金额
+ ¥{formatCurrency(selectedAmount)}
+
+ {getBonus(selectedAmount) > 0 && (
+
+ 赠送金额
+
+ +¥{formatCurrency(getBonus(selectedAmount))}
+
+
+ )}
+
+ 到账金额
+ ¥{formatCurrency(getTotalAmount())}
+
+
+ )}
+
+ {/* 充值按钮 */}
+
+
+ {/* 充值历史 */}
+
+
充值记录
+ {rechargeHistory.map((record) => (
+
+
+
+ +¥{formatCurrency(record.amount + record.bonus)}
+
+
+ {record.createdAt.toLocaleDateString()} {record.createdAt.toLocaleTimeString()}
+
+
+
+ {getStatusText(record.status)}
+
+
+ ))}
+
+
+ );
+};
+
+export default MobileRecharge;
\ No newline at end of file
diff --git a/src/pages/mobile/Settings.tsx b/src/pages/mobile/Settings.tsx
new file mode 100644
index 0000000..5a4fd91
--- /dev/null
+++ b/src/pages/mobile/Settings.tsx
@@ -0,0 +1,357 @@
+import { FC, useState, useEffect } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { BillingService } from '../../services/billingService';
+import { UserAccount, UserType } from '../../types/billing';
+
+const MobileSettings: FC = () => {
+ const navigate = useNavigate();
+ const billingService = BillingService.getInstance();
+
+ const [userAccount, setUserAccount] = useState(null);
+ const [notificationSettings, setNotificationSettings] = useState({
+ callReminder: true,
+ balanceAlert: true,
+ promotions: false,
+ });
+ const [languageSettings, setLanguageSettings] = useState({
+ interface: 'zh-CN',
+ defaultSource: 'zh-CN',
+ defaultTarget: 'en-US',
+ });
+
+ useEffect(() => {
+ const account = billingService.getUserAccount();
+ setUserAccount(account);
+ }, []);
+
+ const formatCurrency = (cents: number) => {
+ return `¥${(cents / 100).toFixed(2)}`;
+ };
+
+ const getUserTypeText = (userType: UserType) => {
+ return userType === UserType.INDIVIDUAL ? '个人用户' : '企业用户';
+ };
+
+ const handleLogout = () => {
+ const confirmed = confirm('确定要退出登录吗?');
+ if (confirmed) {
+ // 这里应该清除用户登录状态
+ navigate('/login');
+ }
+ };
+
+ const settingsOptions = [
+ {
+ category: '账户信息',
+ items: [
+ {
+ label: '个人资料',
+ value: userAccount?.id || '未设置',
+ icon: '👤',
+ onClick: () => navigate('/mobile/profile'),
+ },
+ {
+ label: '账户类型',
+ value: userAccount ? getUserTypeText(userAccount.userType) : '未知',
+ icon: '🏷️',
+ onClick: () => {},
+ },
+ {
+ label: '账户余额',
+ value: userAccount ? formatCurrency(userAccount.balance) : '¥0.00',
+ icon: '💰',
+ onClick: () => navigate('/mobile/recharge'),
+ },
+ ],
+ },
+ {
+ category: '通话设置',
+ items: [
+ {
+ label: '默认通话类型',
+ value: '语音通话',
+ icon: '📞',
+ onClick: () => {},
+ },
+ {
+ label: '音质设置',
+ value: '高清',
+ icon: '🎵',
+ onClick: () => {},
+ },
+ {
+ label: '自动录音',
+ value: '关闭',
+ icon: '🎙️',
+ onClick: () => {},
+ },
+ ],
+ },
+ {
+ category: '翻译设置',
+ items: [
+ {
+ label: '默认源语言',
+ value: '中文',
+ icon: '🌐',
+ onClick: () => {},
+ },
+ {
+ label: '默认目标语言',
+ value: 'English',
+ icon: '🌍',
+ onClick: () => {},
+ },
+ {
+ label: '翻译历史',
+ value: '查看记录',
+ icon: '📝',
+ onClick: () => navigate('/mobile/translation-history'),
+ },
+ ],
+ },
+ {
+ category: '通知设置',
+ items: [
+ {
+ label: '通话提醒',
+ value: notificationSettings.callReminder ? '开启' : '关闭',
+ icon: '🔔',
+ onClick: () => setNotificationSettings(prev => ({
+ ...prev,
+ callReminder: !prev.callReminder
+ })),
+ },
+ {
+ label: '余额提醒',
+ value: notificationSettings.balanceAlert ? '开启' : '关闭',
+ icon: '⚠️',
+ onClick: () => setNotificationSettings(prev => ({
+ ...prev,
+ balanceAlert: !prev.balanceAlert
+ })),
+ },
+ {
+ label: '推广消息',
+ value: notificationSettings.promotions ? '开启' : '关闭',
+ icon: '📢',
+ onClick: () => setNotificationSettings(prev => ({
+ ...prev,
+ promotions: !prev.promotions
+ })),
+ },
+ ],
+ },
+ {
+ category: '其他',
+ items: [
+ {
+ label: '帮助中心',
+ value: '',
+ icon: '❓',
+ onClick: () => navigate('/mobile/help'),
+ },
+ {
+ label: '意见反馈',
+ value: '',
+ icon: '💬',
+ onClick: () => navigate('/mobile/feedback'),
+ },
+ {
+ label: '关于我们',
+ value: 'v1.0.0',
+ icon: 'ℹ️',
+ onClick: () => navigate('/mobile/about'),
+ },
+ {
+ label: '退出登录',
+ value: '',
+ icon: '🚪',
+ onClick: handleLogout,
+ },
+ ],
+ },
+ ];
+
+ const styles = {
+ container: {
+ backgroundColor: '#f5f5f5',
+ minHeight: '100vh',
+ paddingBottom: '80px',
+ },
+ header: {
+ backgroundColor: 'white',
+ padding: '16px',
+ display: 'flex',
+ alignItems: 'center',
+ borderBottom: '1px solid #f0f0f0',
+ },
+ backButton: {
+ background: 'none',
+ border: 'none',
+ fontSize: '24px',
+ cursor: 'pointer',
+ marginRight: '12px',
+ },
+ title: {
+ fontSize: '20px',
+ fontWeight: '600' as const,
+ color: '#333',
+ },
+ userCard: {
+ backgroundColor: 'white',
+ margin: '16px',
+ borderRadius: '16px',
+ padding: '20px',
+ display: 'flex',
+ alignItems: 'center',
+ boxShadow: '0 2px 12px rgba(0, 0, 0, 0.1)',
+ },
+ avatar: {
+ width: '60px',
+ height: '60px',
+ borderRadius: '50%',
+ backgroundColor: '#1890ff',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ fontSize: '24px',
+ color: 'white',
+ marginRight: '16px',
+ },
+ userInfo: {
+ flex: 1,
+ },
+ userName: {
+ fontSize: '18px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '4px',
+ },
+ userType: {
+ fontSize: '14px',
+ color: '#666',
+ marginBottom: '8px',
+ },
+ balance: {
+ fontSize: '16px',
+ fontWeight: '600' as const,
+ color: '#1890ff',
+ },
+ section: {
+ margin: '16px',
+ marginTop: '8px',
+ },
+ sectionTitle: {
+ fontSize: '16px',
+ fontWeight: '600' as const,
+ color: '#333',
+ marginBottom: '12px',
+ paddingLeft: '4px',
+ },
+ settingsGroup: {
+ backgroundColor: 'white',
+ borderRadius: '12px',
+ overflow: 'hidden',
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.1)',
+ },
+ settingItem: {
+ padding: '16px 20px',
+ display: 'flex',
+ alignItems: 'center',
+ borderBottom: '1px solid #f8f8f8',
+ cursor: 'pointer',
+ transition: 'background-color 0.2s',
+ },
+ settingItemLast: {
+ borderBottom: 'none',
+ },
+ settingIcon: {
+ fontSize: '20px',
+ marginRight: '12px',
+ width: '24px',
+ textAlign: 'center' as const,
+ },
+ settingContent: {
+ flex: 1,
+ display: 'flex',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ },
+ settingLabel: {
+ fontSize: '16px',
+ color: '#333',
+ },
+ settingValue: {
+ fontSize: '14px',
+ color: '#666',
+ },
+ arrow: {
+ fontSize: '12px',
+ color: '#ccc',
+ marginLeft: '8px',
+ },
+ };
+
+ return (
+
+ {/* 头部 */}
+
+
+
设置
+
+
+ {/* 用户信息卡片 */}
+
+
+ 👤
+
+
+
+ {userAccount?.id || '用户'}
+
+
+ {userAccount ? getUserTypeText(userAccount.userType) : '未知类型'}
+
+
+ 余额: {userAccount ? formatCurrency(userAccount.balance) : '¥0.00'}
+
+
+
+
+ {/* 设置选项 */}
+ {settingsOptions.map((section, sectionIndex) => (
+
+
{section.category}
+
+ {section.items.map((item, itemIndex) => (
+
+
{item.icon}
+
+
{item.label}
+
+ {item.value && (
+
{item.value}
+ )}
+
›
+
+
+
+ ))}
+
+
+ ))}
+
+ );
+};
+
+export default MobileSettings;
\ No newline at end of file
diff --git a/src/routes/index.tsx b/src/routes/index.tsx
index 910597e..7377ca4 100644
--- a/src/routes/index.tsx
+++ b/src/routes/index.tsx
@@ -3,12 +3,20 @@ import { AppLayout } from '@/components/Layout';
import { Dashboard, UserList, CallList } from '@/pages';
import { useAuth } from '@/store';
-// 导入移动端页面 - 使用Web版本
-import HomeScreen from '@/screens/HomeScreen.web';
-import CallScreen from '@/screens/CallScreen.web';
-import DocumentScreen from '@/screens/DocumentScreen.web';
-import SettingsScreen from '@/screens/SettingsScreen.web';
-import MobileNavigation from '@/components/MobileNavigation.web';
+// 导入移动端组件
+import MobileLayout from '@/components/MobileLayout';
+import MobileHome from '@/pages/mobile/Home';
+import MobileCall from '@/pages/mobile/Call';
+import MobileDocuments from '@/pages/mobile/Documents';
+import MobileSettings from '@/pages/mobile/Settings';
+import MobileRecharge from '@/pages/mobile/Recharge';
+import MobileAppointment from '@/pages/mobile/Appointment';
+
+// 导入设备重定向组件
+import DeviceRedirect from '@/components/DeviceRedirect';
+
+// 导入视频通话测试组件
+import VideoCallTest from '@/components/VideoCallTest';
// 导入视频通话页面
import { VideoCallPage } from '@/pages/VideoCall/VideoCallPage';
@@ -24,7 +32,7 @@ const PrivateRoute = ({ children }: { children: React.ReactNode }) => {
const PublicRoute = ({ children }: { children: React.ReactNode }) => {
const { isAuthenticated } = useAuth();
- return !isAuthenticated ? <>{children}> : ;
+ return !isAuthenticated ? <>{children}> : ;
};
// 登录页面(临时占位符)
@@ -57,25 +65,6 @@ const NotFoundPage = () => (
);
-// 移动端布局组件
-const MobileLayout = ({ children }: { children: React.ReactNode }) => (
-
-);
-
const AppRoutes = () => {
return (
@@ -89,6 +78,22 @@ const AppRoutes = () => {
}
/>
+ {/* 视频通话测试路由 - 独立访问 */}
+ }
+ />
+
+ {/* 根路径 - 智能重定向 */}
+
+
+
+ }
+ />
+
{/* 移动端路由 */}
{
} />
- } />
- } />
- } />
- } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
} />
@@ -115,9 +123,6 @@ const AppRoutes = () => {
- {/* 默认重定向到仪表板 */}
- } />
-
{/* 仪表板 */}
} />
@@ -127,6 +132,9 @@ const AppRoutes = () => {
{/* 通话记录 */}
} />
+ {/* 视频通话测试 */}
+ } />
+
{/* 文档管理 - 待实现 */}
void;
+ };
}
const CallScreen: React.FC = ({ route, navigation }) => {
@@ -33,14 +60,40 @@ const CallScreen: React.FC = ({ route, navigation }) => {
const [callDuration, setCallDuration] = useState(0);
const [currentCall, setCurrentCall] = useState(null);
+ // 计费相关状态
+ const [userAccount, setUserAccount] = useState(null);
+ const [currentCost, setCurrentCost] = useState(0);
+ const [billingService] = useState(() => BillingService.getInstance());
+ const [lastBillingMinute, setLastBillingMinute] = useState(0);
+
const callTimer = useRef(null);
const startTime = useRef(null);
+ const billingInterval = useRef(null);
// 从路由参数获取通话配置
const callMode = route?.params?.mode || 'ai';
const sourceLanguage = route?.params?.sourceLanguage || 'zh';
const targetLanguage = route?.params?.targetLanguage || 'en';
+ // 根据模式确定通话和翻译类型
+ const getCallType = (mode: string): CallType => {
+ return mode === 'video' || mode === 'sign' ? CallType.VIDEO : CallType.VOICE;
+ };
+
+ const getTranslationType = (mode: string): TranslationType => {
+ switch (mode) {
+ case 'sign':
+ return TranslationType.SIGN_LANGUAGE;
+ case 'human':
+ return TranslationType.HUMAN_INTERPRETER;
+ default:
+ return TranslationType.TEXT;
+ }
+ };
+
+ const callType = getCallType(callMode);
+ const translationType = getTranslationType(callMode);
+
// 获取语言信息
const getLanguageInfo = (code: string): Language | undefined => {
return mockLanguages.find(lang => lang.code === code);
@@ -49,6 +102,21 @@ const CallScreen: React.FC = ({ route, navigation }) => {
const sourceLang = getLanguageInfo(sourceLanguage);
const targetLang = getLanguageInfo(targetLanguage);
+ // 初始化用户账户
+ useEffect(() => {
+ const initUserAccount = () => {
+ const mockAccount: UserAccount = {
+ id: 'user-123',
+ userType: UserType.INDIVIDUAL,
+ balance: 10000, // 100元
+ };
+ billingService.setUserAccount(mockAccount);
+ setUserAccount(mockAccount);
+ };
+
+ initUserAccount();
+ }, [billingService]);
+
useEffect(() => {
// 模拟连接过程
connectToCall();
@@ -57,13 +125,100 @@ const CallScreen: React.FC = ({ route, navigation }) => {
if (callTimer.current) {
clearInterval(callTimer.current);
}
+ if (billingInterval.current) {
+ clearInterval(billingInterval.current);
+ }
};
}, []);
+ // 检查余额
+ const checkBalance = (): boolean => {
+ if (!userAccount) return false;
+
+ const balanceCheck = billingService.checkBalance(callType, translationType, 1);
+ if (!balanceCheck.sufficient) {
+ Alert.alert(
+ '余额不足',
+ `需要至少 ¥${(balanceCheck.requiredAmount / 100).toFixed(2)} 才能开始通话`,
+ [{ text: '确定', onPress: () => navigation?.goBack() }]
+ );
+ return false;
+ }
+
+ const shouldWarn = billingService.shouldShowLowBalanceWarning(callType, translationType);
+ if (shouldWarn) {
+ Alert.alert('提醒', '账户余额较低,请及时充值');
+ }
+
+ return true;
+ };
+
+ // 开始计费
+ const startBilling = () => {
+ startTime.current = new Date();
+
+ // 每分钟进行计费
+ billingInterval.current = setInterval(() => {
+ if (startTime.current) {
+ const currentMinute = Math.floor((Date.now() - startTime.current.getTime()) / 60000);
+ if (currentMinute > lastBillingMinute) {
+ performBilling(currentMinute);
+ setLastBillingMinute(currentMinute);
+ }
+ }
+ }, 60000);
+ };
+
+ // 执行计费
+ const performBilling = (minute: number) => {
+ if (!userAccount) return;
+
+ try {
+ const cost = billingService.calculateCallCost(callType, translationType, 1);
+ const newTotalCost = currentCost + cost;
+
+ // 检查余额是否足够继续通话
+ const balanceCheck = billingService.checkBalance(callType, translationType, 1);
+ if (!balanceCheck.sufficient) {
+ Alert.alert('余额不足', '通话即将结束', [
+ { text: '确定', onPress: () => endCall() }
+ ]);
+ return;
+ }
+
+ // 扣费
+ const deductSuccess = billingService.deductBalance(cost);
+ if (deductSuccess) {
+ setCurrentCost(newTotalCost);
+ const updatedAccount = billingService.getUserAccount();
+ setUserAccount(updatedAccount);
+
+ const shouldWarn = billingService.shouldShowLowBalanceWarning(callType, translationType);
+ if (shouldWarn) {
+ Alert.alert('提醒', '账户余额较低,请及时充值');
+ }
+ } else {
+ Alert.alert('扣费失败', '通话即将结束', [
+ { text: '确定', onPress: () => endCall() }
+ ]);
+ }
+ } catch (error) {
+ console.error('计费失败:', error);
+ Alert.alert('计费系统异常', '通话即将结束', [
+ { text: '确定', onPress: () => endCall() }
+ ]);
+ }
+ };
+
const connectToCall = async () => {
try {
setIsConnecting(true);
+ // 检查余额
+ if (!checkBalance()) {
+ return;
+ }
+
// 模拟获取Twilio token和连接过程
// const tokenResponse = await apiService.getTwilioToken(callMode);
// const callResponse = await apiService.startCall({
@@ -77,6 +232,7 @@ const CallScreen: React.FC = ({ route, navigation }) => {
setIsConnecting(false);
setIsConnected(true);
startCallTimer();
+ startBilling(); // 开始计费
// 创建模拟通话会话
const mockCall: CallSession = {
@@ -117,10 +273,14 @@ const CallScreen: React.FC = ({ route, navigation }) => {
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
};
+ const formatCost = (cents: number): string => {
+ return (cents / 100).toFixed(2);
+ };
+
const handleEndCall = () => {
Alert.alert(
'结束通话',
- '确定要结束当前通话吗?',
+ `通话时长: ${formatDuration(callDuration)}\n费用: ¥${formatCost(currentCost)}\n确定要结束当前通话吗?`,
[
{ text: '取消', style: 'cancel' },
{
@@ -139,6 +299,9 @@ const CallScreen: React.FC = ({ route, navigation }) => {
if (callTimer.current) {
clearInterval(callTimer.current);
}
+ if (billingInterval.current) {
+ clearInterval(billingInterval.current);
+ }
// 在实际应用中调用API结束通话
// if (currentCall) {
@@ -196,19 +359,21 @@ const CallScreen: React.FC = ({ route, navigation }) => {
- 📞
- 正在连接...
-
- {getModeTitle(callMode)}
+ 正在连接...
+ {getModeTitle(callMode)}
+
+ {sourceLang?.nativeName} → {targetLang?.nativeName}
-
-
- {sourceLang?.flag} {sourceLang?.nativeName} → {targetLang?.flag} {targetLang?.nativeName}
-
-
- navigation?.goBack()}>
- 取消
-
+ {userAccount && (
+
+
+ 账户余额: ¥{formatCost(userAccount.balance)}
+
+
+ 费率: ¥{formatCost(billingService.calculateCallCost(callType, translationType, 1))}/分钟
+
+
+ )}
);
@@ -229,7 +394,15 @@ const CallScreen: React.FC = ({ route, navigation }) => {
- {formatDuration(callDuration)}
+
+ {formatDuration(callDuration)}
+ ¥{formatCost(currentCost)}
+ {userAccount && (
+
+ 余额: ¥{formatCost(userAccount.balance)}
+
+ )}
+
{/* 视频区域 */}
@@ -265,31 +438,31 @@ const CallScreen: React.FC = ({ route, navigation }) => {
{/* 控制按钮 */}
- {isMuted ? '🔇' : '🔊'}
+ {isMuted ? '🔇' : '🎤'}
+
+ 📞
+
+
{(callMode === 'video' || callMode === 'sign') && (
- {isVideoEnabled ? '📹' : '📵'}
+ {isVideoEnabled ? '📹' : '📷'}
)}
-
-
- 📞
-
);
@@ -304,82 +477,87 @@ const styles = StyleSheet.create({
flex: 1,
justifyContent: 'center',
alignItems: 'center',
- padding: 32,
+ padding: 20,
},
- connectingIcon: {
- fontSize: 80,
- marginBottom: 24,
- },
- connectingTitle: {
+ connectingText: {
fontSize: 24,
- fontWeight: 'bold',
color: '#fff',
- marginBottom: 8,
- textAlign: 'center',
+ marginBottom: 20,
},
- connectingSubtitle: {
- fontSize: 16,
+ modeText: {
+ fontSize: 18,
color: '#ccc',
- marginBottom: 32,
- textAlign: 'center',
+ marginBottom: 10,
},
- languageInfo: {
+ languageText: {
+ fontSize: 16,
+ color: '#999',
+ marginBottom: 20,
+ },
+ balanceInfo: {
backgroundColor: 'rgba(255, 255, 255, 0.1)',
padding: 16,
borderRadius: 12,
marginBottom: 32,
},
- languageText: {
+ balanceText: {
fontSize: 18,
color: '#fff',
textAlign: 'center',
},
- cancelButton: {
- backgroundColor: '#F44336',
- paddingHorizontal: 32,
- paddingVertical: 12,
- borderRadius: 24,
- },
- cancelButtonText: {
- color: '#fff',
+ rateText: {
fontSize: 16,
- fontWeight: 'bold',
+ color: '#ccc',
+ textAlign: 'center',
},
topBar: {
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
- padding: 16,
- backgroundColor: 'rgba(0, 0, 0, 0.3)',
+ padding: 20,
+ backgroundColor: 'rgba(255, 255, 255, 0.1)',
},
callInfo: {
flexDirection: 'row',
alignItems: 'center',
+ flex: 1,
},
modeIcon: {
- fontSize: 32,
+ fontSize: 24,
marginRight: 12,
},
callDetails: {
flex: 1,
},
callTitle: {
- fontSize: 16,
+ fontSize: 18,
fontWeight: 'bold',
color: '#fff',
- marginBottom: 2,
},
languagesText: {
fontSize: 14,
color: '#ccc',
},
+ callStats: {
+ alignItems: 'flex-end',
+ },
duration: {
+ fontSize: 24,
+ fontWeight: 'bold',
+ color: '#fff',
+ },
+ cost: {
fontSize: 18,
fontWeight: 'bold',
color: '#4CAF50',
},
+ balance: {
+ fontSize: 14,
+ color: '#ccc',
+ },
videoContainer: {
flex: 1,
+ padding: 20,
},
videoArea: {
flex: 1,
@@ -388,13 +566,15 @@ const styles = StyleSheet.create({
remoteVideo: {
flex: 1,
backgroundColor: '#333',
+ borderRadius: 12,
justifyContent: 'center',
alignItems: 'center',
+ marginBottom: 20,
},
localVideo: {
position: 'absolute',
- top: 16,
- right: 16,
+ top: 20,
+ right: 20,
width: 120,
height: 160,
backgroundColor: '#555',
@@ -403,9 +583,8 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
videoPlaceholder: {
- color: '#ccc',
+ color: '#fff',
fontSize: 16,
- textAlign: 'center',
},
audioOnlyArea: {
flex: 1,
@@ -413,52 +592,59 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
audioIcon: {
- fontSize: 120,
- marginBottom: 24,
+ fontSize: 80,
+ marginBottom: 20,
},
audioTitle: {
- fontSize: 20,
- fontWeight: 'bold',
+ fontSize: 24,
color: '#fff',
- marginBottom: 32,
- textAlign: 'center',
+ marginBottom: 40,
},
waveform: {
flexDirection: 'row',
- alignItems: 'flex-end',
- height: 60,
+ alignItems: 'center',
+ justifyContent: 'center',
+ gap: 4,
},
waveBar: {
width: 4,
backgroundColor: '#4CAF50',
- marginHorizontal: 2,
borderRadius: 2,
},
controlsContainer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
- padding: 32,
- backgroundColor: 'rgba(0, 0, 0, 0.3)',
+ paddingHorizontal: 40,
+ paddingBottom: 40,
+ gap: 40,
},
controlButton: {
- width: 64,
- height: 64,
- borderRadius: 32,
+ width: 60,
+ height: 60,
+ borderRadius: 30,
backgroundColor: 'rgba(255, 255, 255, 0.2)',
justifyContent: 'center',
alignItems: 'center',
- marginHorizontal: 16,
},
- controlButtonActive: {
+ mutedButton: {
backgroundColor: '#F44336',
},
controlButtonText: {
fontSize: 24,
},
endCallButton: {
+ width: 80,
+ height: 80,
+ borderRadius: 40,
backgroundColor: '#F44336',
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
+ endCallButtonText: {
+ fontSize: 32,
+ transform: [{ rotate: '135deg' }],
},
});
-export default CallScreen;
\ No newline at end of file
+export default CallScreen;
diff --git a/src/services/appointmentService.ts b/src/services/appointmentService.ts
new file mode 100644
index 0000000..4d4359d
--- /dev/null
+++ b/src/services/appointmentService.ts
@@ -0,0 +1,229 @@
+import {
+ Appointment,
+ CallType,
+ TranslationType,
+ Interpreter
+} from '../types/billing';
+
+export class AppointmentService {
+ private static instance: AppointmentService;
+ private appointments: Appointment[] = [];
+ private interpreters: Interpreter[] = [];
+
+ private constructor() {
+ this.initializeMockData();
+ }
+
+ public static getInstance(): AppointmentService {
+ if (!AppointmentService.instance) {
+ AppointmentService.instance = new AppointmentService();
+ }
+ return AppointmentService.instance;
+ }
+
+ // 初始化模拟数据
+ private initializeMockData() {
+ // 模拟翻译员数据
+ this.interpreters = [
+ {
+ id: 'interpreter_1',
+ name: '张翻译',
+ avatar: '👩💼',
+ languages: ['zh-CN', 'en-US'],
+ specialties: ['商务', '法律'],
+ rating: 4.8,
+ pricePerMinute: 150,
+ availability: {},
+ isOnline: true,
+ },
+ {
+ id: 'interpreter_2',
+ name: '李翻译',
+ avatar: '👨💼',
+ languages: ['zh-CN', 'ja-JP'],
+ specialties: ['医疗', '技术'],
+ rating: 4.9,
+ pricePerMinute: 180,
+ availability: {},
+ isOnline: false,
+ },
+ {
+ id: 'interpreter_3',
+ name: '王翻译',
+ avatar: '👩🏫',
+ languages: ['zh-CN', 'ko-KR'],
+ specialties: ['教育', '文化'],
+ rating: 4.7,
+ pricePerMinute: 120,
+ availability: {},
+ isOnline: true,
+ },
+ ];
+
+ // 模拟预约数据
+ this.appointments = [
+ {
+ id: 'appointment_1',
+ userId: 'user_1',
+ title: '商务会议翻译',
+ description: '与韩国客户的商务洽谈',
+ scheduledTime: new Date(Date.now() + 24 * 60 * 60 * 1000), // 明天
+ duration: 60,
+ callType: CallType.VIDEO,
+ translationType: TranslationType.HUMAN_INTERPRETER,
+ interpreterIds: ['interpreter_3'],
+ estimatedCost: 18000, // 180元
+ status: 'scheduled',
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ },
+ {
+ id: 'appointment_2',
+ userId: 'user_1',
+ title: '医疗咨询',
+ description: '日语医疗咨询翻译',
+ scheduledTime: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000), // 3天后
+ duration: 30,
+ callType: CallType.VIDEO,
+ translationType: TranslationType.HUMAN_INTERPRETER,
+ interpreterIds: ['interpreter_2'],
+ estimatedCost: 5400, // 54元
+ status: 'confirmed',
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ },
+ ];
+ }
+
+ // 创建预约
+ createAppointment(appointmentData: Omit): Appointment {
+ const appointment: Appointment = {
+ ...appointmentData,
+ id: `appointment_${Date.now()}`,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ };
+
+ this.appointments.push(appointment);
+ return appointment;
+ }
+
+ // 获取用户预约列表
+ getUserAppointments(userId: string): Appointment[] {
+ return this.appointments.filter(appointment => appointment.userId === userId);
+ }
+
+ // 获取指定日期的预约
+ getAppointmentsByDate(userId: string, date: Date): Appointment[] {
+ const targetDate = new Date(date);
+ targetDate.setHours(0, 0, 0, 0);
+ const nextDate = new Date(targetDate);
+ nextDate.setDate(nextDate.getDate() + 1);
+
+ return this.appointments.filter(appointment =>
+ appointment.userId === userId &&
+ appointment.scheduledTime >= targetDate &&
+ appointment.scheduledTime < nextDate
+ );
+ }
+
+ // 获取指定月份的预约
+ getAppointmentsByMonth(userId: string, year: number, month: number): Appointment[] {
+ return this.appointments.filter(appointment => {
+ const appointmentDate = new Date(appointment.scheduledTime);
+ return appointment.userId === userId &&
+ appointmentDate.getFullYear() === year &&
+ appointmentDate.getMonth() === month;
+ });
+ }
+
+ // 更新预约状态
+ updateAppointmentStatus(appointmentId: string, status: Appointment['status']): boolean {
+ const appointment = this.appointments.find(a => a.id === appointmentId);
+ if (appointment) {
+ appointment.status = status;
+ appointment.updatedAt = new Date();
+ return true;
+ }
+ return false;
+ }
+
+ // 取消预约
+ cancelAppointment(appointmentId: string): boolean {
+ return this.updateAppointmentStatus(appointmentId, 'cancelled');
+ }
+
+ // 获取可用翻译员
+ getAvailableInterpreters(
+ date: Date,
+ languages: string[],
+ specialty?: string
+ ): Interpreter[] {
+ const dateKey = date.toISOString().split('T')[0];
+
+ return this.interpreters.filter(interpreter => {
+ // 检查语言支持
+ const hasLanguage = languages.some(lang => interpreter.languages.includes(lang));
+
+ // 检查专业领域
+ const hasSpecialty = !specialty || interpreter.specialties.includes(specialty);
+
+ // 检查可用性(简化版,实际应该检查具体时间段)
+ const isAvailable = interpreter.availability[dateKey] !== false;
+
+ return hasLanguage && hasSpecialty && isAvailable;
+ });
+ }
+
+ // 获取翻译员信息
+ getInterpreter(interpreterId: string): Interpreter | null {
+ return this.interpreters.find(interpreter => interpreter.id === interpreterId) || null;
+ }
+
+ // 获取所有翻译员
+ getAllInterpreters(): Interpreter[] {
+ return this.interpreters;
+ }
+
+ // 检查时间段是否可用
+ isTimeSlotAvailable(date: Date, duration: number, interpreterIds?: string[]): boolean {
+ const endTime = new Date(date.getTime() + duration * 60 * 1000);
+
+ // 检查是否与现有预约冲突
+ const conflicts = this.appointments.filter(appointment => {
+ if (appointment.status === 'cancelled') return false;
+
+ const appointmentStart = new Date(appointment.scheduledTime);
+ const appointmentEnd = new Date(appointmentStart.getTime() + appointment.duration * 60 * 1000);
+
+ // 检查时间是否重叠
+ const timeOverlap = date < appointmentEnd && endTime > appointmentStart;
+
+ // 如果指定了翻译员,检查翻译员是否冲突
+ const interpreterConflict = interpreterIds && appointment.interpreterIds &&
+ interpreterIds.some(id => appointment.interpreterIds!.includes(id));
+
+ return timeOverlap && (!interpreterIds || interpreterConflict);
+ });
+
+ return conflicts.length === 0;
+ }
+
+ // 获取预约详情
+ getAppointment(appointmentId: string): Appointment | null {
+ return this.appointments.find(appointment => appointment.id === appointmentId) || null;
+ }
+
+ // 获取即将到来的预约
+ getUpcomingAppointments(userId: string, limit: number = 5): Appointment[] {
+ const now = new Date();
+ return this.appointments
+ .filter(appointment =>
+ appointment.userId === userId &&
+ appointment.scheduledTime > now &&
+ appointment.status !== 'cancelled'
+ )
+ .sort((a, b) => a.scheduledTime.getTime() - b.scheduledTime.getTime())
+ .slice(0, limit);
+ }
+}
\ No newline at end of file
diff --git a/src/services/billingService.ts b/src/services/billingService.ts
new file mode 100644
index 0000000..ff753a1
--- /dev/null
+++ b/src/services/billingService.ts
@@ -0,0 +1,217 @@
+import {
+ UserType,
+ CallType,
+ TranslationType,
+ BillingRule,
+ UserAccount,
+ CallRecord,
+ BILLING_CONFIG
+} from '../types/billing';
+
+export class BillingService {
+ private static instance: BillingService;
+ private billingRules: BillingRule[] = [];
+ private userAccount: UserAccount | null = null;
+
+ private constructor() {
+ this.initializeDefaultRules();
+ }
+
+ public static getInstance(): BillingService {
+ if (!BillingService.instance) {
+ BillingService.instance = new BillingService();
+ }
+ return BillingService.instance;
+ }
+
+ // 初始化默认计费规则
+ private initializeDefaultRules() {
+ this.billingRules = [
+ // 普通用户规则
+ {
+ id: 'individual_voice_text',
+ name: '语音通话+文字翻译',
+ callType: CallType.VOICE,
+ translationType: TranslationType.TEXT,
+ pricePerMinute: 50,
+ minimumCharge: 50,
+ userType: UserType.INDIVIDUAL,
+ },
+ {
+ id: 'individual_video_sign',
+ name: '视频通话+手语翻译',
+ callType: CallType.VIDEO,
+ translationType: TranslationType.SIGN_LANGUAGE,
+ pricePerMinute: 100,
+ minimumCharge: 100,
+ userType: UserType.INDIVIDUAL,
+ },
+ {
+ id: 'individual_video_human',
+ name: '视频通话+真人翻译',
+ callType: CallType.VIDEO,
+ translationType: TranslationType.HUMAN_INTERPRETER,
+ pricePerMinute: 200,
+ minimumCharge: 200,
+ userType: UserType.INDIVIDUAL,
+ },
+ // 企业用户规则(相同但可能有优惠)
+ {
+ id: 'enterprise_voice_text',
+ name: '语音通话+文字翻译',
+ callType: CallType.VOICE,
+ translationType: TranslationType.TEXT,
+ pricePerMinute: 40, // 企业优惠价
+ minimumCharge: 40,
+ userType: UserType.ENTERPRISE,
+ },
+ {
+ id: 'enterprise_video_sign',
+ name: '视频通话+手语翻译',
+ callType: CallType.VIDEO,
+ translationType: TranslationType.SIGN_LANGUAGE,
+ pricePerMinute: 80,
+ minimumCharge: 80,
+ userType: UserType.ENTERPRISE,
+ },
+ {
+ id: 'enterprise_video_human',
+ name: '视频通话+真人翻译',
+ callType: CallType.VIDEO,
+ translationType: TranslationType.HUMAN_INTERPRETER,
+ pricePerMinute: 160,
+ minimumCharge: 160,
+ userType: UserType.ENTERPRISE,
+ },
+ ];
+ }
+
+ // 设置用户账户
+ setUserAccount(account: UserAccount) {
+ this.userAccount = account;
+ }
+
+ // 获取用户账户
+ getUserAccount(): UserAccount | null {
+ return this.userAccount;
+ }
+
+ // 获取计费规则
+ getBillingRule(callType: CallType, translationType: TranslationType, userType: UserType): BillingRule | null {
+ return this.billingRules.find(rule =>
+ rule.callType === callType &&
+ rule.translationType === translationType &&
+ rule.userType === userType
+ ) || null;
+ }
+
+ // 计算通话费用
+ calculateCallCost(
+ callType: CallType,
+ translationType: TranslationType,
+ durationMinutes: number,
+ interpreterRate?: number
+ ): number {
+ if (!this.userAccount) return 0;
+
+ const rule = this.getBillingRule(callType, translationType, this.userAccount.userType);
+ if (!rule) return 0;
+
+ // 向上取整分钟数
+ const roundedMinutes = Math.ceil(durationMinutes);
+
+ // 基础费用
+ let baseCost = Math.max(roundedMinutes * rule.pricePerMinute, rule.minimumCharge);
+
+ // 如果有翻译员费用,额外计算
+ let interpreterCost = 0;
+ if (interpreterRate && translationType === TranslationType.HUMAN_INTERPRETER) {
+ interpreterCost = roundedMinutes * interpreterRate;
+ }
+
+ return baseCost + interpreterCost;
+ }
+
+ // 检查余额是否足够
+ checkBalance(
+ callType: CallType,
+ translationType: TranslationType,
+ minutes: number = 1,
+ interpreterRate?: number
+ ): {
+ sufficient: boolean;
+ requiredAmount: number;
+ currentBalance: number;
+ } {
+ if (!this.userAccount) {
+ return { sufficient: false, requiredAmount: 0, currentBalance: 0 };
+ }
+
+ const requiredAmount = this.calculateCallCost(callType, translationType, minutes, interpreterRate);
+
+ return {
+ sufficient: this.userAccount.balance >= requiredAmount,
+ requiredAmount,
+ currentBalance: this.userAccount.balance,
+ };
+ }
+
+ // 检查是否需要低余额警告
+ shouldShowLowBalanceWarning(
+ callType: CallType,
+ translationType: TranslationType,
+ interpreterRate?: number
+ ): boolean {
+ const thresholdCost = this.calculateCallCost(
+ callType,
+ translationType,
+ BILLING_CONFIG.LOW_BALANCE_THRESHOLD_MINUTES,
+ interpreterRate
+ );
+
+ return this.userAccount ? this.userAccount.balance < thresholdCost : true;
+ }
+
+ // 扣费
+ deductBalance(amount: number): boolean {
+ if (!this.userAccount || this.userAccount.balance < amount) {
+ return false;
+ }
+
+ this.userAccount.balance -= amount;
+ return true;
+ }
+
+ // 充值
+ recharge(amount: number): void {
+ if (this.userAccount) {
+ this.userAccount.balance += amount;
+ }
+ }
+
+ // 格式化金额(分转元)
+ formatAmount(cents: number): string {
+ return `¥${(cents / 100).toFixed(2)}`;
+ }
+
+ // 获取所有计费规则
+ getAllBillingRules(): BillingRule[] {
+ return this.billingRules;
+ }
+
+ // 获取用户可用的计费规则
+ getUserBillingRules(): BillingRule[] {
+ if (!this.userAccount) return [];
+ return this.billingRules.filter(rule => rule.userType === this.userAccount!.userType);
+ }
+
+ // 充值账户
+ rechargeAccount(amount: number): boolean {
+ if (!this.userAccount || amount <= 0) {
+ return false;
+ }
+
+ this.userAccount.balance += amount;
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/types/billing.ts b/src/types/billing.ts
new file mode 100644
index 0000000..9dcc2b5
--- /dev/null
+++ b/src/types/billing.ts
@@ -0,0 +1,121 @@
+// 用户类型
+export enum UserType {
+ INDIVIDUAL = 'individual', // 普通用户
+ ENTERPRISE = 'enterprise', // 企业用户
+}
+
+// 通话类型
+export enum CallType {
+ VOICE = 'voice', // 语音通话
+ VIDEO = 'video', // 视频通话
+}
+
+// 翻译类型
+export enum TranslationType {
+ TEXT = 'text', // 文字翻译
+ SIGN_LANGUAGE = 'sign_language', // 手语翻译
+ HUMAN_INTERPRETER = 'human_interpreter', // 真人翻译
+}
+
+// 计费规则
+export interface BillingRule {
+ id: string;
+ name: string;
+ callType: CallType;
+ translationType: TranslationType;
+ pricePerMinute: number; // 每分钟价格(分)
+ minimumCharge: number; // 最低收费(分)
+ userType: UserType;
+}
+
+// 用户账户信息
+export interface UserAccount {
+ id: string;
+ userType: UserType;
+ balance: number; // 余额(分)
+ enterpriseContractId?: string; // 企业合同ID
+ creditLimit?: number; // 信用额度(分)
+}
+
+// 预约信息
+export interface Appointment {
+ id: string;
+ userId: string;
+ title: string;
+ description?: string;
+ scheduledTime: Date;
+ duration: number; // 预计时长(分钟)
+ callType: CallType;
+ translationType: TranslationType;
+ interpreterIds?: string[]; // 翻译员ID列表
+ estimatedCost: number; // 预估费用(分)
+ status: 'scheduled' | 'confirmed' | 'in_progress' | 'completed' | 'cancelled';
+ createdAt: Date;
+ updatedAt: Date;
+}
+
+// 翻译员信息
+export interface Interpreter {
+ id: string;
+ name: string;
+ avatar?: string;
+ languages: string[]; // 支持的语言
+ specialties: string[]; // 专业领域
+ rating: number; // 评分
+ pricePerMinute: number; // 每分钟价格(分)
+ availability: {
+ [key: string]: boolean; // 日期可用性
+ };
+ isOnline: boolean;
+}
+
+// 通话记录
+export interface CallRecord {
+ id: string;
+ userId: string;
+ appointmentId?: string;
+ callType: CallType;
+ translationType: TranslationType;
+ interpreterIds?: string[];
+ startTime: Date;
+ endTime?: Date;
+ duration: number; // 实际时长(分钟)
+ cost: number; // 实际费用(分)
+ status: 'in_progress' | 'completed' | 'failed';
+ billingDetails: {
+ baseRate: number;
+ interpreterRate?: number;
+ totalMinutes: number;
+ totalCost: number;
+ };
+}
+
+// 充值记录
+export interface RechargeRecord {
+ id: string;
+ userId: string;
+ amount: number; // 充值金额(分)
+ bonus: number; // 赠送金额(分)
+ paymentMethod: string;
+ status: 'pending' | 'completed' | 'failed';
+ createdAt: Date;
+ completedAt?: Date;
+}
+
+// 计费配置
+export const BILLING_CONFIG = {
+ // 默认计费规则
+ DEFAULT_RATES: {
+ [CallType.VOICE]: {
+ [TranslationType.TEXT]: 50, // 0.5元/分钟
+ },
+ [CallType.VIDEO]: {
+ [TranslationType.SIGN_LANGUAGE]: 100, // 1元/分钟
+ [TranslationType.HUMAN_INTERPRETER]: 200, // 2元/分钟
+ },
+ },
+ // 低余额警告阈值(5分钟费用)
+ LOW_BALANCE_THRESHOLD_MINUTES: 5,
+ // 最低余额阈值(1分钟费用)
+ MINIMUM_BALANCE_THRESHOLD_MINUTES: 1,
+};
\ No newline at end of file
diff --git a/src/utils/deviceDetection.ts b/src/utils/deviceDetection.ts
new file mode 100644
index 0000000..33ae42d
--- /dev/null
+++ b/src/utils/deviceDetection.ts
@@ -0,0 +1,63 @@
+/**
+ * 检测是否为移动设备
+ */
+export const isMobileDevice = (): boolean => {
+ // 检查用户代理字符串
+ const userAgent = navigator.userAgent;
+ const mobileKeywords = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
+ const isMobileUA = mobileKeywords.test(userAgent);
+
+ // 检查屏幕尺寸
+ const isSmallScreen = window.innerWidth <= 768;
+
+ // 检查触摸支持
+ const hasTouchSupport = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
+
+ return isMobileUA || (isSmallScreen && hasTouchSupport);
+};
+
+/**
+ * 检测是否为平板设备
+ */
+export const isTabletDevice = (): boolean => {
+ const userAgent = navigator.userAgent;
+ const tabletKeywords = /iPad|Android(?!.*Mobile)/i;
+ const isTabletUA = tabletKeywords.test(userAgent);
+
+ const isMediumScreen = window.innerWidth > 768 && window.innerWidth <= 1024;
+
+ return isTabletUA || isMediumScreen;
+};
+
+/**
+ * 获取设备类型
+ */
+export const getDeviceType = (): 'mobile' | 'tablet' | 'desktop' => {
+ if (isMobileDevice()) {
+ return 'mobile';
+ }
+ if (isTabletDevice()) {
+ return 'tablet';
+ }
+ return 'desktop';
+};
+
+/**
+ * 获取推荐的路由路径
+ */
+export const getRecommendedRoute = (): string => {
+ // 暂时让所有设备都重定向到移动端首页,方便测试
+ return '/mobile/home';
+
+ // 原来的逻辑保留备用
+ // const deviceType = getDeviceType();
+ //
+ // switch (deviceType) {
+ // case 'mobile':
+ // case 'tablet':
+ // return '/mobile/home';
+ // case 'desktop':
+ // default:
+ // return '/dashboard';
+ // }
+};
\ No newline at end of file
diff --git a/start-servers.ps1 b/start-servers.ps1
new file mode 100644
index 0000000..a8c7813
--- /dev/null
+++ b/start-servers.ps1
@@ -0,0 +1,69 @@
+# Twilio视频通话服务启动脚本
+Write-Host "🚀 启动 Twilio 视频通话服务..." -ForegroundColor Green
+
+# 检查Node.js是否安装
+if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
+ Write-Host "❌ 错误: 未找到 Node.js,请先安装 Node.js" -ForegroundColor Red
+ exit 1
+}
+
+# 检查npm是否安装
+if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
+ Write-Host "❌ 错误: 未找到 npm,请先安装 npm" -ForegroundColor Red
+ exit 1
+}
+
+Write-Host "📦 检查并安装依赖..." -ForegroundColor Yellow
+
+# 安装前端依赖
+Write-Host "安装前端依赖..." -ForegroundColor Cyan
+if (-not (Test-Path "node_modules")) {
+ npm install
+}
+
+# 安装后端依赖
+Write-Host "安装后端依赖..." -ForegroundColor Cyan
+if (-not (Test-Path "server/node_modules")) {
+ Set-Location server
+ npm install
+ Set-Location ..
+}
+
+Write-Host "🎬 启动服务器..." -ForegroundColor Green
+
+# 启动后端Token服务器
+Write-Host "启动 Twilio Token 服务器 (端口 3001)..." -ForegroundColor Cyan
+Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd server; npm start" -WindowStyle Normal
+
+# 等待2秒让后端启动
+Start-Sleep -Seconds 2
+
+# 启动前端开发服务器
+Write-Host "启动前端开发服务器 (端口 5175)..." -ForegroundColor Cyan
+Start-Process powershell -ArgumentList "-NoExit", "-Command", "npm run dev" -WindowStyle Normal
+
+# 等待3秒让服务器启动
+Start-Sleep -Seconds 3
+
+Write-Host ""
+Write-Host "✅ 服务启动完成!" -ForegroundColor Green
+Write-Host ""
+Write-Host "📋 访问地址:" -ForegroundColor Yellow
+Write-Host " 前端应用: http://localhost:5175" -ForegroundColor White
+Write-Host " 视频测试: http://localhost:5175/video-test" -ForegroundColor White
+Write-Host " 后端API: http://localhost:3001" -ForegroundColor White
+Write-Host " 健康检查: http://localhost:3001/health" -ForegroundColor White
+Write-Host ""
+Write-Host "🧪 测试步骤:" -ForegroundColor Yellow
+Write-Host " 1. 访问 http://localhost:5175/video-test" -ForegroundColor White
+Write-Host " 2. 填写房间名称和用户身份" -ForegroundColor White
+Write-Host " 3. 点击'加入通话'按钮" -ForegroundColor White
+Write-Host " 4. 在新标签页中重复步骤1-3测试多人通话" -ForegroundColor White
+Write-Host ""
+Write-Host "⚠️ 注意事项:" -ForegroundColor Red
+Write-Host " - 确保已配置正确的 Twilio 凭证" -ForegroundColor White
+Write-Host " - 允许浏览器访问摄像头和麦克风" -ForegroundColor White
+Write-Host " - 使用 HTTPS 或 localhost 以获得最佳体验" -ForegroundColor White
+Write-Host ""
+Write-Host "按任意键退出..." -ForegroundColor Gray
+$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
\ No newline at end of file
diff --git a/start-services.ps1 b/start-services.ps1
new file mode 100644
index 0000000..e06ff64
--- /dev/null
+++ b/start-services.ps1
@@ -0,0 +1,63 @@
+# Twilio 视频通话服务启动脚本
+# 使用方法: .\start-services.ps1
+
+Write-Host "🚀 启动 Twilio 视频通话服务..." -ForegroundColor Green
+Write-Host ""
+
+# 检查 Node.js 是否安装
+if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
+ Write-Host "❌ 错误: 未找到 Node.js,请先安装 Node.js" -ForegroundColor Red
+ exit 1
+}
+
+# 检查 npm 是否安装
+if (-not (Get-Command npm -ErrorAction SilentlyContinue)) {
+ Write-Host "❌ 错误: 未找到 npm,请先安装 npm" -ForegroundColor Red
+ exit 1
+}
+
+Write-Host "✅ Node.js 和 npm 已安装" -ForegroundColor Green
+
+# 启动后端服务器
+Write-Host ""
+Write-Host "🔧 启动后端 Token 服务器..." -ForegroundColor Yellow
+Write-Host "端口: 3001" -ForegroundColor Cyan
+
+Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd server; npm install; npm start" -WindowStyle Normal
+
+# 等待后端服务器启动
+Write-Host "⏳ 等待后端服务器启动..." -ForegroundColor Yellow
+Start-Sleep -Seconds 3
+
+# 启动前端应用
+Write-Host ""
+Write-Host "🔧 启动前端应用..." -ForegroundColor Yellow
+Write-Host "端口: 5173" -ForegroundColor Cyan
+
+Start-Process powershell -ArgumentList "-NoExit", "-Command", "npm install; npm run dev" -WindowStyle Normal
+
+# 等待前端应用启动
+Write-Host "⏳ 等待前端应用启动..." -ForegroundColor Yellow
+Start-Sleep -Seconds 5
+
+Write-Host ""
+Write-Host "🎉 服务启动完成!" -ForegroundColor Green
+Write-Host ""
+Write-Host "📋 访问地址:" -ForegroundColor Cyan
+Write-Host " • 前端应用: http://localhost:5173" -ForegroundColor White
+Write-Host " • 后端 API: http://localhost:3001" -ForegroundColor White
+Write-Host " • 健康检查: http://localhost:3001/health" -ForegroundColor White
+Write-Host ""
+Write-Host "🧪 测试页面:" -ForegroundColor Cyan
+Write-Host " • 设备测试: http://localhost:5173/device-test" -ForegroundColor White
+Write-Host " • 视频通话: http://localhost:5173/video-call" -ForegroundColor White
+Write-Host ""
+Write-Host "⚠️ 注意事项:" -ForegroundColor Yellow
+Write-Host " 1. 确保已配置正确的 Twilio 凭证" -ForegroundColor White
+Write-Host " 2. 浏览器需要允许摄像头和麦克风权限" -ForegroundColor White
+Write-Host " 3. 建议使用 Chrome 浏览器进行测试" -ForegroundColor White
+Write-Host ""
+Write-Host "📖 详细测试指南请查看: TWILIO_TEST_GUIDE.md" -ForegroundColor Cyan
+Write-Host ""
+Write-Host "按任意键退出..." -ForegroundColor Gray
+$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
\ No newline at end of file
diff --git a/test-status.html b/test-status.html
new file mode 100644
index 0000000..ed07eb8
--- /dev/null
+++ b/test-status.html
@@ -0,0 +1,263 @@
+
+
+
+
+
+ Twilio 视频通话服务状态检查
+
+
+
+
+
🎥 Twilio 视频通话服务状态
+
+
+
后端 Token 服务器 (localhost:3001)
+
+ 检查中...
+
+
+
+
+
+
前端应用 (localhost:5173)
+
+ 检查中...
+
+
+
+
+
+
摄像头权限
+
+ 未检查
+
+
+
+
+
+
麦克风权限
+
+ 未检查
+
+
+
+
+
+
📋 快速测试指南
+
+ - 步骤 1: 确保所有服务状态显示为"正常"
+ - 步骤 2: 点击"检查权限"按钮允许摄像头和麦克风访问
+ - 步骤 3: 使用下方的快速链接访问测试页面
+ - 步骤 4: 在两个不同的浏览器标签页中测试多人通话
+
+
+
+
+
+
+
⚠️ 注意事项
+
+ - 确保在
server/index.js
中配置了正确的 Twilio 凭证
+ - 建议使用 Chrome 浏览器进行测试
+ - 如果遇到 CORS 错误,请检查服务器配置
+ - 生产环境需要 HTTPS 才能访问摄像头和麦克风
+
+
+
+
+
+
+
\ No newline at end of file