web_shell_flutter/README.md

87 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

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

# web_android_shell
Android 平板专用 H5 壳应用 — Monorepo 多品牌架构。
## 项目结构
```
web_android_shell/
├── apps/ # 品牌应用(每个品牌一个 Flutter App
│ └── quanxue/ # 全学通
├── packages/
│ ├── web_shell_core/ # 核心库WebView 引擎 + Bridge + 服务)
│ └── web_android_shell/ # 旧版入口(已迁移至 apps/quanxue
├── flavors/ # 品牌配置 YAML
│ └── quanxue.yaml
├── tool/
│ ├── generate_app.dart # 一键生成新品牌应用
│ └── flutter_run_fresh.ps1 # Windows 调试脚本(自动杀旧进程)
└── doc/ # 项目文档
```
## 快速开始
### 1. 运行已有品牌
```bash
cd apps/quanxue
flutter run
```
### 2. 生成新品牌
```bash
# 1) 在 flavors/ 下创建品牌配置
cp flavors/quanxue.yaml flavors/新品牌.yaml
# 2) 修改配置中的 app_name, application_id, app_key, theme
# 3) 运行生成脚本
dart run tool/generate_app.dart 新品牌
```
生成脚本会自动完成:
- 创建 Flutter 应用 → `apps/新品牌/`
- 添加 `web_shell_core` 依赖
- 覆写 `MainActivity` 继承 `CoreShellActivity`
- 生成品牌入口 `main.dart`
- 配置 `flutter_launcher_icons`
### 3. 品牌配置格式
```yaml
app_name: "全学通" # 应用名
application_id: "com.wanmake.quanxue" # 包名
app_key: "quanxue_prod" # 业务标识
theme:
accent_color: "0xFF3ED37B" # 主题色
bg_color: "0xFFFFFFFF" # 背景色
text_color: "0xFF1F2937" # 主文字色
muted_text_color: "0xFF6B7280" # 次要文字色
```
## 调试说明
部分教育平板设备使用 `Ctrl+C` 结束 `flutter run` 后,旧进程可能留在后台影响 WebView 启动。
**推荐做法:**
- 调试结束时在 `flutter run` 控制台按 `q` 退出
- 或使用调试脚本自动杀旧进程再启动:
```powershell
.\tool\flutter_run_fresh.ps1 # 自动选设备
.\tool\flutter_run_fresh.ps1 -d F136A # 指定设备
```
## 技术栈
| 组件 | 技术 |
|---|---|
| 框架 | Flutter 3.x (Dart 3.11+) |
| WebView | `webview_flutter` + `webview_flutter_android` |
| 宿主能力 | `image_picker` · `file_picker` · `permission_handler` · `url_launcher` |
| 原生层 | Kotlin Plugin + Java `CoreShellActivity` |
| 代码规范 | `very_good_analysis` |
## 平台约束
**仅支持 Android 平板。** iOS / Web / Desktop 平台已移除。