mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Add Wox.CrashReporter
This commit is contained in:
@@ -6,7 +6,9 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Wox.Core;
|
||||
using Wox.Core.UserSettings;
|
||||
using Wox.Core.Version;
|
||||
using Wox.Helper;
|
||||
using Wox.Infrastructure;
|
||||
using Wox.Infrastructure.Http;
|
||||
@@ -15,7 +17,6 @@ namespace Wox.Update
|
||||
{
|
||||
public class UpdateChecker
|
||||
{
|
||||
private const string updateURL = "https://api.getwox.com/release/latest/";
|
||||
private static Release newRelease;
|
||||
private static bool checkedUpdate = false;
|
||||
|
||||
@@ -27,7 +28,7 @@ namespace Wox.Update
|
||||
public Release CheckUpgrade(bool forceCheck = false)
|
||||
{
|
||||
if (checkedUpdate && !forceCheck) return newRelease;
|
||||
string json = HttpRequest.Get(updateURL,HttpProxy.Instance);
|
||||
string json = HttpRequest.Get(APIServer.LastestReleaseURL,HttpProxy.Instance);
|
||||
if (string.IsNullOrEmpty(json)) return null;
|
||||
|
||||
try
|
||||
@@ -48,46 +49,7 @@ namespace Wox.Update
|
||||
{
|
||||
if (release == null) return false;
|
||||
|
||||
string currentVersion = ConfigurationManager.AppSettings["version"];
|
||||
return CompareVersion(release.version, currentVersion) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if version1 > version2 return 1
|
||||
/// else -1
|
||||
/// </summary>
|
||||
/// <param name="version1"></param>
|
||||
/// <param name="version2"></param>
|
||||
/// <returns></returns>
|
||||
private int CompareVersion(string version1, string version2)
|
||||
{
|
||||
if (version1 == version2) return 0;
|
||||
if (string.IsNullOrEmpty(version1) || string.IsNullOrEmpty(version2)) return 0;
|
||||
|
||||
//semantic version, e.g. 1.1.0
|
||||
List<int> version1List = version1.Split('.').Select(int.Parse).ToList();
|
||||
List<int> version2List = version2.Split('.').Select(int.Parse).ToList();
|
||||
|
||||
if (version1List[0] > version2List[0])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (version1List[0] == version2List[0])
|
||||
{
|
||||
if (version1List[1] > version2List[1])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (version1List[1] == version2List[1])
|
||||
{
|
||||
if (version1List[2] > version2List[2])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return new SemanticVersion(release.version) > VersionManager.Instance.CurrentVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user