feat: 自动战斗地图链接指向PRTS.Map对应的地图

close #6227
This commit is contained in:
uye
2023-10-11 11:08:59 +08:00
parent 17234c359e
commit d03d0df13c
2 changed files with 30 additions and 13 deletions

View File

@@ -160,7 +160,8 @@ namespace MaaWpfGui.ViewModels.UI
private async Task UpdateFileDoc(string filename)
{
ClearLog();
Url = CopilotUiUrl;
CopilotUrl = CopilotUiUrl;
MapUrl = MapUiUrl;
_isVideoTask = false;
string jsonStr;
@@ -256,6 +257,11 @@ namespace MaaWpfGui.ViewModels.UI
return;
}
if (json.TryGetValue("stage_name", out var stageNameValue))
{
MapUrl = MapUiUrl.Replace("areas", "map/" + stageNameValue);
}
AddLog(LocalizationHelper.GetString("CopilotTip"));
var doc = (JObject)json["doc"];
@@ -264,7 +270,6 @@ namespace MaaWpfGui.ViewModels.UI
{
title = titleValue.ToString();
do
{
// 为自动作战列表匹配名字
@@ -314,21 +319,21 @@ namespace MaaWpfGui.ViewModels.UI
AddLog(details, detailsColor);
{
Url = CopilotUiUrl;
CopilotUrl = CopilotUiUrl;
var linkParser = new Regex(@"(?:av\d+|bv[a-z0-9]{10})(?:\/\?p=\d+)?", RegexOptions.Compiled | RegexOptions.IgnoreCase);
foreach (Match match in linkParser.Matches(details))
{
Url = MaaUrls.BilibiliVideo + match.Value;
CopilotUrl = MaaUrls.BilibiliVideo + match.Value;
break;
}
if (string.IsNullOrEmpty(Url))
if (string.IsNullOrEmpty(CopilotUrl))
{
linkParser = new Regex(@"(?:https?://)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
foreach (Match m in linkParser.Matches(details))
{
Url = m.Value;
CopilotUrl = m.Value;
break;
}
}
@@ -945,8 +950,6 @@ namespace MaaWpfGui.ViewModels.UI
AddLog(LocalizationHelper.GetString("ThanksForLikeWebJson"), UiLogColor.Info);
}
private const string CopilotUiUrl = MaaUrls.PrtsPlus;
private string _url = MaaUrls.PrtsPlus;
private string _urlText = LocalizationHelper.GetString("PrtsPlus");
/// <summary>
@@ -958,19 +961,33 @@ namespace MaaWpfGui.ViewModels.UI
private set => SetAndNotify(ref _urlText, value);
}
private const string CopilotUiUrl = MaaUrls.PrtsPlus;
private string _copilotUrl = CopilotUiUrl;
/// <summary>
/// Gets or private sets the copilot URL.
/// </summary>
public string Url
public string CopilotUrl
{
get => _url;
get => _copilotUrl;
private set
{
UrlText = value == CopilotUiUrl ? LocalizationHelper.GetString("PrtsPlus") : LocalizationHelper.GetString("VideoLink");
SetAndNotify(ref _url, value);
SetAndNotify(ref _copilotUrl, value);
}
}
private const string MapUiUrl = MaaUrls.MapPrts;
private string _mapUrl = MapUiUrl;
public string MapUrl
{
get => _mapUrl;
private set => SetAndNotify(ref _mapUrl, value);
}
/// <summary>
/// 点击后移除界面中元素焦点
/// </summary>

View File

@@ -285,7 +285,7 @@
Block.TextAlignment="Center">
<Hyperlink
Cursor="Hand"
NavigateUri="{Binding Url}"
NavigateUri="{Binding CopilotUrl}"
TextDecorations="None">
<TextBlock Text="{Binding UrlText}" />
</Hyperlink>
@@ -351,7 +351,7 @@
Block.TextAlignment="Center">
<Hyperlink
Cursor="Hand"
NavigateUri="{Binding Source={x:Static constants:MaaUrls.MapPrts}}"
NavigateUri="{Binding MapUrl}"
TextDecorations="None">
<TextBlock Text="{DynamicResource MapPrts}" />
</Hyperlink>