From 69fdba7c009a233d1afd2229a7a982fb44eaa5df Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:14:43 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=A7=BB=E9=99=A4SettingsViewModel?= =?UTF-8?q?=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RemoteControl/RemoteControlService.cs | 9 +- .../ViewModels/UI/SettingsViewModel.cs | 14 --- .../UserControl/RemoteControlUserControl.xaml | 94 ++++++++++--------- 3 files changed, 55 insertions(+), 62 deletions(-) diff --git a/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs b/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs index 9e5611b6df..5ffdd2b1b3 100644 --- a/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs +++ b/src/MaaWpfGui/Services/RemoteControl/RemoteControlService.cs @@ -14,15 +14,12 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.ComponentModel; using System.IO; using System.Linq; using System.Net.Http; using System.Reflection; -using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; -using System.Windows; using System.Windows.Media.Imaging; using MaaWpfGui.Constants; using MaaWpfGui.Helper; @@ -43,9 +40,9 @@ namespace MaaWpfGui.Services.RemoteControl public class RemoteControlService { private Task _pollJobTask = Task.CompletedTask; - private readonly List _enqueueTaskIds = new List(); - private readonly ConcurrentQueue _sequentialTaskQueue = new ConcurrentQueue(); - private readonly ConcurrentQueue _instantTaskQueue = new ConcurrentQueue(); + private readonly List _enqueueTaskIds = []; + private readonly ConcurrentQueue _sequentialTaskQueue = new(); + private readonly ConcurrentQueue _instantTaskQueue = new(); private Task _executeSequentialJobTask = Task.CompletedTask; private Task _executeInstantJobTask = Task.CompletedTask; private readonly RunningState _runningState; diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index bb677336cc..c0eeccb273 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -385,20 +385,6 @@ namespace MaaWpfGui.ViewModels.UI #region Remote Control - // UI 绑定的方法 - // ReSharper disable once UnusedMember.Global - public async void RemoteControlConnectionTest() - { - await RemoteControlService.ConnectionTest(); - } - - // UI 绑定的方法 - // ReSharper disable once UnusedMember.Global - public void RemoteControlRegenerateDeviceIdentity() - { - RemoteControlService.RegenerateDeviceIdentity(); - } - private string _remoteControlGetTaskEndpointUri = ConfigurationHelper.GetValue(ConfigurationKeys.RemoteControlGetTaskEndpointUri, string.Empty); public string RemoteControlGetTaskEndpointUri diff --git a/src/MaaWpfGui/Views/UserControl/RemoteControlUserControl.xaml b/src/MaaWpfGui/Views/UserControl/RemoteControlUserControl.xaml index 6fdda48707..2900e9ceca 100644 --- a/src/MaaWpfGui/Views/UserControl/RemoteControlUserControl.xaml +++ b/src/MaaWpfGui/Views/UserControl/RemoteControlUserControl.xaml @@ -2,31 +2,33 @@ x:Class="MaaWpfGui.Views.UserControl.RemoteControlUserControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:hc="https://handyorg.github.io/handycontrol" - xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI" - xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls" - xmlns:calcBinding="clr-namespace:CalcBinding;assembly=CalcBinding" - xmlns:s="https://github.com/canton7/Stylet" + xmlns:calcBinding="clr-namespace:CalcBinding;assembly=CalcBinding" xmlns:constants="clr-namespace:MaaWpfGui.Constants" + xmlns:controls="clr-namespace:MaaWpfGui.Styles.Controls" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:hc="https://handyorg.github.io/handycontrol" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:remoteControl="clr-namespace:MaaWpfGui.Services.RemoteControl" + xmlns:s="https://github.com/canton7/Stylet" + xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI" + d:Background="White" d:DataContext="{d:DesignInstance {x:Type ui:SettingsViewModel}}" d:DesignHeight="300" d:DesignWidth="550" mc:Ignorable="d"> - - - - - - + + + + + + - - - + + + - + - + Grid.ColumnSpan="2" + Margin="0,5,0,5" + Text="{Binding RemoteControlGetTaskEndpointUri}" /> - + - + Grid.ColumnSpan="2" + Margin="0,5,0,5" + Text="{Binding RemoteControlReportStatusUri}" /> - + - + Margin="0,5,0,5" + Text="{Binding RemoteControlUserIdentity}" />