Compare commits

...

6 commits

Author SHA1 Message Date
JieXu
2236b1b688
Update Utils.cs 2025-09-12 12:52:46 +08:00
JieXu
8eeedbdb23
Update CheckUpdateViewModel.cs 2025-09-12 12:35:48 +08:00
JieXu
ef84e735c4
Update CheckUpdateViewModel.cs 2025-09-12 12:34:47 +08:00
JieXu
fffdbd4dd1
Update Utils.cs 2025-09-12 12:27:31 +08:00
JieXu
329a46ab9c
Update Utils.cs 2025-09-12 11:58:30 +08:00
JieXu
3862f6c97c
Update Utils.cs 2025-09-12 11:43:42 +08:00
2 changed files with 51 additions and 22 deletions

View file

@ -857,6 +857,55 @@ public class Utils
return false;
}
public static bool IsPackagedInstall()
{
try
{
if (IsWindows() || IsOSX())
{
return false;
}
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPIMAGE")))
{
return true;
}
var exePath = GetExePath();
var baseDir = string.IsNullOrEmpty(exePath) ? StartupPath() : Path.GetDirectoryName(exePath) ?? "";
var p = baseDir.Replace('\\', '/');
if (string.IsNullOrEmpty(p))
{
return false;
}
if (p.Contains("/.mount_", StringComparison.Ordinal))
{
return true;
}
if (p.StartsWith("/opt/v2rayN", StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (p.StartsWith("/usr/lib/v2rayN", StringComparison.OrdinalIgnoreCase))
{
return true;
}
if (p.StartsWith("/usr/share/v2rayN", StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
catch
{
}
return false;
}
private static async Task<string?> GetLinuxUserId()
{
var arg = new List<string>() { "-c", "id -u" };

View file

@ -61,29 +61,9 @@ public class CheckUpdateViewModel : MyReactiveObject
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)
{
if (coreType == _v2rayN && IsPackagedInstall())
if (coreType == _v2rayN && Utils.IsPackagedInstall())
{
return new()
{
@ -134,7 +114,7 @@ public class CheckUpdateViewModel : MyReactiveObject
}
else if (item.CoreType == _v2rayN)
{
if (IsPackagedInstall())
if (Utils.IsPackagedInstall())
{
await UpdateView(_v2rayN, "Not Support");
continue;