diff --git a/v2rayN/Directory.Packages.props b/v2rayN/Directory.Packages.props index e77fac13..9dcfbe61 100644 --- a/v2rayN/Directory.Packages.props +++ b/v2rayN/Directory.Packages.props @@ -20,6 +20,7 @@ + diff --git a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs index 8fc62dfe..f0e90a0f 100644 --- a/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MsgViewModel.cs @@ -1,5 +1,6 @@ using System.Collections.Concurrent; using System.Reactive.Linq; +using System.Text; using System.Text.RegularExpressions; using ReactiveUI; using ReactiveUI.Fody.Helpers; @@ -9,6 +10,7 @@ namespace ServiceLib.ViewModels; public class MsgViewModel : MyReactiveObject { private readonly ConcurrentQueue _queueMsg = new(); + private readonly StringBuilder _msgBuilder = new(); private readonly int _numMaxMsg = 500; private bool _lastMsgFilterNotAvailable; private bool _blLockShow = false; @@ -42,12 +44,7 @@ public class MsgViewModel : MyReactiveObject } private async Task AppendQueueMsg(string msg) - { - //if (msg == Global.CommandClearMsg) - //{ - // ClearMsg(); - // return; - //} + { if (AutoRefresh == false) { return; @@ -65,9 +62,18 @@ public class MsgViewModel : MyReactiveObject _blLockShow = true; - await Task.Delay(500); - var txt = string.Join("", _queueMsg.ToArray()); - await _updateView?.Invoke(EViewAction.DispatcherShowMsg, txt); + _msgBuilder.Clear(); + //foreach (var it in _queueMsg) + //{ + // _msgBuilder.Append(it); + //} + while (_queueMsg.TryDequeue(out var line)) + { + _msgBuilder.Append(line); + } + + + await _updateView?.Invoke(EViewAction.DispatcherShowMsg, _msgBuilder.ToString()); _blLockShow = false; } diff --git a/v2rayN/v2rayN.Desktop/App.axaml b/v2rayN/v2rayN.Desktop/App.axaml index 4b2577ca..222ab488 100644 --- a/v2rayN/v2rayN.Desktop/App.axaml +++ b/v2rayN/v2rayN.Desktop/App.axaml @@ -11,9 +11,9 @@ RequestedThemeVariant="Default"> + - diff --git a/v2rayN/v2rayN.Desktop/Assets/GlobalResources.axaml b/v2rayN/v2rayN.Desktop/Assets/GlobalResources.axaml index 4cf9c585..f58db043 100644 --- a/v2rayN/v2rayN.Desktop/Assets/GlobalResources.axaml +++ b/v2rayN/v2rayN.Desktop/Assets/GlobalResources.axaml @@ -11,8 +11,6 @@ 32 32 1000 - 14 - Cascadia Code,Consolas,Menlo,Monospace 2 4,0 diff --git a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml index 596de846..54cd078e 100644 --- a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml @@ -71,13 +71,28 @@ Theme="{DynamicResource SimpleToggleSwitch}" /> - - - + + + + + + + + + + diff --git a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs index e2d21101..75889fff 100644 --- a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml.cs @@ -44,9 +44,11 @@ public partial class MsgView : ReactiveUserControl private void ShowMsg(object msg) { - txtMsg.Text = msg.ToString(); + // txtMsg.Text = msg.ToString(); + txtMsg.AppendText(msg.ToString()); if (togScrollToEnd.IsChecked ?? true) { + txtMsg.ScrollToEnd(); _scrollViewer?.ScrollToEnd(); } } diff --git a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj index 67e57f4a..f6ff5735 100644 --- a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj +++ b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj @@ -18,6 +18,7 @@ + true