mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-17 18:01:26 +08:00
fix: 修复无限提示远控地址为空的问题
This commit is contained in:
@@ -18,6 +18,7 @@ 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;
|
||||
@@ -694,7 +695,7 @@ namespace MaaWpfGui.Services.RemoteControl
|
||||
{
|
||||
var endpoint = Instances.SettingsViewModel.RemoteControlGetTaskEndpointUri;
|
||||
|
||||
if (!IsEndpointValid(endpoint))
|
||||
if (!IsEndpointValid(endpoint, alarm: true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -755,12 +756,11 @@ namespace MaaWpfGui.Services.RemoteControl
|
||||
Instances.SettingsViewModel.RemoteControlDeviceIdentity = Guid.NewGuid().ToString("N");
|
||||
}
|
||||
|
||||
public static bool IsEndpointValid(string endpoint)
|
||||
public static bool IsEndpointValid(string endpoint, bool alarm = false)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(endpoint))
|
||||
{
|
||||
using var toast = new ToastNotification(LocalizationHelper.GetString("RemoteControlConnectionTestFailEmpty"));
|
||||
toast.Show();
|
||||
ShowToast("RemoteControlConnectionTestFailEmpty", alarm);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -772,16 +772,23 @@ namespace MaaWpfGui.Services.RemoteControl
|
||||
}
|
||||
else if (lowerEndpoint.StartsWith("http://"))
|
||||
{
|
||||
using var toast = new ToastNotification(LocalizationHelper.GetString("RemoteControlConnectionTestWarningHttpUnsafe"));
|
||||
toast.Show();
|
||||
ShowToast("RemoteControlConnectionTestWarningHttpUnsafe", alarm);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
using var toast = new ToastNotification(LocalizationHelper.GetString("RemoteControlConnectionTestFailNotHttpOrHttps"));
|
||||
toast.Show();
|
||||
ShowToast("RemoteControlConnectionTestFailNotHttpOrHttps", alarm);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ShowToast(string message, bool alarm)
|
||||
{
|
||||
if (alarm)
|
||||
{
|
||||
using var toast = new ToastNotification(LocalizationHelper.GetString(message));
|
||||
toast.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user