Merge pull request #175 from denglihong2007/dev

fix: #171 修复联网获取车次闪退
This commit is contained in:
denglihong2007
2025-06-09 12:39:53 +08:00
committed by GitHub
2 changed files with 15 additions and 8 deletions

View File

@@ -84,7 +84,7 @@ namespace CRSim.Core.Services
string tel = "";
foreach (string station in stations)
{
if (station == "';") continue;
if (station.StartsWith("';")) continue;
if (station.Split("|")[1] == name)
{
tel = station.Split("|")[2];

View File

@@ -538,17 +538,24 @@ public partial class StationManagementPageViewModel : ObservableObject
[RelayCommand]
public async Task ImportFromInternet()
{
if (!CheckCanImport()) return;
var stops = await _networkService.GetTrainNumbersAsync(SelectedStation.Name);
if (stops.Count != 0)
try
{
TrainStops.Clear();
foreach (TrainStop t in stops)
if (!CheckCanImport()) return;
var stops = await _networkService.GetTrainNumbersAsync(SelectedStation.Name);
if (stops.Count != 0)
{
TrainStops.Add(RandomTrainStopProperties(t));
TrainStops.Clear();
foreach (TrainStop t in stops)
{
TrainStops.Add(RandomTrainStopProperties(t));
}
}
else
{
throw new Exception();
}
}
else
catch
{
_dialogService.ShowMessage("获取失败", "服务器繁忙或车站不存在。");
}