ソースを参照

feat(ui): 管理口探测结果增加状态样式区分

根据探测状态动态调整背景与文字颜色,提升视觉反馈。
yangkaixiang 1 ヶ月 前
コミット
7f1a387678

+ 3 - 3
windows/NetworkTool.Client/MainWindow.xaml

@@ -66,14 +66,14 @@
                                             Click="RefreshAdaptersButton_OnClick"
                                             Content="刷新" />
                                 </Grid>
-                                <Border Margin="0,16,0,0" Padding="14" Background="#ECFDF5" CornerRadius="10">
+                                <Border x:Name="AdapterProbeBorder" Margin="0,16,0,0" Padding="14" Background="#F3F4F6" CornerRadius="10">
                                     <StackPanel>
-                                        <TextBlock FontSize="12" Foreground="#065F46" Text="管理口探测结果" />
+                                        <TextBlock x:Name="AdapterProbeTitleTextBlock" FontSize="12" Foreground="#374151" Text="管理口探测结果" />
                                         <TextBlock x:Name="AdapterProbeTextBlock"
                                                    Margin="0,8,0,0"
                                                    FontSize="16"
                                                    FontWeight="SemiBold"
-                                                   Foreground="#065F46"
+                                                   Foreground="#374151"
                                                    Text="-" />
                                     </StackPanel>
                                 </Border>

+ 22 - 3
windows/NetworkTool.Client/MainWindow.xaml.cs

@@ -84,9 +84,10 @@ public partial class MainWindow : Window
         }
 
         UpdateAdapterDetails(adapter);
-        SetStatus(adapter.HasLink
-            ? $"已选择 {adapter.RecommendationLabel} 网卡,可切换到维护网络。{adapter.RecommendationReason}"
-            : "当前网卡未检测到链路,请检查网线连接。", true);
+        if (!adapter.HasLink)
+        {
+            SetStatus("当前网卡未检测到链路,请检查网线连接。", true);
+        }
 
         UpdateButtonStates();
     }
@@ -280,10 +281,28 @@ public partial class MainWindow : Window
         if (adapter is null)
         {
             AdapterProbeTextBlock.Text = "-";
+            ApplyAdapterProbeStyle("未探测");
             return;
         }
 
         AdapterProbeTextBlock.Text = $"{adapter.ProbeStatus} / {adapter.ProbeReason}";
+        ApplyAdapterProbeStyle(adapter.ProbeStatus);
+    }
+
+    private void ApplyAdapterProbeStyle(string probeStatus)
+    {
+        var (background, foreground) = probeStatus switch
+        {
+            "可达" => ("#ECFDF5", "#065F46"),
+            "未通" or "不可达" => ("#FEF3C7", "#92400E"),
+            _ => ("#F3F4F6", "#374151"),
+        };
+
+        var backgroundBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(background));
+        var foregroundBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(foreground));
+        AdapterProbeBorder.Background = backgroundBrush;
+        AdapterProbeTitleTextBlock.Foreground = foregroundBrush;
+        AdapterProbeTextBlock.Foreground = foregroundBrush;
     }
 
     private void OpenDeviceDetailsWindow(string baseAddress, string localIPv4)