fix: request github ua
This commit is contained in:
@ -187,21 +187,15 @@ class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 版本对比
|
// 版本对比
|
||||||
static bool needUpdate(String currentVersion, String remoteVersion) {
|
static bool needUpdate(localVersion, remoteVersion) {
|
||||||
List<int> current = currentVersion.split('.').map(int.parse).toList();
|
List<String> localVersionList = localVersion.split('.');
|
||||||
List<int> remote =
|
List<String> remoteVersionList = remoteVersion.split('v')[1].split('.');
|
||||||
remoteVersion.split('v')[1].split('.').map(int.parse).toList();
|
for (int i = 0; i < localVersionList.length; i++) {
|
||||||
|
int localVersion = int.parse(localVersionList[i]);
|
||||||
int maxLength =
|
int remoteVersion = int.parse(remoteVersionList[i]);
|
||||||
current.length > remote.length ? current.length : remote.length;
|
if (remoteVersion > localVersion) {
|
||||||
|
|
||||||
for (int i = 0; i < maxLength; i++) {
|
|
||||||
int currentValue = i < current.length ? current[i] : 0;
|
|
||||||
int remoteValue = i < remote.length ? remote[i] : 0;
|
|
||||||
|
|
||||||
if (currentValue < remoteValue) {
|
|
||||||
return true;
|
return true;
|
||||||
} else if (currentValue > remoteValue) {
|
} else if (remoteVersion < localVersion) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +206,7 @@ class Utils {
|
|||||||
static Future<bool> checkUpdata() async {
|
static Future<bool> checkUpdata() async {
|
||||||
SmartDialog.dismiss();
|
SmartDialog.dismiss();
|
||||||
var currentInfo = await PackageInfo.fromPlatform();
|
var currentInfo = await PackageInfo.fromPlatform();
|
||||||
var result = await Request().get(Api.latestApp);
|
var result = await Request().get(Api.latestApp, extra: {'ua': 'mob'});
|
||||||
LatestDataModel data = LatestDataModel.fromJson(result.data);
|
LatestDataModel data = LatestDataModel.fromJson(result.data);
|
||||||
bool isUpdate = Utils.needUpdate(currentInfo.version, data.tagName!);
|
bool isUpdate = Utils.needUpdate(currentInfo.version, data.tagName!);
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
|
|||||||
Reference in New Issue
Block a user