From 5d611bad086772dc602a59013a857b03f4c8e959 Mon Sep 17 00:00:00 2001 From: alves Date: Tue, 6 Jan 2026 11:11:27 +0800 Subject: [PATCH] feature code format. --- src/slic3r/GUI/GUI_App.cpp | 7 +++-- src/slic3r/Utils/PresetUpdater.cpp | 41 +++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 71616a018d..77ddd01d18 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -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; diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 8b15071d6d..416787e4ec 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -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";