相应的版本更新

This commit is contained in:
2026-07-06 18:49:55 +08:00
parent 76bff59afc
commit 28824501dc
2 changed files with 32 additions and 17 deletions
+31 -16
View File
@@ -352,6 +352,10 @@ class _BatteryHealthPageState extends State<BatteryHealthPage>
_currentCap = recent.first['capacity'].toDouble(); _currentCap = recent.first['capacity'].toDouble();
_maxVolt = recent.first['volt_max'] ?? 0; _maxVolt = recent.first['volt_max'] ?? 0;
_minVolt = recent.first['volt_min'] ?? 0; _minVolt = recent.first['volt_min'] ?? 0;
// 🟢 数据库目前不存温度,后续升级可扩展,暂时保留为 0
_maxTemp = 0;
_minTemp = 0;
_cycleCount = 0;
_hasData = true; _hasData = true;
}); });
await _updateTrendChart(); await _updateTrendChart();
@@ -378,20 +382,7 @@ class _BatteryHealthPageState extends State<BatteryHealthPage>
return; return;
} }
// 使用 CapacityExtractor 提取容量 // 🟢 提取所有有效行(包含 tbat=
final cap = CapacityExtractor.extractCapacity(lines);
if (cap == null) {
dev.log(
'🔵 未找到容量数据(learned_cap 或 remaining_cap',
name: 'BatteryHealth',
);
setState(() => _hasData = false);
_chargeAnimationController.reset();
_updateChargeState();
return;
}
// 提取最后一条有效数据用于显示
final validLines = lines.where((line) => line.contains('tbat=')).toList(); final validLines = lines.where((line) => line.contains('tbat=')).toList();
if (validLines.isEmpty) { if (validLines.isEmpty) {
dev.log('🔵 无有效数据行', name: 'BatteryHealth'); dev.log('🔵 无有效数据行', name: 'BatteryHealth');
@@ -401,6 +392,8 @@ class _BatteryHealthPageState extends State<BatteryHealthPage>
return; return;
} }
// 🟢 1.4.7 核心改动:字段提取与容量提取解耦
// 无论 cap 是否为 null,都提取常规字段
final lastLine = validLines.last; final lastLine = validLines.last;
final cycle = _extractCycle(lastLine); final cycle = _extractCycle(lastLine);
final temp = _extractTemp(lastLine); final temp = _extractTemp(lastLine);
@@ -409,12 +402,34 @@ class _BatteryHealthPageState extends State<BatteryHealthPage>
final (maxVolt, minVolt) = _extractVoltExtremes(validLines); final (maxVolt, minVolt) = _extractVoltExtremes(validLines);
dev.log( dev.log(
'🔵 解析结果: cap=$cap, cycle=$cycle, temp=$temp, volt=$volt', '🔵 字段提取: cycle=$cycle, temp=$temp, volt=$volt',
name: 'BatteryHealth', name: 'BatteryHealth',
); );
// 🟢 容量提取(可能为 null)
final cap = CapacityExtractor.extractCapacity(lines);
int? finalCap;
if (cap != null) {
// ✅ 今日有充满记录,直接使用
finalCap = cap;
dev.log('🔵 从日志提取容量: $cap', name: 'BatteryHealth');
} else {
// ⚠️ 今日无充满记录,尝试从数据库复制前一天容量
dev.log('🔵 今日无充满记录,尝试复制前一天容量', name: 'BatteryHealth');
final recent = await _dbService.queryRecentData(1);
if (recent.isNotEmpty) {
finalCap = recent.first['capacity'] as int;
dev.log('🔵 复制前一天容量: $finalCap', name: 'BatteryHealth');
} else {
finalCap = null;
dev.log('🔵 无历史数据可复制', name: 'BatteryHealth');
}
}
// 🟢 一次性 setState 更新所有字段
setState(() { setState(() {
_currentCap = cap.toDouble(); _currentCap = (finalCap ?? _currentCap).toDouble();
_cycleCount = cycle; _cycleCount = cycle;
_batteryTemp = temp; _batteryTemp = temp;
_batteryVolt = volt; _batteryVolt = volt;
+1 -1
View File
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.4.5 version: 1.4.7
environment: environment:
sdk: ^3.9.2 sdk: ^3.9.2