mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-14 04:19:12 +00:00
Update CheckUpdateViewModel.cs
This commit is contained in:
parent
29a5abf4d6
commit
6a98ee377d
1 changed files with 35 additions and 0 deletions
|
@ -61,8 +61,38 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
CheckUpdateModels.Add(GetCheckUpdateModel(_geo));
|
CheckUpdateModels.Add(GetCheckUpdateModel(_geo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsPackagedInstall()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Utils.IsWindows())
|
||||||
|
return false;
|
||||||
|
if (!string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("APPIMAGE")))
|
||||||
|
return true;
|
||||||
|
var sp = Utils.StartupPath()?.Replace('\\', '/');
|
||||||
|
if (!string.IsNullOrEmpty(sp) && sp.StartsWith("/opt/v2rayN", StringComparison.Ordinal))
|
||||||
|
return true;
|
||||||
|
var procPath = System.Environment.ProcessPath;
|
||||||
|
var procDir = string.IsNullOrEmpty(procPath) ? "" : System.IO.Path.GetDirectoryName(procPath)?.Replace('\\', '/');
|
||||||
|
if (!string.IsNullOrEmpty(procDir) && procDir.StartsWith("/opt/v2rayN", StringComparison.Ordinal))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private CheckUpdateModel GetCheckUpdateModel(string coreType)
|
private CheckUpdateModel GetCheckUpdateModel(string coreType)
|
||||||
{
|
{
|
||||||
|
if (coreType == _v2rayN && IsPackagedInstall())
|
||||||
|
{
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
IsSelected = false,
|
||||||
|
CoreType = coreType,
|
||||||
|
Remarks = ResUI.menuCheckUpdate + " (Not Support)",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
IsSelected = _config.CheckUpdateItem.SelectedCoreTypes?.Contains(coreType) ?? true,
|
IsSelected = _config.CheckUpdateItem.SelectedCoreTypes?.Contains(coreType) ?? true,
|
||||||
|
@ -104,6 +134,11 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else if (item.CoreType == _v2rayN)
|
else if (item.CoreType == _v2rayN)
|
||||||
{
|
{
|
||||||
|
if (IsPackagedInstall())
|
||||||
|
{
|
||||||
|
await UpdateView(_v2rayN, "Not Support");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
await CheckUpdateN(EnableCheckPreReleaseUpdate);
|
await CheckUpdateN(EnableCheckPreReleaseUpdate);
|
||||||
}
|
}
|
||||||
else if (item.CoreType == ECoreType.Xray.ToString())
|
else if (item.CoreType == ECoreType.Xray.ToString())
|
||||||
|
|
Loading…
Reference in a new issue