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
This commit is contained in:
zorro.zhang 2024-03-25 10:56:48 +08:00 committed by Lane.Wei
parent 8c4773d7fc
commit a2ba70fe62
3 changed files with 31 additions and 45 deletions

View File

@ -8,7 +8,7 @@ function OnInit()
TranslatePage();
SendMsg_GetLoginInfo();
GotoMenu( 'home' );
GotoMenu( 'home' );
}
function HandleStudio( pVal )

View File

@ -424,4 +424,17 @@ function ExecuteDarkMode( DarkCssPath )
}
}
SwitchDarkMode( "./css/dark.css" );
SwitchDarkMode( "./css/dark.css" );
/*-------KeyBoard------*/
function DisableCtrlHotkey()
{
document.onkeydown = function(event) {
event = event || window.event;
if (event.ctrlKey ) {
event.preventDefault();
}
}
}
DisableCtrlHotkey();

View File

@ -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());