From 2d23e2da6fa57470a3bcddb359c62a17be400a80 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:08:07 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B6=88=E9=99=A4=20CopilotViewModel?= =?UTF-8?q?=20qodana=20=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/UI/CopilotViewModel.cs | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs index 049ac3fa89..eac117dbe7 100644 --- a/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/CopilotViewModel.cs @@ -35,14 +35,16 @@ namespace MaaWpfGui.ViewModels.UI /// /// The view model of copilot. /// + // 通过 container.Get(); 实例化或获取实例,需要添加 qodana ignore rule + // ReSharper disable once ClassNeverInstantiated.Global public class CopilotViewModel : Screen { private readonly RunningState _runningState; /// - /// Gets or sets the view models of log items. + /// Gets the view models of log items. /// - public ObservableCollection LogItemViewModels { get; set; } + public ObservableCollection LogItemViewModels { get; } /// /// Initializes a new instance of the class. @@ -99,7 +101,7 @@ namespace MaaWpfGui.ViewModels.UI /// /// Clears log. /// - public void ClearLog() + private void ClearLog() { LogItemViewModels.Clear(); } @@ -389,6 +391,7 @@ namespace MaaWpfGui.ViewModels.UI /// The sender. /// The event arguments. // ReSharper disable once UnusedMember.Global + // ReSharper disable once UnusedParameter.Global // TODO: 不知道为啥现在拖放不用了,之后瞅瞅 public void DropFile(object sender, DragEventArgs e) { @@ -429,6 +432,7 @@ namespace MaaWpfGui.ViewModels.UI /// The sender. /// The event arguments. // ReSharper disable once UnusedMember.Global + // ReSharper disable once UnusedParameter.Global public void OnDropDownOpened(object sender, EventArgs e) { if (!(sender is ComboBox comboBox)) @@ -458,7 +462,7 @@ namespace MaaWpfGui.ViewModels.UI set => SetAndNotify(ref _form, value); } - public bool Loop { get; set; } = false; + public bool Loop { get; set; } private int _loopTimes = int.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.CopilotLoopTimes, "1")); @@ -477,6 +481,8 @@ namespace MaaWpfGui.ViewModels.UI /// /// Starts copilot. /// + // xaml 中绑定了 action + // ReSharper disable once UnusedMember.Global public async void Start() { /* @@ -488,7 +494,7 @@ namespace MaaWpfGui.ViewModels.UI if (_isVideoTask) { - StartVideoTask(); + _ = StartVideoTask(); return; } @@ -524,7 +530,7 @@ namespace MaaWpfGui.ViewModels.UI } } - public bool StartVideoTask() + private bool StartVideoTask() { return Instances.AsstProxy.AsstStartVideoRec(Filename); } @@ -532,6 +538,8 @@ namespace MaaWpfGui.ViewModels.UI /// /// Stops copilot. /// + // xaml 中绑定了 action + // ReSharper disable once UnusedMember.Global public void Stop() { Instances.AsstProxy.AsstStop(); @@ -560,7 +568,7 @@ namespace MaaWpfGui.ViewModels.UI private bool _isDataFromWeb; - public bool IsDataFromWeb + private bool IsDataFromWeb { get => _isDataFromWeb; set @@ -572,7 +580,7 @@ namespace MaaWpfGui.ViewModels.UI private int _copilotId; - public int CopilotId + private int CopilotId { get => _copilotId; set @@ -627,21 +635,21 @@ namespace MaaWpfGui.ViewModels.UI private string _urlText = LocalizationHelper.GetString("PrtsPlus"); /// - /// Gets or sets the UrlText. + /// Gets or private sets the UrlText. /// public string UrlText { get => _urlText; - set => SetAndNotify(ref _urlText, value); + private set => SetAndNotify(ref _urlText, value); } /// - /// Gets or sets the copilot URL. + /// Gets or private sets the copilot URL. /// public string Url { get => _url; - set + private set { UrlText = value == CopilotUiUrl ? LocalizationHelper.GetString("PrtsPlus") : LocalizationHelper.GetString("VideoLink"); SetAndNotify(ref _url, value); @@ -654,6 +662,7 @@ namespace MaaWpfGui.ViewModels.UI /// 点击事件发送者 /// 点击事件 // ReSharper disable once UnusedMember.Global + // ReSharper disable once UnusedParameter.Global public void MouseDown(object sender, MouseButtonEventArgs e) { if (!(sender is UIElement element))