From b939c440db6c336613bc1f015db0063d57b783e1 Mon Sep 17 00:00:00 2001 From: denglihong2007 <98096191+denglihong2007@users.noreply.github.com> Date: Mon, 9 Jun 2025 12:39:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20#171=20=E4=BF=AE=E5=A4=8D=E8=81=94?= =?UTF-8?q?=E7=BD=91=E8=8E=B7=E5=8F=96=E8=BD=A6=E6=AC=A1=E9=97=AA=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CRSim.Core/Services/NetworkService.cs | 2 +- .../StationManagementPageViewModel.cs | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CRSim.Core/Services/NetworkService.cs b/CRSim.Core/Services/NetworkService.cs index 99632fb..727caca 100644 --- a/CRSim.Core/Services/NetworkService.cs +++ b/CRSim.Core/Services/NetworkService.cs @@ -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]; diff --git a/CRSim/ViewModels/Pages/DataManagement/StationManagementPageViewModel.cs b/CRSim/ViewModels/Pages/DataManagement/StationManagementPageViewModel.cs index 7541b10..272cdfc 100644 --- a/CRSim/ViewModels/Pages/DataManagement/StationManagementPageViewModel.cs +++ b/CRSim/ViewModels/Pages/DataManagement/StationManagementPageViewModel.cs @@ -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("获取失败", "服务器繁忙或车站不存在。"); }