feature code format.

This commit is contained in:
alves
2026-01-06 11:11:27 +08:00
parent cec6ccc4b0
commit 5d611bad08
2 changed files with 34 additions and 14 deletions

View File

@@ -4777,14 +4777,17 @@ void GUI_App::check_new_version_sf(bool show_tips, bool by_user)
auto errCode = jsonData["code"];
if (errCode != 200)
return;
// auto isFullUpgrade = jsonData["is_full_upgrade"];
auto isFullUpgrade = jsonData["data"]["is_full_upgrade"];
auto isForceUpgrade = jsonData["data"]["is_force_upgrade"];
auto versionType = jsonData["data"]["stable"];
auto softPlatform = jsonData["data"]["platform_type"];
version_info.version_str = jsonData["data"]["version"];
auto fileSize = jsonData["data"]["full"]["file_size"];
auto fileMd5 = jsonData["data"]["full"]["file_md5"];
auto fileSha256 = jsonData["data"]["full"]["file_sha256"];
version_info.url = jsonData["data"]["full"]["file_url"];
//windows x86_x64, mac arm/x86_x64 universal
version_info.url = jsonData["data"]["full"]["file_url"];
version_info.description = jsonData["data"]["full"]["file_describe"];
version_info.force_upgrade = isForceUpgrade;

View File

@@ -736,21 +736,25 @@ void PresetUpdater::priv::sync_update_flutter_resource(bool isAuto_check)
if (http_status != 200)
return;
try {
json jsonData = json::parse(body);
auto errCode = jsonData["code"];
json jsonObj = json::parse(body);
auto errCode = jsonObj["code"];
if (errCode != 200)
return;
auto buildNumber = jsonData["data"]["build_number"];
auto isForceUpgrade = jsonData["data"]["is_force_upgrade"];
auto minSupportPcVersion = jsonData["data"]["min_support_pc_version"];
auto maxSupportPcVersion = jsonData["data"]["max_support_pc_version"];
auto fileVersion = jsonData["data"]["file_version"];
auto fileSize = jsonData["data"]["file_size"];
auto fileMd5 = jsonData["data"]["file_md5"];
auto fileSha256 = jsonData["data"]["file_sha256"];
auto fileUrl = jsonData["data"]["file_url"];
auto description = jsonData["data"]["file_describe"];
auto dataObj = jsonObj.value("data", json::object());
auto buildNumer = dataObj.value("build_number", "");
auto minSupportPcVersion = dataObj.value("min_support_pc_version", "");
auto maxSupportPcVersion = dataObj.value("max_support_pc_version", "");
auto isForceUpgrade = dataObj.value("is_force_upgrade", false);
auto fileVersion = dataObj.value("file_version", "");
auto fileSize = dataObj.value("file_size", 0);
auto fileMd5 = dataObj.value("file_md5", "");
auto fileSha256 = dataObj.value("file_sha256", "");
auto fileUrl = dataObj.value("file_url", "");
auto description = dataObj.value("file_describe", "");
auto reserveData = dataObj.value("reserve_1", "");
auto reserveData2 = dataObj.value("reserve_2", "");
auto localProfilesjson = cache_path / "flutter_web/version.json";
std::string json_path = data_dir() + "/web/flutter_web/version.json";
@@ -758,6 +762,17 @@ void PresetUpdater::priv::sync_update_flutter_resource(bool isAuto_check)
Semver currentPresetVersion = get_version_from_json(json_path);
Semver remoteVersion(fileVersion);
if (fileVersion.empty())
{
if (!isAuto_check) {
wxCommandEvent* evt = new wxCommandEvent(EVT_NO_WEB_RESOURCE_UPDATE);
GUI::wxGetApp().QueueEvent(evt);
BOOST_LOG_TRIVIAL(info) << format("use check the web update.");
}
return;
}
std::string localOtaPresetVersion = "";
if (fs::exists(localProfilesjson)) {
Semver localOtaVersion = get_version_from_json(localProfilesjson.string());
@@ -833,6 +848,8 @@ void PresetUpdater::priv::sync_config(bool isAuto_check)
auto fileSha256 = jsonData["data"]["file_sha256"];
auto fileUrl = jsonData["data"]["file_url"];
auto description = jsonData["data"]["file_describe"];
auto reserverData = jsonData["data"]["reserver_1"];
auto reserverData2 = jsonData["data"]["reserver_2"];
auto localProfilesjson = cache_path / "profiles/Snapmaker.json";
std::string json_path = data_dir() + "/system/Snapmaker.json";