添加了 Mqtt 的界面和添加对话框

This commit is contained in:
2025-07-04 22:39:44 +08:00
parent 8325717b95
commit f86ce8194b
12 changed files with 452 additions and 14 deletions

View File

@@ -18,12 +18,15 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
[ObservableProperty] private List<Device> _devices;
[ObservableProperty] private List<VariableTable> _variableTables;
[ObservableProperty] private List<MenuBean> menuTrees;
[ObservableProperty] private List<Mqtt> _mqtts;
private readonly DeviceRepository _deviceRepository;
private readonly MenuRepository _menuRepository;
private readonly MqttRepository _mqttRepository;
public event Action<List<Device>> OnDeviceListChanged;
public event Action<List<MenuBean>> OnMenuTreeListChanged;
public event Action<List<Mqtt>> OnMqttListChanged;
partial void OnDevicesChanged(List<Device> devices)
@@ -36,6 +39,11 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
OnMenuTreeListChanged?.Invoke(MenuTrees);
}
partial void OnMqttsChanged(List<Mqtt> mqtts)
{
OnMqttListChanged?.Invoke(mqtts);
}
public DataServices(ILogger<DataServices> logger)
{
@@ -43,6 +51,7 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
IsActive = true;
_deviceRepository = new DeviceRepository();
_menuRepository = new MenuRepository();
_mqttRepository = new MqttRepository();
}
@@ -60,6 +69,7 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
case LoadTypes.All:
await LoadDevices();
await LoadMenus();
await LoadMqtts();
break;
case LoadTypes.Devices:
await LoadDevices();
@@ -67,6 +77,9 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
case LoadTypes.Menu:
await LoadMenus();
break;
case LoadTypes.Mqtts:
await LoadMqtts();
break;
}
}
catch (Exception e)
@@ -90,4 +103,9 @@ public partial class DataServices : ObservableRecipient, IRecipient<LoadMessage>
DataServicesHelper.SortMenus(menu);
}
}
private async Task LoadMqtts()
{
Mqtts = await _mqttRepository.GetAll();
}
}