NEW: Some Feature
1, Add Language in UserAgent of Webview 2, open online model with recommand or browse Param 3, optimize some UI JIRA: none Change-Id: I96a4864ab48e51f5213e43971d276737df12e94d
This commit is contained in:
parent
eb9c334c27
commit
02d228d447
|
@ -217,6 +217,18 @@ body
|
|||
display: none;
|
||||
}
|
||||
|
||||
.JumpIcon
|
||||
{
|
||||
display: none;
|
||||
margin-left:6px;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.BtnItem[menu="makerlab"]:hover .JumpIcon
|
||||
{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.BtnItem:hover
|
||||
{
|
||||
background-color: #E0FCEB;
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
top: 0px;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
left: 0px;
|
||||
left: 0px;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
#RecentTitleBlock
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
<div id="ForU_Models_Bar" class="Title_Bar">
|
||||
<div class="Title_Left_Area">
|
||||
<img class="TitleSmallIcon" src="./img/foru.svg" />
|
||||
<div class="Content-Title trans TextS1" tid="">For You</div>
|
||||
<div class="Content-Title trans TextS1" tid="t107">Online Models</div>
|
||||
</div>
|
||||
<div class="Right_Title_More TextS1" onClick="SwtichLeftMenu('online')"><span class="trans" tid="t108">MORE</span> ></div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M9.93936 0.808459C9.94005 0.611333 9.85937 0.41701 9.71532 0.272961C9.57127 0.128912 9.37913 0.0504131 9.17983 0.0489262L1.80922 0.086108C1.4064 0.0873427 1.09524 0.415955 1.11326 0.816989C1.13128 1.21802 1.46934 1.54346 1.86999 1.54004L7.42585 1.51481L0.268494 8.67216C-0.011402 8.95206 -0.00304711 9.41077 0.287234 9.70105C0.577516 9.99133 1.03623 9.99969 1.31613 9.71979L8.47348 2.56244L8.44396 8.11822C8.44272 8.52105 8.76598 8.85693 9.16701 8.87494C9.56804 8.89296 9.89447 8.57963 9.89789 8.17898L9.93507 0.808381L9.93936 0.808459Z" fill="#6B6B6B"/>
|
||||
</svg>
|
After Width: | Height: | Size: 667 B |
|
@ -58,6 +58,7 @@
|
|||
<div menu="makerlab" class="BtnItem" onClick="GotoMenu('makerlab')">
|
||||
<div class="BtnIcon "><img class="LeftIcon" src="img/left_ml.svg" /></div>
|
||||
<div class="BtnText trans" tid="">Makerlab</div>
|
||||
<div ><img class="JumpIcon" src="img/jump.svg" /></div>
|
||||
<div id="MakerlabNewTag" class="BtnNewIcon">New</div>
|
||||
</div>
|
||||
<div menu="manual" class="BtnItem" onClick="GotoMenu('manual')">
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<script type="text/javascript" src="js/home.js"></script>
|
||||
</head>
|
||||
<body class="ZScrol">
|
||||
<body class="ZScrol" onLoad="TranslatePage()">
|
||||
|
||||
<div id="WikiGuideBoard" >
|
||||
<div class="GuideBlock" onClick="OpenWikiUrl('https://wiki.bambulab.com/en/software/bambu-studio/studio-quick-start')">
|
||||
|
|
|
@ -3143,9 +3143,8 @@ void GUI_App::update_label_colours_from_appconfig()
|
|||
void GUI_App::update_publish_status()
|
||||
{
|
||||
mainframe->show_publish_button(has_model_mall());
|
||||
if (app_config->get("staff_pick_switch") == "true") {
|
||||
mainframe->m_webview->SendDesignStaffpick(has_model_mall());
|
||||
}
|
||||
|
||||
mainframe->m_webview->ResetWholePage();
|
||||
}
|
||||
|
||||
bool GUI_App::has_model_mall()
|
||||
|
|
|
@ -112,7 +112,11 @@ WebViewPanel::WebViewPanel(wxWindow *parent)
|
|||
m_onlinefirst = false;
|
||||
m_online_spec_id = "";
|
||||
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();
|
||||
|
||||
|
||||
wxString language_code = wxGetApp().current_language_code().BeforeFirst('_');
|
||||
language_code = language_code.ToStdString();
|
||||
std::string mwurl = (boost::format("%1%%2%/studio/webview?from=bambustudio") % host % language_code.mb_str()).str();
|
||||
//std::string mwurl = (boost::format("%1%?from=bambustudio") % host).str();
|
||||
m_browserMW = WebView::CreateWebView(this, mwurl);
|
||||
if (m_browserMW == nullptr) {
|
||||
|
@ -269,6 +273,10 @@ WebViewPanel::~WebViewPanel()
|
|||
BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << " End";
|
||||
}
|
||||
|
||||
void WebViewPanel::ResetWholePage()
|
||||
{
|
||||
if (m_browserLeft != nullptr) m_browserLeft->Reload();
|
||||
}
|
||||
|
||||
void WebViewPanel::load_url(wxString& url)
|
||||
{
|
||||
|
@ -520,6 +528,7 @@ void WebViewPanel::SendDesignStaffpick(bool on)
|
|||
body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
|
||||
RunScript(wxString::Format("window.postMessage(%s)", body2));
|
||||
|
||||
m_online_type = "browse";
|
||||
//Show Online Menu
|
||||
SetLeftMenuShow("online", 1);
|
||||
});
|
||||
|
@ -536,6 +545,7 @@ void WebViewPanel::SendDesignStaffpick(bool on)
|
|||
body2.insert(1, "\"command\": \"modelmall_model_customized_get\", ");
|
||||
RunScript(wxString::Format("window.postMessage(%s)", body2));
|
||||
|
||||
m_online_type = "recommend";
|
||||
//Show Online Menu
|
||||
SetLeftMenuShow("online", 1);
|
||||
});
|
||||
|
@ -558,6 +568,7 @@ void WebViewPanel::SendDesignStaffpick(bool on)
|
|||
body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
|
||||
RunScript(wxString::Format("window.postMessage(%s)", body2));
|
||||
|
||||
m_online_type = "browse";
|
||||
//Show Online Menu
|
||||
SetLeftMenuShow("online", 1);
|
||||
});
|
||||
|
@ -567,6 +578,9 @@ void WebViewPanel::SendDesignStaffpick(bool on)
|
|||
std::string body2 = "{\"total\":0, \"hits\":[]}";
|
||||
body2.insert(1, "\"command\": \"modelmall_model_advise_get\", ");
|
||||
RunScript(wxString::Format("window.postMessage(%s)", body2));
|
||||
|
||||
m_online_type = "";
|
||||
SetLeftMenuShow("online", 0);
|
||||
}
|
||||
} catch (nlohmann::detail::parse_error &err) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse got a nlohmann::detail::parse_error, reason = " << err.what();
|
||||
|
@ -796,6 +810,7 @@ void WebViewPanel::SetMakerworldPageLoginStatus(bool login ,wxString ticket)
|
|||
|
||||
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_jumpurl = "";
|
||||
|
||||
bool b = GetJumpUrl(login, ticket, mw_currenturl, mw_jumpurl);
|
||||
|
@ -1236,7 +1251,7 @@ void WebViewPanel::OnError(wxWebViewEvent& evt)
|
|||
wxLogMessage("%s", "Error; url='" + evt.GetURL() + "', error='" + category + " (" + evt.GetString() + ")'");
|
||||
|
||||
// Show the info bar with an error
|
||||
m_info->ShowMessage(_L("An error occurred loading ") + evt.GetURL() + "\n" + "'" + category + "'", wxICON_ERROR);
|
||||
//m_info->ShowMessage(_L("An error occurred loading ") + evt.GetURL() + "\n" + "'" + category + "'", wxICON_ERROR);
|
||||
}
|
||||
|
||||
if (evt.GetInt() == wxWEBVIEW_NAV_ERR_CONNECTION && evt.GetId() == m_browserMW->GetId())
|
||||
|
@ -1300,10 +1315,16 @@ void WebViewPanel::SwitchWebContent(std::string modelname,int refresh)
|
|||
if (m_online_spec_id != "")
|
||||
{
|
||||
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
|
||||
std::string mwurl = (boost::format("%1%studio/webview?modelid=%2%&from=bambustudio") % host % m_online_spec_id).str();
|
||||
|
||||
wxString language_code = wxGetApp().current_language_code().BeforeFirst('_');
|
||||
language_code = language_code.ToStdString();
|
||||
|
||||
std::string mwurl = (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_browserMW->LoadURL(mwurl);
|
||||
m_browserMW->Show();
|
||||
m_browser->Hide();
|
||||
|
||||
m_online_spec_id = "";
|
||||
}
|
||||
|
@ -1326,7 +1347,7 @@ void WebViewPanel::SwitchWebContent(std::string modelname,int refresh)
|
|||
GetSizer()->Layout();
|
||||
|
||||
// conf save
|
||||
wxGetApp().app_config->set_str("homepage", "makerlab_clicked", "1");
|
||||
wxGetApp().app_config->set_str("homepage", "online_clicked", "1");
|
||||
wxGetApp().app_config->save();
|
||||
}
|
||||
else if (modelname.compare("home") == 0 || modelname.compare("recent") == 0 || modelname.compare("manual") == 0 )
|
||||
|
|
|
@ -94,6 +94,8 @@ public:
|
|||
void OnFreshLoginStatus(wxTimerEvent &event);
|
||||
|
||||
public:
|
||||
void ResetWholePage();
|
||||
|
||||
void SwitchWebContent(std::string modelname, int refresh=0);
|
||||
void SwitchLeftMenu(std::string strMenu);
|
||||
void OpenOneMakerlab(std::string url);
|
||||
|
@ -130,8 +132,9 @@ private:
|
|||
wxWebView* m_browserLeft;
|
||||
wxWebView * m_browserMW;
|
||||
std::string m_contentname;
|
||||
bool m_onlinefirst;
|
||||
std::string m_online_spec_id;
|
||||
bool m_onlinefirst; //Online Page First Load
|
||||
std::string m_online_spec_id; //Online Page Spec_ID
|
||||
wxString m_online_type; //recommend & browse
|
||||
|
||||
wxBoxSizer *bSizer_toolbar;
|
||||
wxButton * m_button_back;
|
||||
|
|
|
@ -207,9 +207,13 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
|||
#endif
|
||||
if (webView) {
|
||||
webView->SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE));
|
||||
|
||||
wxString language_code = Slic3r::GUI::wxGetApp().current_language_code().BeforeFirst('_');
|
||||
language_code = language_code.ToStdString();
|
||||
#ifdef __WIN32__
|
||||
webView->SetUserAgent(wxString::Format("BBL-Slicer/v%s (%s) Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.52", SLIC3R_VERSION,
|
||||
webView->SetUserAgent(wxString::Format("BBL-Slicer/v%s BBL-Language/%s (%s) Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.52",
|
||||
SLIC3R_VERSION, language_code.mb_str(),
|
||||
Slic3r::GUI::wxGetApp().dark_mode() ? "dark" : "light"));
|
||||
webView->Create(parent, wxID_ANY, url2, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
// We register the wxfs:// protocol for testing purposes
|
||||
|
@ -222,7 +226,8 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
|||
// And the memory: file system
|
||||
webView->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));
|
||||
webView->Create(parent, wxID_ANY, url2, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE);
|
||||
webView->SetUserAgent(wxString::Format("BBL-Slicer/v%s (%s) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)", SLIC3R_VERSION,
|
||||
webView->SetUserAgent(wxString::Format("BBL-Slicer/v%s BBL-Language/%s (%s) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)",
|
||||
SLIC3R_VERSION, language_code.mb_str(),
|
||||
Slic3r::GUI::wxGetApp().dark_mode() ? "dark" : "light"));
|
||||
#endif
|
||||
#ifdef __WXMAC__
|
||||
|
@ -312,8 +317,11 @@ bool WebView::RunScript(wxWebView *webView, wxString const &javascript)
|
|||
void WebView::RecreateAll()
|
||||
{
|
||||
auto dark = Slic3r::GUI::wxGetApp().dark_mode();
|
||||
wxString language_code = Slic3r::GUI::wxGetApp().current_language_code().BeforeFirst('_');
|
||||
language_code = language_code.ToStdString();
|
||||
for (auto webView : g_webviews) {
|
||||
webView->SetUserAgent(wxString::Format("BBL-Slicer/v%s (%s) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)", SLIC3R_VERSION,
|
||||
webView->SetUserAgent(wxString::Format("BBL-Slicer/v%s BBL-Language/%s (%s) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)",
|
||||
SLIC3R_VERSION, language_code.mb_str(),
|
||||
dark ? "dark" : "light"));
|
||||
webView->Reload();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue