Browse Source

refactor(设备管理): 重构设备类型显示和解绑对话框的多语言支持

移除清除配对设备功能及相关翻译
更新设备类型枚举使用多语言显示
为解绑对话框添加多语言支持
weicu
lxm 1 year ago
parent
commit
fe7074b068
  1. 27
      lib/core/translations/language/en_us.dart
  2. 27
      lib/core/translations/language/zh_cn.dart
  3. 57
      lib/modules/devices/views/devices_view.dart
  4. 70
      lib/modules/settings/controllers/settings_controller.dart

27
lib/core/translations/language/en_us.dart

@ -485,11 +485,11 @@ const Map<String, String> enUS = {
'networkErrorRetry': 'Network error, please try again later',
// 设备管理相关
'clearPairedDevices': 'Clear Paired Devices',
'clearPairedDevicesConfirm':
'Are you sure you want to clear all paired devices?',
'clearPairedDevicesSuccess': 'Clear paired devices successfully',
'clearPairedDevicesFailed': 'Clear paired devices failed',
// 'clearPairedDevices': 'Clear Paired Devices',
// 'clearPairedDevicesConfirm':
// 'Are you sure you want to clear all paired devices?',
// 'clearPairedDevicesSuccess': 'Clear paired devices successfully',
// 'clearPairedDevicesFailed': 'Clear paired devices failed',
// 设置页面 - 实时语音对话
'realtimeVoiceChat': 'Real-time Voice Chat',
@ -498,11 +498,20 @@ const Map<String, String> enUS = {
'loading': 'Loading...',
//设备管理页面
"earphone": "Earphone", // 耳机
"voicerecorder": "Voice Recorder", // 录音笔
"notBound": "Not Bound", // 未绑定
"deviceNotBoundYet": "Device not bound yet", // 还未绑定设备
"deviceTypeUnknown": "Unknown Device",
"deviceTypeClassicBluetoothHeadset": "Classic Bluetooth Headset",
"deviceTypeBleBluetoothHeadset": "BLE Bluetooth Headset",
"deviceTypeSmartVoiceRecorder": "Smart Voice Recorder",
"deviceTypeSmartEye": "Smart Glasses",
"unbind": "Unbind", // 解绑
"noDevicesBound": "No devices bound yet",
"pleaseBindDeviceFirst": "Please bind a device first to manage",
"noMacAddress": "No MAC Address",
"licenseCode": "License Code",
"confirmUnbind": "Confirm Unbind",
"confirmUnbindMessage":
"Are you sure you want to unbind device \"{deviceName}\"?",
"confirmUnbindAction": "Confirm Unbind",
// Agent模块
//Agent View

27
lib/core/translations/language/zh_cn.dart

@ -399,7 +399,8 @@ const Map<String, String> zhCN = {
// Meeting模块 - 云端同步相关
'syncToCloud': '同步到云端',
'syncToCloudTip': '自动将你的录音同步到云端,你可以通过任意VOITRANS APP或VOITRANS Web(web.voitrans.com)播放、管理和分享录音。',
'syncToCloudTip':
'自动将你的录音同步到云端,你可以通过任意VOITRANS APP或VOITRANS Web(web.voitrans.com)播放、管理和分享录音。',
'syncToVoitransApp': '同步VOITRANS APP',
'transcriptionRecord': '转写记录',
@ -458,10 +459,10 @@ const Map<String, String> zhCN = {
'networkErrorRetry': '网络错误,请稍后重试',
// 设备管理相关
'clearPairedDevices': '清除配对设备',
'clearPairedDevicesConfirm': '确定要清除所有配对设备吗?',
'clearPairedDevicesSuccess': '清除配对设备成功',
'clearPairedDevicesFailed': '清除配对设备失败',
// 'clearPairedDevices': '清除配对设备',
// 'clearPairedDevicesConfirm': '确定要清除所有配对设备吗?',
// 'clearPairedDevicesSuccess': '清除配对设备成功',
// 'clearPairedDevicesFailed': '清除配对设备失败',
// 设置页面 - 实时语音对话
"realtimeVoiceChat": "实时语音对话",
@ -469,11 +470,19 @@ const Map<String, String> zhCN = {
"loading": "加载中...",
//设备管理页面
"earphone": "耳机",
"voicerecorder": "录音笔",
"notBound": "未绑定",
"deviceNotBoundYet": "还未绑定设备",
"deviceTypeUnknown": "未知设备",
"deviceTypeClassicBluetoothHeadset": "经典蓝牙耳机",
"deviceTypeBleBluetoothHeadset": "BLE蓝牙耳机",
"deviceTypeSmartVoiceRecorder": "智能录音笔",
"deviceTypeSmartEye": "智能眼镜",
"unbind": "解绑",
"noDevicesBound": "暂未绑定任何设备",
"pleaseBindDeviceFirst": "请先绑定设备后再进行管理",
"noMacAddress": "无MAC地址",
"licenseCode": "授权码",
"confirmUnbind": "确认解绑",
"confirmUnbindMessage": "确定要解绑设备 \"{deviceName}\" 吗?",
"confirmUnbindAction": "确认解绑",
//Agent 模块
// agent View

57
lib/modules/devices/views/devices_view.dart

@ -10,15 +10,30 @@ import '../controllers/devices_controller.dart';
// 设备类型枚举
enum DeviceType {
Unknown(0, "未知设备"),
Classic_bluetooth_Headset(1, "经典蓝牙耳机"),
BLE_Bluetooth_Headset(2, "BLE蓝牙耳机"),
Smart_Voice_Recorder(3, "智能录音笔"),
SmartEye(4, "智能眼镜");
Unknown(0),
Classic_bluetooth_Headset(1),
BLE_Bluetooth_Headset(2),
Smart_Voice_Recorder(3),
SmartEye(4);
const DeviceType(this.value, this.displayName);
const DeviceType(this.value);
final int value;
final String displayName;
// 使用getter获取多语言显示名称
String get displayName {
switch (this) {
case DeviceType.Unknown:
return "deviceTypeUnknown".tr;
case DeviceType.Classic_bluetooth_Headset:
return "deviceTypeClassicBluetoothHeadset".tr;
case DeviceType.BLE_Bluetooth_Headset:
return "deviceTypeBleBluetoothHeadset".tr;
case DeviceType.Smart_Voice_Recorder:
return "deviceTypeSmartVoiceRecorder".tr;
case DeviceType.SmartEye:
return "deviceTypeSmartEye".tr;
}
}
static DeviceType fromValue(int value) {
return DeviceType.values.firstWhere(
@ -168,7 +183,7 @@ class DevicesView extends GetView<DevicesController> {
),
SizedBox(height: 20.h),
Text(
"暂未绑定任何设备",
"noDevicesBound".tr,
style: TextStyle(
fontSize: 16.sp,
color: isDarkMode ? Colors.white70 : Colors.grey[600],
@ -176,7 +191,7 @@ class DevicesView extends GetView<DevicesController> {
),
SizedBox(height: 12.h),
Text(
"请先绑定设备后再进行管理",
"pleaseBindDeviceFirst".tr,
style: TextStyle(
fontSize: 14.sp,
color: isDarkMode ? Colors.white54 : Colors.grey[500],
@ -230,7 +245,9 @@ class DevicesView extends GetView<DevicesController> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
device.devicename.isNotEmpty ? device.devicename : "未知设备",
device.devicename.isNotEmpty
? device.devicename
: "deviceTypeUnknown".tr,
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
@ -239,7 +256,9 @@ class DevicesView extends GetView<DevicesController> {
),
SizedBox(height: 4.h),
Text(
device.devicemac.isNotEmpty ? device.devicemac : "无MAC地址",
device.devicemac.isNotEmpty
? device.devicemac
: "noMacAddress".tr,
style: TextStyle(
fontSize: 14.sp,
color: isDarkMode ? Colors.white70 : Colors.grey[600],
@ -248,7 +267,7 @@ class DevicesView extends GetView<DevicesController> {
if (device.license.isNotEmpty) ...[
SizedBox(height: 4.h),
Text(
"授权码: ${device.license}",
"${"licenseCode".tr}: ${device.license}",
style: TextStyle(
fontSize: 12.sp,
color: isDarkMode ? Colors.white54 : Colors.grey[500],
@ -294,13 +313,15 @@ class DevicesView extends GetView<DevicesController> {
AlertDialog(
backgroundColor: isDarkMode ? AppColors.cardBackground : Colors.white,
title: Text(
"确认解绑",
"confirmUnbind".tr,
style: TextStyle(
color: isDarkMode ? Colors.white : Colors.black87,
),
),
content: Text(
"确定要解绑设备 \"${device.devicename}\" 吗?",
"confirmUnbindMessage"
.tr
.replaceAll('{deviceName}', device.devicename),
style: TextStyle(
color: isDarkMode ? Colors.white70 : Colors.black54,
),
@ -309,7 +330,7 @@ class DevicesView extends GetView<DevicesController> {
TextButton(
onPressed: () => Get.back(),
child: Text(
"取消",
"cancel".tr,
style: TextStyle(
color: isDarkMode ? Colors.white70 : Colors.grey[600],
),
@ -320,9 +341,9 @@ class DevicesView extends GetView<DevicesController> {
Get.back();
controller.unbindearphone(device);
},
child: const Text(
"确认解绑",
style: TextStyle(color: Colors.red),
child: Text(
"confirmUnbindAction".tr,
style: const TextStyle(color: Colors.red),
),
),
],

70
lib/modules/settings/controllers/settings_controller.dart

@ -466,42 +466,42 @@ class SettingsController extends GetxController {
}
/// 清除BLE配对设备
Future<void> clearBleDevices() async {
// 显示确认对话框
final confirmed = await Get.dialog<bool>(
AlertDialog(
title: const Text('清除配对设备'),
content: const Text('确定要清除所有BLE配对设备吗?此操作不可撤销。'),
actions: [
TextButton(
onPressed: () => Get.back(result: false),
child: Text('cancel'.tr),
),
TextButton(
onPressed: () => Get.back(result: true),
style: TextButton.styleFrom(
foregroundColor: Colors.red,
),
child: Text('confirm'.tr), //确认
),
],
),
);
// Future<void> clearBleDevices() async {
// // 显示确认对话框
// final confirmed = await Get.dialog<bool>(
// AlertDialog(
// title: const Text('清除配对设备'),
// content: const Text('确定要清除所有BLE配对设备吗?此操作不可撤销。'),
// actions: [
// TextButton(
// onPressed: () => Get.back(result: false),
// child: Text('cancel'.tr),
// ),
// TextButton(
// onPressed: () => Get.back(result: true),
// style: TextButton.styleFrom(
// foregroundColor: Colors.red,
// ),
// child: Text('confirm'.tr), //确认
// ),
// ],
// ),
// );
if (confirmed == true) {
try {
final bleManager = Get.find<BleManager>();
final result = await bleManager.clearPairedDevices();
if (result) {
Get.snackbar('成功', 'BLE配对设备已清除');
} else {
Get.snackbar('失败', '清除BLE配对设备失败');
}
} catch (e) {
Get.snackbar('错误', '清除BLE配对设备时发生错误');
}
}
}
// if (confirmed == true) {
// try {
// final bleManager = Get.find<BleManager>();
// final result = await bleManager.clearPairedDevices();
// if (result) {
// Get.snackbar('成功', 'BLE配对设备已清除');
// } else {
// Get.snackbar('失败', '清除BLE配对设备失败');
// }
// } catch (e) {
// Get.snackbar('错误', '清除BLE配对设备时发生错误');
// }
// }
// }
/// 手动检查版本更新
Future<void> checkForUpdate() async {

Loading…
Cancel
Save