From 941c92432969d7878ff11eba74b8a390c24fa442 Mon Sep 17 00:00:00 2001 From: alves Date: Wed, 17 Dec 2025 18:24:23 +0800 Subject: [PATCH] feature add privacy policy for guide --- resources/web/guide/11/11.js | 3 +- resources/web/guide/21/index.html | 2 +- resources/web/guide/3/3.css | 22 +++++ resources/web/guide/3/3.js | 118 +++++++++++++++------------ resources/web/guide/3/index.html | 15 ++-- resources/web/guide/31/index.html | 2 +- src/bury_cfg/bury_point.cpp | 21 +++-- src/bury_cfg/bury_point.hpp | 8 +- src/sentry_wrapper/SentryWrapper.cpp | 6 ++ src/slic3r/GUI/GUI_App.cpp | 8 +- src/slic3r/GUI/Plater.cpp | 2 +- src/slic3r/GUI/WebGuideDialog.cpp | 11 ++- src/slic3r/GUI/WebPresetDialog.cpp | 8 ++ 13 files changed, 150 insertions(+), 76 deletions(-) diff --git a/resources/web/guide/11/11.js b/resources/web/guide/11/11.js index 5cbc330192..74a201f338 100644 --- a/resources/web/guide/11/11.js +++ b/resources/web/guide/11/11.js @@ -62,7 +62,8 @@ function GotoPolicyPage() SendWXMessage( JSON.stringify(tSend) ); - window.location.href="../21/index.html"; + + window.location.href="../3/index.html"; } diff --git a/resources/web/guide/21/index.html b/resources/web/guide/21/index.html index 5122ccec49..c0694faffc 100644 --- a/resources/web/guide/21/index.html +++ b/resources/web/guide/21/index.html @@ -104,7 +104,7 @@
-
Back
+
Back
Next
diff --git a/resources/web/guide/3/3.css b/resources/web/guide/3/3.css index bd7d413337..f3044a5792 100644 --- a/resources/web/guide/3/3.css +++ b/resources/web/guide/3/3.css @@ -1,3 +1,25 @@ + +#Title { + height: auto; + min-height: 60px; + padding: 12px 25px; + box-sizing: border-box; +} + +#Title div { + font-size: 16px; + line-height: 24px; + word-wrap: break-word; + white-space: normal; + text-align: center; +} + + +#Content { + flex: 1; + height: auto; +} + .PolicyArea { background-color: #4A4A51; diff --git a/resources/web/guide/3/3.js b/resources/web/guide/3/3.js index 1418d50dda..379cd39441 100644 --- a/resources/web/guide/3/3.js +++ b/resources/web/guide/3/3.js @@ -1,31 +1,12 @@ +var m_Region = ''; + function OnInit() { TranslatePage(); - SendPrivacySelect(); -} - - -function SendPrivacySelect() -{ - let nVal="refuse"; - if( $('#ChoosePrivacy').is(':checked') ) - nVal="agree"; - var tSend={}; - tSend['sequence_id']=Math.round(new Date() / 1000); - tSend['command']="user_private_choice"; - tSend['data']={}; - tSend['data']['action']=nVal; - - SendWXMessage( JSON.stringify(tSend) ); -} - - -function GotoNextPage() -{ - RequestProfile(); + RequestProfile(); } function RequestProfile() @@ -40,41 +21,72 @@ function RequestProfile() function HandleStudio( pVal ) { let strCmd=pVal['command']; - //alert(strCmd); if(strCmd=='response_userguide_profile') { - HandleModelInfo(pVal['response']); + + if(pVal['response'] && pVal['response']['region']) { + m_Region = pVal['response']['region']; + } } } -function HandleModelInfo( pVal ) -{ - let Modellist=pVal["model"]; - let nModel=Modellist.length; - - if(nModel==1) - { -// let pModel=Modellist[0]; -// -// var tSend={}; -// tSend['sequence_id']=Math.round(new Date() / 1000); -// tSend['command']="save_userguide_models"; -// tSend['data']={}; -// -// let ModelName=pModel['model']; -// -// tSend['data'][ModelName]={}; -// tSend['data'][ModelName]['model']=pModel['model']; -// tSend['data'][ModelName]['nozzle_diameter']=pModel['nozzle_diameter']; -// tSend['data'][ModelName]['vendor']=pModel['vendor']; -// -// SendWXMessage( JSON.stringify(tSend) ); - - window.location.href="../22/index.html"; - - return; - } - window.location.href="../21/index.html"; -} \ No newline at end of file +function GotoBackPage() +{ + window.location.href="../11/index.html"; +} + + +function GotoNextPage() +{ + + SendPrivacyChoice("agree"); + + + window.location.href="../21/index.html"; +} + + +function GotoSkipPage() +{ + + SendPrivacyChoice("refuse"); + + + window.location.href="../21/index.html"; +} + + +function SendPrivacyChoice(action) +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="user_private_choice"; + tSend['data']={}; + tSend['data']['action']=action; // "agree" 或 "refuse" + + SendWXMessage( JSON.stringify(tSend) ); +} + + +function OpenPrivacyPolicy() +{ + var privacyUrl = ""; + + + if(m_Region === "China") { + privacyUrl = "https://www.snapmaker.cn/privacy-policy.html"; + } else { + privacyUrl = "https://www.snapmaker.com/privacy-policy"; + } + + + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="common_openurl"; + tSend['url']=privacyUrl; + tSend['local']=m_Region + + SendWXMessage( JSON.stringify(tSend) ); +} diff --git a/resources/web/guide/3/index.html b/resources/web/guide/3/index.html index 836811bf84..daef8b263b 100644 --- a/resources/web/guide/3/index.html +++ b/resources/web/guide/3/index.html @@ -16,24 +16,21 @@
-
We kindly request your help to improve
everyone's printing
+
We kindly request your help to improve everyone's printing.
Come and Join our Customer Experience Improvement Program

