diff --git a/lib/data/models/appconfig_model.dart b/lib/data/models/appconfig_model.dart index 945103b42..7f7b6bd59 100644 --- a/lib/data/models/appconfig_model.dart +++ b/lib/data/models/appconfig_model.dart @@ -1,4 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; +import 'package:get/get.dart'; part 'appconfig_model.g.dart'; // 生成的文件名 @@ -136,3 +137,24 @@ enum DeviceType { /// 设备类型对应的整数值 final int value; } + +// 为 DeviceType 添加扩展方法 +extension DeviceTypeExtension on DeviceType { + /// 获取设备类型的显示名称 + /// @Description 根据设备类型返回对应的翻译键 + String get displayName { + switch (this) { + case DeviceType.unknown: + return "deviceTypeUnknown".tr; // 未知设备 + case DeviceType.classicBluetoothHeadset: + return "deviceTypeClassicBluetoothHeadset".tr; // 经典蓝牙耳机 + case DeviceType.bleBluetoothDoubleHeadset: + case DeviceType.bleBluetoothSingleHeadset: + return "deviceTypeBleBluetoothHeadset".tr; // BLE蓝牙耳机(单端和双端都使用同一个翻译键) + case DeviceType.smartVoiceRecorder: + return "deviceTypeSmartVoiceRecorder".tr; // 智能录音笔 + case DeviceType.smartEye: + return "deviceTypeSmartEye".tr; // 智能眼镜 + } + } +} diff --git a/lib/modules/home/views/home_view.dart b/lib/modules/home/views/home_view.dart index fccea3b5e..5e5a72be4 100644 --- a/lib/modules/home/views/home_view.dart +++ b/lib/modules/home/views/home_view.dart @@ -6,6 +6,7 @@ import '../../../core/widgets/intro_overlay_builder.dart'; import '../controllers/home_controller.dart'; import '../../../routes/app_routes.dart'; import '../../../core/widgets/common_bottom_nav.dart'; +import '../../../data/models/appconfig_model.dart'; // 呼吸灯动画组件 class AnimatedPulsing extends StatefulWidget { @@ -533,8 +534,9 @@ class HomeView extends GetView { // 单端耳机只显示一个电池信息(优先显示左耳,如果左耳电量为0则显示右耳) if (isSingleHeadset) ...[ _buildCompactBatteryItem( - //label: 'deviceTypeBleBluetoothHeadset'.tr, - label: '', + label: controller + .getCurrentDeviceType() + .displayName, // 根据设备类型动态显示文本 batteryLevel: (leftBattery > 0 || rightBattery == 0) ? leftBattery : rightBattery,