更新消息设置
This commit is contained in:
@@ -135,12 +135,14 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
Widget _buildLoggedInContent() {
|
||||
return Obx(() {
|
||||
if (finalUri.isEmpty) {
|
||||
return Center(child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
themeController.currentColor.sc1,
|
||||
),
|
||||
),);
|
||||
return Center(
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
themeController.currentColor.sc1,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 如果设备列表为空
|
||||
@@ -166,7 +168,9 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
return Stack(
|
||||
children: [
|
||||
InAppWebView(
|
||||
initialUrlRequest: URLRequest(url: WebUri(finalUri.value+"?t=${DateTime.now().millisecondsSinceEpoch}")),
|
||||
initialUrlRequest: URLRequest(
|
||||
url: WebUri(finalUri.value +
|
||||
"?t=${DateTime.now().millisecondsSinceEpoch}")),
|
||||
onLoadStart: (controller, url) {
|
||||
isPageLoading.value = true;
|
||||
},
|
||||
@@ -178,12 +182,14 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
valueListenable: isPageLoading,
|
||||
builder: (context, isLoading, child) {
|
||||
return isLoading
|
||||
? Center(child:CircularProgressIndicator(
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
themeController.currentColor.sc1,
|
||||
),
|
||||
),)
|
||||
),
|
||||
)
|
||||
: SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
@@ -212,55 +218,127 @@ class _EPageState extends State<EPage> with AutomaticKeepAliveClientMixin {
|
||||
}
|
||||
|
||||
Future<void> getDeviceList() async {
|
||||
BodyDeviceController bodyDeviceController = Get.find();
|
||||
ApiResponse apiResponse = await bodyDeviceController.getDeviceList();
|
||||
try {
|
||||
BodyDeviceController bodyDeviceController = Get.find();
|
||||
ApiResponse apiResponse =
|
||||
await bodyDeviceController.getDeviceList(isAllDevice: true);
|
||||
|
||||
if (apiResponse.code == HttpStatusCodes.ok) {
|
||||
List<dynamic> rawList = apiResponse.data;
|
||||
if (apiResponse.code == HttpStatusCodes.ok) {
|
||||
List<dynamic> rawList = apiResponse.data;
|
||||
|
||||
// 提取 mac 和 person.name
|
||||
List<Map<String, dynamic>> newList = rawList.map((item) {
|
||||
String mac = item['mac'] ?? '';
|
||||
String name = (item['person'] != null &&
|
||||
item['person']['name'] != null &&
|
||||
item['person']['name'].toString().trim().isNotEmpty)
|
||||
? item['person']['name'] + "_${mac}"
|
||||
: '未命名'.tr + "_${mac}";
|
||||
return {
|
||||
'mac': mac,
|
||||
'name': name,
|
||||
};
|
||||
}).toList();
|
||||
// 提取 mac 和 person.name
|
||||
List<Map<String, dynamic>> newList = rawList.map((item) {
|
||||
String mac = item['mac'] ?? '';
|
||||
String name = (item['person'] != null &&
|
||||
item['person']['name'] != null &&
|
||||
item['person']['name'].toString().trim().isNotEmpty)
|
||||
? item['person']['name'] + "_${mac}"
|
||||
: '未命名'.tr + "_${mac}";
|
||||
return {
|
||||
'mac': mac,
|
||||
'name': name,
|
||||
};
|
||||
}).toList();
|
||||
|
||||
deviceList.value = newList;
|
||||
deviceList.value = newList;
|
||||
|
||||
// 拼接参数 person
|
||||
if (deviceList.isNotEmpty) {
|
||||
// JSON 编码整个 deviceList 对象数组
|
||||
String personParam = Uri.encodeComponent(jsonEncode(deviceList));
|
||||
finalUri.value = "${widget.sleepUri}?person=$personParam";
|
||||
// 拼接参数 person
|
||||
if (deviceList.isNotEmpty) {
|
||||
// JSON 编码整个 deviceList 对象数组
|
||||
String personParam = Uri.encodeComponent(jsonEncode(deviceList));
|
||||
finalUri.value = "${widget.sleepUri}?person=$personParam";
|
||||
} else {
|
||||
finalUri.value = widget.sleepUri;
|
||||
}
|
||||
}
|
||||
String? language = "";
|
||||
if (AppConstants().ent_type == APPPackageType.MHT.code) {
|
||||
if (mhLanguageController.selectLanguage != null) {
|
||||
language = mhLanguageController.selectLanguage.value!.language_code;
|
||||
}
|
||||
} else {
|
||||
finalUri.value = widget.sleepUri;
|
||||
if (languageController.selectLanguage != null) {
|
||||
language = languageController.selectLanguage.value!.language_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
String? language = "";
|
||||
if (AppConstants().ent_type == APPPackageType.MHT.code) {
|
||||
if (mhLanguageController.selectLanguage != null) {
|
||||
language = mhLanguageController.selectLanguage.value!.language_code;
|
||||
}
|
||||
} else {
|
||||
if (languageController.selectLanguage != null) {
|
||||
language = languageController.selectLanguage.value!.language_code;
|
||||
}
|
||||
}
|
||||
|
||||
if (language != null && language.isNotEmpty) {
|
||||
if (finalUri.value.contains("?")) {
|
||||
finalUri.value += "&lang=$language";
|
||||
} else {
|
||||
finalUri.value += "?lang=$language";
|
||||
if (language != null && language.isNotEmpty) {
|
||||
if (finalUri.value.contains("?")) {
|
||||
finalUri.value += "&lang=$language";
|
||||
} else {
|
||||
finalUri.value += "?lang=$language";
|
||||
}
|
||||
}
|
||||
ef.log("msg");
|
||||
} catch (e) {
|
||||
ef.log(e.toString());
|
||||
}
|
||||
ef.log("msg");
|
||||
}
|
||||
|
||||
// Future<void> getDeviceList() async {
|
||||
// try {
|
||||
// BodyDeviceController bodyDeviceController = Get.find();
|
||||
// ApiResponse apiResponse =
|
||||
// await bodyDeviceController.getDeviceList(isAllDevice: true);
|
||||
|
||||
// // 调试:打印返回的数据结构
|
||||
// print('API响应数据: $apiResponse');
|
||||
// print('API响应数据类型: ${apiResponse.data.runtimeType}');
|
||||
// print('API响应数据内容: ${apiResponse.data}');
|
||||
|
||||
// if (apiResponse.code == HttpStatusCodes.ok) {
|
||||
// List<dynamic> rawList = apiResponse.data;
|
||||
|
||||
// // 调试:检查 rawList 的类型和内容
|
||||
// print('rawList 类型: ${rawList.runtimeType}');
|
||||
// print('rawList 长度: ${rawList.length}');
|
||||
// if (rawList.isNotEmpty) {
|
||||
// print('rawList[0] 类型: ${rawList[0].runtimeType}');
|
||||
// print('rawList[0] 内容: ${rawList[0]}');
|
||||
// }
|
||||
|
||||
// // 安全处理:确保每个元素都是 Map
|
||||
// List<Map<String, dynamic>> newList =
|
||||
// rawList.whereType<Map>().map((item) {
|
||||
// // 调试每个 item
|
||||
// print('处理 item: $item');
|
||||
// print('item 类型: ${item.runtimeType}');
|
||||
|
||||
// String mac = (item['mac'] ?? '').toString();
|
||||
// String name = '未命名'.tr + "_${mac}";
|
||||
|
||||
// if (item['person'] != null && item['person'] is Map) {
|
||||
// var person = item['person'] as Map;
|
||||
// if (person['name'] != null &&
|
||||
// person['name'].toString().trim().isNotEmpty) {
|
||||
// name = '${person['name']}_${mac}';
|
||||
// }
|
||||
// }
|
||||
|
||||
// return {
|
||||
// 'mac': mac,
|
||||
// 'name': name,
|
||||
// };
|
||||
// }).toList();
|
||||
|
||||
// deviceList.value = newList;
|
||||
|
||||
// // 拼接参数 person
|
||||
// if (deviceList.isNotEmpty) {
|
||||
// // JSON 编码整个 deviceList 对象数组
|
||||
// String personParam = Uri.encodeComponent(jsonEncode(deviceList));
|
||||
// finalUri.value = "${widget.sleepUri}?person=$personParam";
|
||||
// } else {
|
||||
// finalUri.value = widget.sleepUri;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // ... 后续语言处理代码不变
|
||||
// } catch (e) {
|
||||
// print('getDeviceList 错误详情: $e');
|
||||
// print('错误堆栈: ${e}');
|
||||
// ef.log(e.toString());
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user