@@ -827,10 +827,64 @@ private Border CreateDeviceCard(Network.Device device)
827827 Grid . SetColumn ( statusBadge , 1 ) ;
828828 layout . Children . Add ( statusBadge ) ;
829829
830+ var isCurrentDevice = string . Equals (
831+ device . DeviceId ,
832+ _settingsManager . Settings . DeviceId ,
833+ StringComparison . OrdinalIgnoreCase ) ;
834+
835+ var removeButton = new Button
836+ {
837+ Content = isCurrentDevice ? "Current Device" : "Remove" ,
838+ Margin = new Thickness ( 0 , 44 , 0 , 0 ) ,
839+ Padding = new Thickness ( 12 , 6 , 12 , 6 ) ,
840+ MinWidth = 110 ,
841+ HorizontalAlignment = HorizontalAlignment . Right ,
842+ VerticalAlignment = VerticalAlignment . Top ,
843+ Style = FindResource ( "SecondaryButtonStyle" ) as Style ,
844+ IsEnabled = ! isCurrentDevice
845+ } ;
846+ removeButton . Click += async ( s , e ) => await OnUnregisterDeviceAsync ( device ) ;
847+ Grid . SetColumn ( removeButton , 1 ) ;
848+ layout . Children . Add ( removeButton ) ;
849+
830850 card . Child = layout ;
831851 return card ;
832852 }
833853
854+ private async Task OnUnregisterDeviceAsync ( Network . Device device )
855+ {
856+ if ( string . IsNullOrWhiteSpace ( device . DeviceId ) )
857+ {
858+ MessageBox . Show ( "设备 ID 不可用,无法移除该设备。" , "无法移除设备" , MessageBoxButton . OK , MessageBoxImage . Warning ) ;
859+ return ;
860+ }
861+
862+ if ( string . Equals ( device . DeviceId , _settingsManager . Settings . DeviceId , StringComparison . OrdinalIgnoreCase ) )
863+ {
864+ MessageBox . Show ( "当前这台设备不能在这里移除,请先在其他设备上操作。" , "当前设备" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
865+ return ;
866+ }
867+
868+ var result = MessageBox . Show (
869+ $ "确定要移除设备“{ GetDeviceDisplayName ( device ) } ”吗?该设备将需要重新登录后才能继续同步。",
870+ "移除设备" ,
871+ MessageBoxButton . YesNo ,
872+ MessageBoxImage . Warning ) ;
873+
874+ if ( result != MessageBoxResult . Yes )
875+ {
876+ return ;
877+ }
878+
879+ var success = await _syncEngine . UnregisterDeviceAsync ( device . DeviceId ) ;
880+ if ( ! success )
881+ {
882+ return ;
883+ }
884+
885+ await RefreshDeviceListAsync ( force : true ) ;
886+ }
887+
834888 private void UpdateHomeSummary ( )
835889 {
836890 if ( _homeView == null )
0 commit comments