@@ -9,6 +9,7 @@
|
|||||||
public const string NUrl = @"https://github.com/2dust/clashN/releases";
|
public const string NUrl = @"https://github.com/2dust/clashN/releases";
|
||||||
public const string clashCoreUrl = "https://github.com/Dreamacro/clash/releases";
|
public const string clashCoreUrl = "https://github.com/Dreamacro/clash/releases";
|
||||||
public const string clashMetaCoreUrl = "https://github.com/MetaCubeX/Clash.Meta/releases";
|
public const string clashMetaCoreUrl = "https://github.com/MetaCubeX/Clash.Meta/releases";
|
||||||
|
public const string mihomoCoreUrl = "https://github.com/MetaCubeX/mihomo/releases";
|
||||||
public const string geoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat";
|
public const string geoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -90,6 +90,18 @@ namespace ClashN.Handler
|
|||||||
match = "Clash Meta"
|
match = "Clash Meta"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
coreInfos.Add(new CoreInfo
|
||||||
|
{
|
||||||
|
coreType = CoreKind.Mihomo,
|
||||||
|
coreExes = new List<string> { $"mihomo-windows-amd64{(Avx2.X64.IsSupported ? "" : "-compatible")}", "mihomo-windows-amd64-compatible", "mihomo-windows-amd64", "mihomo-windows-386", "mihomo", "clash" },
|
||||||
|
arguments = "-f config.yaml",
|
||||||
|
coreUrl = Global.mihomoCoreUrl,
|
||||||
|
coreLatestUrl = Global.mihomoCoreUrl + "/latest",
|
||||||
|
coreDownloadUrl32 = Global.mihomoCoreUrl + "/download/{0}/mihomo-windows-386-{0}.zip",
|
||||||
|
coreDownloadUrl64 = Global.mihomoCoreUrl + "/download/{0}/mihomo-windows-amd64" + (Avx2.X64.IsSupported ? "" : "-compatible") + "-{0}.zip",
|
||||||
|
match = "Mihomo"
|
||||||
|
});
|
||||||
|
|
||||||
coreInfos.Add(new CoreInfo
|
coreInfos.Add(new CoreInfo
|
||||||
{
|
{
|
||||||
coreType = CoreKind.ClashPremium,
|
coreType = CoreKind.ClashPremium,
|
||||||
|
|||||||
@@ -310,10 +310,10 @@ namespace ClashN.Handler
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string fileName = Utils.GetPath(Utils.GetDownloadFileName(url));
|
string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(url));
|
||||||
if (File.Exists(fileName))
|
if (File.Exists(fileName))
|
||||||
{
|
{
|
||||||
string targetPath = Utils.GetPath($"{geoName}.dat");
|
string targetPath = Utils.GetDataPath($"{geoName}.dat");
|
||||||
if (File.Exists(targetPath))
|
if (File.Exists(targetPath))
|
||||||
{
|
{
|
||||||
File.Delete(targetPath);
|
File.Delete(targetPath);
|
||||||
@@ -455,6 +455,19 @@ namespace ClashN.Handler
|
|||||||
url = string.Format(coreInfo.coreDownloadUrl32, version);
|
url = string.Format(coreInfo.coreDownloadUrl32, version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (type == CoreKind.Mihomo)
|
||||||
|
{
|
||||||
|
curVersion = getCoreVersion(type);
|
||||||
|
message = string.Format(ResUI.IsLatestCore, curVersion);
|
||||||
|
if (Environment.Is64BitProcess)
|
||||||
|
{
|
||||||
|
url = string.Format(coreInfo.coreDownloadUrl64, version);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
url = string.Format(coreInfo.coreDownloadUrl32, version);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (type == CoreKind.ClashN)
|
else if (type == CoreKind.ClashN)
|
||||||
{
|
{
|
||||||
curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString();
|
curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
Clash = 1,
|
Clash = 1,
|
||||||
ClashMeta = 2,
|
ClashMeta = 2,
|
||||||
ClashPremium = 3,
|
ClashPremium = 3,
|
||||||
|
Mihomo = 4,
|
||||||
ClashN = 99
|
ClashN = 99
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -599,6 +599,27 @@ namespace ClashN
|
|||||||
}
|
}
|
||||||
return Path.Combine(startupPath, fileName);
|
return Path.Combine(startupPath, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取启动了应用程序的数据文件的路径
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetDataPath(string fileName)
|
||||||
|
{
|
||||||
|
string _tempPath = Path.Combine(StartupPath(), "data");
|
||||||
|
if (!Directory.Exists(_tempPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(_tempPath);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(fileName))
|
||||||
|
{
|
||||||
|
return _tempPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Path.Combine(_tempPath, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取启动了应用程序的可执行文件的路径及文件名
|
/// 获取启动了应用程序的可执行文件的路径及文件名
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ namespace ClashN.ViewModels
|
|||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> CheckUpdateCmd { get; }
|
public ReactiveCommand<Unit, Unit> CheckUpdateCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> CheckUpdateClashCoreCmd { get; }
|
public ReactiveCommand<Unit, Unit> CheckUpdateClashCoreCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> CheckUpdateClashMetaCoreCmd { get; }
|
public ReactiveCommand<Unit, Unit> CheckUpdateMihomoCoreCmd { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> CheckUpdateGeoDataCmd { get; }
|
||||||
|
|
||||||
public HelpViewModel()
|
public HelpViewModel()
|
||||||
{
|
{
|
||||||
@@ -30,10 +31,29 @@ namespace ClashN.ViewModels
|
|||||||
{
|
{
|
||||||
CheckUpdateCore(CoreKind.Clash);
|
CheckUpdateCore(CoreKind.Clash);
|
||||||
});
|
});
|
||||||
CheckUpdateClashMetaCoreCmd = ReactiveCommand.Create(() =>
|
CheckUpdateMihomoCoreCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
CheckUpdateCore(CoreKind.ClashMeta);
|
CheckUpdateCore(CoreKind.Mihomo);
|
||||||
});
|
});
|
||||||
|
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 CheckUpdateN()
|
private void CheckUpdateN()
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Margin="16,16,16,4"
|
Margin="16,16,16,4"
|
||||||
Style="{StaticResource TabItemTitle}"
|
Style="{StaticResource TabItemTitle}"
|
||||||
Text="Update Clash.Meta Core" />
|
Text="Update Mihomo Core" />
|
||||||
|
|
||||||
<Separator Grid.Row="1" Style="{StaticResource MaterialDesignLightSeparator}" />
|
<Separator Grid.Row="1" Style="{StaticResource MaterialDesignLightSeparator}" />
|
||||||
|
|
||||||
@@ -160,7 +160,45 @@
|
|||||||
Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
Style="{StaticResource MaterialDesignCaptionTextBlock}"
|
||||||
Text="" />
|
Text="" />
|
||||||
<Button
|
<Button
|
||||||
x:Name="btnCheckUpdateClashMetaCore"
|
x:Name="btnCheckUpdateMihomoCore"
|
||||||
|
Width="100"
|
||||||
|
Content="{x:Static resx:ResUI.TbHelpCheck}"
|
||||||
|
DockPanel.Dock="Right"
|
||||||
|
Style="{StaticResource DefButton}" />
|
||||||
|
</DockPanel>
|
||||||
|
</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"
|
Width="100"
|
||||||
Content="{x:Static resx:ResUI.TbHelpCheck}"
|
Content="{x:Static resx:ResUI.TbHelpCheck}"
|
||||||
DockPanel.Dock="Right"
|
DockPanel.Dock="Right"
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ namespace ClashN.Views
|
|||||||
{
|
{
|
||||||
this.BindCommand(ViewModel, vm => vm.CheckUpdateCmd, v => v.btnCheckUpdateN).DisposeWith(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.CheckUpdateClashMetaCoreCmd, v => v.btnCheckUpdateClashMetaCore).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.CheckUpdateMihomoCoreCmd, v => v.btnCheckUpdateMihomoCore).DisposeWith(disposables);
|
||||||
|
this.BindCommand(ViewModel, vm => vm.CheckUpdateGeoDataCmd, v => v.btnCheckUpdateGeo).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user