diff --git a/PetWash.Api/Data/PetWashDbContext.cs b/PetWash.Api/Data/PetWashDbContext.cs index a716393..a49d399 100644 --- a/PetWash.Api/Data/PetWashDbContext.cs +++ b/PetWash.Api/Data/PetWashDbContext.cs @@ -16,9 +16,9 @@ public class PetWashDbContext : DbContext // 初始化套餐数据 modelBuilder.Entity().HasData( - new Package { Id = 1, Name = "基础清洗", Price = 50, DurationMinutes = 15, Description = "基础清洗服务,适合小型宠物" }, - new Package { Id = 2, Name = "标准清洗", Price = 80, DurationMinutes = 25, Description = "标准清洗+烘干,适合中型宠物" }, - new Package { Id = 3, Name = "豪华清洗", Price = 120, DurationMinutes = 35, Description = "深度清洗+烘干+护理,适合大型宠物" } + new Package { Id = 1, Name = "套餐1", Price = 50, DurationMinutes = 38, Description = "适用于小型犬" }, + new Package { Id = 2, Name = "套餐2", Price = 80, DurationMinutes = 48, Description = "适用于中型犬" }, + new Package { Id = 3, Name = "套餐3", Price = 120, DurationMinutes = 60, Description = "适用于大型犬" } ); } } diff --git a/PetWash.Api/petwash.db b/PetWash.Api/petwash.db index ee09653..b190d96 100644 Binary files a/PetWash.Api/petwash.db and b/PetWash.Api/petwash.db differ diff --git a/PetWashControl/PetWashControl.csproj b/PetWashControl/PetWashControl.csproj index 034a214..b1c9053 100644 --- a/PetWashControl/PetWashControl.csproj +++ b/PetWashControl/PetWashControl.csproj @@ -17,8 +17,9 @@ + + - diff --git a/PetWashControl/ViewModels/MainViewModel.cs b/PetWashControl/ViewModels/MainViewModel.cs index bb062af..068e860 100644 --- a/PetWashControl/ViewModels/MainViewModel.cs +++ b/PetWashControl/ViewModels/MainViewModel.cs @@ -53,6 +53,8 @@ public partial class MainViewModel : ObservableObject [ObservableProperty] private string _currentView = "Idle"; + private string _previousView = "Idle"; // 保存进入设置前的视图 + [ObservableProperty] private int _washProgress; @@ -192,15 +194,51 @@ public partial class MainViewModel : ObservableObject [RelayCommand] private void ShowSettings() { + // 保存当前视图状态 + _previousView = CurrentView; + CurrentView = "Settings"; ViewChanged?.Invoke("Settings"); StatusMessage = "系统设置"; - _logger.LogInfo("切换到设置界面"); + _logger.LogInfo($"切换到设置界面,之前的视图: {_previousView}"); } [RelayCommand] private void BackToIdle() { + // 如果从设置页面返回,且之前不是待机界面,则返回到之前的视图 + if (CurrentView == "Settings" && _previousView != "Idle" && _previousView != "Settings") + { + CurrentView = _previousView; + ViewChanged?.Invoke(_previousView); + + // 根据返回的视图设置相应的状态消息 + switch (_previousView) + { + case "Washing": + StatusMessage = "洗护进行中..."; + _logger.LogInfo("从设置返回到洗护界面"); + break; + case "Payment": + StatusMessage = "请选择套餐"; + _logger.LogInfo("从设置返回到支付界面"); + break; + case "QRCode": + StatusMessage = $"请扫码支付 ¥{SelectedPackage?.Price}"; + _logger.LogInfo("从设置返回到二维码支付界面"); + break; + default: + StatusMessage = "系统就绪,请点击开始"; + _logger.LogInfo("从设置返回到待机界面"); + break; + } + + // 重置之前的视图状态 + _previousView = "Idle"; + return; + } + + // 默认返回到待机界面 CurrentView = "Idle"; ViewChanged?.Invoke("Idle"); StatusMessage = "系统就绪,请点击开始"; @@ -215,6 +253,7 @@ public partial class MainViewModel : ObservableObject step.IsActive = false; } + _previousView = "Idle"; _logger.LogInfo("返回待机界面"); } diff --git a/PetWashControl/Views/MainWindow.xaml b/PetWashControl/Views/MainWindow.xaml index 7b18380..615a68a 100644 --- a/PetWashControl/Views/MainWindow.xaml +++ b/PetWashControl/Views/MainWindow.xaml @@ -665,24 +665,28 @@ HorizontalAlignment="Center" Margin="0,0,0,15"/> - + - - + - - + HorizontalAlignment="Center" + Margin="0,0,0,5"/> + + + +