diff --git a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs index e0c265a0e6..17be0efb07 100644 --- a/src/MeoAsstGui/ViewModels/CopilotViewModel.cs +++ b/src/MeoAsstGui/ViewModels/CopilotViewModel.cs @@ -12,9 +12,11 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; using System.IO; using System.Linq; using System.Runtime.InteropServices; +using System.Text.RegularExpressions; using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -45,6 +47,12 @@ namespace MeoAsstGui //LogItemViewModels.Insert(0, new LogItemViewModel(time + content, color, weight)); } + public void AddLogWithUrl(string content,string url, string color = "Gray", string weight = "Regular") + { + LogItemViewModels.Add(new LogItemViewModel(content, color, weight)); + //LogItemViewModels.Insert(0, new LogItemViewModel(time + content, color, weight)); + } + private bool _idel = true; public bool Idle @@ -119,8 +127,25 @@ namespace MeoAsstGui details_color = doc["details_color"].ToString(); } AddLog(details, details_color); + + { + Url = ""; + var linkParser = new Regex(@"(?:https?://)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + foreach (Match m in linkParser.Matches(details)) + { + Url = m.Value; + break; + } + } } - } + + AddLog(string.Format("\n共{0}名干员", ((JContainer)json["opers"]).Count), "black"); + foreach (JObject oper in json["opers"]) + { + AddLog(string.Format("{0}, {1}技能", oper["name"], oper["skill"]), "black"); + } + } catch (Exception) { } @@ -200,5 +225,27 @@ namespace MeoAsstGui asstProxy.AsstStop(); Idle = true; } + + private string _url = ""; + + public string Url + { + get => _url; + set => SetAndNotify(ref _url, value); + } + + public void Hyperlink_Click(string url) + { + try + { + if (!string.IsNullOrEmpty(url)) + { + Process.Start(new ProcessStartInfo(url)); + } + } + catch (Exception) + { + } + } } } diff --git a/src/MeoAsstGui/Views/CopilotView.xaml b/src/MeoAsstGui/Views/CopilotView.xaml index 0cb9ba4e2d..4cda0df789 100644 --- a/src/MeoAsstGui/Views/CopilotView.xaml +++ b/src/MeoAsstGui/Views/CopilotView.xaml @@ -22,6 +22,9 @@