- -
-
Back
-
Next
+
Back
+
Skip
+
Join the Program
diff --git a/resources/web/guide/31/index.html b/resources/web/guide/31/index.html index 65b81fd420..3a68b05338 100644 --- a/resources/web/guide/31/index.html +++ b/resources/web/guide/31/index.html @@ -19,7 +19,7 @@
diff --git a/src/bury_cfg/bury_point.cpp b/src/bury_cfg/bury_point.cpp index cf3e1dc9ce..282474f30e 100644 --- a/src/bury_cfg/bury_point.cpp +++ b/src/bury_cfg/bury_point.cpp @@ -4,6 +4,15 @@ #include #include +bool get_privacy_policy() +{ + return isAgreeSlice; +} + +void set_privacy_policy(bool isAgree) { + isAgreeSlice = isAgree; +} + std::string get_timestamp_seconds() { auto now = std::chrono::system_clock::now(); @@ -26,16 +35,16 @@ long long get_time_timestamp() return timestamp; } -std::string get_works_time(const uint64_t& timestamp) +std::string get_works_time(const long long& timestamp) { - uint64_t hours = timestamp / 3600000; - uint64_t remaining_ms = timestamp % 3600000; + long long hours = timestamp / 3600000; + long long remaining_ms = timestamp % 3600000; - uint64_t minutes = remaining_ms / 60000; + long long minutes = remaining_ms / 60000; remaining_ms = remaining_ms % 60000; - uint64_t seconds = remaining_ms / 1000; - uint64_t ms = remaining_ms % 1000; + long long seconds = remaining_ms / 1000; + long long ms = remaining_ms % 1000; char buffer[32] = {0}; std::snprintf(buffer, sizeof(buffer), "%02llu:%02llu:%02llu.%03llu", hours, minutes, seconds, ms); diff --git a/src/bury_cfg/bury_point.hpp b/src/bury_cfg/bury_point.hpp index 132ef3446f..647c4d968f 100644 --- a/src/bury_cfg/bury_point.hpp +++ b/src/bury_cfg/bury_point.hpp @@ -2,6 +2,7 @@ #define _BURY_POINT_hpp_ #include #include +#include #define BURY_POINT "bury_point" @@ -37,9 +38,12 @@ - static bool isAgreeSlice = false; + static std::atomic isAgreeSlice = true; + + bool get_privacy_policy(); + void set_privacy_policy(bool isAgree); extern std::string get_timestamp_seconds(); extern long long get_time_timestamp(); - extern std::string get_works_time(const uint64_t& timestamp); + extern std::string get_works_time(const long long& timestamp); #endif \ No newline at end of file diff --git a/src/sentry_wrapper/SentryWrapper.cpp b/src/sentry_wrapper/SentryWrapper.cpp index 6f72348634..4774bff7a7 100644 --- a/src/sentry_wrapper/SentryWrapper.cpp +++ b/src/sentry_wrapper/SentryWrapper.cpp @@ -57,6 +57,12 @@ static sentry_value_t on_crash_callback(const sentry_ucontext_t* uctx, sentry_va static sentry_value_t before_send(sentry_value_t event, void* hint, void* data) { + if (!get_privacy_policy()) + { + sentry_value_decref(event); + return sentry_value_new_null(); + } + sentry_value_t level_val = sentry_value_get_by_key(event, SENTRY_KEY_LEVEL); std::string levelName = sentry_value_as_string(level_val); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index a7fe3e4a8d..d889b01510 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -120,7 +120,7 @@ #include "PrivacyUpdateDialog.hpp" #include "ModelMall.hpp" #include "HintNotification.hpp" - +#include "bury_cfg/bury_point.hpp" //#ifdef WIN32 //#include "BaseException.h" //#endif @@ -3754,6 +3754,9 @@ if (res) { } catch (std::exception &) { // wxMessageBox(e.what(), "", MB_OK); } + auto isAgree = wxGetApp().app_config->get("snapmaker_privacy_policy", "isagree"); + + set_privacy_policy(isAgree == "true"); } void GUI_App::ShowDownNetPluginDlg() { @@ -7059,6 +7062,9 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage mainframe->refresh_plugin_tips(); // BBS: remove SLA related message } + auto isAgree = wxGetApp().app_config->get("snapmaker_privacy_policy", "isagree"); + + set_privacy_policy(isAgree == "true"); return res; } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index edfeabd849..1cbd8e013e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7746,7 +7746,7 @@ void Plater::priv::on_process_completed(SlicingProcessCompletedEvent &evt) if (m_slice_timing_active) { auto end_time = std::chrono::steady_clock::now(); auto duration_ms = std::chrono::duration_cast(end_time - m_slice_start_time).count(); - uint64_t timess = duration_ms; + auto timess = duration_ms; if (evt.cancelled()) { BOOST_LOG_TRIVIAL(info) << "Slicing cancelled after " << duration_ms << " ms"; m_slice_start_time = {}; diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index e30c1a6506..483508bdef 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -492,6 +492,15 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt) this->Close(); } else if (strCmd == "save_region") { m_Region = j["region"]; + m_ProfileJson["region"] = m_Region; + } + else if (strCmd == "common_openurl") { + + std::string url = j["url"]; + std::string local = j["local"]; + if (!url.empty()) { + wxLaunchDefaultBrowser(url); + } } else if (strCmd == "network_plugin_install") { std::string sAction = j["data"]["action"]; @@ -617,7 +626,7 @@ int GuideFrame::SaveProfile() // m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "privacyuse", "1"); // } else // m_MainPtr->app_config->set(std::string(m_SectionName.mb_str()), "privacyuse", "0"); - + m_MainPtr->app_config->set("snapmaker_privacy_policy", "isagree", PrivacyUse); m_MainPtr->app_config->set("region", m_Region); m_MainPtr->app_config->set_bool("stealth_mode", StealthMode); diff --git a/src/slic3r/GUI/WebPresetDialog.cpp b/src/slic3r/GUI/WebPresetDialog.cpp index 0f7771699a..aee23c9e1d 100644 --- a/src/slic3r/GUI/WebPresetDialog.cpp +++ b/src/slic3r/GUI/WebPresetDialog.cpp @@ -588,6 +588,14 @@ void WebPresetDialog::OnScriptMessage(wxWebViewEvent& evt) this->Close(); } else if (strCmd == "save_region") { m_Region = j["region"]; + m_ProfileJson["region"] = m_Region; + } + else if (strCmd == "common_openurl") { + + std::string url = j["url"]; + if (!url.empty()) { + wxLaunchDefaultBrowser(url); + } } else if (strCmd == "network_plugin_install") { std::string sAction = j["data"]["action"];