Bug fix and remove adjust core
This commit is contained in:
@@ -105,7 +105,7 @@
|
||||
""
|
||||
};
|
||||
|
||||
public static readonly List<string> coreTypes = new List<string> { "Clash", "ClashPremium", "ClashMeta", };
|
||||
public static readonly List<string> coreTypes = new List<string> { "Clash", "ClashPremium", "ClashMeta", "Mihomo" };
|
||||
|
||||
public static readonly List<string> allowSelectType = new List<string> { "selector", "urltest", "loadbalance", "fallback" };
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ namespace ClashN.Handler
|
||||
}
|
||||
if (profileItem.coreType is null)
|
||||
{
|
||||
profileItem.coreType = CoreKind.ClashMeta;
|
||||
profileItem.coreType = CoreKind.Mihomo;
|
||||
}
|
||||
if (!config.ProfileItems.Exists(it => it.indexId == profileItem.indexId))
|
||||
{
|
||||
@@ -558,7 +558,7 @@ namespace ClashN.Handler
|
||||
{
|
||||
groupId = groupId,
|
||||
url = clipboardData,
|
||||
coreType = CoreKind.ClashMeta,
|
||||
coreType = CoreKind.Mihomo,
|
||||
address = string.Empty,
|
||||
enabled = true,
|
||||
remarks = "clash_subscription"
|
||||
@@ -582,7 +582,7 @@ namespace ClashN.Handler
|
||||
{
|
||||
groupId = groupId,
|
||||
url = query["url"] ?? string.Empty,
|
||||
coreType = CoreKind.ClashMeta,
|
||||
coreType = CoreKind.Mihomo,
|
||||
address = string.Empty,
|
||||
enabled = true,
|
||||
remarks = "clash_subscription"
|
||||
@@ -600,7 +600,7 @@ namespace ClashN.Handler
|
||||
{
|
||||
groupId = groupId,
|
||||
url = "",
|
||||
coreType = CoreKind.ClashMeta,
|
||||
coreType = CoreKind.Mihomo,
|
||||
address = string.Empty,
|
||||
enabled = false,
|
||||
remarks = "clash_local_file"
|
||||
|
||||
@@ -302,12 +302,12 @@ namespace ClashN.Handler
|
||||
});
|
||||
}
|
||||
|
||||
public List<ProxiesItem> GetClashProxyGroups()
|
||||
public List<ProxiesItem>? GetClashProxyGroups()
|
||||
{
|
||||
try
|
||||
{
|
||||
var fileContent = LazyConfig.Instance.ProfileContent;
|
||||
if (!fileContent.ContainsKey("proxy-groups"))
|
||||
if (fileContent is null || fileContent?.ContainsKey("proxy-groups") == false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -106,8 +106,9 @@ namespace ClashN.Handler
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
var serverStatItem = config_.GetProfileItem(config_.IndexId);
|
||||
|
||||
ParseOutput(result, out ulong up, out ulong down);
|
||||
if (up + down > 0)
|
||||
if (serverStatItem != null && (up + down) > 0)
|
||||
{
|
||||
serverStatItem.uploadRemote += up;
|
||||
serverStatItem.downloadRemote += down;
|
||||
|
||||
@@ -86,16 +86,19 @@ namespace ClashN
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="strJson"></param>
|
||||
/// <returns></returns>
|
||||
public static T FromJson<T>(string strJson)
|
||||
public static T? FromJson<T>(string? strJson)
|
||||
{
|
||||
try
|
||||
{
|
||||
T obj = JsonConvert.DeserializeObject<T>(strJson);
|
||||
return obj;
|
||||
if (string.IsNullOrEmpty(strJson))
|
||||
{
|
||||
return default;
|
||||
}
|
||||
return JsonConvert.DeserializeObject<T>(strJson);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>("");
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,14 +107,25 @@ namespace ClashN
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToJson(Object obj)
|
||||
public static string ToJson(object? obj, bool indented = true)
|
||||
{
|
||||
string result = string.Empty;
|
||||
try
|
||||
{
|
||||
result = JsonConvert.SerializeObject(obj,
|
||||
if (obj == null)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
if (indented)
|
||||
{
|
||||
result = JsonConvert.SerializeObject(obj,
|
||||
Formatting.Indented,
|
||||
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
}
|
||||
else
|
||||
{
|
||||
result = JsonConvert.SerializeObject(obj, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -895,18 +909,7 @@ namespace ClashN
|
||||
/// <returns></returns>
|
||||
public static T DeepCopy<T>(T obj)
|
||||
{
|
||||
object retval;
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
BinaryFormatter bf = new BinaryFormatter();
|
||||
//序列化成流
|
||||
bf.Serialize(ms, obj);
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
//反序列化成对象
|
||||
retval = bf.Deserialize(ms);
|
||||
ms.Close();
|
||||
}
|
||||
return (T)retval;
|
||||
return FromJson<T>(ToJson(obj, false))!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace ClashN.ViewModels
|
||||
private NoticeHandler? _noticeHandler;
|
||||
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateClashCoreCmd { get; }
|
||||
//public ReactiveCommand<Unit, Unit> CheckUpdateClashCoreCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateMihomoCoreCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> CheckUpdateGeoDataCmd { get; }
|
||||
//public ReactiveCommand<Unit, Unit> CheckUpdateGeoDataCmd { get; }
|
||||
|
||||
public HelpViewModel()
|
||||
{
|
||||
@@ -27,34 +27,34 @@ namespace ClashN.ViewModels
|
||||
{
|
||||
CheckUpdateN();
|
||||
});
|
||||
CheckUpdateClashCoreCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateCore(CoreKind.Clash);
|
||||
});
|
||||
//CheckUpdateClashCoreCmd = ReactiveCommand.Create(() =>
|
||||
//{
|
||||
// CheckUpdateCore(CoreKind.Clash);
|
||||
//});
|
||||
CheckUpdateMihomoCoreCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateCore(CoreKind.Mihomo);
|
||||
});
|
||||
CheckUpdateGeoDataCmd = ReactiveCommand.Create(() =>
|
||||
{
|
||||
CheckUpdateGeoData();
|
||||
});
|
||||
//CheckUpdateGeoDataCmd = ReactiveCommand.Create(() =>
|
||||
//{
|
||||
// CheckUpdateGeoData();
|
||||
//});
|
||||
}
|
||||
|
||||
private void CheckUpdateGeoData()
|
||||
{
|
||||
void _updateUI(bool success, string msg)
|
||||
{
|
||||
_noticeHandler?.SendMessage(msg);
|
||||
if (success)
|
||||
{
|
||||
Locator.Current.GetService<MainWindowViewModel>()?.MyAppExit(false);
|
||||
}
|
||||
};
|
||||
UpdateHandle update = new UpdateHandle();
|
||||
update.UpdateGeoFile(GeoKind.GEO_IP, _config, _updateUI);
|
||||
update.UpdateGeoFile(GeoKind.GEO_SITE, _config, _updateUI);
|
||||
}
|
||||
//private void CheckUpdateGeoData()
|
||||
//{
|
||||
// void _updateUI(bool success, string msg)
|
||||
// {
|
||||
// _noticeHandler?.SendMessage(msg);
|
||||
// if (success)
|
||||
// {
|
||||
// Locator.Current.GetService<MainWindowViewModel>()?.MyAppExit(false);
|
||||
// }
|
||||
// };
|
||||
// UpdateHandle update = new UpdateHandle();
|
||||
// update.UpdateGeoFile(GeoKind.GEO_IP, _config, _updateUI);
|
||||
// update.UpdateGeoFile(GeoKind.GEO_SITE, _config, _updateUI);
|
||||
//}
|
||||
|
||||
private void CheckUpdateN()
|
||||
{
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace ClashN.ViewModels
|
||||
{
|
||||
item = new()
|
||||
{
|
||||
coreType = CoreKind.ClashMeta
|
||||
coreType = CoreKind.Mihomo
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
@@ -96,42 +96,6 @@
|
||||
</DockPanel>
|
||||
</materialDesign:Card>
|
||||
|
||||
<materialDesign:Card
|
||||
Width="300"
|
||||
Margin="8"
|
||||
Padding="16"
|
||||
materialDesign:UniformCornerRadius="8">
|
||||
<DockPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="16,16,16,4"
|
||||
Style="{StaticResource TabItemTitle}"
|
||||
Text="Update Clash Core" />
|
||||
|
||||
<Separator Grid.Row="1" Style="{StaticResource MaterialDesignLightSeparator}" />
|
||||
|
||||
<DockPanel Grid.Row="2" HorizontalAlignment="Right">
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="8"
|
||||
Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
||||
Text="" />
|
||||
<Button
|
||||
x:Name="btnCheckUpdateClashCore"
|
||||
Width="100"
|
||||
Content="{x:Static resx:ResUI.TbHelpCheck}"
|
||||
DockPanel.Dock="Right"
|
||||
Style="{StaticResource DefButton}" />
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</materialDesign:Card>
|
||||
|
||||
<materialDesign:Card
|
||||
Width="300"
|
||||
@@ -169,44 +133,8 @@
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</materialDesign:Card>
|
||||
|
||||
|
||||
<materialDesign:Card
|
||||
Width="300"
|
||||
Margin="8"
|
||||
Padding="16"
|
||||
materialDesign:UniformCornerRadius="8">
|
||||
<DockPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="16,16,16,4"
|
||||
Style="{StaticResource TabItemTitle}"
|
||||
Text="Update Geo Data" />
|
||||
|
||||
<Separator Grid.Row="1" Style="{StaticResource MaterialDesignLightSeparator}" />
|
||||
|
||||
<DockPanel Grid.Row="2" HorizontalAlignment="Right">
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="8"
|
||||
Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
||||
Text="" />
|
||||
<Button
|
||||
x:Name="btnCheckUpdateGeo"
|
||||
Width="100"
|
||||
Content="{x:Static resx:ResUI.TbHelpCheck}"
|
||||
DockPanel.Dock="Right"
|
||||
Style="{StaticResource DefButton}" />
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</materialDesign:Card>
|
||||
</WrapPanel>
|
||||
</ScrollViewer>
|
||||
</DockPanel>
|
||||
|
||||
@@ -17,9 +17,9 @@ namespace ClashN.Views
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateCmd, v => v.btnCheckUpdateN).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateClashCoreCmd, v => v.btnCheckUpdateClashCore).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateClashCoreCmd, v => v.btnCheckUpdateClashCore).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateMihomoCoreCmd, v => v.btnCheckUpdateMihomoCore).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateGeoDataCmd, v => v.btnCheckUpdateGeo).DisposeWith(disposables);
|
||||
//this.BindCommand(ViewModel, vm => vm.CheckUpdateGeoDataCmd, v => v.btnCheckUpdateGeo).DisposeWith(disposables);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user