mirror of
https://github.com/bolucat/Archive.git
synced 2025-10-15 20:52:27 +08:00
Update On Mon Oct 7 20:33:43 CEST 2024
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Splat;
|
||||
using System.Reactive;
|
||||
|
||||
namespace ServiceLib.ViewModels
|
||||
@@ -20,8 +19,7 @@ namespace ServiceLib.ViewModels
|
||||
|
||||
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||
{
|
||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||
_config = LazyConfig.Instance.Config;
|
||||
_config = AppHandler.Instance.Config;
|
||||
_updateView = updateView;
|
||||
|
||||
if (profileItem.indexId.IsNullOrEmpty())
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,12 +82,12 @@ namespace ServiceLib.ViewModels
|
||||
return;
|
||||
}
|
||||
|
||||
var item = LazyConfig.Instance.GetProfileItem(SelectedSource.indexId);
|
||||
var item = AppHandler.Instance.GetProfileItem(SelectedSource.indexId);
|
||||
item ??= SelectedSource;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user