更新小e

This commit is contained in:
wyf
2025-09-18 17:52:02 +08:00
parent 2efbd5df57
commit 676c51f339
11 changed files with 405 additions and 69 deletions

View File

@@ -126,6 +126,8 @@ class DeviceListController extends GetControllerEx<DeviceListModel> {
} else {
msg = '删除成功'.tr;
}
//删除用户的自定义配置
delDeviceSleepHabit(device);
},
onFailure: (res) {
if (type == 1) {
@@ -161,4 +163,43 @@ class DeviceListController extends GetControllerEx<DeviceListModel> {
},
);
}
void delDeviceSleepHabit(Map device) {
String serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.user_setting;
String type = "sleep_habit_${formatMacAddress(device['mac'])}";
String queryUrl =
"${serviceAddress}${serviceName}${serviceApi}?type=${type}";
requestWithLog(
logTitle: "删除设备自定义配置",
method: MyHttpMethod.delete,
queryUrl: queryUrl,
onSuccess: (res) {
print(res);
},
onFailure: (res) {
print(res);
},
);
}
String formatMacAddress(String input) {
if (input.isEmpty) return input;
// 1. 移除所有非16进制字符去掉冒号、空格、破折号等
String clean = input.replaceAll(RegExp(r'[^a-fA-F0-9]'), '');
// 2. 如果长度不足12左侧补0MAC地址长度固定12
clean = clean.padLeft(12, '0');
// 3. 按2个字符一组拼接冒号
List<String> parts = [];
for (int i = 0; i < 12; i += 2) {
parts.add(clean.substring(i, i + 2).toUpperCase());
}
// 4. 返回格式化字符串
return parts.join(':');
}
}