Compare commits
14 Commits
85e9632326
...
feature/ne
| Author | SHA1 | Date | |
|---|---|---|---|
| dc006c2935 | |||
| 167229371f | |||
| 208147cdf2 | |||
| b3a700491a | |||
| d230279f4f | |||
| 32397f8899 | |||
| c8b597f683 | |||
| a1e01da241 | |||
| 3547f80383 | |||
| 4b88a291a5 | |||
| 877ff932d4 | |||
| 43c0b68e1a | |||
| 356c2a1925 | |||
| 3ba480f63f |
21
.gitignore
vendored
21
.gitignore
vendored
@@ -20,7 +20,9 @@ build/
|
||||
gen/
|
||||
local.properties
|
||||
.gradle/
|
||||
.kotlin/
|
||||
captures/
|
||||
hs_err_pid*.log
|
||||
.idea/modules.xml
|
||||
.idea/workspace.xml
|
||||
|
||||
@@ -79,6 +81,25 @@ Debug/
|
||||
# ----------------------------------------------------------------------------
|
||||
lib/generated_plugin_registrant.dart
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Node.js 依赖目录(前端/工具链产物,不需要提交)
|
||||
# ----------------------------------------------------------------------------
|
||||
node_modules/
|
||||
**/node_modules/
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# 日志与崩溃转储(本地调试产物,不需要提交)
|
||||
# ----------------------------------------------------------------------------
|
||||
flutter_*.log
|
||||
test_run.log
|
||||
*.log
|
||||
.sentry-native/
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Office 临时锁文件(Word/Excel 打开时生成,不需要提交)
|
||||
# ----------------------------------------------------------------------------
|
||||
~$*
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# 编辑器与系统文件
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,6 @@
|
||||
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dhttps.protocols=TLSv1.3,TLSv1.2,TLSv1.1 -Djava.net.preferIPv4Stack=true -Djavax.net.ssl.trustStoreType=JKS
|
||||
org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dhttps.protocols=TLSv1.3,TLSv1.2,TLSv1.1 -Djava.net.preferIPv4Stack=true -Djavax.net.ssl.trustStoreType=JKS
|
||||
# 限制 Kotlin 编译守护进程内存,避免与 Gradle 守护进程叠加挤占系统内存
|
||||
kotlin.daemon.jvmargs=-Xmx2G -XX:MaxMetaspaceSize=512m
|
||||
android.useAndroidX=true
|
||||
|
||||
# 使用阿里云镜像加速
|
||||
|
||||
BIN
assets/images/app_logo_gray_transparent.png
Normal file
BIN
assets/images/app_logo_gray_transparent.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.0 MiB |
52
build_patch.bat
Normal file
52
build_patch.bat
Normal file
@@ -0,0 +1,52 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo ============================================
|
||||
echo Re Build Patch
|
||||
echo ============================================
|
||||
echo.
|
||||
|
||||
set PATCH_VERSION=1.0.2
|
||||
set TARGET_VERSION_CODE=1
|
||||
|
||||
echo [1/3] Building Release APK ...
|
||||
echo.
|
||||
call flutter build apk --release
|
||||
if %errorlevel% neq 0 (
|
||||
echo.
|
||||
echo APK build failed!
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo.
|
||||
echo APK build done
|
||||
echo.
|
||||
|
||||
echo [2/3] Generating patch ...
|
||||
echo.
|
||||
call dart run flutter_patcher:pack ^
|
||||
--apk build/app/outputs/flutter-apk/app-release.apk ^
|
||||
--version %PATCH_VERSION% ^
|
||||
--target-version-code %TARGET_VERSION_CODE%
|
||||
if %errorlevel% neq 0 (
|
||||
echo.
|
||||
echo Patch generation failed!
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo.
|
||||
echo Patch generation done
|
||||
echo.
|
||||
|
||||
echo [3/3] Output:
|
||||
echo.
|
||||
echo APK: build\app\outputs\flutter-apk\app-release.apk
|
||||
echo Patch: dist\libapp.so
|
||||
echo Manifest: dist\manifest.json
|
||||
echo.
|
||||
echo ============================================
|
||||
echo Next: Upload dist\libapp.so to server
|
||||
echo ============================================
|
||||
echo.
|
||||
pause
|
||||
4
dist/manifest.json
vendored
4
dist/manifest.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": "1.0.8",
|
||||
"md5": "3793eb271a2a4f992b11b5f3623420e5",
|
||||
"version": "1.0.10",
|
||||
"md5": "416e3f0e2a701bb8b4a0856a29dba597",
|
||||
"targetVersionCode": 1,
|
||||
"abi": "arm64-v8a"
|
||||
}
|
||||
|
||||
520
docs/SOP_使用文档.md
Normal file
520
docs/SOP_使用文档.md
Normal file
@@ -0,0 +1,520 @@
|
||||
# 迈步 Satabot App 使用说明书
|
||||
|
||||
> 版本:1.0.0 | 适用对象:终端用户(运维人员)
|
||||
|
||||
---
|
||||
|
||||
## 目录
|
||||
|
||||
1. [应用简介](#1-应用简介)
|
||||
2. [安装与登录](#2-安装与登录)
|
||||
3. [首页](#3-首页)
|
||||
4. [设备管理](#4-设备管理)
|
||||
5. [机器人控制](#5-机器人控制)
|
||||
6. [无人机巡检](#6-无人机巡检)
|
||||
7. [告警中心](#7-告警中心)
|
||||
8. [工单管理](#8-工单管理)
|
||||
9. [问题上报](#9-问题上报)
|
||||
10. [我的](#10-我的)
|
||||
11. [蓝牙设备绑定](#11-蓝牙设备绑定)
|
||||
12. [常见问题](#12-常见问题)
|
||||
|
||||
---
|
||||
|
||||
## 1. 应用概述
|
||||
|
||||
### 1.1 产品简介
|
||||
|
||||
迈步 Satabot 是一款面向光伏电站的智能管理移动应用,为电站运维人员提供一站式的设备监控、远程控制、告警处理和工单管理能力。通过本 App,运维人员可以随时随地掌握电站运行状况,快速响应设备异常,提升运维效率。
|
||||
|
||||
### 1.2 适用人群
|
||||
|
||||
| 角色 | 说明 |
|
||||
|------|------|
|
||||
| 电站运维人员 | 日常巡检、设备监控、告警处理、工单执行 |
|
||||
| 设备管理人员 | 设备绑定、参数配置、运行状态查看 |
|
||||
| 管理人员 | 电站发电数据查看、工单统计 |
|
||||
|
||||
### 1.3 核心功能
|
||||
|
||||
| 功能模块 | 说明 |
|
||||
|---------|------|
|
||||
| 首页 | 电站发电概览、实时功率、设备统计、快捷入口 |
|
||||
| 设备管理 | 设备列表、分类筛选、搜索、蓝牙扫描、设备详情 |
|
||||
| 机器人控制 | 远程方向控制、任务管理、运行参数设置 |
|
||||
| 无人机巡检 | 机场状态、实时监控、视频直播、飞行任务管理 |
|
||||
| 告警中心 | 告警统计、告警处理、派发工单、AI 诊断 |
|
||||
| 工单管理 | 工单全流程(新建→执行→完成/挂起/转派) |
|
||||
| 问题上报 | 问题类型选择、媒体上传、设备关联 |
|
||||
| 个人中心 | 个人信息、系统设置、夜间模式、导航自定义 |
|
||||
|
||||
### 1.4 设备类型
|
||||
|
||||
本 App 管理以下类型的设备:
|
||||
|
||||
| 设备类型 | 说明 |
|
||||
|---------|------|
|
||||
| 光伏逆变器 | 将直流电转换为交流电的核心设备 |
|
||||
| 汇流箱 | 汇集多个光伏组件的直流电 |
|
||||
| 光伏组件 | 将太阳能转化为直流电的组件 |
|
||||
| 监控设备 | 数据采集与传输设备 |
|
||||
| 清洁除草机器人 | MC700 系列,光伏面板清洁除草机器人 |
|
||||
| 无人机机场 | 无人机自动机巢,含无人机巡检 |
|
||||
|
||||
### 1.5 底部导航栏
|
||||
|
||||
App 底部有以下功能页签,可在"我的 → 底部导航设置"中自定义显示和排序:
|
||||
|
||||
| 页签 | 名称 | 说明 |
|
||||
|------|------|------|
|
||||
| 首页 | 电站概览 | 发电数据、设备统计、快捷入口 |
|
||||
| 设备 | 设备管理 | 设备列表、机器人、无人机 |
|
||||
| 告警 | 告警中心 | 查看和处理设备告警 |
|
||||
| 工单 | 工单管理 | 工单全流程管理 |
|
||||
| 上报 | 问题上报 | 上报设备问题 |
|
||||
| 我的 | 个人中心 | 个人信息、系统设置 |
|
||||
|
||||
---
|
||||
|
||||
## 2. 安装与登录
|
||||
|
||||
### 2.1 安装
|
||||
|
||||
- **Android**:扫描二维码下载 APK 安装
|
||||
- **iOS**:扫描二维码跳转 App Store 安装
|
||||
- 安装时如提示"未知来源",请在手机设置中允许安装
|
||||
|
||||
### 2.2 登录
|
||||
|
||||
1. 打开 App,进入登录页面
|
||||
2. 输入**用户名**和**密码**
|
||||
3. 勾选"已阅读并同意用户协议"
|
||||
4. 点击**登录**按钮
|
||||
5. 登录成功后自动跳转到首页
|
||||
|
||||
> **提示**:如果忘记密码,请联系管理员重置。
|
||||
|
||||
### 2.3 注册
|
||||
|
||||
1. 在登录页面点击**注册账号**
|
||||
2. 填写用户名、密码等信息
|
||||
3. 提交后等待管理员审核
|
||||
|
||||
### 2.4 修改密码
|
||||
|
||||
1. 登录后进入"我的"页面
|
||||
2. 点击"修改密码"
|
||||
3. 输入旧密码和新密码
|
||||
4. 提交完成修改
|
||||
|
||||
---
|
||||
|
||||
## 3. 首页
|
||||
|
||||
### 3.1 页面说明
|
||||
|
||||
首页展示当前选中电站的整体运行情况。
|
||||
|
||||
### 3.2 切换电站
|
||||
|
||||
- 页面顶部左侧显示当前电站名称
|
||||
- 点击电站名称可下拉切换其他电站
|
||||
- 切换后所有数据自动刷新
|
||||
|
||||
### 3.3 功能区域
|
||||
|
||||
| 区域 | 说明 |
|
||||
|------|------|
|
||||
| 天气信息 | 显示电站所在地天气 |
|
||||
| 电站概览 | 装机容量、今日发电量等 |
|
||||
| 功率卡片 | 实时功率、今日累计发电量、功率趋势图 |
|
||||
| 统计网格 | 设备总数、在线数、离线数、异常数 |
|
||||
| 工单卡片 | 待处理工单数量,点击进入工单页 |
|
||||
| 快捷入口 | 设备管理、告警、工单等快速跳转 |
|
||||
| TCP 状态 | 右上角圆点显示通信连接状态(绿色=正常) |
|
||||
|
||||
### 3.4 下拉刷新
|
||||
|
||||
- 在首页任意位置**下拉**可刷新所有数据
|
||||
|
||||
---
|
||||
|
||||
## 4. 设备管理
|
||||
|
||||
### 4.1 进入设备页
|
||||
|
||||
点击底部导航栏的**设备**页签。
|
||||
|
||||
### 4.2 切换电站
|
||||
|
||||
- 页面顶部左侧可切换电站,切换后设备列表自动刷新
|
||||
|
||||
### 4.3 搜索设备
|
||||
|
||||
- 页面上方搜索框中输入设备名称
|
||||
- 点击搜索按钮或按确认键进行搜索
|
||||
|
||||
### 4.4 设备分类筛选
|
||||
|
||||
页面中部有设备类型筛选条:
|
||||
|
||||
| 筛选项 | 说明 |
|
||||
|--------|------|
|
||||
| 全部 | 显示所有设备 |
|
||||
| 逆变器 | 仅显示逆变器设备 |
|
||||
| 汇流箱 | 仅显示汇流箱设备 |
|
||||
| 组件 | 仅显示光伏组件 |
|
||||
| 监控 | 仅显示监控设备 |
|
||||
| 机器人 | 仅显示清洁除草机器人 |
|
||||
| 无人机机场 | 仅显示无人机机巢 |
|
||||
|
||||
### 4.5 添加设备
|
||||
|
||||
- 点击页面右上角 **+** 按钮
|
||||
- 可选择**扫一扫**(扫码绑定)或**蓝牙**(蓝牙搜索绑定)
|
||||
|
||||
### 4.6 蓝牙扫描
|
||||
|
||||
- 点击搜索框旁边的**蓝牙图标**
|
||||
- App 开始扫描附近蓝牙设备
|
||||
- 扫描结果中,名称为纯数字的设备(时间戳格式)自动**置顶**显示
|
||||
- 可在搜索框中输入关键词过滤设备
|
||||
- 点击设备可进入设备详情页
|
||||
|
||||
### 4.7 设备详情
|
||||
|
||||
点击设备列表中的设备,进入设备详情页:
|
||||
|
||||
- **光伏设备**:显示设备运行参数(功率、电压、电流、温度等)
|
||||
- **机器人**:进入机器人控制页(详见第 5 章)
|
||||
- **无人机机场**:进入机场详情页(详见第 6 章)
|
||||
|
||||
---
|
||||
|
||||
## 5. 机器人控制
|
||||
|
||||
### 5.1 进入方式
|
||||
|
||||
设备页 → 筛选"机器人" → 点击机器人设备
|
||||
|
||||
### 5.2 机器人详情页
|
||||
|
||||
| 区域 | 说明 |
|
||||
|------|------|
|
||||
| 设备信息卡 | 显示机器人名称、序列号、在线状态、电量 |
|
||||
| 状态栏 | 运行状态、工作模式、当前位置 |
|
||||
| 控制面板 | 方向控制(前进/后退/左转/右转/停止) |
|
||||
| 检查清单 | 任务执行前的检查项 |
|
||||
| 任务信息 | 当前任务详情 |
|
||||
| 操作按钮 | 启动任务、暂停、取消等 |
|
||||
|
||||
### 5.3 远程控制
|
||||
|
||||
1. 进入机器人详情页后,App 自动申请远程控制权限
|
||||
2. 获得权限后可使用控制面板上的方向按钮
|
||||
3. 点击**停止**按钮停止移动
|
||||
4. 退出页面时自动释放控制权限
|
||||
|
||||
### 5.4 任务管理
|
||||
|
||||
| 操作 | 说明 |
|
||||
|------|------|
|
||||
| 创建任务 | 设置工作区域参数后创建清洁任务 |
|
||||
| 启动任务 | 选择任务后点击启动 |
|
||||
| 暂停任务 | 执行中点击暂停 |
|
||||
| 恢复任务 | 暂停后点击恢复 |
|
||||
| 取消任务 | 取消当前任务 |
|
||||
|
||||
### 5.5 运行参数设置
|
||||
|
||||
1. 在机器人详情页点击设置图标
|
||||
2. 可调整运行参数(速度、切割高度等)
|
||||
3. 点击保存生效
|
||||
|
||||
---
|
||||
|
||||
## 6. 无人机巡检
|
||||
|
||||
### 6.1 进入方式
|
||||
|
||||
设备页 → 筛选"无人机机场" → 点击机场设备
|
||||
|
||||
### 6.2 机场详情页
|
||||
|
||||
| 信息 | 说明 |
|
||||
|------|------|
|
||||
| 机场状态 | 在线状态、仓内温度 |
|
||||
| 无人机状态 | 电量、位置、飞行状态 |
|
||||
| 视频监控 | 仓内监控画面 |
|
||||
|
||||
### 6.3 实时监控
|
||||
|
||||
- 点击"实时监控"进入无人机监控页
|
||||
- 显示无人机 OSD 数据:经纬度、高度、速度、电量、航向等
|
||||
|
||||
### 6.4 视频直播
|
||||
|
||||
1. 点击"视频直播"进入直播页面
|
||||
2. 可切换摄像头:广角 / 变焦 / 红外
|
||||
3. 支持画面全屏、方向控制
|
||||
|
||||
### 6.5 飞行任务
|
||||
|
||||
| 操作 | 说明 |
|
||||
|------|------|
|
||||
| 查看任务 | 查看已有飞行任务列表 |
|
||||
| 创建任务 | 选择航线、设置参数后创建 |
|
||||
| 执行任务 | 选择任务后点击执行 |
|
||||
| 暂停任务 | 飞行中可暂停 |
|
||||
| 返航 | 一键返航 |
|
||||
|
||||
---
|
||||
|
||||
## 7. 告警中心
|
||||
|
||||
### 7.1 进入方式
|
||||
|
||||
点击底部导航栏的**告警**页签。
|
||||
|
||||
### 7.2 告警统计
|
||||
|
||||
- 页面上方显示告警数量统计卡片
|
||||
- 按状态分类:待处理、处理中、已处理、已关闭
|
||||
|
||||
### 7.3 告警列表
|
||||
|
||||
- 按状态 Tab 分类展示
|
||||
- 下拉刷新,上拉加载更多
|
||||
- 点击告警条目进入详情页
|
||||
|
||||
### 7.4 告警详情
|
||||
|
||||
| 信息 | 说明 |
|
||||
|------|------|
|
||||
| 告警信息 | 告警名称、级别、时间、设备 |
|
||||
| 告警详情 | 详细描述、可能原因 |
|
||||
| AI 诊断 | AI 辅助分析告警原因和建议 |
|
||||
|
||||
### 7.5 处理告警
|
||||
|
||||
1. 在告警详情页点击"处理"
|
||||
2. 选择处理方式(确认/关闭)
|
||||
3. 填写处理说明
|
||||
4. 提交完成处理
|
||||
|
||||
### 7.6 派发工单
|
||||
|
||||
1. 在告警详情页点击"派发工单"
|
||||
2. 选择工单模型
|
||||
3. 填写派发信息
|
||||
4. 提交后自动生成工单
|
||||
|
||||
---
|
||||
|
||||
## 8. 工单管理
|
||||
|
||||
### 8.1 进入方式
|
||||
|
||||
点击底部导航栏的**工单**页签。
|
||||
|
||||
### 8.2 工单统计
|
||||
|
||||
- 页面上方显示各状态工单数量统计
|
||||
- 点击数字可快速筛选对应状态的工单
|
||||
|
||||
### 8.3 工单列表
|
||||
|
||||
- 按状态 Tab 分类展示:待处理、处理中、已完成、已挂起
|
||||
- 下拉刷新,上拉加载更多
|
||||
- 点击工单条目进入详情页
|
||||
|
||||
### 8.4 工单详情
|
||||
|
||||
显示工单编号、类型、设备、描述、处理记录等信息。
|
||||
|
||||
### 8.5 工单操作
|
||||
|
||||
| 操作 | 说明 |
|
||||
|------|------|
|
||||
| 开始执行 | 接收工单后开始处理 |
|
||||
| 完成 | 处理完毕后标记完成 |
|
||||
| 挂起 | 暂时无法处理,挂起工单 |
|
||||
| 恢复 | 挂起的工单恢复处理 |
|
||||
| 转派 | 将工单转给其他人员 |
|
||||
|
||||
### 8.6 新建工单
|
||||
|
||||
1. 在工单页面点击"上报"按钮
|
||||
2. 选择工单类型
|
||||
3. 填写问题描述
|
||||
4. 关联设备
|
||||
5. 提交生成工单
|
||||
|
||||
---
|
||||
|
||||
## 9. 问题上报
|
||||
|
||||
### 9.1 进入方式
|
||||
|
||||
点击底部导航栏的**上报**页签。
|
||||
|
||||
### 9.2 上报流程
|
||||
|
||||
1. **选择上报类型**:故障 / 建议 / 投诉等
|
||||
2. **选择严重等级**:紧急 / 严重 / 一般 / 轻微
|
||||
3. **选择设备**:从设备列表中关联相关设备
|
||||
4. **上传媒体**:拍照、录像或选择图片/视频
|
||||
5. **填写描述**:文字描述问题详情
|
||||
6. 点击**提交**完成上报
|
||||
|
||||
### 9.3 媒体上传
|
||||
|
||||
- 点击拍照按钮直接拍照
|
||||
- 或从手机相册选择图片/视频
|
||||
- 点击已上传的媒体可预览大图/视频
|
||||
|
||||
---
|
||||
|
||||
## 10. 我的
|
||||
|
||||
### 10.1 进入方式
|
||||
|
||||
点击底部导航栏的**我的**页签。
|
||||
|
||||
### 10.2 功能列表
|
||||
|
||||
| 功能 | 说明 |
|
||||
|------|------|
|
||||
| 用户信息卡 | 头像、昵称、联系方式,点击进入编辑页 |
|
||||
| 快捷操作 | 常用功能快速入口 |
|
||||
| 个人资料 | 修改昵称、头像等 |
|
||||
| 系统设置 | 夜间模式、语言切换、清除缓存 |
|
||||
| 底部导航设置 | 自定义底部 Tab 显示/隐藏和排序 |
|
||||
| 版本更新 | 检查并下载新版本 |
|
||||
| 退出登录 | 清除登录状态返回登录页 |
|
||||
|
||||
### 10.3 夜间模式
|
||||
|
||||
- 我的 → 系统设置 → 夜间模式开关
|
||||
- 开启后 App 切换为深色主题
|
||||
|
||||
### 10.4 底部导航设置
|
||||
|
||||
1. 我的 → 底部导航设置(或首页 → 设置入口)
|
||||
2. 可开关每个 Tab 的显示/隐藏
|
||||
3. 至少保留一个 Tab
|
||||
4. 可调整 Tab 排列顺序
|
||||
5. 设置即时生效
|
||||
|
||||
---
|
||||
|
||||
## 11. 蓝牙设备绑定
|
||||
|
||||
### 11.1 方式一:扫码绑定
|
||||
|
||||
1. 设备页 → 点击右上角 **+**
|
||||
2. 选择"扫一扫"
|
||||
3. 扫描设备上的二维码
|
||||
4. App 获取设备名称(如 `MC700AIR-CN-JS-1777272534998-0000000A-75`)
|
||||
5. 进入绑定页面
|
||||
6. 选择所属组织和场站
|
||||
7. 点击提交完成绑定
|
||||
|
||||
### 11.2 方式二:蓝牙搜索绑定
|
||||
|
||||
1. 设备页 → 点击搜索框旁的**蓝牙图标**
|
||||
2. App 扫描附近蓝牙设备
|
||||
3. 在搜索框输入关键词可过滤设备
|
||||
4. 蓝牙名为纯数字的设备(时间戳格式)自动置顶
|
||||
5. 点击目标设备进入设备详情页
|
||||
6. 点击**连接设备**按钮连接蓝牙
|
||||
7. 连接成功后,**绑定设备**按钮变为可点击状态
|
||||
8. 未连接时"绑定设备"按钮为灰色,不可点击
|
||||
9. 点击"绑定设备"
|
||||
- App 自动获取全部设备列表
|
||||
- 用蓝牙名(时间戳,如 `1777272534998`)匹配设备
|
||||
- 匹配成功后自动跳转到绑定页面
|
||||
10. 选择所属组织和场站
|
||||
11. 点击提交完成绑定
|
||||
|
||||
### 11.3 设备名说明
|
||||
|
||||
| 位置 | 名称示例 | 说明 |
|
||||
|------|---------|------|
|
||||
| 蓝牙广播名 | `1777272534998` | 纯数字时间戳 |
|
||||
| 设备完整名 | `MC700AIR-CN-JS-1777272534998-0000000A-75` | 设备序列号 |
|
||||
| 匹配方式 | 完整名包含蓝牙名 | 蓝牙名是完整名的一部分 |
|
||||
|
||||
---
|
||||
|
||||
## 12. 常见问题
|
||||
|
||||
### Q1:登录提示"登录失败"?
|
||||
|
||||
- 检查用户名和密码是否正确
|
||||
- 检查网络是否正常
|
||||
- 联系管理员确认账号是否已开通
|
||||
|
||||
### Q2:蓝牙扫描不到设备?
|
||||
|
||||
- 确认手机蓝牙已开启
|
||||
- 确认已授予 App 蓝牙权限和定位权限
|
||||
- 靠近设备后重试
|
||||
- 安卓手机需开启"位置信息"开关
|
||||
|
||||
### Q3:蓝牙连接失败?
|
||||
|
||||
- 确认设备已通电
|
||||
- 确认设备未被其他手机连接
|
||||
- 靠近设备重试
|
||||
- 重启手机蓝牙后重试
|
||||
|
||||
### Q4:绑定设备按钮灰色不可点击?
|
||||
|
||||
- "绑定设备"按钮需要**先连接蓝牙**后才能使用
|
||||
- 请先点击"连接设备"按钮,连接成功后按钮变为可点击
|
||||
|
||||
### Q5:点击绑定设备后提示"未匹配到设备"?
|
||||
|
||||
- 确认设备已录入后台系统
|
||||
- 联系管理员确认设备名中是否包含当前蓝牙名(时间戳)
|
||||
|
||||
### Q6:首页数据显示"加载失败"?
|
||||
|
||||
- 检查网络连接
|
||||
- 点击"重试"按钮
|
||||
- 确认当前账号有权限访问该电站
|
||||
|
||||
### Q7:机器人控制无反应?
|
||||
|
||||
- 确认机器人在线
|
||||
- 确认已获得远程控制权限
|
||||
- 确认机器人未在执行其他任务
|
||||
- 退出页面重新进入
|
||||
|
||||
### Q8:无人机视频不显示?
|
||||
|
||||
- 确认无人机和机场在线
|
||||
- 确认网络畅通
|
||||
- 尝试切换摄像头
|
||||
|
||||
### Q9:TCP 状态显示异常?
|
||||
|
||||
- 首页右上角圆点显示 TCP 连接状态
|
||||
- 红色表示未连接,绿色表示正常
|
||||
- 如持续异常,检查网络或联系管理员
|
||||
|
||||
### Q10:App 版本过旧无法使用?
|
||||
|
||||
- 进入"我的"→"版本更新"检查新版本
|
||||
- 下载并安装最新版本
|
||||
|
||||
---
|
||||
|
||||
## 联系与反馈
|
||||
|
||||
如遇到本说明书未涵盖的问题,请通过以下方式联系:
|
||||
|
||||
- **客服电话**:请联系管理员获取
|
||||
- **问题反馈**:App 内"上报"页面提交问题反馈
|
||||
- **技术支持**:请联系管理员获取联系方式
|
||||
@@ -1,6 +1,7 @@
|
||||
# Uncomment this line to define a global platform for your project
|
||||
# platform :ios, '13.0'
|
||||
source 'https://github.com/volcengine/volcengine-specs.git'error: Classes can only extend other classes. (extends_non_class at [maibu_satabot_v2] lib\features\v2\device_list\domain\entities\video_stream_entity.dart:2)error: Classes can only extend other classes. (extends_non_class at [maibu_satabot_v2] lib\features\v2\device_list\domain\entities\video_stream_entity.dart:2)you
|
||||
platform :ios, '13.0'
|
||||
source 'https://github.com/volcengine/volcengine-specs.git'
|
||||
source 'https://cdn.cocoapods.org/'
|
||||
|
||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
||||
|
||||
121
ios/Podfile.lock
121
ios/Podfile.lock
@@ -1,7 +1,58 @@
|
||||
PODS:
|
||||
- agora_rtc_engine (6.5.3):
|
||||
- AgoraIrisRTC_iOS (= 4.5.2-build.1)
|
||||
- AgoraRtcEngine_iOS (= 4.5.2)
|
||||
- Flutter
|
||||
- AgoraInfra_iOS (1.2.13.1)
|
||||
- AgoraIrisRTC_iOS (4.5.2-build.1)
|
||||
- AgoraRtcEngine_iOS (4.5.2):
|
||||
- AgoraRtcEngine_iOS/AIAEC (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/AIAECLL (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/AINS (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/AINSLL (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/AudioBeauty (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/ClearVision (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/ContentInspect (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/FaceCapture (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/FaceDetection (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/LipSync (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/ReplayKit (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/RtcBasic (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/SpatialAudio (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/VideoAv1CodecDec (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/VideoAv1CodecEnc (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/VideoCodecDec (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/VideoCodecEnc (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/VirtualBackground (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/VQA (= 4.5.2)
|
||||
- AgoraRtcEngine_iOS/AIAEC (4.5.2)
|
||||
- AgoraRtcEngine_iOS/AIAECLL (4.5.2)
|
||||
- AgoraRtcEngine_iOS/AINS (4.5.2)
|
||||
- AgoraRtcEngine_iOS/AINSLL (4.5.2)
|
||||
- AgoraRtcEngine_iOS/AudioBeauty (4.5.2)
|
||||
- AgoraRtcEngine_iOS/ClearVision (4.5.2)
|
||||
- AgoraRtcEngine_iOS/ContentInspect (4.5.2)
|
||||
- AgoraRtcEngine_iOS/FaceCapture (4.5.2)
|
||||
- AgoraRtcEngine_iOS/FaceDetection (4.5.2)
|
||||
- AgoraRtcEngine_iOS/LipSync (4.5.2)
|
||||
- AgoraRtcEngine_iOS/ReplayKit (4.5.2)
|
||||
- AgoraRtcEngine_iOS/RtcBasic (4.5.2):
|
||||
- AgoraInfra_iOS (= 1.2.13.1)
|
||||
- AgoraRtcEngine_iOS/SpatialAudio (4.5.2)
|
||||
- AgoraRtcEngine_iOS/VideoAv1CodecDec (4.5.2)
|
||||
- AgoraRtcEngine_iOS/VideoAv1CodecEnc (4.5.2)
|
||||
- AgoraRtcEngine_iOS/VideoCodecDec (4.5.2)
|
||||
- AgoraRtcEngine_iOS/VideoCodecEnc (4.5.2)
|
||||
- AgoraRtcEngine_iOS/VirtualBackground (4.5.2)
|
||||
- AgoraRtcEngine_iOS/VQA (4.5.2)
|
||||
- connectivity_plus (0.0.1):
|
||||
- Flutter
|
||||
- device_info_plus (0.0.1):
|
||||
- Flutter
|
||||
- Flutter (1.0.0)
|
||||
- flutter_blue_plus_darwin (0.0.2):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- flutter_webrtc (1.4.0):
|
||||
- Flutter
|
||||
- WebRTC-SDK (= 144.7559.01)
|
||||
@@ -44,6 +95,8 @@ PODS:
|
||||
- GTMSessionFetcher/Core (2.3.0)
|
||||
- image_picker_ios (0.0.1):
|
||||
- Flutter
|
||||
- iris_method_channel (0.0.1):
|
||||
- Flutter
|
||||
- isar_community_flutter_libs (1.0.0):
|
||||
- Flutter
|
||||
- MLImage (1.0.0-beta4)
|
||||
@@ -72,6 +125,8 @@ PODS:
|
||||
- nanopb/encode (= 2.30910.0)
|
||||
- nanopb/decode (2.30910.0)
|
||||
- nanopb/encode (2.30910.0)
|
||||
- open_file_ios (1.0.3):
|
||||
- Flutter
|
||||
- package_info_plus (0.4.5):
|
||||
- Flutter
|
||||
- permission_handler_apple (9.3.0):
|
||||
@@ -89,29 +144,67 @@ PODS:
|
||||
- Flutter
|
||||
- vibration (3.0.0):
|
||||
- Flutter
|
||||
- video_player_avfoundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
- volc_engine_rtc (3.60.4):
|
||||
- Flutter
|
||||
- VolcApiEngine (= 1.7.0)
|
||||
- VolcEngineRTC (= 3.60.103.2100)
|
||||
- VolcApiEngine (1.7.0)
|
||||
- VolcEngineRTC (3.60.103.2100):
|
||||
- VolcEngineRTC/BMF (= 3.60.103.2100)
|
||||
- VolcEngineRTC/ByteRTCVideoDenoiseExtension (= 3.60.103.2100)
|
||||
- VolcEngineRTC/ByteRTCVideoSharpenExtension (= 3.60.103.2100)
|
||||
- VolcEngineRTC/ByteRTCVideoSRExtension (= 3.60.103.2100)
|
||||
- VolcEngineRTC/Core (= 3.60.103.2100)
|
||||
- VolcEngineRTC/CVByteNN (= 3.60.103.2100)
|
||||
- VolcEngineRTC/RealXBase (= 3.60.103.2100)
|
||||
- VolcEngineRTC/RTCFFmpeg (= 3.60.103.2100)
|
||||
- VolcEngineRTC/BMF (3.60.103.2100)
|
||||
- VolcEngineRTC/ByteRTCVideoDenoiseExtension (3.60.103.2100)
|
||||
- VolcEngineRTC/ByteRTCVideoSharpenExtension (3.60.103.2100)
|
||||
- VolcEngineRTC/ByteRTCVideoSRExtension (3.60.103.2100)
|
||||
- VolcEngineRTC/Core (3.60.103.2100)
|
||||
- VolcEngineRTC/CVByteNN (3.60.103.2100)
|
||||
- VolcEngineRTC/RealXBase (3.60.103.2100)
|
||||
- VolcEngineRTC/RTCFFmpeg (3.60.103.2100)
|
||||
- WebRTC-SDK (144.7559.01)
|
||||
- webview_flutter_wkwebview (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
|
||||
DEPENDENCIES:
|
||||
- agora_rtc_engine (from `.symlinks/plugins/agora_rtc_engine/ios`)
|
||||
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
|
||||
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
|
||||
- Flutter (from `Flutter`)
|
||||
- flutter_blue_plus_darwin (from `.symlinks/plugins/flutter_blue_plus_darwin/darwin`)
|
||||
- flutter_webrtc (from `.symlinks/plugins/flutter_webrtc/ios`)
|
||||
- geolocator_apple (from `.symlinks/plugins/geolocator_apple/darwin`)
|
||||
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||
- iris_method_channel (from `.symlinks/plugins/iris_method_channel/ios`)
|
||||
- isar_community_flutter_libs (from `.symlinks/plugins/isar_community_flutter_libs/ios`)
|
||||
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/ios`)
|
||||
- open_file_ios (from `.symlinks/plugins/open_file_ios/ios`)
|
||||
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
|
||||
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
|
||||
- sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`)
|
||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||
- vibration (from `.symlinks/plugins/vibration/ios`)
|
||||
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)
|
||||
- volc_engine_rtc (from `.symlinks/plugins/volc_engine_rtc/ios`)
|
||||
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`)
|
||||
|
||||
SPEC REPOS:
|
||||
https://github.com/volcengine/volcengine-specs.git:
|
||||
- VolcApiEngine
|
||||
- VolcEngineRTC
|
||||
trunk:
|
||||
- AgoraInfra_iOS
|
||||
- AgoraIrisRTC_iOS
|
||||
- AgoraRtcEngine_iOS
|
||||
- GoogleDataTransport
|
||||
- GoogleMLKit
|
||||
- GoogleToolboxForMac
|
||||
@@ -128,20 +221,30 @@ SPEC REPOS:
|
||||
- WebRTC-SDK
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
agora_rtc_engine:
|
||||
:path: ".symlinks/plugins/agora_rtc_engine/ios"
|
||||
connectivity_plus:
|
||||
:path: ".symlinks/plugins/connectivity_plus/ios"
|
||||
device_info_plus:
|
||||
:path: ".symlinks/plugins/device_info_plus/ios"
|
||||
Flutter:
|
||||
:path: Flutter
|
||||
flutter_blue_plus_darwin:
|
||||
:path: ".symlinks/plugins/flutter_blue_plus_darwin/darwin"
|
||||
flutter_webrtc:
|
||||
:path: ".symlinks/plugins/flutter_webrtc/ios"
|
||||
geolocator_apple:
|
||||
:path: ".symlinks/plugins/geolocator_apple/darwin"
|
||||
image_picker_ios:
|
||||
:path: ".symlinks/plugins/image_picker_ios/ios"
|
||||
iris_method_channel:
|
||||
:path: ".symlinks/plugins/iris_method_channel/ios"
|
||||
isar_community_flutter_libs:
|
||||
:path: ".symlinks/plugins/isar_community_flutter_libs/ios"
|
||||
mobile_scanner:
|
||||
:path: ".symlinks/plugins/mobile_scanner/ios"
|
||||
open_file_ios:
|
||||
:path: ".symlinks/plugins/open_file_ios/ios"
|
||||
package_info_plus:
|
||||
:path: ".symlinks/plugins/package_info_plus/ios"
|
||||
permission_handler_apple:
|
||||
@@ -154,12 +257,22 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/url_launcher_ios/ios"
|
||||
vibration:
|
||||
:path: ".symlinks/plugins/vibration/ios"
|
||||
video_player_avfoundation:
|
||||
:path: ".symlinks/plugins/video_player_avfoundation/darwin"
|
||||
volc_engine_rtc:
|
||||
:path: ".symlinks/plugins/volc_engine_rtc/ios"
|
||||
webview_flutter_wkwebview:
|
||||
:path: ".symlinks/plugins/webview_flutter_wkwebview/darwin"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
agora_rtc_engine: 0c7d50312967c4dc31c3c45e50589ce48f57e08a
|
||||
AgoraInfra_iOS: 3691b2b277a1712a35ae96de25af319de0d73d08
|
||||
AgoraIrisRTC_iOS: eab58c126439adf5ec99632828a558ea216860da
|
||||
AgoraRtcEngine_iOS: 97e2398a2addda9057815a2a583a658e36796ff6
|
||||
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
|
||||
device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe
|
||||
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
||||
flutter_blue_plus_darwin: ee2377ea51a6c9e481f2ed76ec597717ef5d287d
|
||||
flutter_webrtc: ec91d94b484ad49cf191ef93413f64a40ffd3b4c
|
||||
geolocator_apple: ab36aa0e8b7d7a2d7639b3b4e48308394e8cef5e
|
||||
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
|
||||
@@ -169,6 +282,7 @@ SPEC CHECKSUMS:
|
||||
GoogleUtilitiesComponents: 679b2c881db3b615a2777504623df6122dd20afe
|
||||
GTMSessionFetcher: 3a63d75eecd6aa32c2fc79f578064e1214dfdec2
|
||||
image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326
|
||||
iris_method_channel: 7d661cf3259b3009ae423508470dbeb9374446ee
|
||||
isar_community_flutter_libs: bede843185a61a05ff364a05c9b23209523f7e0d
|
||||
MLImage: 7bb7c4264164ade9bf64f679b40fb29c8f33ee9b
|
||||
MLKitBarcodeScanning: 04e264482c5f3810cb89ebc134ef6b61e67db505
|
||||
@@ -176,6 +290,7 @@ SPEC CHECKSUMS:
|
||||
MLKitVision: 8baa5f46ee3352614169b85250574fde38c36f49
|
||||
mobile_scanner: b67191637a5ea7ba15652ca208069d2bae1900ab
|
||||
nanopb: 438bc412db1928dac798aa6fd75726007be04262
|
||||
open_file_ios: 46184d802ee7959203f6392abcfa0dd49fdb5be0
|
||||
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
|
||||
permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d
|
||||
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
|
||||
@@ -184,9 +299,13 @@ SPEC CHECKSUMS:
|
||||
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
||||
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b
|
||||
vibration: ca8104a8875b9c493e15b21b04e456befd0ff6eb
|
||||
video_player_avfoundation: 3453f792138786248960ca029747fcd9f318ef52
|
||||
volc_engine_rtc: 1bc697fba3c7a2f6513a18ec2abfb629188ce6ff
|
||||
VolcApiEngine: e1f8b47ec5ef64bf6b48e3600be132c42643f8f0
|
||||
VolcEngineRTC: 889b981b13621208b25942263f0fd5817c93b9bc
|
||||
WebRTC-SDK: ab9b5319e458c2bfebdc92b3600740da35d5630d
|
||||
webview_flutter_wkwebview: 8ebf4fded22593026f7dbff1fbff31ea98573c8d
|
||||
|
||||
PODFILE CHECKSUM: 3c63482e143d1b91d2d2560aee9fb04ecc74ac7e
|
||||
PODFILE CHECKSUM: 2da7455b7ebb4d9567497e4f758b13986b3bb736
|
||||
|
||||
COCOAPODS: 1.16.2
|
||||
|
||||
@@ -494,14 +494,14 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = R5KTW5WPS3;
|
||||
DEVELOPMENT_TEAM = 93X3AN3P79;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2.dev;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -519,7 +519,7 @@
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2.RunnerTests;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2.dev.RunnerTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
@@ -537,7 +537,7 @@
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2.RunnerTests;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2.dev.RunnerTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
|
||||
@@ -553,7 +553,7 @@
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2.RunnerTests;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2.dev.RunnerTests;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
|
||||
@@ -680,14 +680,14 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = R5KTW5WPS3;
|
||||
DEVELOPMENT_TEAM = 93X3AN3P79;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2.dev;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -706,14 +706,14 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||
DEVELOPMENT_TEAM = R5KTW5WPS3;
|
||||
DEVELOPMENT_TEAM = 93X3AN3P79;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.maibu.maibuSatabotV2.dev;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
||||
@@ -83,15 +83,10 @@
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>需要使用相机</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>需要使用麦克风</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
<!-- 蓝牙权限 -->
|
||||
<key>NSBluetoothAlwaysUsageDescription</key>
|
||||
<string>需要使用蓝牙连接设备</string>
|
||||
<key>NSBluetoothPeripheralUsageDescription</key>
|
||||
<string>需要使用蓝牙连接设备</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:developer' as developer;
|
||||
import 'dart:io' show Platform;
|
||||
import 'dart:typed_data';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
@@ -15,6 +16,9 @@ class BleManager {
|
||||
BluetoothCharacteristic? _writeCharacteristic;
|
||||
BluetoothCharacteristic? _readCharacteristic;
|
||||
|
||||
/// 🔥 已连接设备的名称(连接时从扫描结果或设备属性保存,断开时清空)
|
||||
String? _connectedDeviceName;
|
||||
|
||||
/// 有状态的协议解析器(支持 BLE 分片)
|
||||
final ProtocolParser _parser = ProtocolParser();
|
||||
|
||||
@@ -32,6 +36,7 @@ class BleManager {
|
||||
StreamSubscription<List<int>>? _readSubscription;
|
||||
StreamSubscription<BluetoothAdapterState>? _adapterStateSubscription;
|
||||
StreamSubscription<BluetoothConnectionState>? _deviceConnectionSubscription;
|
||||
StreamSubscription<int>? _mtuSubscription;
|
||||
|
||||
/// 防止异步竞态:stopScan() 后 in-flight 的 startScan() 不应生效
|
||||
int _scanGen = 0;
|
||||
@@ -50,11 +55,19 @@ class BleManager {
|
||||
bool get isConnected => _connectedDevice != null;
|
||||
BluetoothDevice? get connectedDevice => _connectedDevice;
|
||||
BluetoothDevice? get connectingDevice => _connectingDevice;
|
||||
|
||||
/// 🔥 获取已连接设备的名称(连接时缓存,断开后为 null)
|
||||
String? get connectedDeviceName => _connectedDeviceName;
|
||||
Stream<List<ScanResult>> get scanResults => _scanController.stream;
|
||||
Stream<BlePacket> get packetStream => _packetController.stream;
|
||||
Stream<BluetoothAdapterState> get adapterState =>
|
||||
FlutterBluePlus.adapterState;
|
||||
|
||||
/// 🔥 获取当前蓝牙扫描结果列表(供外部查询使用)
|
||||
List<ScanResult> getScanResults() {
|
||||
return _scanResults.values.toList();
|
||||
}
|
||||
|
||||
/// 连接状态变化流:连接成功时发出 device,断开时发出 null
|
||||
Stream<BluetoothDevice?> get connectionStream => _connectionController.stream;
|
||||
|
||||
@@ -67,47 +80,46 @@ class BleManager {
|
||||
}
|
||||
|
||||
Future<bool> requestPermissions() async {
|
||||
final connStatus = await Permission.bluetoothConnect.status;
|
||||
developer.log(
|
||||
'[BLE] bluetoothConnect status: $connStatus',
|
||||
name: 'BleManager',
|
||||
);
|
||||
if (connStatus.isDenied) {
|
||||
developer.log('[BLE] requesting bluetoothConnect...', name: 'BleManager');
|
||||
await Permission.bluetoothConnect.request();
|
||||
}
|
||||
|
||||
final scanStatus = await Permission.bluetoothScan.status;
|
||||
developer.log(
|
||||
'[BLE] bluetoothScan status: $scanStatus',
|
||||
name: 'BleManager',
|
||||
);
|
||||
if (scanStatus.isDenied) {
|
||||
developer.log('[BLE] requesting bluetoothScan...', name: 'BleManager');
|
||||
await Permission.bluetoothScan.request();
|
||||
}
|
||||
|
||||
final locStatus = await Permission.locationWhenInUse.status;
|
||||
developer.log(
|
||||
'[BLE] locationWhenInUse status: $locStatus',
|
||||
name: 'BleManager',
|
||||
);
|
||||
if (locStatus.isDenied) {
|
||||
if (Platform.isAndroid) {
|
||||
final connStatus = await Permission.bluetoothConnect.status;
|
||||
developer.log(
|
||||
'[BLE] requesting locationWhenInUse...',
|
||||
'[BLE] bluetoothConnect status: $connStatus',
|
||||
name: 'BleManager',
|
||||
);
|
||||
await Permission.locationWhenInUse.request();
|
||||
}
|
||||
if (connStatus.isDenied) {
|
||||
await Permission.bluetoothConnect.request();
|
||||
}
|
||||
|
||||
final allGranted =
|
||||
await Permission.bluetoothConnect.isGranted &&
|
||||
await Permission.bluetoothScan.isGranted;
|
||||
developer.log(
|
||||
'[BLE] all permissions granted: $allGranted',
|
||||
name: 'BleManager',
|
||||
);
|
||||
return allGranted;
|
||||
final scanStatus = await Permission.bluetoothScan.status;
|
||||
developer.log(
|
||||
'[BLE] bluetoothScan status: $scanStatus',
|
||||
name: 'BleManager',
|
||||
);
|
||||
if (scanStatus.isDenied) {
|
||||
await Permission.bluetoothScan.request();
|
||||
}
|
||||
|
||||
final locStatus = await Permission.locationWhenInUse.status;
|
||||
developer.log(
|
||||
'[BLE] locationWhenInUse status: $locStatus',
|
||||
name: 'BleManager',
|
||||
);
|
||||
if (locStatus.isDenied) {
|
||||
await Permission.locationWhenInUse.request();
|
||||
}
|
||||
|
||||
final allGranted =
|
||||
await Permission.bluetoothConnect.isGranted &&
|
||||
await Permission.bluetoothScan.isGranted;
|
||||
developer.log(
|
||||
'[BLE] all permissions granted: $allGranted',
|
||||
name: 'BleManager',
|
||||
);
|
||||
return allGranted;
|
||||
}
|
||||
// iOS: 蓝牙权限由 Info.plist 声明,系统弹窗授权,无需主动请求
|
||||
developer.log('[BLE] iOS platform, skipping Android permissions', name: 'BleManager');
|
||||
return true;
|
||||
}
|
||||
|
||||
Future<void> openBluetooth() async {
|
||||
@@ -168,15 +180,17 @@ class BleManager {
|
||||
return;
|
||||
}
|
||||
|
||||
final locEnabled = await _checkLocationService();
|
||||
if (myGen != _scanGen) return;
|
||||
if (!locEnabled) {
|
||||
developer.log(
|
||||
'[BLE] Location service OFF, directing to settings',
|
||||
name: 'BleManager',
|
||||
);
|
||||
await _openLocationSettings();
|
||||
return;
|
||||
if (Platform.isAndroid) {
|
||||
final locEnabled = await _checkLocationService();
|
||||
if (myGen != _scanGen) return;
|
||||
if (!locEnabled) {
|
||||
developer.log(
|
||||
'[BLE] Location service OFF, directing to settings',
|
||||
name: 'BleManager',
|
||||
);
|
||||
await _openLocationSettings();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_scanSubscription?.cancel();
|
||||
@@ -238,6 +252,18 @@ class BleManager {
|
||||
|
||||
/// 连接设备,返回 null 表示成功,返回错误信息字符串表示失败
|
||||
Future<String?> connect(BluetoothDevice device) async {
|
||||
// 🔥 连接前先保存设备名(从扫描结果或设备属性中获取)
|
||||
final scanResult = _scanResults[device.remoteId];
|
||||
final advName = scanResult?.device.advName ?? '';
|
||||
final platformName = device.platformName;
|
||||
_connectedDeviceName = platformName.isNotEmpty
|
||||
? platformName
|
||||
: (advName.isNotEmpty ? advName : device.remoteId.toString());
|
||||
developer.log(
|
||||
'[BLE] 🔥 保存已连接设备名: $_connectedDeviceName',
|
||||
name: 'BleManager',
|
||||
);
|
||||
|
||||
// 标记正在连接,通知所有监听者
|
||||
_connectingDevice = device;
|
||||
_connectingController.add(device);
|
||||
@@ -264,14 +290,8 @@ class BleManager {
|
||||
});
|
||||
_connectionController.add(device);
|
||||
await _discoverServices(device);
|
||||
// 确认协商后的 MTU
|
||||
try {
|
||||
final mtu = await device.requestMtu(512);
|
||||
_negotiatedMtu = mtu;
|
||||
developer.log('[BLE] MTU: $mtu', name: 'BleManager');
|
||||
} catch (e) {
|
||||
developer.log('[BLE] requestMtu failed: $e', name: 'BleManager');
|
||||
}
|
||||
// 确认协商后的 MTU(Android 主动请求;iOS 由 CoreBluetooth 自动协商)
|
||||
await _setupMtu(device);
|
||||
return null; // 成功
|
||||
} catch (e) {
|
||||
// 连接失败,清除连接中状态
|
||||
@@ -285,14 +305,59 @@ class BleManager {
|
||||
}
|
||||
}
|
||||
|
||||
/// 平台差异化的 MTU 协商
|
||||
/// - Android: 主动 requestMtu(512),一般协商到 247/517
|
||||
/// - iOS: CoreBluetooth 自动协商,requestMtu 会抛异常;读 mtuNow 并订阅 mtu 流
|
||||
Future<void> _setupMtu(BluetoothDevice device) async {
|
||||
if (Platform.isAndroid) {
|
||||
try {
|
||||
final mtu = await device.requestMtu(512);
|
||||
_negotiatedMtu = mtu;
|
||||
developer.log('[BLE] Android MTU negotiated: $mtu', name: 'BleManager');
|
||||
} catch (e) {
|
||||
developer.log('[BLE] requestMtu failed: $e', name: 'BleManager');
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (Platform.isIOS) {
|
||||
// iOS 上 connect 完成后系统会异步协商 MTU,稍等一拍再读取实际值
|
||||
try {
|
||||
await Future.delayed(const Duration(milliseconds: 300));
|
||||
final mtu = device.mtuNow;
|
||||
// iOS 保底 185(现代 iPhone CoreBluetooth 常见协商值),避免默认 23 把长帧切成 9 片
|
||||
_negotiatedMtu = mtu > 23 ? mtu : 185;
|
||||
developer.log(
|
||||
'[BLE] iOS MTU (auto-negotiated): mtuNow=$mtu, using=$_negotiatedMtu',
|
||||
name: 'BleManager',
|
||||
);
|
||||
// 订阅后续 MTU 变化(部分外设会在服务发现后再次协商)
|
||||
_mtuSubscription?.cancel();
|
||||
_mtuSubscription = device.mtu.listen((m) {
|
||||
if (m > 23 && m != _negotiatedMtu) {
|
||||
_negotiatedMtu = m;
|
||||
developer.log('[BLE] iOS MTU updated: $m', name: 'BleManager');
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
_negotiatedMtu = 185;
|
||||
developer.log(
|
||||
'[BLE] iOS MTU setup failed, fallback to 185: $e',
|
||||
name: 'BleManager',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _onDeviceDisconnected() {
|
||||
_connectedDevice = null;
|
||||
_connectingDevice = null;
|
||||
_connectedDeviceName = null; // 🔥 清空已连接设备名
|
||||
_writeCharacteristic = null;
|
||||
_readCharacteristic = null;
|
||||
_negotiatedMtu = 23;
|
||||
_readSubscription?.cancel();
|
||||
_deviceConnectionSubscription?.cancel();
|
||||
_mtuSubscription?.cancel();
|
||||
_connectionController.add(null);
|
||||
_connectingController.add(null);
|
||||
// 清空协议解析器缓冲区
|
||||
@@ -405,7 +470,7 @@ class BleManager {
|
||||
final totalChunks = (frame.length + maxWriteLen - 1) ~/ maxWriteLen;
|
||||
if (totalChunks > 1) {
|
||||
developer.log(
|
||||
'[BLE] 🔀 分${totalChunks}片写入 (MTU=$_negotiatedMtu, 每片≤${maxWriteLen}B)',
|
||||
'[BLE] 🔀 分${totalChunks}片写入 (platform=${Platform.isIOS ? "iOS" : "Android"}, MTU=$_negotiatedMtu, 每片≤${maxWriteLen}B)',
|
||||
name: 'BleManager',
|
||||
);
|
||||
}
|
||||
@@ -422,6 +487,13 @@ class BleManager {
|
||||
);
|
||||
}
|
||||
await char.write(chunk, withoutResponse: false);
|
||||
// iOS 分片间加小延时,给 MCU 侧协议解析器留出帧间处理时间,
|
||||
// 避免长帧(如 0x06 写配置 176B)被拆多片时因间隔过短触发丢帧
|
||||
if (Platform.isIOS &&
|
||||
totalChunks > 1 &&
|
||||
offset + maxWriteLen < frame.length) {
|
||||
await Future.delayed(const Duration(milliseconds: 20));
|
||||
}
|
||||
}
|
||||
developer.log('[BLE] ✅ 写入完成', name: 'BleManager');
|
||||
}
|
||||
@@ -440,6 +512,7 @@ class BleManager {
|
||||
_readSubscription?.cancel();
|
||||
_adapterStateSubscription?.cancel();
|
||||
_deviceConnectionSubscription?.cancel();
|
||||
_mtuSubscription?.cancel();
|
||||
_scanController.close();
|
||||
_packetController.close();
|
||||
_connectionController.close();
|
||||
|
||||
@@ -68,27 +68,38 @@ class BleProtocolDecoder {
|
||||
static BleDecodedResult _decodeStatusInfo(Uint8List data, String hex) {
|
||||
final fields = <BleField>[];
|
||||
|
||||
// 🔥 关键修复:协议帧为 AB AA 02 [24个逗号字段] CRC_lo CRC_hi AA AB。
|
||||
// ProtocolParser 只剥离了帧尾 AA AB,payload 末尾仍带 2 字节 CRC16(小端)。
|
||||
// 障碍物标志位是最后一个字段(fields[23]),若不先去掉 CRC,
|
||||
// 这 2 字节会粘到障碍物字段上导致乱码。此处先剥离尾部 2 字节 CRC。
|
||||
final Uint8List body =
|
||||
data.length > 2 ? Uint8List.sublistView(data, 0, data.length - 2) : data;
|
||||
|
||||
try {
|
||||
final text = utf8.decode(data);
|
||||
// allowMalformed 兜底:非法字节不再抛异常、不再落入 latin1 造成整段乱码
|
||||
var text = utf8.decode(body, allowMalformed: true);
|
||||
// 去掉控制字符(\0 \r \n 等)与替换符(U+FFFD):固件常在串尾补 \0,
|
||||
// 或残留 CRC 被解码成非法字符,粘在最后一个字段(障碍物)上造成乱码
|
||||
text = text.replaceAll(RegExp(r'[\u0000-\u001F\uFFFD]'), '');
|
||||
if (text.contains(',')) {
|
||||
final parts = text.split(',');
|
||||
return BleDecodedResult(fields: _parseStatusFields(parts), rawHex: hex);
|
||||
}
|
||||
} catch (e) {
|
||||
try {
|
||||
final text = latin1.decode(data);
|
||||
if (text.contains(',')) {
|
||||
final parts = text.split(',');
|
||||
return BleDecodedResult(
|
||||
fields: _parseStatusFields(parts),
|
||||
rawHex: hex,
|
||||
// 诊断:仅当控制模式槽位(parts[20])出现协议外码(如6)时,打印全字段索引对齐,
|
||||
// 用于判断是固件扩展码还是字段错位;正常包不打印,避免刷屏
|
||||
if (parts.length > 20 &&
|
||||
!const ['0', '1', '2', '3', '4'].contains(parts[20].trim())) {
|
||||
developer.log(
|
||||
'[BLE-0x02] 字段对齐诊断: ' +
|
||||
List.generate(parts.length, (i) => '[$i]=${parts[i]}')
|
||||
.join(' '),
|
||||
name: 'BleProtocolDecoder',
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
return BleDecodedResult(fields: _parseStatusFields(parts), rawHex: hex);
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
if (data.isNotEmpty) {
|
||||
final status = data[0];
|
||||
if (body.isNotEmpty) {
|
||||
final status = body[0];
|
||||
fields.add(
|
||||
BleField(
|
||||
label: '状态码',
|
||||
@@ -96,8 +107,8 @@ class BleProtocolDecoder {
|
||||
),
|
||||
);
|
||||
}
|
||||
if (data.length >= 2) {
|
||||
final mode = data[1];
|
||||
if (body.length >= 2) {
|
||||
final mode = body[1];
|
||||
const modes = {0x00: '待机', 0x01: '遥控', 0x02: '自动', 0x03: '急停'};
|
||||
fields.add(
|
||||
BleField(
|
||||
@@ -106,10 +117,10 @@ class BleProtocolDecoder {
|
||||
),
|
||||
);
|
||||
}
|
||||
if (data.length >= 3)
|
||||
fields.add(BleField(label: '电量', value: '${data[2]}%'));
|
||||
if (data.length >= 4) {
|
||||
final fault = data[3];
|
||||
if (body.length >= 3)
|
||||
fields.add(BleField(label: '电量', value: '${body[2]}%'));
|
||||
if (body.length >= 4) {
|
||||
final fault = body[3];
|
||||
fields.add(
|
||||
BleField(
|
||||
label: '故障状态',
|
||||
@@ -119,13 +130,13 @@ class BleProtocolDecoder {
|
||||
),
|
||||
);
|
||||
}
|
||||
if (data.length >= 6) {
|
||||
final speed = (data[5] << 8) | data[4];
|
||||
if (body.length >= 6) {
|
||||
final speed = (body[5] << 8) | body[4];
|
||||
fields.add(BleField(label: '速度', value: '$speed'));
|
||||
}
|
||||
if (data.length > 8) {
|
||||
if (body.length > 8) {
|
||||
try {
|
||||
final text = String.fromCharCodes(data.sublist(8));
|
||||
final text = String.fromCharCodes(body.sublist(8));
|
||||
if (text.isNotEmpty && !text.contains('\x00')) {
|
||||
fields.add(BleField(label: '附加', value: text));
|
||||
}
|
||||
@@ -141,24 +152,32 @@ class BleProtocolDecoder {
|
||||
parts.add('');
|
||||
}
|
||||
|
||||
// 协议定义 控制模式: 0无控制 1本地遥控 2蓝牙 3TCP 4其他接口;
|
||||
// 先按整数解析(容忍前后空格),有映射的一律显示对应文字;
|
||||
// 超出协议范围的码(如固件扩展值)显示为 未知(n),避免被误当成有效模式
|
||||
String controlModeText(String v) {
|
||||
return switch (v) {
|
||||
'0' => '待机',
|
||||
'1' => '遥控',
|
||||
'2' => '自动',
|
||||
'3' => '急停',
|
||||
_ => v.isNotEmpty ? v : '--',
|
||||
final n = int.tryParse(v.trim());
|
||||
if (n == null) return v.isEmpty ? '--' : v;
|
||||
return switch (n) {
|
||||
0 => '无控制',
|
||||
1 => '本地遥控',
|
||||
2 => '蓝牙',
|
||||
3 => 'TCP',
|
||||
4 => '其他接口',
|
||||
_ => '未知($n)',
|
||||
};
|
||||
}
|
||||
|
||||
// 协议定义 定位质量: 0无效 1GPS单点 2DGPS差分/SBAS 4RTK固定解 5RTK浮点解 7手动输入
|
||||
String qualText(String v) {
|
||||
final q = int.tryParse(v) ?? -1;
|
||||
return switch (q) {
|
||||
0 => '无效',
|
||||
1 => '单点定位',
|
||||
2 => '差分定位',
|
||||
4 => '固定解',
|
||||
5 => '浮点解',
|
||||
1 => 'GPS 单点定位',
|
||||
2 => 'DGPS 差分/SBAS',
|
||||
4 => 'RTK 固定解',
|
||||
5 => 'RTK 浮点解',
|
||||
7 => '手动输入模式',
|
||||
_ => v.isNotEmpty ? v : '--',
|
||||
};
|
||||
}
|
||||
@@ -173,11 +192,14 @@ class BleProtocolDecoder {
|
||||
}
|
||||
|
||||
String obstacleText(String v) {
|
||||
final o = int.tryParse(v) ?? -1;
|
||||
return switch (o) {
|
||||
// 障碍物标志位为单个数字 0/1;字段尾部可能粘有 CRC/\0 等杂质,
|
||||
// 取第一个数字字符作为标志,无数字则显示 '--',杜绝杂质乱码
|
||||
final d = RegExp(r'[0-9]').firstMatch(v);
|
||||
if (d == null) return '--';
|
||||
return switch (int.parse(d.group(0)!)) {
|
||||
0 => '无障碍',
|
||||
1 => '有障碍',
|
||||
_ => v.isNotEmpty ? v : '--',
|
||||
_ => v,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,10 @@ class HttpApiConsts {
|
||||
// 获取全部设备列表(用于蓝牙绑定匹配)
|
||||
static String get getDeviceList => "$baseUrl/iot/device/getDeviceList";
|
||||
|
||||
// 根据拆分码(蓝牙设备名/时间戳)精确查询设备(用于蓝牙绑定匹配)
|
||||
static String get getDeviceBySpiltCode =>
|
||||
"$baseUrl/iot/device/getDeviceBySpiltCode";
|
||||
|
||||
// 获取机器人列表
|
||||
static String get getRobotList => "$baseUrl/iot/device/getSiteList";
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ import '../../features/v2/device_list/domain/repositories/device_repository.dart
|
||||
import '../../features/v2/device_list/domain/usecases/get_device_status_data_usecase.dart'
|
||||
as device_v2_usecase;
|
||||
import '../../features/v2/device_list/domain/usecases/get_all_devices_usecase.dart';
|
||||
import '../../features/v2/device_list/domain/usecases/get_device_by_spilt_code_usecase.dart';
|
||||
import '../../features/v2/device_list/presentation/bloc/device_status_bloc.dart'
|
||||
as device_v2_bloc;
|
||||
import '../../features/v2/device_list/data/datasources/drone_station_datasource.dart';
|
||||
@@ -380,6 +381,9 @@ Future<void> init() async {
|
||||
sl.registerLazySingleton<GetAllDevicesUseCase>(
|
||||
() => GetAllDevicesUseCase(repository: sl()),
|
||||
);
|
||||
sl.registerLazySingleton<GetDeviceBySpiltCodeUseCase>(
|
||||
() => GetDeviceBySpiltCodeUseCase(repository: sl()),
|
||||
);
|
||||
sl.registerFactory<device_v2_bloc.DeviceStatusBloc>(
|
||||
() => device_v2_bloc.DeviceStatusBloc(sl()),
|
||||
);
|
||||
|
||||
6
lib/core/env/env_config.dart
vendored
6
lib/core/env/env_config.dart
vendored
@@ -1,7 +1,7 @@
|
||||
class EnvConfig {
|
||||
static const String environment = String.fromEnvironment(
|
||||
'ENV',
|
||||
defaultValue: 'test',
|
||||
defaultValue: 'prod',
|
||||
);
|
||||
|
||||
static String get sentryDsn {
|
||||
@@ -24,4 +24,8 @@ class EnvConfig {
|
||||
// ─── HTTP 接口 ───
|
||||
static int get httpPort => isProduction ? 8081 : 59003;
|
||||
static String get baseUrl => 'http://$serverHost:$httpPort';
|
||||
|
||||
// ─── MQTT(一方后端:任务消息 / 割草机实时状态,prod=1883 / test=59007)───
|
||||
// 注:第三方无人机 OSD(droneOsd,WebSocket 8083)不纳入环境管理,保持硬编码
|
||||
static int get mqttPort => isProduction ? 1883 : 59007;
|
||||
}
|
||||
|
||||
@@ -40,12 +40,17 @@ class DioClient {
|
||||
if (response.data is Map<String, dynamic>) {
|
||||
final code = response.data['code'];
|
||||
if (code == 401 || code == 403) {
|
||||
print(
|
||||
'>>> [DIO] 🚨🚨🚨 收到业务错误码 $code,触发 Token 过期处理!URL: ${response.requestOptions.uri},时间: ${DateTime.now()}',
|
||||
);
|
||||
try {
|
||||
sl<AuthCubit>().tokenExpired();
|
||||
} catch (ex) {}
|
||||
// 🔥 仅在当前确实处于登录态时,才把 401 当作「登录过期」弹窗。
|
||||
// 退出登录过程中 AppUserCubit.user 已被清为 null,此时残留/竞态请求
|
||||
// 返回的 401 不应再打扰用户(人已经在退出了),否则会误弹「登录已过期」。
|
||||
if (sl<AppUserCubit>().state.user != null) {
|
||||
print(
|
||||
'>>> [DIO] 🚨🚨🚨 收到业务错误码 $code,触发 Token 过期处理!URL: ${response.requestOptions.uri},时间: ${DateTime.now()}',
|
||||
);
|
||||
try {
|
||||
sl<AuthCubit>().tokenExpired();
|
||||
} catch (ex) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
return handler.next(response);
|
||||
@@ -53,12 +58,15 @@ class DioClient {
|
||||
|
||||
onError: (DioException e, handler) async {
|
||||
if (e.response?.statusCode == 401 || e.response?.statusCode == 403) {
|
||||
print(
|
||||
'>>> [DIO] 🚨🚨🚨 收到 HTTP ${e.response?.statusCode},触发 Token 过期处理!URL: ${e.requestOptions.uri},时间: ${DateTime.now()}',
|
||||
);
|
||||
try {
|
||||
sl<AuthCubit>().tokenExpired();
|
||||
} catch (ex) {}
|
||||
// 🔥 同上:已退出登录(user==null)时不再触发过期弹窗
|
||||
if (sl<AppUserCubit>().state.user != null) {
|
||||
print(
|
||||
'>>> [DIO] 🚨🚨🚨 收到 HTTP ${e.response?.statusCode},触发 Token 过期处理!URL: ${e.requestOptions.uri},时间: ${DateTime.now()}',
|
||||
);
|
||||
try {
|
||||
sl<AuthCubit>().tokenExpired();
|
||||
} catch (ex) {}
|
||||
}
|
||||
}
|
||||
|
||||
return handler.next(e);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
import '../../../../env/env_config.dart';
|
||||
|
||||
/// MQTT 传输协议类型
|
||||
enum MqttProtocol {
|
||||
/// 纯 TCP 连接(原生 MQTT)
|
||||
@@ -67,11 +69,11 @@ class MqttConfig extends Equatable {
|
||||
);
|
||||
}
|
||||
|
||||
/// 任务状态消息(TCP MQTT)
|
||||
/// 任务状态消息(TCP MQTT)——端口随环境切换(prod=1883 / test=59007)
|
||||
factory MqttConfig.taskMessage() {
|
||||
return const MqttConfig(
|
||||
host: '1.95.137.212',
|
||||
port: 1883,
|
||||
return MqttConfig(
|
||||
host: EnvConfig.serverHost,
|
||||
port: EnvConfig.mqttPort,
|
||||
username: 'maibu',
|
||||
password: 'jsmbzn520',
|
||||
protocol: MqttProtocol.tcp,
|
||||
@@ -81,12 +83,12 @@ class MqttConfig extends Equatable {
|
||||
);
|
||||
}
|
||||
|
||||
/// 🔥 割草机机器状态(TCP MQTT)——独立连接,地址 1.95.137.212:59007
|
||||
/// 🔥 割草机机器状态(TCP MQTT)——独立连接,端口随环境切换(prod=1883 / test=59007)
|
||||
/// 仅用于 mower/{sn}/property/realtime/post 和 mower/{sn}/property/location/post
|
||||
factory MqttConfig.mowerRealtime() {
|
||||
return const MqttConfig(
|
||||
host: '1.95.137.212',
|
||||
port: 59007,
|
||||
return MqttConfig(
|
||||
host: EnvConfig.serverHost,
|
||||
port: EnvConfig.mqttPort,
|
||||
username: 'maibu',
|
||||
password: 'jsmbzn520',
|
||||
protocol: MqttProtocol.tcp,
|
||||
|
||||
@@ -30,13 +30,19 @@ GoRouter createRouter(AuthCubit authCubit) {
|
||||
|
||||
return GoRouter(
|
||||
navigatorKey: navigatorKey, // 🔥 绑定全局 navigatorKey,使异地登录弹窗能获取 context
|
||||
initialLocation: RoutePaths.login,
|
||||
initialLocation: RoutePaths.splash,
|
||||
refreshListenable: GoRouterRefreshStream(authCubit.stream),
|
||||
redirect: (context, state) {
|
||||
final loggedIn = authCubit.state is AuthAuthenticated;
|
||||
final onSplash = state.matchedLocation == RoutePaths.splash;
|
||||
final loggingIn = state.matchedLocation == RoutePaths.login;
|
||||
final registering = state.matchedLocation == RoutePaths.register;
|
||||
|
||||
// 启动屏:交给 SplashPage 自己根据就绪信号跳转,路由层不干预
|
||||
if (onSplash) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 如果未登录,只允许访问 login 和 register 页面
|
||||
if (!loggedIn && !loggingIn && !registering) {
|
||||
return RoutePaths.login;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
class RoutePaths {
|
||||
/// 启动页(App 第一个路由)
|
||||
static const splash = '/splash';
|
||||
|
||||
/// 账号相关页面
|
||||
static const login = '/auth/login';
|
||||
static const register = '/auth/register';
|
||||
|
||||
@@ -18,19 +18,47 @@ class LoginPage extends StatefulWidget {
|
||||
State<LoginPage> createState() => _LoginPageState();
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
class _LoginPageState extends State<LoginPage> with SingleTickerProviderStateMixin {
|
||||
final _userCtrl = TextEditingController();
|
||||
final _pwdCtrl = TextEditingController();
|
||||
bool _isAgreed = false; // 协议勾选状态
|
||||
bool _obscurePwd = true; // 密码可见性
|
||||
|
||||
// 进场动画控制器
|
||||
late final AnimationController _entranceController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_entranceController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 900),
|
||||
);
|
||||
// 等首帧渲染 + 图片解码完成后再播放,避开启动初始化争抢导致的掉帧
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
Future.delayed(const Duration(milliseconds: 120), () {
|
||||
if (mounted) _entranceController.forward();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_entranceController.dispose();
|
||||
_userCtrl.dispose();
|
||||
_pwdCtrl.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 生成一个错峰区间的动画(0.0 ~ 1.0)
|
||||
Animation<double> _interval(double begin, double end) {
|
||||
return CurvedAnimation(
|
||||
parent: _entranceController,
|
||||
curve: Interval(begin, end, curve: Curves.easeOut),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -64,130 +92,94 @@ class _LoginPageState extends State<LoginPage> {
|
||||
// 顶部区域:图片 + 认证信息 + 标题(压缩空间)
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// 顶部居中图片和认证信息
|
||||
Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/huawei.png',
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: Text(
|
||||
"通过华为云生态技术认证,请放心使用,证书编号C202605301",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: context.appColors.textTertiary,
|
||||
height: 1.3,
|
||||
// ① 顶部居中图片和认证信息(缩放淡入)
|
||||
_Entrance(
|
||||
animation: _interval(0.00, 0.35),
|
||||
scale: true,
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Image.asset(
|
||||
'assets/images/huawei.png',
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||
child: Text(
|
||||
"通过华为云生态技术认证,请放心使用,证书编号C202605301",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: context.appColors.textTertiary,
|
||||
height: 1.3,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
"账号登录",
|
||||
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: context.appColors.textPrimary),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text("请填写以下信息以验证身份", style: TextStyle(fontSize: 15, color: context.appColors.textTertiary)),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 表单区域
|
||||
// 账号输入框
|
||||
_buildInputLabel("账号"),
|
||||
TextField(
|
||||
controller: _userCtrl,
|
||||
style: TextStyle(fontSize: 14, color: context.appColors.textPrimary),
|
||||
cursorColor: context.appColors.textPrimary,
|
||||
decoration: _inputDecoration(hint: "请输入用户名"),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// 密码输入框
|
||||
_buildInputLabel("密码"),
|
||||
TextField(
|
||||
controller: _pwdCtrl,
|
||||
obscureText: _obscurePwd,
|
||||
style: TextStyle(fontSize: 14, color: context.appColors.textPrimary),
|
||||
cursorColor: context.appColors.textPrimary,
|
||||
decoration: _inputDecoration(
|
||||
hint: "请输入密码",
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscurePwd ? Icons.visibility_off_outlined : Icons.visibility_outlined, color: context.appColors.textTertiary, size: 20),
|
||||
onPressed: () => setState(() => _obscurePwd = !_obscurePwd),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 协议勾选区域
|
||||
_buildProtocolSection(),
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// 底部区域:登录按钮 + 注册链接
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: BlocBuilder<LoginCubit, LoginState>(
|
||||
builder: (context, state) {
|
||||
bool isLoading = state is LoginLoading;
|
||||
|
||||
return CCPrimaryButton(
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () {
|
||||
if (!_isAgreed) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('请先阅读并同意用户协议'),
|
||||
duration: Duration(seconds: 1),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
_handleLogin();
|
||||
},
|
||||
text: isLoading ? '登录中...' : '登 录',
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
// ② 标题区(上滑淡入)
|
||||
_Entrance(
|
||||
animation: _interval(0.10, 0.45),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"没有账号吗?",
|
||||
style: TextStyle(fontSize: 14, color: context.appColors.textTertiary),
|
||||
"账号登录",
|
||||
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: context.appColors.textPrimary),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
debugPrint(' 点击了立即注册');
|
||||
debugPrint('👉 跳转路径: ${RoutePaths.register}');
|
||||
context.go(RoutePaths.register);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: Text(
|
||||
"立即注册",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: context.appColors.textPrimary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text("请填写以下信息以验证身份", style: TextStyle(fontSize: 15, color: context.appColors.textTertiary)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// ③ 表单区域
|
||||
// 账号输入框(上滑淡入)
|
||||
_Entrance(
|
||||
animation: _interval(0.20, 0.55),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildInputLabel("账号"),
|
||||
TextField(
|
||||
controller: _userCtrl,
|
||||
style: TextStyle(fontSize: 14, color: context.appColors.textPrimary),
|
||||
cursorColor: context.appColors.textPrimary,
|
||||
decoration: _inputDecoration(hint: "请输入用户名"),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// 密码输入框(上滑淡入)
|
||||
_Entrance(
|
||||
animation: _interval(0.28, 0.63),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildInputLabel("密码"),
|
||||
TextField(
|
||||
controller: _pwdCtrl,
|
||||
obscureText: _obscurePwd,
|
||||
style: TextStyle(fontSize: 14, color: context.appColors.textPrimary),
|
||||
cursorColor: context.appColors.textPrimary,
|
||||
decoration: _inputDecoration(
|
||||
hint: "请输入密码",
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscurePwd ? Icons.visibility_off_outlined : Icons.visibility_outlined, color: context.appColors.textTertiary, size: 20),
|
||||
onPressed: () => setState(() => _obscurePwd = !_obscurePwd),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -195,6 +187,83 @@ class _LoginPageState extends State<LoginPage> {
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// ④ 协议勾选区域(上滑淡入)
|
||||
_Entrance(
|
||||
animation: _interval(0.36, 0.71),
|
||||
child: _buildProtocolSection(),
|
||||
),
|
||||
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// ⑤ 底部区域:登录按钮(上滑淡入)
|
||||
_Entrance(
|
||||
animation: _interval(0.45, 0.82),
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: BlocBuilder<LoginCubit, LoginState>(
|
||||
builder: (context, state) {
|
||||
bool isLoading = state is LoginLoading;
|
||||
|
||||
return CCPrimaryButton(
|
||||
onPressed: isLoading
|
||||
? null
|
||||
: () {
|
||||
if (!_isAgreed) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('请先阅读并同意用户协议'),
|
||||
duration: Duration(seconds: 1),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
_handleLogin();
|
||||
},
|
||||
text: isLoading ? '登录中...' : '登 录',
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 注册链接(上滑淡入,最后登场)
|
||||
_Entrance(
|
||||
animation: _interval(0.55, 0.95),
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"没有账号吗?",
|
||||
style: TextStyle(fontSize: 14, color: context.appColors.textTertiary),
|
||||
),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
debugPrint(' 点击了立即注册');
|
||||
debugPrint('👉 跳转路径: ${RoutePaths.register}');
|
||||
context.go(RoutePaths.register);
|
||||
},
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: Text(
|
||||
"立即注册",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: context.appColors.textPrimary,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
),
|
||||
@@ -320,3 +389,37 @@ class _LoginPageState extends State<LoginPage> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 进场动画包装组件:淡入 + 上滑(默认)或淡入 + 缩放(scale=true)
|
||||
class _Entrance extends StatelessWidget {
|
||||
const _Entrance({
|
||||
required this.animation,
|
||||
required this.child,
|
||||
this.scale = false,
|
||||
this.slideOffset = const Offset(0, 0.15),
|
||||
});
|
||||
|
||||
final Animation<double> animation;
|
||||
final Widget child;
|
||||
final bool scale;
|
||||
final Offset slideOffset;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final curved = CurvedAnimation(parent: animation, curve: Curves.easeOutCubic);
|
||||
|
||||
if (scale) {
|
||||
final scaleAnim = Tween<double>(begin: 0.85, end: 1.0).animate(curved);
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: ScaleTransition(scale: scaleAnim, child: child),
|
||||
);
|
||||
}
|
||||
|
||||
final slideAnim = Tween<Offset>(begin: slideOffset, end: Offset.zero).animate(curved);
|
||||
return FadeTransition(
|
||||
opacity: animation,
|
||||
child: SlideTransition(position: slideAnim, child: child),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
114
lib/features/auth/presentation/pages/splash_page.dart
Normal file
114
lib/features/auth/presentation/pages/splash_page.dart
Normal file
@@ -0,0 +1,114 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../../core/router/route_paths.dart';
|
||||
import '../bloc/auth_cubit.dart';
|
||||
import '../bloc/auth_state.dart';
|
||||
|
||||
/// 启动页:展示 App Logo 并循环播放「呼吸缩放」动画。
|
||||
///
|
||||
/// 该页面作为 App 的第一个路由,衔接原生启动屏(静态 Logo)。
|
||||
/// 动画会一直循环,直到 [AuthCubit.appStarted] 完成、登录态确定
|
||||
/// ([AuthAuthenticated] / [AuthUnauthenticated])这一「就绪信号」到来,
|
||||
/// 才停止动画并跳转到首页或登录页。
|
||||
class SplashPage extends StatefulWidget {
|
||||
const SplashPage({super.key});
|
||||
|
||||
@override
|
||||
State<SplashPage> createState() => _SplashPageState();
|
||||
}
|
||||
|
||||
class _SplashPageState extends State<SplashPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
/// 呼吸动画控制器(循环往复)
|
||||
late final AnimationController _breathController;
|
||||
|
||||
/// 就绪信号是否已到达
|
||||
bool _ready = false;
|
||||
|
||||
/// 就绪后的目标登录态
|
||||
AuthState? _resolvedState;
|
||||
|
||||
/// 防止重复跳转
|
||||
bool _navigated = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_breathController = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 900),
|
||||
)..repeat(reverse: true);
|
||||
|
||||
// 处理进入 splash 时登录态已经确定的情况(appStarted 先于首帧完成)
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) _onReady(context.read<AuthCubit>().state);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_breathController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// 记录就绪信号,并尝试跳转
|
||||
void _onReady(AuthState state) {
|
||||
if (state is AuthAuthenticated || state is AuthUnauthenticated) {
|
||||
_resolvedState = state;
|
||||
_ready = true;
|
||||
_maybeNavigate();
|
||||
}
|
||||
// AuthInitial:尚未就绪,继续停留在启动页播放动画
|
||||
}
|
||||
|
||||
/// 就绪信号到达即离开启动页,不额外增加打开时间
|
||||
void _maybeNavigate() {
|
||||
if (_navigated || !mounted) return;
|
||||
if (!_ready || _resolvedState == null) return;
|
||||
|
||||
_navigated = true;
|
||||
_breathController.stop();
|
||||
if (_resolvedState is AuthAuthenticated) {
|
||||
context.go(RoutePaths.home);
|
||||
} else {
|
||||
context.go(RoutePaths.login);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocListener<AuthCubit, AuthState>(
|
||||
listenWhen: (prev, cur) =>
|
||||
cur is AuthAuthenticated || cur is AuthUnauthenticated,
|
||||
listener: (context, state) => _onReady(state),
|
||||
child: Scaffold(
|
||||
// 与原生启动屏白底保持一致,避免切换时闪色
|
||||
backgroundColor: Colors.white,
|
||||
body: Center(
|
||||
child: AnimatedBuilder(
|
||||
animation: _breathController,
|
||||
builder: (context, child) {
|
||||
// easeInOut 让呼吸更柔和;scale 从 1.0 起始以贴合原生屏尺寸
|
||||
final t = Curves.easeInOut.transform(_breathController.value);
|
||||
final scale = 1.0 - 0.22 * t; // 1.0 -> 0.78,幅度更大更明显
|
||||
final opacity = 1.0 - 0.55 * t; // 1.0 -> 0.45
|
||||
return Opacity(
|
||||
opacity: opacity,
|
||||
child: Transform.scale(scale: scale, child: child),
|
||||
);
|
||||
},
|
||||
// 透明底应用图标,避免白底上出现浅灰"阴影"底块
|
||||
child: Image.asset(
|
||||
'assets/images/app_logo_gray_transparent.png',
|
||||
width: 180,
|
||||
height: 180,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,15 @@ import 'package:maibu_satabot_v2/core/router/route_paths.dart';
|
||||
import 'package:maibu_satabot_v2/features/auth/presentation/pages/login_page.dart';
|
||||
|
||||
import '../pages/register_page.dart';
|
||||
import '../pages/splash_page.dart';
|
||||
|
||||
class AuthRoutes {
|
||||
// 返回一个 List<RouteBase>
|
||||
static List<RouteBase> routes = [
|
||||
GoRoute(
|
||||
path: RoutePaths.splash,
|
||||
builder: (context, state) => const SplashPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: RoutePaths.login,
|
||||
builder: (context, state) => const LoginPage(),
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'dart:convert';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:xml/xml.dart';
|
||||
|
||||
import '../../../../core/consts/http_api_consts.dart';
|
||||
import '../../../../core/di/injection.dart';
|
||||
import '../../../../core/storage/user_storage.dart';
|
||||
import '../../domain/repositories/path_repository.dart';
|
||||
@@ -47,7 +48,7 @@ class PathRepositoryImpl implements PathRepository {
|
||||
required String userId,
|
||||
required String jsonData,
|
||||
}) async {
|
||||
final url = Uri.parse('http://1.95.137.212:59003/iot/workRecord/add');
|
||||
final url = Uri.parse('${HttpApiConsts.baseUrl}/iot/workRecord/add');
|
||||
final headers = {'Content-Type': 'application/json'};
|
||||
final body = jsonEncode({
|
||||
'workName': workName,
|
||||
@@ -74,7 +75,7 @@ class PathRepositoryImpl implements PathRepository {
|
||||
}) async {
|
||||
final timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final url = Uri.parse(
|
||||
'http://1.95.137.212:59003/iot/workRecord/selectByUserId',
|
||||
'${HttpApiConsts.baseUrl}/iot/workRecord/selectByUserId',
|
||||
).replace(queryParameters: {'userId': userId, '_t': timestamp.toString()});
|
||||
|
||||
try {
|
||||
@@ -103,7 +104,7 @@ class PathRepositoryImpl implements PathRepository {
|
||||
final timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final url =
|
||||
Uri.parse(
|
||||
'http://1.95.137.212:59003/iot/workRecord/deleteByWorkName',
|
||||
'${HttpApiConsts.baseUrl}/iot/workRecord/deleteByWorkName',
|
||||
).replace(
|
||||
queryParameters: {'workName': workName, '_t': timestamp.toString()},
|
||||
);
|
||||
@@ -132,7 +133,7 @@ class PathRepositoryImpl implements PathRepository {
|
||||
final timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final url =
|
||||
Uri.parse(
|
||||
'http://1.95.137.212:59003/iot/workRecord/selectByWorkName',
|
||||
'${HttpApiConsts.baseUrl}/iot/workRecord/selectByWorkName',
|
||||
).replace(
|
||||
queryParameters: {'workName': workName, '_t': timestamp.toString()},
|
||||
);
|
||||
@@ -268,7 +269,7 @@ class PathRepositoryImpl implements PathRepository {
|
||||
final timestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final url =
|
||||
Uri.parse(
|
||||
'http://1.95.137.212:59003/iot/workRecord/selectBySiteId',
|
||||
'${HttpApiConsts.baseUrl}/iot/workRecord/selectBySiteId',
|
||||
).replace(
|
||||
queryParameters: {
|
||||
'siteId': siteId.toString(),
|
||||
@@ -508,7 +509,7 @@ class PathRepositoryImpl implements PathRepository {
|
||||
}
|
||||
|
||||
/// 鍒涘缓璁惧<E79281>浠诲姟锛堥€氳繃鎺ュ彛鎵ц<E98EB5>浣滀笟锛?
|
||||
/// 鎺ュ彛鍦板潃: http://1.95.137.212:59003/iot/deviceTask/createDeviceTask
|
||||
/// 鎺ュ彛鍦板潃: ${HttpApiConsts.baseUrl}/iot/deviceTask/createDeviceTask
|
||||
/// 鍏ュ弬: {"deviceId":"...","routeId":76,"siteId":22,"orgId":5}
|
||||
/// 杩斿洖: 鍒涘缓鎴愬姛鐨勪换鍔<E68DA2>D
|
||||
@override
|
||||
@@ -531,7 +532,7 @@ class PathRepositoryImpl implements PathRepository {
|
||||
|
||||
try {
|
||||
final response = await dio.post(
|
||||
'http://1.95.137.212:59003/iot/deviceTask/createDeviceTask',
|
||||
'${HttpApiConsts.baseUrl}/iot/deviceTask/createDeviceTask',
|
||||
data: body,
|
||||
);
|
||||
|
||||
|
||||
@@ -102,6 +102,9 @@ class DeviceTaskCubit extends Cubit<DeviceTaskState> {
|
||||
taskPool: taskList,
|
||||
currentTask: currentTask,
|
||||
currentTaskId: currentTask?.id,
|
||||
// 🔥 活跃任务为空时必须显式清空,否则 copyWith 会保留旧任务导致卡片一直显示
|
||||
clearCurrentTask: currentTask == null,
|
||||
clearCurrentTaskId: currentTask == null,
|
||||
activeTasks: activeTasks,
|
||||
),
|
||||
);
|
||||
@@ -398,7 +401,7 @@ class DeviceTaskCubit extends Cubit<DeviceTaskState> {
|
||||
|
||||
/// 清除当前任务
|
||||
void clearCurrentTask() {
|
||||
emit(state.copyWith(currentTask: null, currentTaskId: null));
|
||||
emit(state.copyWith(clearCurrentTask: true, clearCurrentTaskId: true));
|
||||
_logger.logWithLevel('🧹 清除当前任务');
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ class DeviceTaskState extends Equatable {
|
||||
DeviceTaskState copyWith({
|
||||
List<DeviceTaskEntity>? taskPool,
|
||||
DeviceTaskEntity? currentTask,
|
||||
bool clearCurrentTask = false, // 🔥 显式清空 currentTask(copyWith 传 null 无法置空)
|
||||
int? currentTaskId,
|
||||
bool clearCurrentTaskId = false, // 🔥 显式清空 currentTaskId
|
||||
List<DeviceTaskEntity>? activeTasks, // 🔥 新增
|
||||
bool? isLoading,
|
||||
String? errorMessage,
|
||||
@@ -41,8 +43,9 @@ class DeviceTaskState extends Equatable {
|
||||
}) {
|
||||
return DeviceTaskState(
|
||||
taskPool: taskPool ?? this.taskPool,
|
||||
currentTask: currentTask ?? this.currentTask,
|
||||
currentTaskId: currentTaskId ?? this.currentTaskId,
|
||||
currentTask: clearCurrentTask ? null : (currentTask ?? this.currentTask),
|
||||
currentTaskId:
|
||||
clearCurrentTaskId ? null : (currentTaskId ?? this.currentTaskId),
|
||||
activeTasks: activeTasks ?? this.activeTasks, // 🔥 新增
|
||||
isLoading: isLoading ?? this.isLoading,
|
||||
errorMessage: errorMessage,
|
||||
|
||||
@@ -183,6 +183,9 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
|
||||
LatLng _mapCenter = const LatLng(39.9042, 116.4074);
|
||||
double _headingAngle = 0.0; // 当前机器航向角(单位:度)
|
||||
|
||||
// 🔥 地图 zoom 日志节流:上次已打印过的 zoom 值(变化 ≥ 0.1 才再打)
|
||||
double? _lastLoggedZoom;
|
||||
List typedPathList =
|
||||
<work_area_model.DeviceAddPathPointModel>[]; // 存储生成路径的坐标列表(已转换为LatLng)
|
||||
|
||||
@@ -274,6 +277,34 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 🔥 新增:zoom 变化日志(节流)
|
||||
// 用途:方便开发者手动 pinch/双击缩放到“理想级别”,从日志里读出 zoom 数值,
|
||||
// 反向调整 fitBounds 的 maxZoom(或其他缩放相关参数)。
|
||||
// 节流策略:只有 zoom 变化 ≥ 0.1 才打一次,避免拖拽/缩放过程中刷屏。
|
||||
// 事件来源(event.source)可区分“用户手势”还是“代码调用”:
|
||||
// - dragUpdate / pinchZoomUpdate / doubleTapZoomAnimation* → 用户交互
|
||||
// - custom → controller.move / fitBounds 等代码调用
|
||||
if (mounted && _mapController.camera != null) {
|
||||
final camera = _mapController.camera!;
|
||||
final currentZoom = camera.zoom;
|
||||
final shouldLog =
|
||||
_lastLoggedZoom == null ||
|
||||
(currentZoom - _lastLoggedZoom!).abs() >= 0.1;
|
||||
if (shouldLog) {
|
||||
final delta =
|
||||
_lastLoggedZoom == null
|
||||
? 'init'
|
||||
: '${currentZoom > _lastLoggedZoom! ? "↑放大" : "↓缩小"} '
|
||||
'${(currentZoom - _lastLoggedZoom!).toStringAsFixed(2)}';
|
||||
debugPrint(
|
||||
'🔍 [地图缩放] zoom=${currentZoom.toStringAsFixed(3)} ($delta), '
|
||||
'center=(${camera.center.latitude.toStringAsFixed(6)}, ${camera.center.longitude.toStringAsFixed(6)}), '
|
||||
'source=${event.source}',
|
||||
);
|
||||
_lastLoggedZoom = currentZoom;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 🌐 场站高清图层:监听动态范围更新 + 触发一次 GetCapabilities 刷新
|
||||
@@ -687,6 +718,47 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 🔥 选中路线任务时,自动校验"上次执行的任务"是否仍然存在
|
||||
/// 若任务已被取消/完成/不存在,则清除当前任务,避免面板显示过期任务卡片
|
||||
Future<void> _validateCurrentTaskOnSelect() async {
|
||||
try {
|
||||
final targetDevice =
|
||||
context.read<RemoteControlCubit>().state.targetDevice;
|
||||
final deviceId = targetDevice?.deviceName;
|
||||
if (deviceId == null || deviceId.isEmpty) return;
|
||||
|
||||
final taskCubit = sl<DeviceTaskCubit>();
|
||||
|
||||
// 优先取内存中的 taskId,其次从本地恢复(仅用于存在性校验,不提前构造卡片,避免闪现假任务)
|
||||
var previousTaskId = taskCubit.state.currentTaskId;
|
||||
if (previousTaskId == null) {
|
||||
previousTaskId = await _restoreTaskIdFromLocal(deviceId);
|
||||
}
|
||||
|
||||
// 没有历史任务,无需校验,也不展示卡片
|
||||
if (previousTaskId == null) return;
|
||||
|
||||
debugPrint(
|
||||
'🔄 [选中校验] 校验上次任务是否存在, deviceId=$deviceId, taskId=$previousTaskId',
|
||||
);
|
||||
await taskCubit.fetchAndFilterTask(deviceId);
|
||||
|
||||
// 🔥 查询后如果上次的任务已不在活跃任务中,清除当前任务,卡片不再展示
|
||||
final stillExists = taskCubit.state.activeTasks.any(
|
||||
(t) => t.id == previousTaskId,
|
||||
);
|
||||
if (!stillExists) {
|
||||
debugPrint('🔄 [选中校验] 任务已不存在,清除当前任务与本地缓存');
|
||||
taskCubit.clearCurrentTask();
|
||||
await _clearTaskIdFromLocal(deviceId);
|
||||
} else {
|
||||
debugPrint('🔄 [选中校验] 任务仍存在,保留显示');
|
||||
}
|
||||
} catch (e) {
|
||||
debugPrint('🔄 [选中校验] 校验失败: $e');
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 新增:计算坐标列表的边界范围 ==========
|
||||
LatLngBounds? calculateBounds(List<LatLng> points) {
|
||||
if (points.isEmpty) return null;
|
||||
@@ -1833,6 +1905,9 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
_selectedPlot = plot;
|
||||
});
|
||||
|
||||
// 🔥 选中任务时自动校验上次的任务是否还存在:不存在则不展示(等同手动刷新)
|
||||
_validateCurrentTaskOnSelect();
|
||||
|
||||
try {
|
||||
_traceManager.reset();
|
||||
|
||||
@@ -2081,7 +2156,25 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
'🗺️ [选中地块] 准备移动地图: allPoints=${allPoints.length}, gcjPathPoints=${gcjPathPoints.length}, gcjOuterPoints=${gcjOuterPoints.length}',
|
||||
);
|
||||
if (allPoints.isNotEmpty) {
|
||||
moveMapToPointsCenter(allPoints);
|
||||
// 🔥 选中路线时自动定位到路径区域:
|
||||
// - center = bounds.center = 金黄线(gcjPathPoints)+ 灰色边框(gcjOuterPoints)所有点的
|
||||
// bounding box 几何中心,保证路径永远居中,不会因屏幕当前位置而偏移
|
||||
// - zoom = 21.0 固定值(开发者实测的理想级别):不管路径大小都缩到同一级别,视觉一致
|
||||
// - ⚠️ zoom=21 超过 ESRI 底图 19 级上限,底图可能白或靠场站高清叠加层显示(开发者已确认可接受)
|
||||
// - 一次性操作,不锁交互:用户之后仍可自由 pinch/drag 缩放平移
|
||||
final bounds = calculateBounds(allPoints);
|
||||
if (bounds != null) {
|
||||
const double targetZoom = 21.0;
|
||||
final zoomBefore = _mapController.camera?.zoom;
|
||||
_mapController.move(bounds.center, targetZoom);
|
||||
debugPrint(
|
||||
'🗺️ [选中地块] move 完成: zoom=$zoomBefore → $targetZoom, '
|
||||
'center=${bounds.center} (路径几何中心)',
|
||||
);
|
||||
} else {
|
||||
debugPrint('⚠️ [选中地块] bounds 计算失败,回退到仅居中(保持原缩放)');
|
||||
moveMapToPointsCenter(allPoints);
|
||||
}
|
||||
} else {
|
||||
debugPrint('❌ [选中地块] allPoints 为空,无法移动地图!');
|
||||
}
|
||||
@@ -3262,8 +3355,10 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
||||
gctracePoint?.clear();
|
||||
tracePoint = [];
|
||||
gctracePoint = [];
|
||||
// 🔥 取消任务后消除规划路径显示,只保留原先的边界框(gcjOuterPoints)
|
||||
gcjPathPoints = [];
|
||||
});
|
||||
debugPrint('[停止作业] 最终 setState 完成,轨迹已清空');
|
||||
debugPrint('[停止作业] 最终 setState 完成,轨迹与路径已清空,保留边界框');
|
||||
}
|
||||
|
||||
debugPrint('══════════ [停止作业] 结束 ══════════');
|
||||
|
||||
@@ -50,6 +50,40 @@ class TabConfig extends Equatable {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/// roleKey == 'personal'(个人角色):底部导航与「系统设置 → Tab 设置」强制只保留
|
||||
/// 「设备(device) + 我的(me)」,且常显、开关锁定不可关闭;其他角色不受影响。
|
||||
static const String personalRoleKey = 'personal';
|
||||
static const Set<String> personalVisibleTabIds = {'device', 'me'};
|
||||
|
||||
/// 底部导航实际渲染的 Tab:
|
||||
/// - personal:强制返回 设备 + 我的(忽略 isEnabled,恒为启用),按 order 排序
|
||||
/// - 其他角色:返回用户启用的 Tab(enabledItems)
|
||||
List<TabConfigItem> navItemsForRole(String? roleKey) {
|
||||
if (roleKey == personalRoleKey) {
|
||||
final forced = items
|
||||
.where((item) => personalVisibleTabIds.contains(item.id))
|
||||
.map((item) => item.copyWith(isEnabled: true))
|
||||
.toList();
|
||||
forced.sort((a, b) => a.order.compareTo(b.order));
|
||||
return forced;
|
||||
}
|
||||
return enabledItems;
|
||||
}
|
||||
|
||||
/// 「Tab 设置」列表应展示的 Tab:
|
||||
/// - personal:只列出 设备 + 我的,按 order 排序
|
||||
/// - 其他角色:列出全部
|
||||
List<TabConfigItem> settingItemsForRole(String? roleKey) {
|
||||
if (roleKey == personalRoleKey) {
|
||||
final visible = items
|
||||
.where((item) => personalVisibleTabIds.contains(item.id))
|
||||
.toList();
|
||||
visible.sort((a, b) => a.order.compareTo(b.order));
|
||||
return visible;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
TabConfig copyWith({List<TabConfigItem>? items}) {
|
||||
return TabConfig(items: items ?? this.items);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import 'package:maibu_satabot_v2/features/v2/device_list/presentation/float_bar/
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/float_bar/cubit/float_bar_setting_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/di/injection.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
|
||||
class MainWrapper extends StatefulWidget {
|
||||
const MainWrapper({super.key});
|
||||
@@ -30,8 +31,6 @@ class MainWrapper extends StatefulWidget {
|
||||
class _MainWrapperState extends State<MainWrapper> {
|
||||
int _currentIndex = 0;
|
||||
final PageController _pageController = PageController();
|
||||
final List<GlobalKey> _tabKeys = [];
|
||||
double? _circleLeft;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -39,22 +38,6 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
|
||||
// 🔥 确保 FloatBarSettingService 已初始化
|
||||
GetIt.I<FloatBarSettingService>();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_updateCirclePosition();
|
||||
});
|
||||
}
|
||||
|
||||
void _updateCirclePosition() {
|
||||
if (_tabKeys.isEmpty || _currentIndex >= _tabKeys.length) return;
|
||||
|
||||
final key = _tabKeys[_currentIndex];
|
||||
final renderBox = key.currentContext?.findRenderObject() as RenderBox?;
|
||||
if (renderBox != null) {
|
||||
setState(() {
|
||||
_circleLeft = renderBox.localToGlobal(Offset.zero).dx;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -68,52 +51,36 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
_currentIndex = index;
|
||||
});
|
||||
_pageController.jumpToPage(index);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_updateCirclePosition();
|
||||
});
|
||||
}
|
||||
|
||||
IconData _getIconData(String iconName) {
|
||||
/// Tab 图标:选中用 filled(实心),未选用 outlined(描边),对比更清晰
|
||||
IconData _navIcon(String iconName, bool selected) {
|
||||
switch (iconName) {
|
||||
case 'home_rounded':
|
||||
return Icons.home_rounded;
|
||||
return selected ? Icons.home_rounded : Icons.home_outlined;
|
||||
case 'grid_view_rounded':
|
||||
return Icons.grid_view_rounded;
|
||||
return selected ? Icons.grid_view_rounded : Icons.grid_view_outlined;
|
||||
case 'devices_rounded':
|
||||
return Icons.devices_rounded;
|
||||
return selected ? Icons.devices_rounded : Icons.devices_outlined;
|
||||
case 'auto_awesome_rounded':
|
||||
return Icons.auto_awesome_rounded;
|
||||
return selected
|
||||
? Icons.auto_awesome_rounded
|
||||
: Icons.auto_awesome_outlined;
|
||||
case 'warning_amber_rounded':
|
||||
return Icons.warning_amber_rounded;
|
||||
return selected
|
||||
? Icons.warning_amber_rounded
|
||||
: Icons.warning_amber_outlined;
|
||||
case 'assignment_rounded':
|
||||
return Icons.assignment_rounded;
|
||||
return selected ? Icons.assignment_rounded : Icons.assignment_outlined;
|
||||
case 'post_add_rounded':
|
||||
return Icons.post_add_rounded;
|
||||
return selected ? Icons.post_add_rounded : Icons.post_add_outlined;
|
||||
case 'person_rounded':
|
||||
return Icons.person_rounded;
|
||||
return selected ? Icons.person_rounded : Icons.person_outlined;
|
||||
default:
|
||||
return Icons.home_rounded;
|
||||
return selected ? Icons.home_rounded : Icons.home_outlined;
|
||||
}
|
||||
}
|
||||
|
||||
double _getIndicatorPosition(int itemCount, int currentIndex) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final itemWidth = screenWidth / itemCount;
|
||||
return currentIndex * itemWidth;
|
||||
}
|
||||
|
||||
double _getCircularLeftPosition(int itemCount, int currentIndex) {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
final itemWidth = screenWidth / itemCount;
|
||||
// 圆形应该在每个Tab项的中心
|
||||
final tabCenterX = 12 + (currentIndex * itemWidth) + (itemWidth / 2);
|
||||
final circularLeft = tabCenterX - 22; // 22 = 44/2,让圆形中心对齐Tab中心
|
||||
|
||||
// 边界限制
|
||||
final maxLeft = screenWidth - 12 - 44;
|
||||
return circularLeft.clamp(12.0, maxLeft);
|
||||
}
|
||||
|
||||
Widget _buildCurrentPage(TabConfigItem tab) {
|
||||
switch (tab.id) {
|
||||
case 'home_v2':
|
||||
@@ -147,6 +114,8 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 🔥 个人角色(roleKey == 'personal')底部导航强制只显示「设备 + 我的」
|
||||
final roleKey = context.watch<AppUserCubit>().state.user?.roleKey;
|
||||
return BlocBuilder<TabConfigCubit, TabConfigState>(
|
||||
builder: (context, state) {
|
||||
if (state is! TabConfigLoaded) {
|
||||
@@ -156,7 +125,7 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
}
|
||||
|
||||
final config = state.config;
|
||||
final enabledItems = config.enabledItems;
|
||||
final enabledItems = config.navItemsForRole(roleKey);
|
||||
|
||||
if (enabledItems.isEmpty) {
|
||||
return const Scaffold(body: Center(child: Text('请至少启用一个 Tab')));
|
||||
@@ -166,24 +135,16 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
_currentIndex = 0;
|
||||
}
|
||||
|
||||
// 初始化 GlobalKey
|
||||
if (_tabKeys.length != enabledItems.length) {
|
||||
_tabKeys.clear();
|
||||
for (int i = 0; i < enabledItems.length; i++) {
|
||||
_tabKeys.add(GlobalKey());
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_updateCirclePosition();
|
||||
});
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
extendBody: false,
|
||||
// 底部导航预留区(SafeArea 那条)与页面同色,消除突兀的底色带
|
||||
backgroundColor: context.appColors.pageBackground,
|
||||
body: Stack(
|
||||
children: [
|
||||
PageView(
|
||||
controller: _pageController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
// 🔥 启用左右滑动切换 Tab
|
||||
physics: const BouncingScrollPhysics(),
|
||||
onPageChanged: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
@@ -205,102 +166,138 @@ class _MainWrapperState extends State<MainWrapper> {
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.cardBackground,
|
||||
),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottomNavigationBar: SafeArea(
|
||||
top: false,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 16),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 16,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.cardBackground,
|
||||
borderRadius: BorderRadius.circular(25),
|
||||
border: Border.all(
|
||||
color: context.appColors.divider,
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: context.appColors.cardShadow,
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
// 滑动圆形背景
|
||||
if (_circleLeft != null)
|
||||
AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
curve: Curves.easeInOut,
|
||||
left: _circleLeft! - 8, // 减去外层 margin + 向右偏移
|
||||
top: 6,
|
||||
child: Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.divider,
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: context.appColors.divider,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Tab 项
|
||||
Row(
|
||||
children: enabledItems.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final item = entry.value;
|
||||
final isSelected = _currentIndex == index;
|
||||
final itemCount = enabledItems.length;
|
||||
// Tab 较少时收缩整体宽度并居中,Tab 多时铺满可用宽度
|
||||
const double preferredTabWidth = 84;
|
||||
const double barPaddingH = 6;
|
||||
final double maxBarWidth = constraints.maxWidth;
|
||||
final double barWidth =
|
||||
itemCount * preferredTabWidth < maxBarWidth
|
||||
? itemCount * preferredTabWidth
|
||||
: maxBarWidth;
|
||||
final double tabWidth =
|
||||
(barWidth - barPaddingH * 2) / itemCount;
|
||||
// 选中高亮:包裹「图标 + 文字」的紧凑胶囊 chip
|
||||
const double indicatorH = 46;
|
||||
final double indicatorW =
|
||||
tabWidth - 8 < 54 ? tabWidth - 8 : 54.0;
|
||||
|
||||
return Expanded(
|
||||
key: _tabKeys[index],
|
||||
child: InkWell(
|
||||
onTap: () => _onTabChanged(index),
|
||||
child: SizedBox(
|
||||
height: 56,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
_getIconData(item.icon),
|
||||
size: 24,
|
||||
color: isSelected
|
||||
? context.appColors.textPrimary
|
||||
: context.appColors.textTertiary,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
item.name,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isSelected
|
||||
? context.appColors.textPrimary
|
||||
: context.appColors.textTertiary,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
// 用 Align + heightFactor 只水平居中,高度贴合内容;
|
||||
// 切勿用 Center:它在底部栏有界高度约束下会撑满全屏,把 body 挤没
|
||||
return Align(
|
||||
alignment: Alignment.center,
|
||||
heightFactor: 1.0,
|
||||
child: Container(
|
||||
width: barWidth,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: barPaddingH,
|
||||
vertical: 2,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.cardBackground,
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
border: Border.all(
|
||||
color: context.appColors.divider,
|
||||
width: 1,
|
||||
),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: context.appColors.cardShadow,
|
||||
blurRadius: 12,
|
||||
offset: const Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: SizedBox(
|
||||
height: 56,
|
||||
child: Stack(
|
||||
children: [
|
||||
// 蓝色胶囊 chip:纯数学定位,居中包裹图标 + 文字
|
||||
AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 280),
|
||||
curve: Curves.easeOutCubic,
|
||||
left: _currentIndex * tabWidth +
|
||||
(tabWidth - indicatorW) / 2,
|
||||
top: (56 - indicatorH) / 2,
|
||||
width: indicatorW,
|
||||
height: indicatorH,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.primary.withOpacity(
|
||||
0.12,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(
|
||||
indicatorH / 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
// Tab 项
|
||||
Row(
|
||||
children:
|
||||
enabledItems.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final item = entry.value;
|
||||
final isSelected = _currentIndex == index;
|
||||
|
||||
return Expanded(
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(
|
||||
indicatorH / 2,
|
||||
),
|
||||
onTap: () => _onTabChanged(index),
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
AnimatedScale(
|
||||
scale: isSelected ? 1.1 : 1.0,
|
||||
duration: const Duration(
|
||||
milliseconds: 200,
|
||||
),
|
||||
curve: Curves.easeOutBack,
|
||||
child: Icon(
|
||||
_navIcon(item.icon, isSelected),
|
||||
size: 22,
|
||||
color: isSelected
|
||||
? context.appColors.primary
|
||||
: context
|
||||
.appColors.textTertiary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
AnimatedDefaultTextStyle(
|
||||
duration: const Duration(
|
||||
milliseconds: 200,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
height: 1.0,
|
||||
color: isSelected
|
||||
? context.appColors.primary
|
||||
: context
|
||||
.appColors.textTertiary,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.w400,
|
||||
),
|
||||
child: Text(item.name),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -14,6 +14,9 @@ abstract class DeviceRemoteDataSource {
|
||||
String? typeFilter,
|
||||
});
|
||||
Future<List<DeviceDataModel>> getAllDevices();
|
||||
|
||||
/// 根据拆分码(蓝牙设备名/时间戳)精确查询设备,未查到时返回 null
|
||||
Future<DeviceDataModel?> getDeviceBySpiltCode(String code);
|
||||
}
|
||||
|
||||
/// 设备远程数据源实现类 - 从真实 API 获取数据
|
||||
@@ -97,6 +100,44 @@ class DeviceRemoteDataSourceImpl implements DeviceRemoteDataSource {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DeviceDataModel?> getDeviceBySpiltCode(String code) async {
|
||||
try {
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.getDeviceBySpiltCode,
|
||||
queryParameters: {'code': code},
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('网络请求失败: ${response.statusCode}');
|
||||
}
|
||||
|
||||
final responseData = response.data;
|
||||
if (responseData['code'] != 200) {
|
||||
throw Exception(responseData['msg'] ?? '业务异常');
|
||||
}
|
||||
|
||||
// 未查到时后端仅返回 {msg, code},无 data 字段
|
||||
final data = responseData['data'];
|
||||
if (data == null) {
|
||||
debugPrint(
|
||||
'>>> [DeviceRemoteDataSource] getDeviceBySpiltCode 未查到设备 code=$code',
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
// data 结构与 getDeviceList 的单条 row 一致,复用解析(deviceName 即 serialNumber)
|
||||
final model = _parseDeviceFromJson(Map<String, dynamic>.from(data as Map));
|
||||
debugPrint(
|
||||
'>>> [DeviceRemoteDataSource] getDeviceBySpiltCode 命中 code=$code serialNumber=${model.name}',
|
||||
);
|
||||
return model;
|
||||
} catch (e) {
|
||||
debugPrint('>>> [DeviceRemoteDataSource] getDeviceBySpiltCode error: $e');
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<DeviceDataModel>> _fetchDevicesFromAPI(int siteId) async {
|
||||
final response = await dio.get(
|
||||
HttpApiConsts.getSiteDeviceList,
|
||||
|
||||
@@ -9,6 +9,7 @@ class RobotDataModel {
|
||||
final int statusCode; // 接口原始 status 状态码
|
||||
final double battery;
|
||||
final String task;
|
||||
final bool hasHost;
|
||||
|
||||
const RobotDataModel({
|
||||
required this.name,
|
||||
@@ -20,6 +21,7 @@ class RobotDataModel {
|
||||
this.statusCode = 0,
|
||||
required this.battery,
|
||||
required this.task,
|
||||
this.hasHost = false,
|
||||
});
|
||||
|
||||
/// 从 JSON 创建数据模型
|
||||
@@ -46,6 +48,7 @@ class RobotDataModel {
|
||||
statusCode: statusCode is int ? statusCode : 0,
|
||||
battery: batteryValue,
|
||||
task: json['task'] ?? json['currentTask'] ?? '待机中',
|
||||
hasHost: json['hasHost'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,4 +26,10 @@ class DeviceRepositoryImpl implements DeviceRepository {
|
||||
final dataModels = await remoteDataSource.getAllDevices();
|
||||
return dataModels.map((model) => model.toEntity()).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<DeviceEntity?> getDeviceBySpiltCode(String code) async {
|
||||
final dataModel = await remoteDataSource.getDeviceBySpiltCode(code);
|
||||
return dataModel?.toEntity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,7 @@ abstract class DeviceRepository {
|
||||
Future<DeviceStatusEntity> getDeviceStatus();
|
||||
Future<List<DeviceEntity>> getDeviceList({int? siteId, String? typeFilter});
|
||||
Future<List<DeviceEntity>> getAllDevices();
|
||||
|
||||
/// 根据拆分码(蓝牙设备名/时间戳)精确查询设备,未查到时返回 null
|
||||
Future<DeviceEntity?> getDeviceBySpiltCode(String code);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import '../entities/device_entity.dart';
|
||||
import '../repositories/device_repository.dart';
|
||||
|
||||
/// 根据拆分码(蓝牙设备名/时间戳)精确查询设备用例(用于蓝牙绑定匹配)
|
||||
class GetDeviceBySpiltCodeUseCase {
|
||||
final DeviceRepository repository;
|
||||
|
||||
const GetDeviceBySpiltCodeUseCase({required this.repository});
|
||||
|
||||
Future<DeviceEntity?> execute(String code) async {
|
||||
return await repository.getDeviceBySpiltCode(code);
|
||||
}
|
||||
}
|
||||
@@ -13,14 +13,23 @@ import '../../../../../core/protocol/machine_protocol_constants.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import '../../../../../core/services/device_permission_service.dart';
|
||||
import '../../domain/entities/device_entity.dart';
|
||||
import '../../domain/usecases/get_all_devices_usecase.dart';
|
||||
import '../../domain/usecases/get_device_by_spilt_code_usecase.dart';
|
||||
import 'bind_device_page.dart';
|
||||
|
||||
class BleDeviceDetailPage extends StatefulWidget {
|
||||
final BluetoothDevice device;
|
||||
final ScanResult? scanResult;
|
||||
|
||||
const BleDeviceDetailPage({super.key, required this.device, this.scanResult});
|
||||
/// 后端设备长名称(如 MC700PLUS-CN-JS-1760408682847-0000002A-A9),
|
||||
/// 由列表页跳转时传入;为空时回退到蓝牙广播名
|
||||
final String? displayName;
|
||||
|
||||
const BleDeviceDetailPage({
|
||||
super.key,
|
||||
required this.device,
|
||||
this.scanResult,
|
||||
this.displayName,
|
||||
});
|
||||
|
||||
@override
|
||||
State<BleDeviceDetailPage> createState() => _BleDeviceDetailPageState();
|
||||
@@ -59,6 +68,14 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
super.initState();
|
||||
_initConnectionListener();
|
||||
_syncInitialState();
|
||||
|
||||
// 🔥 页面加载完成后自动连接设备(如果尚未连接且未在连接中)
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
if (!_isConnected && !_isConnecting) {
|
||||
_connect();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// 监听 BleManager 的全局连接状态流
|
||||
@@ -290,32 +307,22 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
);
|
||||
|
||||
try {
|
||||
final getAllDevicesUseCase = GetIt.instance<GetAllDevicesUseCase>();
|
||||
final devices = await getAllDevicesUseCase.execute();
|
||||
// 用蓝牙名(时间戳)作为 code,调 getDeviceBySpiltCode 精确查询设备
|
||||
final getDeviceBySpiltCodeUseCase =
|
||||
GetIt.instance<GetDeviceBySpiltCodeUseCase>();
|
||||
final DeviceEntity? matchedDevice =
|
||||
await getDeviceBySpiltCodeUseCase.execute(bleName);
|
||||
|
||||
if (loadingCtx != null && Navigator.canPop(loadingCtx!)) {
|
||||
Navigator.pop(loadingCtx!);
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
'>>> [BindDevice] bleName=$bleName, devices=${devices.length}',
|
||||
'>>> [BindDevice] bleName=$bleName, matched=${matchedDevice == null ? "未查到" : matchedDevice.name}',
|
||||
);
|
||||
for (int i = 0; i < devices.length && i < 10; i++) {
|
||||
debugPrint(
|
||||
'>>> [BindDevice] device[$i]: id=${devices[i].deviceId}, name=${devices[i].name}',
|
||||
);
|
||||
}
|
||||
|
||||
// 用蓝牙名(时间戳)匹配设备名中包含该时间戳的设备
|
||||
DeviceEntity? matchedDevice;
|
||||
for (final device in devices) {
|
||||
if (device.name.contains(bleName)) {
|
||||
matchedDevice = device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedDevice == null) {
|
||||
// 接口未查到(返回无 data)→ 与之前一致弹窗提示
|
||||
if (matchedDevice == null || matchedDevice.name.isEmpty) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
@@ -334,11 +341,11 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
// 复用扫一扫的绑定页面流程
|
||||
// 复用扫一扫的绑定页面流程(scanResult 传序列号 serialNumber)
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => BindDevicePage(scanResult: matchedDevice!.name),
|
||||
builder: (_) => BindDevicePage(scanResult: matchedDevice.name),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
@@ -517,7 +524,9 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
final advData = widget.scanResult?.advertisementData;
|
||||
// 优先使用广告数据中的名称(含扫描响应),手机蓝牙列表也是这样显示的
|
||||
final name =
|
||||
_resolvedName ??
|
||||
(widget.displayName?.isNotEmpty == true
|
||||
? widget.displayName!
|
||||
: _resolvedName) ??
|
||||
(advData?.advName.isNotEmpty == true
|
||||
? advData!.advName
|
||||
: (device.platformName.isNotEmpty
|
||||
@@ -549,13 +558,7 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
_buildDeviceInfoCard(name, scanResult),
|
||||
const SizedBox(height: 16),
|
||||
_buildConnectionControl(),
|
||||
if (_isConnected && _services.isNotEmpty) ...[
|
||||
const SizedBox(height: 16),
|
||||
_buildServicesList(),
|
||||
],
|
||||
if (_isConnected) ...[
|
||||
const SizedBox(height: 16),
|
||||
_buildCommandSection(),
|
||||
const SizedBox(height: 16),
|
||||
_buildDeviceConfigCard(),
|
||||
const SizedBox(height: 16),
|
||||
@@ -611,14 +614,6 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
color: context.appColors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'${widget.device.remoteId}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: context.appColors.textTertiary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -629,7 +624,6 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
Divider(height: 1, color: context.appColors.divider),
|
||||
const SizedBox(height: 12),
|
||||
_buildInfoRow('设备名称', name),
|
||||
_buildInfoRow('设备ID', '${widget.device.remoteId}'),
|
||||
if (scanResult != null) ...[
|
||||
_buildInfoRow('信号强度', '${scanResult.rssi} dBm'),
|
||||
_buildInfoRow(
|
||||
@@ -807,6 +801,27 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
// 读配置 按钮(未连接时灰色禁用)
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: _isConnected ? _sendReadConfig : null,
|
||||
icon: const Icon(Icons.settings, size: 18),
|
||||
label: const Text('读配置'),
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(vertical: 14),
|
||||
backgroundColor: _isConnected
|
||||
? context.appColors.primary
|
||||
: context.appColors.fillBackground,
|
||||
foregroundColor: _isConnected
|
||||
? Colors.white
|
||||
: context.appColors.textTertiary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -999,7 +1014,11 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
}
|
||||
|
||||
Widget _buildCommLogSection() {
|
||||
final pushes = _latestPushByCommand.values.toList();
|
||||
final pushes = _latestPushByCommand.values
|
||||
.where((p) =>
|
||||
p.command != MachineProtocolConstants.cmdRemoteControl &&
|
||||
p.command != MachineProtocolConstants.cmdReadConfig)
|
||||
.toList();
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -1114,23 +1133,6 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: colors.badge,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
'0x${p.command.toRadixString(16).toUpperCase().padLeft(2, '0')}',
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'monospace',
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
name,
|
||||
@@ -1237,7 +1239,7 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
'设备配置 (0x05)',
|
||||
'设备配置',
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -1487,33 +1489,6 @@ class _BleDeviceDetailPageState extends State<BleDeviceDetailPage> {
|
||||
return;
|
||||
}
|
||||
|
||||
// 权限通过提示
|
||||
await showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (dialogCtx) => AlertDialog(
|
||||
title: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.check_circle,
|
||||
color: context.appColors.success,
|
||||
size: 28,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
const Text('权限通过'),
|
||||
],
|
||||
),
|
||||
content: const Text('您有权限操作此设备'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogCtx),
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
if (!mounted) return;
|
||||
|
||||
// 0. 连接状态诊断
|
||||
developer.log(
|
||||
'[WriteConfig] 🏥 连接状态: isConnected=${BleManager.instance.isConnected}, '
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
@@ -11,6 +12,7 @@ import '../../../../../components/tcp_status_indicator.dart';
|
||||
import '../../../../../components/device_status_modal.dart';
|
||||
import '../../../../v2/site/presentation/cubit/site_cubit.dart';
|
||||
import '../../../site/presentation/widgets/site_selector_widget.dart';
|
||||
import '../../../../main_container/domain/tab_config.dart';
|
||||
import '../bloc/device_status_bloc.dart' as DeviceListBloc;
|
||||
import '../bloc/device_status_event.dart' as DeviceListEvent;
|
||||
import '../bloc/device_status_state.dart' as DeviceListState;
|
||||
@@ -18,6 +20,7 @@ import 'package:maibu_satabot_v2/features/devices/presentation/bloc/device_statu
|
||||
import '../bloc/drone_station_bloc.dart';
|
||||
import '../bloc/drone_station_event.dart';
|
||||
import '../bloc/drone_station_state.dart';
|
||||
import 'ble_device_detail_page.dart';
|
||||
import '../bloc/robot_list_bloc.dart'; // 🔥 添加 RobotListBloc 导入
|
||||
import '../bloc/robot_list_event.dart'; // 🔥 添加 RobotListEvent 导入
|
||||
import '../bloc/robot_list_state.dart'; // 🔥 添加 RobotListState 导入
|
||||
@@ -71,9 +74,29 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
/// 当前缓存的 siteId,用于判断是否真的发生了变化
|
||||
int? _currentSiteId;
|
||||
|
||||
/// 🔥 下拉刷新计数器:变更时联动重建"全部"标签下的机器人/无人机场内嵌列表,
|
||||
/// 使其与统计卡片(DeviceStatusBloc)同步刷新,避免统计数字与实际卡片对不上
|
||||
int _refreshTick = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 🔥 个人角色(roleKey == 'personal')只有一个场站,自动默认选中第一个
|
||||
final roleKey = sl<AppUserCubit>().state.user?.roleKey;
|
||||
if (roleKey == TabConfig.personalRoleKey) {
|
||||
final siteCubit = sl<SiteCubit>();
|
||||
if (siteCubit.state.sites.isEmpty) {
|
||||
// 场站列表为空则先加载
|
||||
siteCubit.loadSites();
|
||||
} else if (siteCubit.state.selectedSite == null) {
|
||||
// 还没有选中场站则自动选中第一个
|
||||
final firstSite = siteCubit.state.sites.first;
|
||||
debugPrint(
|
||||
'🔥 [DeviceStatus] 个人角色自动选中首个场站: ${firstSite.siteName} (id=${firstSite.id})',
|
||||
);
|
||||
siteCubit.selectSite(firstSite);
|
||||
}
|
||||
}
|
||||
_currentSiteId = sl<SiteCubit>().state.selectedSite?.id;
|
||||
_siteSub = sl<SiteCubit>().stream.listen((siteState) {
|
||||
if (!mounted) return;
|
||||
@@ -210,6 +233,10 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
}
|
||||
|
||||
Widget _buildAppBar(BuildContext context) {
|
||||
// 🔥 个人角色(roleKey == 'personal')隐藏场站选择器
|
||||
final roleKey = context.watch<AppUserCubit>().state.user?.roleKey;
|
||||
final showSiteSelector = roleKey != TabConfig.personalRoleKey;
|
||||
|
||||
return Container(
|
||||
height: 44.0,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
@@ -218,8 +245,10 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
const Flexible(child: SiteSelectorWidget(compact: true)),
|
||||
const SizedBox(width: 8),
|
||||
if (showSiteSelector) ...[
|
||||
const Flexible(child: SiteSelectorWidget(compact: true)),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
Container(
|
||||
width: 1,
|
||||
height: 20,
|
||||
@@ -397,24 +426,40 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
}
|
||||
|
||||
Widget _buildTypeFilterBar(BuildContext context) {
|
||||
final typeCodes = [
|
||||
'all',
|
||||
'robot',
|
||||
'drone_station',
|
||||
'inverter',
|
||||
'combiner_box',
|
||||
'module',
|
||||
'monitor',
|
||||
];
|
||||
final typeLabels = [
|
||||
AppLocalizations.of(context).translate('device_list_v2.all'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.robot'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.drone_station'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.inverter'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.combiner_box'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.module'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.monitor'),
|
||||
];
|
||||
// 🔥 个人角色(roleKey == 'personal')只显示「全部、机器人、无人机」3 个 tab
|
||||
final roleKey = context.watch<AppUserCubit>().state.user?.roleKey;
|
||||
final isPersonal = roleKey == TabConfig.personalRoleKey;
|
||||
|
||||
List<String> typeCodes;
|
||||
List<String> typeLabels;
|
||||
|
||||
if (isPersonal) {
|
||||
typeCodes = ['all', 'robot', 'drone_station'];
|
||||
typeLabels = [
|
||||
AppLocalizations.of(context).translate('device_list_v2.all'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.robot'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.drone_station'),
|
||||
];
|
||||
} else {
|
||||
typeCodes = [
|
||||
'all',
|
||||
'robot',
|
||||
'drone_station',
|
||||
'inverter',
|
||||
'combiner_box',
|
||||
'module',
|
||||
'monitor',
|
||||
];
|
||||
typeLabels = [
|
||||
AppLocalizations.of(context).translate('device_list_v2.all'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.robot'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.drone_station'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.inverter'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.combiner_box'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.module'),
|
||||
AppLocalizations.of(context).translate('device_list_v2.monitor'),
|
||||
];
|
||||
}
|
||||
|
||||
return BlocBuilder<
|
||||
DeviceListBloc.DeviceStatusBloc,
|
||||
@@ -426,56 +471,81 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
selectedType = state.selectedType;
|
||||
}
|
||||
|
||||
// 获取当前选中的索引
|
||||
int selectedIndex = typeCodes.indexOf(selectedType);
|
||||
if (selectedIndex == -1) selectedIndex = 0; // 默认为 'all'
|
||||
|
||||
return SizedBox(
|
||||
height: 40,
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
itemCount: typeCodes.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(width: 24.0),
|
||||
itemBuilder: (context, index) {
|
||||
final typeCode = typeCodes[index];
|
||||
final typeLabel = typeLabels[index];
|
||||
final isSelected = selectedType == typeCode;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
child: NotificationListener<ScrollNotification>(
|
||||
onNotification: (ScrollNotification notification) {
|
||||
// 🔥 监听滑动结束事件,自动切换选中状态
|
||||
if (notification is ScrollEndNotification &&
|
||||
notification.metrics.axis == Axis.horizontal) {
|
||||
final position = notification.metrics.pixels;
|
||||
final itemWidth = 56.0; // 预估每个 tab 的宽度(包括间距)
|
||||
final newIndex = (position / itemWidth).round();
|
||||
|
||||
if (newIndex >= 0 &&
|
||||
newIndex < typeCodes.length &&
|
||||
newIndex != selectedIndex) {
|
||||
final newTypeCode = typeCodes[newIndex];
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
DeviceListEvent.DeviceStatusChangeType(typeCode),
|
||||
DeviceListEvent.DeviceStatusChangeType(newTypeCode),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
typeLabel,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: isSelected
|
||||
? context.appColors.primary
|
||||
: context.appColors.textSecondary,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
width: 20,
|
||||
height: 2,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? context.appColors.primary
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(1),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
child: ListView.separated(
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
itemCount: typeCodes.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(width: 24.0),
|
||||
itemBuilder: (context, index) {
|
||||
final typeCode = typeCodes[index];
|
||||
final typeLabel = typeLabels[index];
|
||||
final isSelected = selectedType == typeCode;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
DeviceListEvent.DeviceStatusChangeType(typeCode),
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
typeLabel,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
color: isSelected
|
||||
? context.appColors.primary
|
||||
: context.appColors.textSecondary,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
width: 20,
|
||||
height: 2,
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? context.appColors.primary
|
||||
: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(1),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
@@ -550,9 +620,16 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
// 🔥 同步刷新:统计卡片(DeviceStatusBloc) + 下方机器人列表(RobotListBloc)
|
||||
// + 无人机场列表(DroneStationBloc)。三者数据源相互独立,只刷统计会导致
|
||||
// 数字与实际卡片对不上,故用 _refreshTick 变更内嵌列表的 ValueKey 强制
|
||||
// 重建对应 BlocProvider,使其重新拉取数据。
|
||||
context.read<DeviceListBloc.DeviceStatusBloc>().add(
|
||||
const DeviceListEvent.DeviceStatusRefresh(),
|
||||
);
|
||||
if (state.selectedType == 'all') {
|
||||
setState(() => _refreshTick++);
|
||||
}
|
||||
},
|
||||
color: context.appColors.primary,
|
||||
child: ListView(
|
||||
@@ -573,7 +650,7 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
_buildDroneStationList(
|
||||
context,
|
||||
embedded: true,
|
||||
key: ValueKey('embedded_drone_station_$_currentSiteId'),
|
||||
key: ValueKey('embedded_drone_station_${_currentSiteId}_$_refreshTick'),
|
||||
),
|
||||
// 🔥 普通设备列表(仅类型 tab 生效,"全部"模式下 filteredByType 为空)
|
||||
...filteredDevices
|
||||
@@ -608,7 +685,7 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
|
||||
return BlocProvider(
|
||||
// 🔥 电站切换时通过 key 变化强制重建 BlocProvider,重新用新 siteId 加载
|
||||
key: ValueKey('embedded_robot_$siteId'),
|
||||
key: ValueKey('embedded_robot_${siteId}_$_refreshTick'),
|
||||
create: (_) =>
|
||||
sl<RobotListBloc>()..add(RobotListLoadData(siteId: siteId)),
|
||||
child: BlocConsumer<RobotListBloc, RobotListState>(
|
||||
@@ -677,6 +754,36 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
debugPrint(
|
||||
'🔴🔴🔴 [全部-选中机器人] name: ${robot.name}, id: ${robot.id}, type: ${robot.type}',
|
||||
);
|
||||
debugPrint(
|
||||
'🔴🔴🔴 [全部-选中机器人] hasHost: ${robot.hasHost}',
|
||||
);
|
||||
|
||||
// 🔥 hasHost 字段判定:false → 蓝牙连接流程
|
||||
if (!robot.hasHost) {
|
||||
debugPrint('⚠️ [全部-EmbeddedRobotList] hasHost=false,进入蓝牙连接流程');
|
||||
|
||||
// 从设备名中提取时间戳(如 MC700PRO-CN-JS-1751525588120-0000000A-9527 → 1751525588120)
|
||||
final timestamp = _extractTimestamp(robot.name);
|
||||
if (timestamp == null || timestamp.isEmpty) {
|
||||
debugPrint('❌ [全部-EmbeddedRobotList] 未提取到时间戳');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('设备名称异常,暂时无法连接'),
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint('✅ [全部-EmbeddedRobotList] 提取到时间戳: $timestamp');
|
||||
|
||||
// 调用蓝牙连接流程
|
||||
_connectToDeviceViaBluetooth(context, robot.name, timestamp);
|
||||
return;
|
||||
}
|
||||
|
||||
// hasHost == true → 走原来的逻辑
|
||||
debugPrint('✅ [全部-EmbeddedRobotList] hasHost=true,走正常控制流程');
|
||||
|
||||
// 1. 将当前机器人设置为全局待控制设备
|
||||
final device = DeviceEntity(
|
||||
@@ -871,12 +978,12 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
BuildContext context,
|
||||
DeviceListState.DeviceStatusLoaded state,
|
||||
) {
|
||||
// 从实际设备列表计算统计数据(不再使用硬编码的假数据)
|
||||
// 从实际设备列表计算统计数据(设备状态仅有"在线/离线"两种,接口不会返回"异常",
|
||||
// 故不再统计恒为 0 的"告警"项)
|
||||
final devices = state.devices;
|
||||
final totalCount = devices.length;
|
||||
final onlineCount = devices.where((d) => d.status == '在线').length;
|
||||
final exceptionCount = devices.where((d) => d.status == '异常').length;
|
||||
final offlineCount = totalCount - onlineCount - exceptionCount;
|
||||
final offlineCount = totalCount - onlineCount;
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
@@ -912,15 +1019,6 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
textColor: context.appColors.success,
|
||||
),
|
||||
Container(width: 1, height: 40, color: context.appColors.divider),
|
||||
_buildStatItem(
|
||||
value: exceptionCount.toString(),
|
||||
label: AppLocalizations.of(
|
||||
context,
|
||||
).translate('device_list_v2.alarm'),
|
||||
dotColor: context.appColors.warning,
|
||||
textColor: context.appColors.warning,
|
||||
),
|
||||
Container(width: 1, height: 40, color: context.appColors.divider),
|
||||
_buildStatItem(
|
||||
value: offlineCount.toString(),
|
||||
label: AppLocalizations.of(
|
||||
@@ -1234,4 +1332,186 @@ class _DeviceStatusViewState extends State<DeviceStatusView> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 🔥 从设备名中提取时间戳
|
||||
String? _extractTimestamp(String deviceName) {
|
||||
final regex = RegExp(r'(\d{13})');
|
||||
final match = regex.firstMatch(deviceName);
|
||||
return match?.group(1);
|
||||
}
|
||||
|
||||
/// 🔥 蓝牙连接流程
|
||||
Future<void> _connectToDeviceViaBluetooth(
|
||||
BuildContext context,
|
||||
String deviceName,
|
||||
String timestamp,
|
||||
) async {
|
||||
final bleManager = BleManager.instance;
|
||||
|
||||
// 🔥 0. 优先检查:如果该设备已经连接,直接跳转详情页,不再扫描
|
||||
final connectedDevice = bleManager.connectedDevice;
|
||||
if (connectedDevice != null) {
|
||||
final connectedName = bleManager.connectedDeviceName ?? '';
|
||||
debugPrint('🔍 [蓝牙连接] 已连接设备名: $connectedName,匹配时间戳: $timestamp');
|
||||
if (connectedName.contains(timestamp)) {
|
||||
debugPrint('✅ [蓝牙连接] 设备已连接,直接跳转详情页: $connectedName');
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => BleDeviceDetailPage(
|
||||
device: connectedDevice,
|
||||
displayName: deviceName,
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 1. 检查蓝牙状态
|
||||
final isBluetoothOn = await bleManager.checkBluetooth();
|
||||
if (!isBluetoothOn) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('请先打开手机蓝牙'),
|
||||
duration: Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 显示加载圈
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => const Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 16),
|
||||
Text('正在搜索蓝牙设备...', style: TextStyle(color: Colors.white)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// 3. 启动蓝牙扫描
|
||||
await bleManager.startScan(continuous: false);
|
||||
await Future.delayed(const Duration(milliseconds: 1500));
|
||||
|
||||
// 4. 关闭加载圈
|
||||
Navigator.of(context).pop();
|
||||
|
||||
// 5. 获取扫描结果并查找匹配设备
|
||||
final scanResults = bleManager.getScanResults();
|
||||
BluetoothDevice? matchedDevice;
|
||||
for (final result in scanResults) {
|
||||
final devName = result.device.platformName.isNotEmpty
|
||||
? result.device.platformName
|
||||
: result.device.advName;
|
||||
if (devName.contains(timestamp)) {
|
||||
matchedDevice = result.device;
|
||||
debugPrint('✅ [蓝牙连接] 找到匹配设备: $devName');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedDevice != null) {
|
||||
debugPrint('🚀 [蓝牙连接] 跳转到 BLE 详情页并连接');
|
||||
final device = matchedDevice;
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => BleDeviceDetailPage(
|
||||
device: device,
|
||||
displayName: deviceName,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
debugPrint('⚠️ [蓝牙连接] 未在扫描列表中找到设备,弹窗提示并后台监测');
|
||||
_showNotFoundDialogAndMonitor(context, deviceName, timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
/// 🔥 弹窗提示并后台持续监测设备(单例模式,防止重复弹窗)
|
||||
void _showNotFoundDialogAndMonitor(
|
||||
BuildContext context,
|
||||
String deviceName,
|
||||
String timestamp,
|
||||
) {
|
||||
// 🔥 检查是否已有弹窗存在,如果有则先关闭
|
||||
if (Navigator.of(context).canPop()) {
|
||||
debugPrint('⚠️ [后台监测] 检测到已有弹窗,先关闭上一个');
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
bool dialogShown = true;
|
||||
StreamSubscription? subscription;
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (dialogContext) {
|
||||
dialogShown = true;
|
||||
return AlertDialog(
|
||||
title: const Text('未找到设备'),
|
||||
content: const Text('暂未匹配到该设备,稍后重试'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
dialogShown = false;
|
||||
Navigator.pop(dialogContext);
|
||||
},
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
dialogShown = false;
|
||||
Navigator.pop(dialogContext);
|
||||
},
|
||||
child: const Text('确认'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
// 启动后台监测
|
||||
final bleManager = BleManager.instance;
|
||||
subscription = bleManager.scanResults.listen((results) {
|
||||
if (!dialogShown) {
|
||||
subscription?.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
for (final result in results) {
|
||||
final devName = result.device.platformName.isEmpty
|
||||
? result.device.advName
|
||||
: result.device.platformName;
|
||||
|
||||
if (devName.contains(timestamp)) {
|
||||
debugPrint('✅ [后台监测] 匹配成功!设备名: $devName');
|
||||
subscription?.cancel();
|
||||
|
||||
// 🔥 弹窗可能已关闭,需要先 pop 当前弹窗再跳转
|
||||
if (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => BleDeviceDetailPage(
|
||||
device: result.device,
|
||||
displayName: deviceName,
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:maibu_satabot_v2/core/bluetooth/ble_manager.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import '../../../../../core/di/injection.dart';
|
||||
import '../../../../../core/logging/i_logger_service.dart';
|
||||
import '../../../../devices/presentation/bloc/devices_cubit.dart';
|
||||
import '../../../../devices/domain/entities/device_entity.dart';
|
||||
import '../../../../devices/presentation/bloc/device_status_bloc.dart';
|
||||
import '../../../../remote_control/presentation/bloc/remote_control_cubit.dart';
|
||||
import '../../../../v2/site/presentation/cubit/site_cubit.dart';
|
||||
import '../../data/models/robot_data_model.dart';
|
||||
@@ -14,6 +19,7 @@ import '../bloc/robot_list_bloc.dart';
|
||||
import '../bloc/robot_list_event.dart';
|
||||
import '../bloc/robot_list_state.dart';
|
||||
import '../widgets/robot_item_card.dart';
|
||||
import 'ble_device_detail_page.dart';
|
||||
import 'robot_control_page.dart';
|
||||
import 'cleaning_weeding_robot_task_page.dart';
|
||||
|
||||
@@ -87,7 +93,8 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
children: [
|
||||
_buildStatsCard(state),
|
||||
_buildQuickActions(state),
|
||||
_buildCurrentTask(state),
|
||||
// 🔥 个人角色暂时注释掉当前任务卡片
|
||||
// _buildCurrentTask(state),
|
||||
..._buildRobotList(state),
|
||||
],
|
||||
),
|
||||
@@ -646,6 +653,38 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
debugPrint(
|
||||
'🔴🔴🔴 [选中机器人] status: ${robot.status}, battery: ${robot.battery}, task: ${robot.task}',
|
||||
);
|
||||
debugPrint(
|
||||
'🔴🔴🔴 [选中机器人] hasHost: ${robot.hasHost}',
|
||||
);
|
||||
|
||||
// 🔥 hasHost 字段判定:false → 蓝牙连接流程,true 走原逻辑
|
||||
if (!robot.hasHost) {
|
||||
// hasHost == false 或接口未返回该字段 → 蓝牙连接流程
|
||||
debugPrint('⚠️ [RobotListPage] hasHost=false,进入蓝牙连接流程');
|
||||
debugPrint('📱 [RobotListPage] 机器人名称: ${robot.name}');
|
||||
|
||||
// 从设备名中提取时间戳(例如:MC700PRO-CN-JS-1751525588120-0000000A-9527)
|
||||
final timestamp = _extractTimestamp(robot.name);
|
||||
if (timestamp == null || timestamp.isEmpty) {
|
||||
debugPrint('❌ [RobotListPage] 无法从设备名中提取时间戳: ${robot.name}');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text('设备名称异常,暂时无法连接'),
|
||||
backgroundColor: context.appColors.warning,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint('✅ [RobotListPage] 提取到时间戳: $timestamp');
|
||||
|
||||
// 调用蓝牙连接流程
|
||||
_connectToDeviceViaBluetooth(context, robot.name, timestamp);
|
||||
return;
|
||||
}
|
||||
|
||||
// hasHost == true → 走原来的逻辑
|
||||
debugPrint('✅ [RobotListPage] hasHost=true,走正常控制流程');
|
||||
|
||||
// 1. 将当前机器人设置为全局待控制设备(用 robot.name 作为 deviceName)
|
||||
final device = DeviceEntity(
|
||||
@@ -687,4 +726,228 @@ class _RobotListViewState extends State<RobotListView> {
|
||||
)
|
||||
.toList();
|
||||
}
|
||||
|
||||
/// 🔥 从设备名中提取时间戳
|
||||
/// 例如:MC700PRO-CN-JS-1751525588120-0000000A-9527 → 1751525588120
|
||||
String? _extractTimestamp(String deviceName) {
|
||||
try {
|
||||
// 使用正则表达式匹配中间的一串数字(13位时间戳)
|
||||
final regex = RegExp(r'(\d{13})');
|
||||
final match = regex.firstMatch(deviceName);
|
||||
if (match != null) {
|
||||
return match.group(1);
|
||||
}
|
||||
debugPrint('⚠️ [_extractTimestamp] 未找到时间戳格式,返回 null');
|
||||
return null;
|
||||
} catch (e) {
|
||||
debugPrint('❌ [_extractTimestamp] 解析失败: $e');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// 🔥 蓝牙连接流程
|
||||
/// 1. 检查蓝牙状态
|
||||
/// 2. 在 BLE 扫描列表中查找包含时间戳的设备
|
||||
/// 3. 如果找到则连接并跳转详情页
|
||||
/// 4. 如果没找到则弹窗提示并后台持续监测
|
||||
Future<void> _connectToDeviceViaBluetooth(
|
||||
BuildContext context,
|
||||
String deviceName,
|
||||
String timestamp,
|
||||
) async {
|
||||
final bleManager = BleManager.instance;
|
||||
|
||||
// 🔥 0. 优先检查:如果该设备已经连接,直接跳转详情页,不再扫描
|
||||
final connectedDevice = bleManager.connectedDevice;
|
||||
if (connectedDevice != null) {
|
||||
final connectedName = bleManager.connectedDeviceName ?? '';
|
||||
debugPrint('🔍 [蓝牙连接] 已连接设备名: $connectedName,匹配时间戳: $timestamp');
|
||||
if (connectedName.contains(timestamp)) {
|
||||
debugPrint('✅ [蓝牙连接] 设备已连接,直接跳转详情页: $connectedName');
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => BleDeviceDetailPage(
|
||||
device: connectedDevice,
|
||||
displayName: deviceName,
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 1. 检查蓝牙是否打开
|
||||
final isBluetoothOn = await bleManager.checkBluetooth();
|
||||
if (!isBluetoothOn) {
|
||||
debugPrint('❌ [蓝牙连接] 蓝牙未打开,提示用户');
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text('请先打开蓝牙'),
|
||||
backgroundColor: context.appColors.warning,
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint('✅ [蓝牙连接] 蓝牙已打开,开始搜索设备: $deviceName');
|
||||
|
||||
// 2. 显示加载圈
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (_) => const Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 16),
|
||||
Text('正在搜索蓝牙设备...', style: TextStyle(color: Colors.white)),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// 3. 启动蓝牙扫描(只扫一次,不要连续扫)
|
||||
try {
|
||||
await bleManager.startScan(continuous: false);
|
||||
} catch (e) {
|
||||
debugPrint('❌ [蓝牙连接] 启动扫描失败: $e');
|
||||
}
|
||||
|
||||
// 4. 等待一下让扫描结果出现
|
||||
await Future.delayed(const Duration(milliseconds: 1500));
|
||||
|
||||
// 5. 关闭加载圈
|
||||
Navigator.of(context).pop();
|
||||
|
||||
// 6. 获取当前扫描结果列表
|
||||
final scanResults = bleManager.getScanResults();
|
||||
debugPrint('🔍 [蓝牙连接] 扫描到 ${scanResults.length} 个设备');
|
||||
|
||||
// 5. 查找包含时间戳的设备
|
||||
BluetoothDevice? matchedDevice;
|
||||
for (final result in scanResults) {
|
||||
final dev = result.device;
|
||||
final devName = dev.platformName.isEmpty
|
||||
? (dev.advName.isEmpty ? dev.remoteId.toString() : dev.advName)
|
||||
: dev.platformName;
|
||||
|
||||
debugPrint(' 📱 发现设备: $devName (包含时间戳?: ${devName.contains(timestamp)})');
|
||||
|
||||
// 检查设备名是否包含时间戳
|
||||
if (devName.contains(timestamp)) {
|
||||
debugPrint('✅ [蓝牙连接] 匹配成功!设备名: $devName');
|
||||
matchedDevice = dev;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedDevice != null) {
|
||||
debugPrint('🚀 [蓝牙连接] 跳转到 BLE 详情页并连接');
|
||||
// 跳转到 BLE 设备详情页(详情页会自动连接)
|
||||
final device = matchedDevice;
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => BleDeviceDetailPage(
|
||||
device: device,
|
||||
displayName: deviceName,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
debugPrint('⚠️ [蓝牙连接] 未在扫描列表中找到设备,弹窗提示并后台监测');
|
||||
// 6. 没找到设备,弹窗提示并后台持续监测
|
||||
_showNotFoundDialogAndMonitor(context, deviceName, timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
/// 🔥 弹窗提示并后台持续监测设备(单例模式,防止重复弹窗)
|
||||
void _showNotFoundDialogAndMonitor(
|
||||
BuildContext context,
|
||||
String deviceName,
|
||||
String timestamp,
|
||||
) {
|
||||
// 🔥 检查是否已有弹窗存在,如果有则先关闭
|
||||
if (Navigator.of(context).canPop()) {
|
||||
debugPrint('⚠️ [后台监测] 检测到已有弹窗,先关闭上一个');
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
bool dialogShown = true;
|
||||
StreamSubscription? subscription;
|
||||
|
||||
// 先显示对话框
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (dialogContext) {
|
||||
dialogShown = true;
|
||||
return AlertDialog(
|
||||
title: const Text('未找到设备'),
|
||||
content: const Text('暂未匹配到该设备,稍后重试'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
dialogShown = false;
|
||||
Navigator.pop(dialogContext);
|
||||
},
|
||||
child: const Text('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
dialogShown = false;
|
||||
Navigator.pop(dialogContext);
|
||||
},
|
||||
child: const Text('确认'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
).then((_) {
|
||||
// 对话框关闭后不停止监测,继续运行
|
||||
});
|
||||
|
||||
// 启动后台监测 BLE 扫描列表
|
||||
final bleManager = BleManager.instance;
|
||||
subscription = bleManager.scanResults.listen((results) {
|
||||
if (!dialogShown) {
|
||||
// 对话框已关闭,停止监测
|
||||
subscription?.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
debugPrint('🔍 [后台监测] 扫描到 ${results.length} 个设备,搜索时间戳: $timestamp');
|
||||
|
||||
for (final result in results) {
|
||||
final dev = result.device;
|
||||
final devName = dev.platformName.isEmpty
|
||||
? (dev.advName.isEmpty ? dev.remoteId.toString() : dev.advName)
|
||||
: dev.platformName;
|
||||
|
||||
if (devName.contains(timestamp)) {
|
||||
debugPrint('✅ [后台监测] 匹配成功!设备名: $devName');
|
||||
subscription?.cancel();
|
||||
|
||||
// 🔥 弹窗可能已关闭,需要先 pop 当前弹窗再跳转
|
||||
if (Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => BleDeviceDetailPage(
|
||||
device: dev!,
|
||||
displayName: deviceName,
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
716
lib/features/v2/my/presentation/pages/help_feedback_page.dart
Normal file
716
lib/features/v2/my/presentation/pages/help_feedback_page.dart
Normal file
@@ -0,0 +1,716 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:maibu_satabot_v2/core/localization/app_localizations.dart';
|
||||
import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
|
||||
/// 帮助与反馈页面
|
||||
class HelpFeedbackPage extends StatefulWidget {
|
||||
const HelpFeedbackPage({super.key});
|
||||
|
||||
@override
|
||||
State<HelpFeedbackPage> createState() => _HelpFeedbackPageState();
|
||||
}
|
||||
|
||||
class _HelpFeedbackPageState extends State<HelpFeedbackPage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late TabController _tabController;
|
||||
final TextEditingController _feedbackController = TextEditingController();
|
||||
final TextEditingController _contactController = TextEditingController();
|
||||
int _selectedFeedbackType = 0;
|
||||
List<String> _selectedImages = [];
|
||||
|
||||
static const _feedbackTypes = [
|
||||
{'icon': Icons.lightbulb_outline, 'label': '功能建议'},
|
||||
{'icon': Icons.bug_report_outlined, 'label': 'Bug报告'},
|
||||
{'icon': Icons.sentiment_dissatisfied_outlined, 'label': '体验问题'},
|
||||
{'icon': Icons.more_horiz, 'label': '其他'},
|
||||
];
|
||||
|
||||
static const _faqList = [
|
||||
{
|
||||
'category': '设备绑定',
|
||||
'questions': [
|
||||
{
|
||||
'q': '扫码绑定失败怎么办?',
|
||||
'a': '请检查设备是否已开机并处于待绑定状态,确保手机蓝牙已开启且网络正常。如仍无法绑定,请尝试重启设备后重新扫码。'
|
||||
},
|
||||
{
|
||||
'q': '搜不到设备蓝牙信号?',
|
||||
'a': '请确认设备已开机且蓝牙指示灯正常闪烁。尝试靠近设备(1米以内)后重新搜索。如多个设备同时绑定,请逐一操作。'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'category': '路径规划',
|
||||
'questions': [
|
||||
{
|
||||
'q': '无法生成路径?',
|
||||
'a': '请确保已绘制完整的作业区域(至少3个打点),并检查GPS信号是否良好。如果使用自动规划模式,请确认区域边界没有自相交。'
|
||||
},
|
||||
{
|
||||
'q': '地图不显示或定位偏移?',
|
||||
'a': '请检查手机GPS是否已开启,并授权App位置权限。在室内或信号较弱的区域可能出现定位偏移,建议到开阔区域使用。'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'category': '远程控制',
|
||||
'questions': [
|
||||
{
|
||||
'q': '远程视频卡顿/连接超时?',
|
||||
'a': '请检查手机和设备的网络连接是否稳定。建议在4G/Wi-Fi信号良好的环境下使用远程控制功能。如持续卡顿,可尝试降低视频分辨率。'
|
||||
},
|
||||
{
|
||||
'q': '急停功能怎么使用?',
|
||||
'a': '在远程控制页面,点击屏幕中央红色急停按钮即可立即停止设备运行。急停后需手动解除才能恢复操作。'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'category': '工单系统',
|
||||
'questions': [
|
||||
{
|
||||
'q': '如何提交工单?',
|
||||
'a': '在「工单」页面点击右下角「新建工单」按钮,选择工单类型,填写问题描述并上传相关图片后提交即可。'
|
||||
},
|
||||
{
|
||||
'q': '工单状态怎么看?',
|
||||
'a': '在「工单」页面可查看所有已提交的工单及其当前状态(待处理/处理中/已完成)。点击具体工单可查看详情和回复。'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'category': '账号问题',
|
||||
'questions': [
|
||||
{
|
||||
'q': '忘记密码怎么办?',
|
||||
'a': '在登录页面点击「忘记密码」,通过注册手机号验证后即可重置密码。'
|
||||
},
|
||||
{
|
||||
'q': '换设备登录需要重新绑定?',
|
||||
'a': '更换手机登录同一账号后,设备绑定关系不会丢失。但需要在新设备上重新搜索和连接设备。'
|
||||
},
|
||||
]
|
||||
},
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
_feedbackController.dispose();
|
||||
_contactController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: const SystemUiOverlayStyle(
|
||||
statusBarColor: Colors.transparent,
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: context.appColors.pageBackground,
|
||||
appBar: AppBar(
|
||||
elevation: 0,
|
||||
leading: IconButton(
|
||||
icon: Icon(Icons.arrow_back, color: context.appColors.textPrimary),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(
|
||||
AppLocalizations.of(context).translate('my_v2.help_feedback'),
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: context.appColors.textPrimary,
|
||||
),
|
||||
),
|
||||
centerTitle: true,
|
||||
bottom: TabBar(
|
||||
controller: _tabController,
|
||||
labelColor: const Color(0xFF165DFF),
|
||||
unselectedLabelColor: context.appColors.textTertiary,
|
||||
indicatorColor: const Color(0xFF165DFF),
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
tabs: const [
|
||||
Tab(text: '常见问题'),
|
||||
Tab(text: '意见反馈'),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: TabBarView(
|
||||
controller: _tabController,
|
||||
children: [
|
||||
_buildFAQTab(),
|
||||
_buildFeedbackTab(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ==================== 常见问题 ====================
|
||||
|
||||
Widget _buildFAQTab() {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
..._faqList.map((category) => _buildFAQCategory(category)),
|
||||
const SizedBox(height: 20),
|
||||
_buildContactSection(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFAQCategory(Map<String, dynamic> categoryData) {
|
||||
final questions = categoryData['questions'] as List;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 8),
|
||||
child: Text(
|
||||
categoryData['category'] as String,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: context.appColors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.cardBackground,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: context.appColors.cardShadow,
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
children: questions.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final item = entry.value as Map<String, dynamic>;
|
||||
final isLast = index == questions.length - 1;
|
||||
return _buildFAQItem(
|
||||
item['q'] as String,
|
||||
item['a'] as String,
|
||||
isLast,
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFAQItem(String question, String answer, bool isLast) {
|
||||
return Column(
|
||||
children: [
|
||||
ExpansionTile(
|
||||
tilePadding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
childrenPadding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
shape: const Border(),
|
||||
collapsedShape: const Border(),
|
||||
title: Text(
|
||||
question,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: context.appColors.textPrimary,
|
||||
),
|
||||
),
|
||||
children: [
|
||||
Text(
|
||||
answer,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
height: 1.6,
|
||||
color: context.appColors.textSecondary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (!isLast)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 48),
|
||||
child: Divider(
|
||||
height: 1,
|
||||
thickness: 0.5,
|
||||
color: context.appColors.divider,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// ==================== 联系客服 ====================
|
||||
|
||||
Widget _buildContactSection() {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.cardBackground,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: context.appColors.cardShadow,
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'联系客服',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: context.appColors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildContactItem(
|
||||
Icons.phone_outlined,
|
||||
'客服热线',
|
||||
'400-000-0000',
|
||||
onTap: () => _showPhoneDialog('400-000-0000'),
|
||||
),
|
||||
const Divider(height: 24),
|
||||
_buildContactItem(
|
||||
Icons.qr_code_2,
|
||||
'企业微信',
|
||||
'扫码添加客服微信',
|
||||
onTap: () => debugPrint('显示企业微信二维码'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContactItem(
|
||||
IconData icon,
|
||||
String title,
|
||||
String subtitle, {
|
||||
VoidCallback? onTap,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 22, color: context.appColors.textSecondary),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: context.appColors.textPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
subtitle,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: context.appColors.textTertiary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Icon(
|
||||
Icons.chevron_right,
|
||||
color: context.appColors.textTertiary,
|
||||
size: 20,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ==================== 意见反馈 ====================
|
||||
|
||||
Widget _buildFeedbackTab() {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// 反馈类型
|
||||
_buildSectionCard(
|
||||
title: '反馈类型',
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: _feedbackTypes.asMap().entries.map((entry) {
|
||||
final index = entry.key;
|
||||
final type = entry.value;
|
||||
final isSelected = _selectedFeedbackType == index;
|
||||
return GestureDetector(
|
||||
onTap: () => setState(() => _selectedFeedbackType = index),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14,
|
||||
vertical: 8,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF).withOpacity(0.1)
|
||||
: context.appColors.fillBackground,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF)
|
||||
: Colors.transparent,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
type['icon'] as IconData,
|
||||
size: 16,
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF)
|
||||
: context.appColors.textSecondary,
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
type['label'] as String,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: isSelected
|
||||
? const Color(0xFF165DFF)
|
||||
: context.appColors.textSecondary,
|
||||
fontWeight:
|
||||
isSelected ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 问题描述
|
||||
_buildSectionCard(
|
||||
title: '问题描述',
|
||||
child: TextField(
|
||||
controller: _feedbackController,
|
||||
maxLines: 5,
|
||||
maxLength: 500,
|
||||
decoration: InputDecoration(
|
||||
hintText: '请详细描述您遇到的问题或建议...',
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: context.appColors.textTertiary,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide(color: context.appColors.divider),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide(color: context.appColors.divider),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: const BorderSide(
|
||||
color: Color(0xFF165DFF),
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: context.appColors.fillBackground,
|
||||
contentPadding: const EdgeInsets.all(12),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 添加截图
|
||||
_buildSectionCard(
|
||||
title: '添加截图 (${_selectedImages.length}/6)',
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
..._selectedImages.asMap().entries.map((entry) {
|
||||
return _buildImageItem(entry.key, entry.value);
|
||||
}),
|
||||
if (_selectedImages.length < 6) _buildAddImageButton(),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 联系方式
|
||||
_buildSectionCard(
|
||||
title: '联系方式(选填)',
|
||||
child: TextField(
|
||||
controller: _contactController,
|
||||
decoration: InputDecoration(
|
||||
hintText: '手机号/微信号,方便我们回访',
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
color: context.appColors.textTertiary,
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide(color: context.appColors.divider),
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide(color: context.appColors.divider),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: const BorderSide(
|
||||
color: Color(0xFF165DFF),
|
||||
width: 1.5,
|
||||
),
|
||||
),
|
||||
filled: true,
|
||||
fillColor: context.appColors.fillBackground,
|
||||
contentPadding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 14,
|
||||
),
|
||||
prefixIcon: const Icon(
|
||||
Icons.phone_outlined,
|
||||
size: 20,
|
||||
color: Color(0xFF86909C),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 提交按钮
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
child: ElevatedButton(
|
||||
onPressed: _submitFeedback,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF165DFF),
|
||||
foregroundColor: Colors.white,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: const Text(
|
||||
'提交反馈',
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionCard({
|
||||
required String title,
|
||||
required Widget child,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.cardBackground,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: context.appColors.cardShadow,
|
||||
blurRadius: 8,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: context.appColors.textPrimary,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
child,
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildImageItem(int index, String path) {
|
||||
return Stack(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Image.file(
|
||||
File(path),
|
||||
width: 80,
|
||||
height: 80,
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (context, error, stackTrace) => Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
color: context.appColors.fillBackground,
|
||||
child: Icon(
|
||||
Icons.broken_image_outlined,
|
||||
color: context.appColors.textTertiary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 2,
|
||||
right: 2,
|
||||
child: GestureDetector(
|
||||
onTap: () => setState(() => _selectedImages.removeAt(index)),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(2),
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.black54,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
size: 14,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAddImageButton() {
|
||||
return GestureDetector(
|
||||
onTap: _pickImage,
|
||||
child: Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.fillBackground,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: context.appColors.divider,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.add_photo_alternate_outlined,
|
||||
size: 28,
|
||||
color: context.appColors.textTertiary,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'添加截图',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: context.appColors.textTertiary,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// ==================== 交互方法 ====================
|
||||
|
||||
void _showPhoneDialog(String phoneNumber) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('客服热线'),
|
||||
content: SelectableText(
|
||||
phoneNumber,
|
||||
style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('关闭'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: phoneNumber));
|
||||
Navigator.pop(context);
|
||||
ScaffoldMessenger.of(this.context).showSnackBar(
|
||||
const SnackBar(content: Text('号码已复制')),
|
||||
);
|
||||
},
|
||||
child: const Text('复制号码'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _pickImage() {
|
||||
// 占位:接入 image_picker 后实现
|
||||
debugPrint('选择图片');
|
||||
setState(() {
|
||||
_selectedImages.add('placeholder_${_selectedImages.length}');
|
||||
});
|
||||
}
|
||||
|
||||
void _submitFeedback() {
|
||||
if (_feedbackController.text.trim().isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('请输入问题描述'),
|
||||
backgroundColor: Color(0xFFF53F3F),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: 调用后端接口提交反馈
|
||||
debugPrint('提交反馈: type=${_feedbackTypes[_selectedFeedbackType]['label']}, '
|
||||
'content=${_feedbackController.text}, '
|
||||
'images=${_selectedImages.length}, '
|
||||
'contact=${_contactController.text}');
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: const Text('反馈已提交,感谢您的支持!'),
|
||||
backgroundColor: context.appColors.success,
|
||||
),
|
||||
);
|
||||
|
||||
// 重置表单
|
||||
_feedbackController.clear();
|
||||
_contactController.clear();
|
||||
setState(() {
|
||||
_selectedFeedbackType = 0;
|
||||
_selectedImages.clear();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import 'package:maibu_satabot_v2/features/v2/my/presentation/widgets/quick_actio
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/widgets/menu_item_card.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/system_settings_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/profile_detail_page.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/presentation/pages/help_feedback_page.dart';
|
||||
|
||||
/// 我的页面(100% 还原设计稿)
|
||||
class MyPage extends StatelessWidget {
|
||||
@@ -73,93 +74,94 @@ class _MyPageContent extends StatelessWidget {
|
||||
final userName = user?.nickname ?? user?.username ?? '未知用户';
|
||||
final userRole = user?.email ?? user?.phone ?? '未设置';
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// 用户信息卡片(延伸到状态栏)
|
||||
UserProfileCard(
|
||||
name: userName,
|
||||
role: userRole,
|
||||
avatar: user?.avatar,
|
||||
onTap: () {
|
||||
// 跳转到个人信息详情页
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ProfileDetailPage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
// 快捷入口卡片(负margin向上重叠)
|
||||
Transform.translate(
|
||||
offset: const Offset(0, -15),
|
||||
child: QuickActionCard(
|
||||
onMessageTap: () {
|
||||
debugPrint('我的消息');
|
||||
},
|
||||
onFavoriteTap: () {
|
||||
debugPrint('我的收藏');
|
||||
},
|
||||
onWorkOrderTap: () {
|
||||
debugPrint('我的工单');
|
||||
},
|
||||
),
|
||||
),
|
||||
// 菜单列表(白色卡片)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(
|
||||
top: 15,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.cardBackground,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: context.appColors.cardShadow,
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.5,
|
||||
),
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.zero,
|
||||
// 末尾追加退出登录,占据“关于我们”原来的位置
|
||||
itemCount: state.menuItems.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
// 退出登录(列表最后一项,在可滚动区域内避免底部溢出)
|
||||
if (index == state.menuItems.length) {
|
||||
return _buildLogoutButton(context);
|
||||
}
|
||||
final item = state.menuItems[index];
|
||||
// 🔥 夜间模式开关值以全局 ThemeCubit 状态为准
|
||||
final displayItem = item.id == 'night_mode'
|
||||
? item.copyWith(switchValue: isDarkMode)
|
||||
: item;
|
||||
return MenuItemCard(
|
||||
item: displayItem,
|
||||
onTap: () => _handleMenuItemTap(context, cubit, item),
|
||||
onSwitchChanged: item.hasSwitch
|
||||
? (value) {
|
||||
// 更新菜单 UI 状态
|
||||
cubit.toggleNightMode(value);
|
||||
// 🔥 真正切换全局主题
|
||||
context
|
||||
.read<ThemeCubit>()
|
||||
.toggleDarkMode(value);
|
||||
}
|
||||
: null,
|
||||
return SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
// 用户信息卡片(延伸到状态栏)
|
||||
UserProfileCard(
|
||||
name: userName,
|
||||
role: userRole,
|
||||
avatar: user?.avatar,
|
||||
onTap: () {
|
||||
// 跳转到个人信息详情页
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ProfileDetailPage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
// 快捷入口卡片(负margin向上重叠)
|
||||
Transform.translate(
|
||||
offset: const Offset(0, -15),
|
||||
child: QuickActionCard(
|
||||
onMessageTap: () {
|
||||
debugPrint('我的消息');
|
||||
},
|
||||
onFavoriteTap: () {
|
||||
debugPrint('我的收藏');
|
||||
},
|
||||
onWorkOrderTap: () {
|
||||
debugPrint('我的工单');
|
||||
},
|
||||
),
|
||||
),
|
||||
// 菜单列表(白色卡片)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(
|
||||
top: 15,
|
||||
left: 16,
|
||||
right: 16,
|
||||
bottom: 16,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: context.appColors.cardBackground,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: context.appColors.cardShadow,
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
// 末尾追加退出登录,占据“关于我们”原来的位置
|
||||
itemCount: state.menuItems.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
// 退出登录(列表最后一项,在可滚动区域内避免底部溢出)
|
||||
if (index == state.menuItems.length) {
|
||||
return _buildLogoutButton(context);
|
||||
}
|
||||
final item = state.menuItems[index];
|
||||
// 🔥 夜间模式开关值以全局 ThemeCubit 状态为准
|
||||
final displayItem = item.id == 'night_mode'
|
||||
? item.copyWith(switchValue: isDarkMode)
|
||||
: item;
|
||||
return MenuItemCard(
|
||||
item: displayItem,
|
||||
onTap: () =>
|
||||
_handleMenuItemTap(context, cubit, item),
|
||||
onSwitchChanged: item.hasSwitch
|
||||
? (value) {
|
||||
// 更新菜单 UI 状态
|
||||
cubit.toggleNightMode(value);
|
||||
// 🔥 真正切换全局主题
|
||||
context.read<ThemeCubit>().toggleDarkMode(
|
||||
value,
|
||||
);
|
||||
}
|
||||
: null,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -196,6 +198,13 @@ class _MyPageContent extends StatelessWidget {
|
||||
MaterialPageRoute(builder: (context) => const SystemSettingsPage()),
|
||||
);
|
||||
break;
|
||||
case 'help_feedback':
|
||||
// 跳转到帮助与反馈页面
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const HelpFeedbackPage()),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
debugPrint('点击菜单: ${item.title}');
|
||||
// TODO: 根据 ID 跳转到对应页面
|
||||
|
||||
@@ -10,6 +10,8 @@ import 'package:maibu_satabot_v2/core/theme/AppTheme.dart';
|
||||
import 'package:maibu_satabot_v2/core/storage/user_storage.dart';
|
||||
import 'package:maibu_satabot_v2/features/auth/presentation/bloc/auth_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/presentation/cubit/tab_config_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/main_container/domain/tab_config.dart';
|
||||
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/device_list/presentation/float_bar/cubit/float_bar_setting_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/update/update_cubit.dart';
|
||||
import 'package:maibu_satabot_v2/core/update/update_state.dart';
|
||||
@@ -146,6 +148,9 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
|
||||
/// Tab 设置
|
||||
Widget _buildTabSettingsSection() {
|
||||
// 🔥 个人角色(roleKey == 'personal'):Tab 设置只列出「设备 + 我的」,且开关常开锁定
|
||||
final roleKey = context.watch<AppUserCubit>().state.user?.roleKey;
|
||||
final isPersonal = roleKey == TabConfig.personalRoleKey;
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -177,7 +182,7 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
final tabs = state.config.items;
|
||||
final tabs = state.config.settingItemsForRole(roleKey);
|
||||
|
||||
return ListView.builder(
|
||||
shrinkWrap: true,
|
||||
@@ -199,10 +204,13 @@ class _SystemSettingsPageState extends State<SystemSettingsPage> {
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: tab.isEnabled,
|
||||
onChanged: (value) {
|
||||
context.read<TabConfigCubit>().toggleTab(tab.id);
|
||||
},
|
||||
// 个人角色:设备/我的 强制常开且不可关闭
|
||||
value: isPersonal ? true : tab.isEnabled,
|
||||
onChanged: isPersonal
|
||||
? null
|
||||
: (value) {
|
||||
context.read<TabConfigCubit>().toggleTab(tab.id);
|
||||
},
|
||||
activeColor: const Color(0xFF165DFF),
|
||||
),
|
||||
],
|
||||
|
||||
204
package-lock.json
generated
Normal file
204
package-lock.json
generated
Normal file
@@ -0,0 +1,204 @@
|
||||
{
|
||||
"name": "flutter-app-02",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"docx": "^9.7.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "25.9.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-25.9.5.tgz",
|
||||
"integrity": "sha512-OScDchr2fwuUmWdf4kZ9h7PcJiYDVInhJizG/biAq3cAvqwYktuy/TYGGdZNMtNTFUP7rnb0NU4TUdm82kt4Rg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": ">=7.24.0 <7.24.7"
|
||||
}
|
||||
},
|
||||
"node_modules/core-util-is": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
|
||||
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/docx": {
|
||||
"version": "9.7.1",
|
||||
"resolved": "https://registry.npmjs.org/docx/-/docx-9.7.1.tgz",
|
||||
"integrity": "sha512-ilXFf9Moz47ABjFpDiA5s1w9lpb4EFSp7+5iiJSbfyYDM+bpZdAgLlSr7fW4aXhVe/E+F6QCv0EvRVFEd5CsWg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "^25.2.3",
|
||||
"hash.js": "^1.1.7",
|
||||
"jszip": "^3.10.1",
|
||||
"nanoid": "^5.1.3",
|
||||
"xml": "^1.0.1",
|
||||
"xml-js": "^1.6.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/hash.js": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz",
|
||||
"integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"inherits": "^2.0.3",
|
||||
"minimalistic-assert": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/immediate": {
|
||||
"version": "3.0.6",
|
||||
"resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz",
|
||||
"integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/jszip": {
|
||||
"version": "3.10.1",
|
||||
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz",
|
||||
"integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==",
|
||||
"license": "(MIT OR GPL-3.0-or-later)",
|
||||
"dependencies": {
|
||||
"lie": "~3.3.0",
|
||||
"pako": "~1.0.2",
|
||||
"readable-stream": "~2.3.6",
|
||||
"setimmediate": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/lie": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz",
|
||||
"integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"immediate": "~3.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/minimalistic-assert": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
|
||||
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "5.1.16",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.1.16.tgz",
|
||||
"integrity": "sha512-kVrnsrJqMR8+oLJnGEmSWw9BivK5mt7H3FZatVRjrc5wGqFYuBxX1yG7+A7Gi5AefkX6t/oCkizcQgpu0cY1dQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/ai"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"nanoid": "bin/nanoid.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18 || >=20"
|
||||
}
|
||||
},
|
||||
"node_modules/pako": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz",
|
||||
"integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==",
|
||||
"license": "(MIT AND Zlib)"
|
||||
},
|
||||
"node_modules/process-nextick-args": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
|
||||
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/readable-stream": {
|
||||
"version": "2.3.8",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",
|
||||
"integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/sax": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.6.1.tgz",
|
||||
"integrity": "sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==",
|
||||
"license": "BlueOak-1.0.0",
|
||||
"engines": {
|
||||
"node": ">=11.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/setimmediate": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz",
|
||||
"integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "7.24.6",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.24.6.tgz",
|
||||
"integrity": "sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/xml": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz",
|
||||
"integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/xml-js": {
|
||||
"version": "1.6.11",
|
||||
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz",
|
||||
"integrity": "sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"sax": "^1.2.4"
|
||||
},
|
||||
"bin": {
|
||||
"xml-js": "bin/cli.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
5
package.json
Normal file
5
package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"docx": "^9.7.1"
|
||||
}
|
||||
}
|
||||
BIN
satabot-user-guide/_shared/fonts/Outfit-Bold.ttf
Normal file
BIN
satabot-user-guide/_shared/fonts/Outfit-Bold.ttf
Normal file
Binary file not shown.
93
satabot-user-guide/_shared/fonts/Outfit-OFL.txt
Normal file
93
satabot-user-guide/_shared/fonts/Outfit-OFL.txt
Normal file
@@ -0,0 +1,93 @@
|
||||
Copyright 2021 The Outfit Project Authors (https://github.com/Outfitio/Outfit-Fonts)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
BIN
satabot-user-guide/_shared/fonts/Outfit-Regular.ttf
Normal file
BIN
satabot-user-guide/_shared/fonts/Outfit-Regular.ttf
Normal file
Binary file not shown.
1200
satabot-user-guide/satabot-user-guide.html
Normal file
1200
satabot-user-guide/satabot-user-guide.html
Normal file
File diff suppressed because it is too large
Load Diff
57
test/ble_protocol_decoder_test.dart
Normal file
57
test/ble_protocol_decoder_test.dart
Normal file
@@ -0,0 +1,57 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:maibu_satabot_v2/core/bluetooth/ble_protocol_decoder.dart';
|
||||
import 'package:maibu_satabot_v2/core/protocol/machine_protocol_constants.dart';
|
||||
|
||||
void main() {
|
||||
// 协议表示例:24 个逗号字段,控制模式=2(蓝牙),障碍物=1(有障碍)
|
||||
const sheet =
|
||||
'52.2,2000,2000,190,190,45.2,46.6,40.5,40.5,40,50,5,5,32,5,1,'
|
||||
'120.772,32.078,2026-09-10 12:34:56,2000,2,98,12.65,1';
|
||||
|
||||
Uint8List payloadWith(String body, List<int> tail) =>
|
||||
Uint8List.fromList([...utf8.encode(body), ...tail]);
|
||||
|
||||
String valueOf(BleDecodedResult r, String label) =>
|
||||
r.fields.firstWhere((f) => f.label == label).value;
|
||||
|
||||
test('0x02 带2字节CRC:控制模式/障碍物解析正确', () {
|
||||
final r = BleProtocolDecoder.decode(
|
||||
MachineProtocolConstants.cmdStatusInfo,
|
||||
payloadWith(sheet, [0x12, 0x34]), // 尾部 CRC16 小端
|
||||
);
|
||||
expect(valueOf(r, '控制模式'), '蓝牙');
|
||||
expect(valueOf(r, '障碍物'), '有障碍');
|
||||
expect(valueOf(r, '电压'), '52.20 V'); // _tryParseDouble 保留两位小数
|
||||
expect(valueOf(r, '电量'), '98%');
|
||||
});
|
||||
|
||||
test('0x02 串尾带\\0再加CRC:仍解析正确(不乱码)', () {
|
||||
final r = BleProtocolDecoder.decode(
|
||||
MachineProtocolConstants.cmdStatusInfo,
|
||||
payloadWith('$sheet\x00', [0x12, 0x34]),
|
||||
);
|
||||
expect(valueOf(r, '控制模式'), '蓝牙');
|
||||
expect(valueOf(r, '障碍物'), '有障碍');
|
||||
});
|
||||
|
||||
test('0x02 控制模式带空格(如" 3"):仍映射为文字 TCP', () {
|
||||
final spaced = sheet.replaceFirst(',2000,2,98', ',2000, 3,98');
|
||||
final r = BleProtocolDecoder.decode(
|
||||
MachineProtocolConstants.cmdStatusInfo,
|
||||
payloadWith(spaced, [0x12, 0x34]),
|
||||
);
|
||||
expect(valueOf(r, '控制模式'), 'TCP');
|
||||
});
|
||||
|
||||
test('0x02 控制模式为协议外码6:显示 未知(6) 而非裸6', () {
|
||||
final bad = sheet.replaceFirst(',2000,2,98', ',2000,6,98');
|
||||
final r = BleProtocolDecoder.decode(
|
||||
MachineProtocolConstants.cmdStatusInfo,
|
||||
payloadWith(bad, [0x12, 0x34]),
|
||||
);
|
||||
expect(valueOf(r, '控制模式'), '未知(6)');
|
||||
});
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <agora_rtc_engine/agora_rtc_engine_plugin.h>
|
||||
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
|
||||
#include <file_selector_windows/file_selector_windows.h>
|
||||
#include <flutter_blue_plus_winrt/flutter_blue_plus_plugin.h>
|
||||
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
|
||||
@@ -21,8 +20,6 @@
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
AgoraRtcEnginePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("AgoraRtcEnginePlugin"));
|
||||
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
|
||||
FileSelectorWindowsRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FileSelectorWindows"));
|
||||
FlutterBluePlusPluginRegisterWithRegistrar(
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
agora_rtc_engine
|
||||
connectivity_plus
|
||||
file_selector_windows
|
||||
flutter_blue_plus_winrt
|
||||
flutter_webrtc
|
||||
|
||||
BIN
草坪作业规划APP功能使用手册.docx
Normal file
BIN
草坪作业规划APP功能使用手册.docx
Normal file
Binary file not shown.
BIN
草坪作业规划APP功能使用手册_v2.docx
Normal file
BIN
草坪作业规划APP功能使用手册_v2.docx
Normal file
Binary file not shown.
BIN
草坪作业规划APP功能使用手册_v3.docx
Normal file
BIN
草坪作业规划APP功能使用手册_v3.docx
Normal file
Binary file not shown.
Reference in New Issue
Block a user