优化
This commit is contained in:
221
client/flutter/README.md
Normal file
221
client/flutter/README.md
Normal file
@@ -0,0 +1,221 @@
|
||||
# Sales Chat Flutter App
|
||||
|
||||
销售聊天系统 Flutter 移动端应用
|
||||
|
||||
## 项目说明
|
||||
|
||||
这是一个独立的 Flutter 应用,用于销售邀请追踪和数据统计。
|
||||
|
||||
**技术栈**: Flutter + Provider + Dio
|
||||
|
||||
## 功能特性
|
||||
|
||||
- 📱 群组聊天
|
||||
- 🎫 邀请码管理
|
||||
- 📊 销售数据统计
|
||||
- 📈 个人/团队排行榜
|
||||
- 🔍 消息搜索
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 环境要求
|
||||
|
||||
- Flutter SDK >= 3.0.0
|
||||
- Dart >= 3.0.0
|
||||
- iOS: Xcode >= 14 (macOS only)
|
||||
- Android: Android Studio / SDK
|
||||
|
||||
### 2. 安装依赖
|
||||
|
||||
```bash
|
||||
cd client/flutter
|
||||
flutter pub get
|
||||
```
|
||||
|
||||
### 3. 配置后端地址
|
||||
|
||||
编辑 `lib/services/api_service.dart`:
|
||||
|
||||
```dart
|
||||
// 开发环境 - 连接独立后端
|
||||
static const String _baseUrl = 'http://localhost:3001/api';
|
||||
|
||||
// 或者连接 Tailchat 插件 API
|
||||
// static const String _baseUrl = 'http://localhost:11000/api/plugin/com.msgbyte.saleschat';
|
||||
```
|
||||
|
||||
### 4. 运行应用
|
||||
|
||||
```bash
|
||||
# 开发模式
|
||||
flutter run
|
||||
|
||||
# 指定设备
|
||||
flutter run -d chrome # Web
|
||||
flutter run -d iphone # iOS
|
||||
flutter run -d android # Android
|
||||
|
||||
# 生产构建
|
||||
flutter build apk # Android APK
|
||||
flutter build ios # iOS (需要 Xcode)
|
||||
flutter build web # Web
|
||||
```
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
lib/
|
||||
├── main.dart # 应用入口
|
||||
├── models/ # 数据模型
|
||||
│ ├── invite.dart
|
||||
│ ├── message.dart
|
||||
│ └── stats.dart
|
||||
├── screens/ # 页面
|
||||
│ ├── home/
|
||||
│ ├── chat/
|
||||
│ ├── invite/
|
||||
│ └── stats/
|
||||
├── services/ # 服务
|
||||
│ ├── api_service.dart # API 调用
|
||||
│ ├── auth_service.dart # 认证
|
||||
│ └── storage_service.dart # 本地存储
|
||||
├── providers/ # 状态管理
|
||||
│ ├── auth_provider.dart
|
||||
│ ├── chat_provider.dart
|
||||
│ └── stats_provider.dart
|
||||
└── widgets/ # 通用组件
|
||||
├── invite_card.dart
|
||||
├── message_bubble.dart
|
||||
└── stats_chart.dart
|
||||
```
|
||||
|
||||
## API 配置
|
||||
|
||||
### 独立后端模式
|
||||
|
||||
连接 `sales-chat-backend` (端口 3001):
|
||||
|
||||
```dart
|
||||
static const String _baseUrl = 'http://localhost:3001/api';
|
||||
```
|
||||
|
||||
API 路径:
|
||||
- `/auth/login` - 登录
|
||||
- `/invites` - 邀请管理
|
||||
- `/stats/my` - 个人统计
|
||||
- `/groups` - 群组管理
|
||||
|
||||
### Tailchat 插件模式
|
||||
|
||||
连接 Tailchat (端口 11000):
|
||||
|
||||
```dart
|
||||
static const String _baseUrl = 'http://localhost:11000/api/plugin/com.msgbyte.saleschat';
|
||||
```
|
||||
|
||||
API 路径:
|
||||
- `/invite/create` - 创建邀请
|
||||
- `/invite/my` - 我的邀请
|
||||
- `/stats/my` - 个人统计
|
||||
|
||||
## 开发
|
||||
|
||||
### 代码规范
|
||||
|
||||
```bash
|
||||
# 格式化代码
|
||||
dart format .
|
||||
|
||||
# 静态分析
|
||||
flutter analyze
|
||||
|
||||
# 运行测试
|
||||
flutter test
|
||||
```
|
||||
|
||||
### 环境配置
|
||||
|
||||
创建 `.env` 文件:
|
||||
|
||||
```env
|
||||
API_BASE_URL=http://localhost:3001/api
|
||||
ENABLE_LOGGING=true
|
||||
```
|
||||
|
||||
## 部署
|
||||
|
||||
### Android
|
||||
|
||||
```bash
|
||||
# 构建 APK
|
||||
flutter build apk --release
|
||||
|
||||
# 构建 App Bundle (Google Play)
|
||||
flutter build appbundle --release
|
||||
|
||||
# 输出位置
|
||||
# build/app/outputs/flutter-apk/app-release.apk
|
||||
```
|
||||
|
||||
### iOS
|
||||
|
||||
```bash
|
||||
# 构建 iOS
|
||||
flutter build ios --release
|
||||
|
||||
# 在 Xcode 中打开
|
||||
open ios/Runner.xcworkspace
|
||||
|
||||
# 上传到 App Store Connect
|
||||
# 使用 Xcode 或 Transporter
|
||||
```
|
||||
|
||||
### Web
|
||||
|
||||
```bash
|
||||
# 构建 Web
|
||||
flutter build web --release
|
||||
|
||||
# 输出位置
|
||||
# build/web/
|
||||
|
||||
# 本地预览
|
||||
cd build/web
|
||||
python3 -m http.server 8080
|
||||
```
|
||||
|
||||
## 故障排除
|
||||
|
||||
### 依赖问题
|
||||
|
||||
```bash
|
||||
# 清理并重新获取依赖
|
||||
flutter clean
|
||||
flutter pub get
|
||||
```
|
||||
|
||||
### iOS 构建失败
|
||||
|
||||
```bash
|
||||
# 更新 CocoaPods
|
||||
cd ios
|
||||
pod install --repo-update
|
||||
```
|
||||
|
||||
### Android 构建失败
|
||||
|
||||
```bash
|
||||
# 清理 Gradle 缓存
|
||||
cd android
|
||||
./gradlew clean
|
||||
```
|
||||
|
||||
## 相关项目
|
||||
|
||||
- **后端插件**: `server/plugins/com.msgbyte.saleschat/`
|
||||
- **原项目**: `/Users/sion/Desktop/projects/sales-chat/`
|
||||
- **Tailchat**: https://github.com/msgbyte/tailchat
|
||||
|
||||
## 许可证
|
||||
|
||||
MIT
|
||||
Reference in New Issue
Block a user