From a2ba70fe6281586bb1c2f5576ca4bc60c75b6663 Mon Sep 17 00:00:00 2001 From: "zorro.zhang" Date: Mon, 25 Mar 2024 10:56:48 +0800 Subject: [PATCH] ENH: Important issue update 1, Reset Whole PageInfo when Country Change 2, Disable Makerlab list when Country is China 3, Disable Ctrl+ HotKey in WebPage JIRA: none Change-Id: I8622dc6d5b340ee26910b059fef49e3062ca65ff --- resources/web/homepage2/js/left.js | 2 +- resources/web/include/globalapi.js | 15 +++++++- src/slic3r/GUI/WebViewDialog.cpp | 59 ++++++++---------------------- 3 files changed, 31 insertions(+), 45 deletions(-) diff --git a/resources/web/homepage2/js/left.js b/resources/web/homepage2/js/left.js index 72dd48f8a..73eff5510 100644 --- a/resources/web/homepage2/js/left.js +++ b/resources/web/homepage2/js/left.js @@ -8,7 +8,7 @@ function OnInit() TranslatePage(); SendMsg_GetLoginInfo(); - GotoMenu( 'home' ); + GotoMenu( 'home' ); } function HandleStudio( pVal ) diff --git a/resources/web/include/globalapi.js b/resources/web/include/globalapi.js index 0553483e1..e906e21c1 100644 --- a/resources/web/include/globalapi.js +++ b/resources/web/include/globalapi.js @@ -424,4 +424,17 @@ function ExecuteDarkMode( DarkCssPath ) } } -SwitchDarkMode( "./css/dark.css" ); \ No newline at end of file +SwitchDarkMode( "./css/dark.css" ); + +/*-------KeyBoard------*/ +function DisableCtrlHotkey() +{ + document.onkeydown = function(event) { + event = event || window.event; + if (event.ctrlKey ) { + event.preventDefault(); + } + } +} + +DisableCtrlHotkey(); \ No newline at end of file diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 5785bba41..11cd56ae2 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -119,7 +119,6 @@ WebViewPanel::WebViewPanel(wxWindow *parent) m_browserLeft->SetMinSize(wxSize(FromDIP(224), -1)); m_browserLeft->SetMaxSize(wxSize(FromDIP(224), -1)); - this->SetBackgroundColour(*wxWHITE); m_home_web->Add(m_browserLeft, 0, wxEXPAND | wxALL, 0); m_home_web->Add(m_browser, 1, wxEXPAND | wxALL, 0); m_home_web->Add(m_browserMW, 1, wxEXPAND | wxALL, 0); @@ -271,6 +270,10 @@ WebViewPanel::~WebViewPanel() void WebViewPanel::ResetWholePage() { if (m_browserLeft != nullptr && m_leftfirst) m_browserLeft->Reload(); + + auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code()); + std::string mwurl = (boost::format("%1%studio/webview?from=bambustudio") % host).str(); + m_browserMW->LoadURL(mwurl); } void WebViewPanel::load_url(wxString& url) @@ -610,10 +613,19 @@ void WebViewPanel::SendMakerlabList( ) } CallAfter([this, body] { auto body2 = from_u8(body); - body2.insert(1, "\"command\": \"homepage_makerlab_get\", "); - RunScript(wxString::Format("window.postMessage(%s)", body2)); - SetLeftMenuShow("makerlab", 1); + json jLab = json::parse(body2); + if (jLab.contains("list")) + { + int nSize = jLab["list"].size(); + if (nSize > 0) + { + body2.insert(1, "\"command\": \"homepage_makerlab_get\", "); + RunScript(wxString::Format("window.postMessage(%s)", body2)); + + SetLeftMenuShow("makerlab", 1); + } + } }); }); } catch (nlohmann::detail::parse_error &err) { @@ -627,22 +639,6 @@ void WebViewPanel::SendMakerlabList( ) } } -//void WebViewPanel::OpenModelDetail(std::string id, NetworkAgent *agent) -//{ -// std::string url; -// if ((agent ? agent->get_model_mall_detail_url(&url, id) : get_model_mall_detail_url(&url, id)) == 0) -// { -// if (url.find("?") != std::string::npos) -// { -// url += "&from=bambustudio"; -// } else { -// url += "?from=bambustudio"; -// } -// -// wxLaunchDefaultBrowser(url); -// } -//} - void WebViewPanel::OpenModelDetail(std::string id, NetworkAgent *agent) { SwitchLeftMenu("online"); @@ -760,29 +756,6 @@ std::string UrlDecode(const std::string &str) return strTemp; } -//void WebViewPanel::UpdateMakerworldLoginStatus() { -// NetworkAgent *agent = GUI::wxGetApp().getAgent(); -// if (agent == nullptr) return; -// -// int ret = agent->get_login_ticket([this](std::string body) { -// if (body.empty() || body.front() != '{') { -// BOOST_LOG_TRIVIAL(warning) << "get_login_ticket failed " + body; -// -// SetMakerworldPageLoginStatus(false); -// -// return; -// } -// CallAfter([this, body] { -// json jticket = json::parse(body); -// -// std::string ticket = jticket["ticket"]; -// -// SetMakerworldPageLoginStatus(true, ticket); -// }); -// } -// ); -//} - bool WebViewPanel::GetJumpUrl(bool login, wxString ticket, wxString targeturl, wxString &finalurl) { std::string h = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());