From 388048ce5220b59eb318306f26a5778aa8ae182a Mon Sep 17 00:00:00 2001 From: sakuraxp Date: Mon, 30 May 2022 02:03:16 +0800 Subject: [PATCH] =?UTF-8?q?feat.=E8=87=AA=E5=8A=A8=E6=88=98=E6=96=97?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=A2=9E=E5=8A=A0=E6=98=BE=E7=A4=BA=E5=B9=B2?= =?UTF-8?q?=E5=91=98=E9=98=B5=E5=AE=B9=E5=92=8C=E6=94=BB=E7=95=A5url?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAsstGui/ViewModels/CopilotViewModel.cs | 49 ++++++++++++++++++- src/MeoAsstGui/Views/CopilotView.xaml | 3 ++ 2 files changed, 51 insertions(+), 1 deletion(-) 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 @@