ENH: Open Login Dialog When Open Model in MW

JIRA: none
Change-Id: I962e93570bfdb137a01b2ec64f963b347765faf0
This commit is contained in:
zorro.zhang 2024-06-04 15:55:05 +08:00 committed by Lane.Wei
parent bce7bc9a97
commit d94c87879d
3 changed files with 30 additions and 3 deletions

View File

@ -4030,6 +4030,19 @@ std::string GUI_App::handle_web_request(std::string cmd)
});
}
else if (command_str.compare("homepage_login_or_register") == 0) {
if (root.get_child_optional("makerworld_model_id") != boost::none) {
boost::optional<std::string> ModelID = root.get_optional<std::string>("makerworld_model_id");
if (ModelID.has_value()) {
if (mainframe) {
if (mainframe->m_webview)
{
mainframe->m_webview->SetMakerworldModelID(ModelID.value());
}
}
}
}
CallAfter([this] {
this->request_login(true);
});

View File

@ -802,9 +802,22 @@ void WebViewPanel::SetMakerworldPageLoginStatus(bool login ,wxString ticket)
{
if (m_browserMW == nullptr) return;
std::string h = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
wxString mw_currenturl = m_browserMW->GetCurrentURL();
mw_currenturl.Replace("modelid=", "");
wxString mw_currenturl;
if (m_online_spec_id != "") {
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
wxString language_code = wxGetApp().current_language_code().BeforeFirst('_');
language_code = language_code.ToStdString();
mw_currenturl = (boost::format("%1%%2%/studio/webview?modelid=%3%&from=%4%") % host % language_code.mb_str() % m_online_spec_id % m_online_type.mb_str()).str();
m_onlinefirst = true;
m_online_spec_id = "";
} else {
mw_currenturl = m_browserMW->GetCurrentURL();
}
//mw_currenturl.Replace("modelid=", "");
wxString mw_jumpurl = "";
bool b = GetJumpUrl(login, ticket, mw_currenturl, mw_jumpurl);

View File

@ -96,6 +96,7 @@ public:
public:
void ResetWholePage();
void SetMakerworldModelID(std::string ModelID) { m_online_spec_id = ModelID; }
void SwitchWebContent(std::string modelname, int refresh=0);
void SwitchLeftMenu(std::string strMenu);
void OpenOneMakerlab(std::string url);