fix version compare

This commit is contained in:
huiyadanli
2023-12-03 15:27:20 +08:00
parent 94260d73b4
commit 1c314f419e
2 changed files with 21 additions and 1 deletions

View File

@@ -26,11 +26,22 @@ public class Global
return null;
}
/// <summary>
/// 新获取到的版本号与当前版本号比较,判断是否为新版本
/// </summary>
/// <param name="currentVersion">新获取到的版本</param>
/// <returns></returns>
public static bool IsNewVersion(string currentVersion)
{
return IsNewVersion(Version, currentVersion);
}
/// <summary>
/// 新获取到的版本号与当前版本号比较,判断是否为新版本
/// </summary>
/// <param name="oldVersion">老版本</param>
/// <param name="currentVersion">新获取到的版本</param>
/// <returns>是否需要更新</returns>
public static bool IsNewVersion(string oldVersion, string currentVersion)
{
var currentVersionArr = oldVersion.Split('.');
@@ -40,10 +51,18 @@ public class Global
return false;
}
for (int i = 0; i < currentVersionArr.Length; i++)
for (var i = 0; i < currentVersionArr.Length; i++)
{
if (int.Parse(currentVersionArr[i]) > int.Parse(newVersionArr[i]))
{
// 不需要更新
return false;
}
if (int.Parse(currentVersionArr[i]) < int.Parse(newVersionArr[i]))
{
// 需要更新
return true;
}
}

View File

@@ -33,6 +33,7 @@ cd /d ..\BetterGenshinImpact\bin\x64\Release\net7.0-windows10.0.22621.0
xcopy * "%tmpfolder%" /E /C /I /Y
rd /s /q "%tmpfolder%\log"
rd /s /q "%tmpfolder%\runtimes\android"
rd /s /q "%tmpfolder%\runtimes\ios"
rd /s /q "%tmpfolder%\runtimes\linux-arm64"