mirror of https://github.com/2dust/v2rayN
Refactor NoticeHandler
parent
d5c6a42a9a
commit
4ccc7aa92d
|
@ -6,6 +6,5 @@ namespace ServiceLib.Base
|
|||
{
|
||||
protected static Config? _config;
|
||||
protected Func<EViewAction, object?, Task<bool>>? _updateView;
|
||||
protected NoticeHandler? _noticeHandler;
|
||||
}
|
||||
}
|
|
@ -4,11 +4,14 @@
|
|||
{
|
||||
v2fly = 1,
|
||||
Xray = 2,
|
||||
|
||||
//SagerNet = 3,
|
||||
v2fly_v5 = 4,
|
||||
|
||||
//clash = 11,
|
||||
//clash_meta = 12,
|
||||
mihomo = 13,
|
||||
|
||||
hysteria = 21,
|
||||
naiveproxy = 22,
|
||||
tuic = 23,
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using Splat;
|
||||
|
||||
namespace ServiceLib.Handler
|
||||
namespace ServiceLib.Handler
|
||||
{
|
||||
public sealed class AppHandler
|
||||
{
|
||||
|
@ -33,7 +31,7 @@ namespace ServiceLib.Handler
|
|||
#region Init
|
||||
|
||||
public AppHandler()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
public bool InitApp()
|
||||
|
@ -42,7 +40,6 @@ namespace ServiceLib.Handler
|
|||
{
|
||||
return false;
|
||||
}
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => new NoticeHandler(), typeof(NoticeHandler));
|
||||
Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage);
|
||||
|
||||
//Under Win10
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using ServiceLib.Services.CoreConfig;
|
||||
|
||||
namespace ServiceLib.Handler
|
||||
namespace ServiceLib.Handler
|
||||
{
|
||||
/// <summary>
|
||||
/// Core configuration file processing class
|
||||
|
|
|
@ -4,6 +4,9 @@ namespace ServiceLib.Handler
|
|||
{
|
||||
public class NoticeHandler
|
||||
{
|
||||
private static readonly Lazy<NoticeHandler> _instance = new(() => new());
|
||||
public static NoticeHandler Instance => _instance.Value;
|
||||
|
||||
public void Enqueue(string? content)
|
||||
{
|
||||
if (content.IsNullOrEmpty())
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using ServiceLib.Services.Statistics;
|
||||
|
||||
namespace ServiceLib.Handler
|
||||
namespace ServiceLib.Handler
|
||||
{
|
||||
public class StatisticsHandler
|
||||
{
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using ServiceLib.Services;
|
||||
|
||||
namespace ServiceLib.Handler
|
||||
namespace ServiceLib.Handler
|
||||
{
|
||||
public class TaskHandler
|
||||
{
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace ServiceLib.Handler
|
|||
}
|
||||
else
|
||||
{
|
||||
SaveLog(result.Description);
|
||||
SaveLog(result.Description);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
|
@ -20,7 +19,6 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
_config = AppHandler.Instance.Config;
|
||||
_updateView = updateView;
|
||||
|
||||
|
@ -55,25 +53,25 @@ namespace ServiceLib.ViewModels
|
|||
string remarks = SelectedSource.remarks;
|
||||
if (Utils.IsNullOrEmpty(remarks))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseFillRemarks);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Utils.IsNullOrEmpty(SelectedSource.address))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillServerAddressCustom);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
||||
return;
|
||||
}
|
||||
SelectedSource.coreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType);
|
||||
|
||||
if (ConfigHandler.EditCustomServer(_config, SelectedSource) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +87,7 @@ namespace ServiceLib.ViewModels
|
|||
item.address = fileName;
|
||||
if (ConfigHandler.AddCustomServer(_config, item, false) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.SuccessfullyImportedCustomServer);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer);
|
||||
if (Utils.IsNotEmpty(item.indexId))
|
||||
{
|
||||
SelectedSource = JsonUtils.DeepCopy(item);
|
||||
|
@ -98,7 +96,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FailedImportedCustomServer);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FailedImportedCustomServer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,7 +105,7 @@ namespace ServiceLib.ViewModels
|
|||
var address = SelectedSource.address;
|
||||
if (Utils.IsNullOrEmpty(address))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillServerAddressCustom);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -118,7 +116,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FailedReadConfiguration);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FailedReadConfiguration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
|
@ -18,7 +17,7 @@ namespace ServiceLib.ViewModels
|
|||
public AddServerViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
|
||||
if (profileItem.indexId.IsNullOrEmpty())
|
||||
|
@ -45,32 +44,32 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (Utils.IsNullOrEmpty(SelectedSource.remarks))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseFillRemarks);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Utils.IsNullOrEmpty(SelectedSource.address))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillServerAddress);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddress);
|
||||
return;
|
||||
}
|
||||
var port = SelectedSource.port.ToString();
|
||||
if (Utils.IsNullOrEmpty(port) || !Utils.IsNumeric(port)
|
||||
|| SelectedSource.port <= 0 || SelectedSource.port >= Global.MaxPort)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillCorrectServerPort);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectServerPort);
|
||||
return;
|
||||
}
|
||||
if (SelectedSource.configType == EConfigType.Shadowsocks)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(SelectedSource.id))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillPassword);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillPassword);
|
||||
return;
|
||||
}
|
||||
if (Utils.IsNullOrEmpty(SelectedSource.security))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectEncryption);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectEncryption);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +78,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (Utils.IsNullOrEmpty(SelectedSource.id))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillUUID);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillUUID);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -87,12 +86,12 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
if (ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_updateView = updateView;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
WebDavCheckCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_updateView = updateView;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
RefreshSubItems();
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ using DynamicData;
|
|||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using static ServiceLib.Models.ClashProviders;
|
||||
|
@ -44,7 +43,6 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
public ClashProxiesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
_config = AppHandler.Instance.Config;
|
||||
_updateView = updateView;
|
||||
|
||||
|
@ -135,7 +133,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
private void UpdateHandler(bool notify, string msg)
|
||||
{
|
||||
_noticeHandler?.SendMessageEx(msg);
|
||||
NoticeHandler.Instance.SendMessageEx(msg);
|
||||
}
|
||||
|
||||
public void ProxiesReload()
|
||||
|
@ -363,7 +361,7 @@ namespace ServiceLib.ViewModels
|
|||
var selectedProxy = TryGetProxy(name);
|
||||
if (selectedProxy == null || selectedProxy.type != "Selector")
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -379,7 +377,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
SelectedGroup = group2;
|
||||
}
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
|
||||
private void ProxiesDelayTest(bool blAll)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
|
@ -24,7 +23,7 @@ namespace ServiceLib.ViewModels
|
|||
public DNSSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
|
||||
var item = AppHandler.Instance.GetDNSItem(ECoreType.Xray);
|
||||
|
@ -68,7 +67,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (normalDNS.Contains("{") || normalDNS.Contains("}"))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillCorrectDNSText);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +77,7 @@ namespace ServiceLib.ViewModels
|
|||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(normalDNS2);
|
||||
if (obj2 == null)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillCorrectDNSText);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +86,7 @@ namespace ServiceLib.ViewModels
|
|||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(tunDNS2);
|
||||
if (obj2 == null)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillCorrectDNSText);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +105,7 @@ namespace ServiceLib.ViewModels
|
|||
item2.tunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(tunDNS2)); ;
|
||||
ConfigHandler.SaveDNSItems(_config, item2);
|
||||
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace ServiceLib.ViewModels
|
|||
public MainWindowViewModel(bool isAdministrator, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
_isAdministrator = isAdministrator;
|
||||
|
||||
|
@ -281,7 +281,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (await _updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
});
|
||||
RebootAsAdminCmd = ReactiveCommand.Create(() =>
|
||||
|
@ -364,16 +364,16 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
private void UpdateHandler(bool notify, string msg)
|
||||
{
|
||||
_noticeHandler?.SendMessage(msg);
|
||||
NoticeHandler.Instance.SendMessage(msg);
|
||||
if (notify)
|
||||
{
|
||||
_noticeHandler?.Enqueue(msg);
|
||||
NoticeHandler.Instance.Enqueue(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTaskHandler(bool success, string msg)
|
||||
{
|
||||
_noticeHandler?.SendMessageEx(msg);
|
||||
NoticeHandler.Instance.SendMessageEx(msg);
|
||||
if (success)
|
||||
{
|
||||
var indexIdOld = _config.indexId;
|
||||
|
@ -559,7 +559,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
RefreshSubscriptions();
|
||||
RefreshServers();
|
||||
_noticeHandler?.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret));
|
||||
NoticeHandler.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -567,7 +567,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (Utils.IsNullOrEmpty(result))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.NoValidQRcodeFound);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.NoValidQRcodeFound);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -576,7 +576,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
RefreshSubscriptions();
|
||||
RefreshServers();
|
||||
_noticeHandler?.Enqueue(ResUI.SuccessfullyImportedServerViaScan);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -594,7 +594,7 @@ namespace ServiceLib.ViewModels
|
|||
var item = AppHandler.Instance.GetProfileItem(indexId);
|
||||
if (item is null)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
await (new UpdateService()).RunAvailabilityCheck(async (bool success, string msg) =>
|
||||
{
|
||||
_noticeHandler?.SendMessageEx(msg);
|
||||
NoticeHandler.Instance.SendMessageEx(msg);
|
||||
await _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
|
||||
});
|
||||
}
|
||||
|
@ -784,7 +784,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
//await _updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false);
|
||||
await _updateView?.Invoke(EViewAction.UpdateSysProxy, false);
|
||||
_noticeHandler?.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}");
|
||||
NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}");
|
||||
|
||||
BlSystemProxyClear = (type == ESysProxyType.ForcedClear);
|
||||
BlSystemProxySet = (type == ESysProxyType.ForcedChange);
|
||||
|
@ -844,7 +844,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
if (ConfigHandler.SetDefaultRouting(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.SendMessageEx(ResUI.TipChangeRouting);
|
||||
NoticeHandler.Instance.SendMessageEx(ResUI.TipChangeRouting);
|
||||
Reload();
|
||||
await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
@ -24,7 +23,6 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_updateView = updateView;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
MessageBus.Current.Listen<string>(Global.CommandSendMsgView).Subscribe(async x => await AppendQueueMsg(x));
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
|
@ -103,7 +102,7 @@ namespace ServiceLib.ViewModels
|
|||
public OptionSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
|
||||
#region Core
|
||||
|
@ -251,7 +250,7 @@ namespace ServiceLib.ViewModels
|
|||
if (Utils.IsNullOrEmpty(localPort.ToString()) || !Utils.IsNumeric(localPort.ToString())
|
||||
|| localPort <= 0 || localPort >= Global.MaxPort)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.FillLocalListeningPort);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort);
|
||||
return;
|
||||
}
|
||||
var needReboot = (EnableStatistics != _config.guiItem.enableStatistics
|
||||
|
@ -267,7 +266,7 @@ namespace ServiceLib.ViewModels
|
|||
// || Utile.IsNullOrEmpty(KcpreadBufferSize.ToString()) || !Utile.IsNumeric(KcpreadBufferSize.ToString())
|
||||
// || Utile.IsNullOrEmpty(KcpwriteBufferSize.ToString()) || !Utile.IsNumeric(KcpwriteBufferSize.ToString()))
|
||||
//{
|
||||
// _noticeHandler?.Enqueue(ResUI.FillKcpParameters);
|
||||
// NoticeHandler.Instance.Enqueue(ResUI.FillKcpParameters);
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
@ -337,17 +336,17 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (needReboot)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.NeedRebootTips);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips);
|
||||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ using DynamicData;
|
|||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using ServiceLib.Services;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
|
@ -99,7 +98,7 @@ namespace ServiceLib.ViewModels
|
|||
public ProfilesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
|
||||
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||
|
@ -259,8 +258,8 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (Utils.IsNullOrEmpty(result.IndexId))
|
||||
{
|
||||
_noticeHandler?.SendMessageEx(result.Delay);
|
||||
_noticeHandler?.Enqueue(result.Delay);
|
||||
NoticeHandler.Instance.SendMessageEx(result.Delay);
|
||||
NoticeHandler.Instance.Enqueue(result.Delay);
|
||||
return;
|
||||
}
|
||||
var item = _profileItems.Where(it => it.indexId == result.IndexId).FirstOrDefault();
|
||||
|
@ -430,7 +429,7 @@ namespace ServiceLib.ViewModels
|
|||
var item = AppHandler.Instance.GetProfileItem(SelectedProfile.indexId);
|
||||
if (item is null)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||
return;
|
||||
}
|
||||
eConfigType = item.configType;
|
||||
|
@ -467,7 +466,7 @@ namespace ServiceLib.ViewModels
|
|||
var exists = lstSelecteds.Exists(t => t.indexId == _config.indexId);
|
||||
|
||||
ConfigHandler.RemoveServer(_config, lstSelecteds);
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
|
||||
RefreshServers();
|
||||
if (exists)
|
||||
|
@ -481,7 +480,7 @@ namespace ServiceLib.ViewModels
|
|||
var tuple = ConfigHandler.DedupServerList(_config, _config.subIndexId);
|
||||
RefreshServers();
|
||||
Reload();
|
||||
_noticeHandler?.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
|
||||
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
|
||||
}
|
||||
|
||||
private void CopyServer()
|
||||
|
@ -493,7 +492,7 @@ namespace ServiceLib.ViewModels
|
|||
if (ConfigHandler.CopyServer(_config, lstSelecteds) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -519,7 +518,7 @@ namespace ServiceLib.ViewModels
|
|||
var item = AppHandler.Instance.GetProfileItem(indexId);
|
||||
if (item is null)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -552,7 +551,7 @@ namespace ServiceLib.ViewModels
|
|||
var item = AppHandler.Instance.GetProfileItem(SelectedProfile.indexId);
|
||||
if (item is null)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||
return;
|
||||
}
|
||||
var url = FmtHandler.GetShareUri(item);
|
||||
|
@ -573,7 +572,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
if (ConfigHandler.AddCustomServer4Multiple(_config, lstSelecteds, coreType, out string indexId) != 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||
return;
|
||||
}
|
||||
if (indexId == _config.indexId)
|
||||
|
@ -618,7 +617,7 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
|
||||
ConfigHandler.MoveToGroup(_config, lstSelecteds, SelectedMoveToGroup.id);
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
|
||||
RefreshServers();
|
||||
SelectedMoveToGroup = new();
|
||||
|
@ -630,7 +629,7 @@ namespace ServiceLib.ViewModels
|
|||
var item = _lstProfile.FirstOrDefault(t => t.indexId == SelectedProfile.indexId);
|
||||
if (item is null)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -685,19 +684,19 @@ namespace ServiceLib.ViewModels
|
|||
var item = AppHandler.Instance.GetProfileItem(SelectedProfile.indexId);
|
||||
if (item is null)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectServer);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||
return;
|
||||
}
|
||||
if (blClipboard)
|
||||
{
|
||||
if (CoreConfigHandler.GenerateClientConfig(item, null, out string msg, out string content) != 0)
|
||||
{
|
||||
Locator.Current.GetService<NoticeHandler>()?.Enqueue(msg);
|
||||
NoticeHandler.Instance.Enqueue(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _updateView?.Invoke(EViewAction.SetClipboardData, content);
|
||||
_noticeHandler?.SendMessage(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.SendMessage(ResUI.OperationSuccess);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -714,12 +713,12 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
if (CoreConfigHandler.GenerateClientConfig(item, fileName, out string msg, out string content) != 0)
|
||||
{
|
||||
Locator.Current.GetService<NoticeHandler>()?.Enqueue(msg);
|
||||
NoticeHandler.Instance.Enqueue(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = string.Format(ResUI.SaveClientConfigurationIn, fileName);
|
||||
Locator.Current.GetService<NoticeHandler>()?.SendMessageAndEnqueue(msg);
|
||||
NoticeHandler.Instance.SendMessageAndEnqueue(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -751,7 +750,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString());
|
||||
}
|
||||
_noticeHandler?.SendMessage(ResUI.BatchExportURLSuccessfully);
|
||||
NoticeHandler.Instance.SendMessage(ResUI.BatchExportURLSuccessfully);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
|
@ -30,7 +29,7 @@ namespace ServiceLib.ViewModels
|
|||
public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
|
||||
if (rulesItem.id.IsNullOrEmpty())
|
||||
|
@ -84,10 +83,10 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
if (!hasRule)
|
||||
{
|
||||
_noticeHandler?.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP/Process"));
|
||||
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP/Process"));
|
||||
return;
|
||||
}
|
||||
//_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
//NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using ServiceLib.Services;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
|
@ -38,7 +36,7 @@ namespace ServiceLib.ViewModels
|
|||
public RoutingRuleSettingViewModel(RoutingItem routingItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
SelectedSource = new();
|
||||
|
||||
|
@ -160,7 +158,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||
return;
|
||||
}
|
||||
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
|
@ -183,7 +181,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -207,7 +205,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -228,7 +226,7 @@ namespace ServiceLib.ViewModels
|
|||
string remarks = SelectedRouting.remarks;
|
||||
if (Utils.IsNullOrEmpty(remarks))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseFillRemarks);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||
return;
|
||||
}
|
||||
var item = SelectedRouting;
|
||||
|
@ -241,12 +239,12 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
if (ConfigHandler.SaveRoutingItem(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +266,7 @@ namespace ServiceLib.ViewModels
|
|||
if (ret == 0)
|
||||
{
|
||||
RefreshRulesItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,7 +281,7 @@ namespace ServiceLib.ViewModels
|
|||
if (ret == 0)
|
||||
{
|
||||
RefreshRulesItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,7 +290,7 @@ namespace ServiceLib.ViewModels
|
|||
var url = SelectedRouting.url;
|
||||
if (Utils.IsNullOrEmpty(url))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.MsgNeedUrl);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.MsgNeedUrl);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -302,7 +300,7 @@ namespace ServiceLib.ViewModels
|
|||
if (ret == 0)
|
||||
{
|
||||
RefreshRulesItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
|
@ -68,7 +67,7 @@ namespace ServiceLib.ViewModels
|
|||
public RoutingSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
SelectedSource = new();
|
||||
|
||||
|
@ -200,12 +199,12 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
if (ConfigHandler.SaveConfig(_config) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,8 +218,8 @@ namespace ServiceLib.ViewModels
|
|||
DirectIP = "geoip:private,geoip:cn";
|
||||
BlockDomain = "geosite:category-ads-all";
|
||||
|
||||
//_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
//NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
}
|
||||
|
||||
public async Task RoutingAdvancedEditAsync(bool blNew)
|
||||
|
@ -249,7 +248,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
if (SelectedSource is null || SelectedSource.remarks.IsNullOrEmpty())
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||
return;
|
||||
}
|
||||
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||
|
@ -274,7 +273,7 @@ namespace ServiceLib.ViewModels
|
|||
var item = AppHandler.Instance.GetRoutingItem(SelectedSource?.id);
|
||||
if (item is null)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
|
@ -15,7 +14,7 @@ namespace ServiceLib.ViewModels
|
|||
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
|
||||
if (subItem.id.IsNullOrEmpty())
|
||||
|
@ -38,18 +37,18 @@ namespace ServiceLib.ViewModels
|
|||
string remarks = SelectedSource.remarks;
|
||||
if (Utils.IsNullOrEmpty(remarks))
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.PleaseFillRemarks);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.AddSubItem(_config, SelectedSource) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationFailed);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using DynamicData.Binding;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
|
@ -26,7 +25,7 @@ namespace ServiceLib.ViewModels
|
|||
public SubSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
_updateView = updateView;
|
||||
|
||||
SelectedSource = new();
|
||||
|
@ -95,7 +94,7 @@ namespace ServiceLib.ViewModels
|
|||
ConfigHandler.DeleteSubItem(_config, it.id);
|
||||
}
|
||||
RefreshSubItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
IsModified = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ namespace v2rayN.Desktop.ViewModels
|
|||
public AppViewModel()
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
AddServerViaClipboardCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@ using Avalonia.Controls;
|
|||
using Avalonia.Styling;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive.Linq;
|
||||
|
||||
namespace v2rayN.Desktop.ViewModels
|
||||
|
@ -22,7 +21,6 @@ namespace v2rayN.Desktop.ViewModels
|
|||
public ThemeSettingViewModel()
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
BindingUI();
|
||||
RestoreUI();
|
||||
|
@ -75,7 +73,7 @@ namespace v2rayN.Desktop.ViewModels
|
|||
_config.uiItem.currentLanguage = CurrentLanguage;
|
||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
_noticeHandler?.Enqueue(ResUI.NeedRebootTips);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using Avalonia.Interactivity;
|
||||
using Avalonia.ReactiveUI;
|
||||
using ReactiveUI;
|
||||
using Splat;
|
||||
using System.Reactive.Disposables;
|
||||
using v2rayN.Desktop.Common;
|
||||
|
||||
|
@ -10,7 +9,6 @@ namespace v2rayN.Desktop.Views
|
|||
{
|
||||
public partial class BackupAndRestoreView : ReactiveUserControl<BackupAndRestoreViewModel>
|
||||
{
|
||||
private NoticeHandler? _noticeHandler;
|
||||
private Window _window;
|
||||
|
||||
public BackupAndRestoreView(Window window)
|
||||
|
@ -23,7 +21,6 @@ namespace v2rayN.Desktop.Views
|
|||
|
||||
ViewModel = new BackupAndRestoreViewModel(UpdateViewHandler);
|
||||
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables);
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace v2rayN.Desktop.Views
|
|||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4SingboxCmd, v => v.btnImportDefConfig4Singbox).DisposeWith(disposables);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
|
|
|
@ -79,7 +79,6 @@ namespace v2rayN.Desktop.Views
|
|||
this.BindCommand(ViewModel, vm => vm.ClearServerStatisticsCmd, v => v.menuClearServerStatistics).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.OpenTheFileLocationCmd, v => v.menuOpenTheFileLocation).DisposeWith(disposables);
|
||||
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
|
||||
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ namespace v2rayN.Desktop.Views
|
|||
else
|
||||
{
|
||||
ViewModel?.EditServerAsync(EConfigType.Custom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LstProfiles_LoadingRow(object? sender, DataGridRowEventArgs e)
|
||||
|
@ -313,6 +313,7 @@ namespace v2rayN.Desktop.Views
|
|||
ViewModel?.RefreshServers();
|
||||
}
|
||||
}
|
||||
|
||||
private void MenuStorageUI_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
StorageUI();
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace v2rayN.Desktop.Views
|
|||
txtContent.Text = url;
|
||||
imgQrcode.Source = GetQRCode(url);
|
||||
|
||||
// btnCancel.Click += (s, e) => this.Close();
|
||||
// btnCancel.Click += (s, e) => this.Close();
|
||||
}
|
||||
|
||||
private Bitmap? GetQRCode(string? url)
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace v2rayN
|
|||
uint attributeSize = (uint)Marshal.SizeOf(attribute);
|
||||
DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1, ref attribute, attributeSize);
|
||||
DwmSetWindowAttribute(hWnd, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, ref attribute, attributeSize);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开机自动启动
|
||||
|
|
|
@ -5,7 +5,6 @@ using MaterialDesignColors.ColorManipulation;
|
|||
using MaterialDesignThemes.Wpf;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
@ -38,7 +37,7 @@ namespace v2rayN.ViewModels
|
|||
public ThemeSettingViewModel()
|
||||
{
|
||||
_config = AppHandler.Instance.Config;
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
|
||||
RegisterSystemColorSet(_config, Application.Current.MainWindow, (bool bl) => { ModifyTheme(bl); });
|
||||
|
||||
BindingUI();
|
||||
|
@ -161,7 +160,7 @@ namespace v2rayN.ViewModels
|
|||
_config.uiItem.currentLanguage = CurrentLanguage;
|
||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
_noticeHandler?.Enqueue(ResUI.NeedRebootTips);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace v2rayN.Views
|
|||
foreach (ECoreType it in Enum.GetValues(typeof(ECoreType)))
|
||||
{
|
||||
if (it == ECoreType.v2rayN)
|
||||
continue;
|
||||
continue;
|
||||
cmbCoreType.Items.Add(it.ToString());
|
||||
}
|
||||
cmbCoreType.Items.Add(string.Empty);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using ReactiveUI;
|
||||
using Splat;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows;
|
||||
|
||||
|
@ -7,8 +6,6 @@ namespace v2rayN.Views
|
|||
{
|
||||
public partial class BackupAndRestoreView
|
||||
{
|
||||
private NoticeHandler? _noticeHandler;
|
||||
|
||||
public BackupAndRestoreView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -17,7 +14,6 @@ namespace v2rayN.Views
|
|||
|
||||
ViewModel = new BackupAndRestoreViewModel(UpdateViewHandler);
|
||||
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables);
|
||||
|
@ -32,7 +28,7 @@ namespace v2rayN.Views
|
|||
this.BindCommand(ViewModel, vm => vm.RemoteBackupCmd, v => v.menuRemoteBackup).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.RemoteRestoreCmd, v => v.menuRemoteRestore).DisposeWith(disposables);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void MenuLocalBackup_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<reactiveui:ReactiveUserControl
|
||||
x:Class="v2rayN.Views.ClashConnectionsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:reactiveui="http://reactiveui.net"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:reactiveui="http://reactiveui.net"
|
||||
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
||||
xmlns:vms="clr-namespace:ServiceLib.ViewModels;assembly=ServiceLib"
|
||||
d:DesignHeight="450"
|
||||
|
|
|
@ -172,7 +172,7 @@ namespace v2rayN.Views
|
|||
{
|
||||
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
|
||||
}
|
||||
|
||||
|
||||
RestoreUI();
|
||||
AddHelpMenuItem();
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ namespace v2rayN.Views
|
|||
{
|
||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
|
||||
foreach (var it in coreInfo
|
||||
.Where(t => t.coreType != ECoreType.v2fly
|
||||
.Where(t => t.coreType != ECoreType.v2fly
|
||||
&& t.coreType != ECoreType.hysteria))
|
||||
{
|
||||
var item = new MenuItem()
|
||||
|
|
|
@ -164,8 +164,6 @@
|
|||
HorizontalAlignment="Left"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbRoutingTips}" />
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel
|
||||
|
|
Loading…
Reference in New Issue