diff --git a/resources/web/data/text.js b/resources/web/data/text.js
index 4822d901c..775740621 100644
--- a/resources/web/data/text.js
+++ b/resources/web/data/text.js
@@ -115,7 +115,8 @@ var LangText={
"t121": "Search",
"t122": "Search online models",
"t123": "Plate",
- "t124": ""
+ "t124": "",
+ "t125": "Maker’s Supply"
},
"zh_CN": {
"t1": "欢迎使用Bambu Studio",
@@ -233,7 +234,8 @@ var LangText={
"t121": "搜索",
"t122": "搜索在线模型",
"t123": "第",
- "t124": " 盘",
+ "t124": " 盘",
+ "t125": "创客宝库",
"wk1": "快速入门指南",
"wk2": "本文介绍了Bambu Studio的最基本用法。它指导用户配置软件,创建项目,并逐步完成第一个打印任务。",
"wk3": "基于项目的工作流",
diff --git a/resources/web/homepage3/img/left_ms.svg b/resources/web/homepage3/img/left_ms.svg
new file mode 100644
index 000000000..299e48a57
--- /dev/null
+++ b/resources/web/homepage3/img/left_ms.svg
@@ -0,0 +1,21 @@
+
diff --git a/resources/web/homepage3/js/left.js b/resources/web/homepage3/js/left.js
index a40f7adf3..6538f32df 100644
--- a/resources/web/homepage3/js/left.js
+++ b/resources/web/homepage3/js/left.js
@@ -70,7 +70,7 @@ function GotoMenu( strMenu )
{
ShowMenuNewTag(strMenu,0);
- if(NowMenu==strMenu && strMenu!='makerlab')
+ if(NowMenu==strMenu && strMenu!='makersupply')
return;
NowMenu=strMenu;
@@ -84,7 +84,7 @@ function GotoMenu( strMenu )
if( $(OneBtn).attr("menu")==strMenu )
{
- //if(strMenu!=='makerlab')
+ if(strMenu!=='makersupply')
{
$(".BtnItem").removeClass("BtnItemSelected");
$(OneBtn).addClass("BtnItemSelected");
diff --git a/resources/web/homepage3/js/test.js b/resources/web/homepage3/js/test.js
index e29e92c98..e24661e27 100644
--- a/resources/web/homepage3/js/test.js
+++ b/resources/web/homepage3/js/test.js
@@ -91,8 +91,8 @@ var Test_PrintTaskList={
"weight": 0
}
],
- "mode": "cloud_slice",
- "isPublicProfile": true,
+ "mode": "user_slice",
+ "isPublicProfile": false,
"isPrintable": true,
"isDelete": false,
"deviceModel": "X1E",
diff --git a/resources/web/homepage3/left.html b/resources/web/homepage3/left.html
index 4056abf92..901ee9b78 100644
--- a/resources/web/homepage3/left.html
+++ b/resources/web/homepage3/left.html
@@ -59,6 +59,10 @@
MakerLab
New
+
Print History
diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp
index 12874ed3e..70ed80aa0 100644
--- a/src/slic3r/GUI/GUI_App.cpp
+++ b/src/slic3r/GUI/GUI_App.cpp
@@ -4324,34 +4324,49 @@ std::string GUI_App::handle_web_request(std::string cmd)
if (mainframe && mainframe->m_webview) {
mainframe->m_webview->ShowUserPrintTask(true);
}
- }
+ }
else if (command_str.compare("homepage_leftmenu_change_width") == 0) {
int NewWidth = 214;
if (root.get_child_optional("width") != boost::none) NewWidth = root.get
("width");
- if (mainframe && mainframe->m_webview)
- {
- mainframe->m_webview->SetLeftMenuWidth(NewWidth);
+ if (mainframe && mainframe->m_webview)
+ {
+ mainframe->m_webview->SetLeftMenuWidth(NewWidth);
mainframe->m_webview->Layout();
}
- }
+ }
else if (command_str.compare("homepage_makerlab_open_3mf_binary") == 0) {
if (root.get_child_optional("3mf") != boost::none) {
std::string str3MFBase64 = root.get_optional("3mf").value();
std::string str3MFName = "makerlab";
- if (root.get_child_optional("3mf_name") != boost::none)
- {
+ if (root.get_child_optional("3mf_name") != boost::none)
+ {
std::string strTmp = from_u8(root.get_optional("3mf_name").value()).ToStdString();
if (strTmp != "") str3MFName = strTmp;
}
- if (mainframe && mainframe->m_webview)
- {
+ if (mainframe && mainframe->m_webview)
+ {
mainframe->m_webview->OpenMakerlab3mf(str3MFBase64,str3MFName);
}
}
}
+ else if (command_str.compare("homepage_makerlab_stl_download")==0)
+ {
+ if (root.get_child_optional("file_data") != boost::none && root.get_child_optional("sequence_id") != boost::none) {
+ int SeqID = root.get_optional("sequence_id").value();
+ std::string strSTLBase64 = root.get_optional("file_data").value();
+
+ std::string strSTLName = "makerlab";
+ if (root.get_child_optional("file_name") != boost::none) {
+ std::string strTmp = from_u8(root.get_optional("file_name").value()).ToStdString();
+ if (strTmp != "") strSTLName = strTmp;
+ }
+
+ if (mainframe && mainframe->m_webview) { mainframe->m_webview->SaveMakerlabStl(SeqID,strSTLBase64, strSTLName); }
+ }
+ }
}
}
catch (...) {
diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp
index 330a2c081..d95799553 100644
--- a/src/slic3r/GUI/WebViewDialog.cpp
+++ b/src/slic3r/GUI/WebViewDialog.cpp
@@ -536,16 +536,15 @@ void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event)
{
m_loginstatus = 1;
- if (m_onlinefirst)
- {
+ if (m_onlinefirst)
+ {
UpdateMakerworldLoginStatus();
- }
+ }
- if (m_MakerLabFirst)
- {
+ if (m_MakerLabFirst)
+ {
SetMakerlabUrl("");
- m_browserML->LoadURL(m_MakerLab_LastUrl);
- m_MakerLab_LastUrl = "";
+ UpdateMakerlabStatus();
}
}
@@ -563,8 +562,7 @@ void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event)
if (m_MakerLabFirst) {
SetMakerlabUrl("");
- m_browserML->LoadURL(m_MakerLab_LastUrl);
- m_MakerLab_LastUrl = "";
+ UpdateMakerlabStatus();
}
}
@@ -818,19 +816,6 @@ void WebViewPanel::SetMakerlabUrl(std::string url) {
LabUrl = (boost::format("%1%%2%?from=bambustudio") % host % url).str();
m_MakerLab_LastUrl = LabUrl;
- NetworkAgent *agent = GUI::wxGetApp().getAgent();
- if (!agent) return;
-
- if (agent->is_user_login()) {
- std::string newticket;
- int ret = agent->request_bind_ticket(&newticket);
- if (ret == 0) {
- GetJumpUrl(true, newticket, m_MakerLab_LastUrl, m_MakerLab_LastUrl);
- } else
- return;
- } else {
- GetJumpUrl(false, "", m_MakerLab_LastUrl, m_MakerLab_LastUrl);
- }
}
void WebViewPanel::OpenOneMakerlab(std::string url)
@@ -838,15 +823,13 @@ void WebViewPanel::OpenOneMakerlab(std::string url)
NetworkAgent *agent = GUI::wxGetApp().getAgent();
if (!agent) return;
- if (!agent->is_user_login()) wxGetApp().ShowUserLogin(true);
+ //if (!agent->is_user_login()) {
+ // wxGetApp().CallAfter([this] { wxGetApp().handle_web_request("{\"sequence_id\":1,\"command\":\"homepage_login_or_register\"}"); });
+ //}
- if (agent->is_user_login()) {
- SetMakerlabUrl(url);
+ SetMakerlabUrl(url);
+ SwitchLeftMenu("makerlab");
- SwitchLeftMenu("makerlab");
- } else {
- return;
- }
}
std::string GenerateRandomString(int length)
@@ -860,23 +843,28 @@ std::string GenerateRandomString(int length)
return randomString;
}
-void WebViewPanel::OpenMakerlab3mf(std::string Base64Buf, std::string FileName)
-{
+bool WebViewPanel::SaveBase64ToLocal(std::string Base64Buf, std::string FileName, std::string FileTail, wxString &download_path, wxString &download_file)
+{
int nSize = wxBase64DecodedSize(Base64Buf.length());
- char *DstBuf = new char[nSize+1];
+ char *DstBuf = new char[nSize + 1];
+ if (!DstBuf)
+ {
+ BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": New Failed. Memory Not Enough";
+ return false;
+ }
memset(DstBuf, 0, nSize + 1);
- int nWrite=wxBase64Decode(DstBuf, nSize+1, Base64Buf.c_str(), Base64Buf.length());
+ int nWrite = wxBase64Decode(DstBuf, nSize + 1, Base64Buf.c_str(), Base64Buf.length());
// Format Time String
std::time_t currentTime = std::time(nullptr);
std::tm *timeInfo = std::localtime(¤tTime);
- int year = timeInfo->tm_year % 100;
- int month = timeInfo->tm_mon + 1;
- int day = timeInfo->tm_mday;
- int hour = timeInfo->tm_hour;
- int minute = timeInfo->tm_min;
- int second = timeInfo->tm_sec;
+ int year = timeInfo->tm_year % 100;
+ int month = timeInfo->tm_mon + 1;
+ int day = timeInfo->tm_mday;
+ int hour = timeInfo->tm_hour;
+ int minute = timeInfo->tm_min;
+ int second = timeInfo->tm_sec;
std::stringstream ss;
ss << std::setfill('0') << std::setw(2) << year << std::setw(2) << month << std::setw(2) << day << std::setw(2) << hour << std::setw(2) << minute << std::setw(2) << second;
@@ -886,20 +874,20 @@ void WebViewPanel::OpenMakerlab3mf(std::string Base64Buf, std::string FileName)
char separator = boost::filesystem::path::preferred_separator;
std::string separatorStr(1, separator);
- wxString download_path = wxString::FromUTF8(wxGetApp().app_config->get("download_path"));
- wxString download_file = download_path + separatorStr + FileName + "_" + ss.str() + "_" + GenerateRandomString(4) + ".3mf";
+ download_path = wxString::FromUTF8(wxGetApp().app_config->get("download_path"));
+ download_file = download_path + separatorStr + FileName + "_" + ss.str() + "_" + GenerateRandomString(4) + "."+ FileTail;
std::ofstream outFile(download_file.ToStdString(), std::ios::binary);
if (!outFile) {
delete DstBuf;
std::cerr << "Error opening file for writing." << std::endl;
- return;
+ return false;
}
outFile.write(DstBuf, nWrite);
if (!outFile) {
delete DstBuf;
std::cerr << "Error writing to file." << std::endl;
- return;
+ return false;
}
delete DstBuf;
@@ -907,14 +895,91 @@ void WebViewPanel::OpenMakerlab3mf(std::string Base64Buf, std::string FileName)
std::cout << "Data written to file successfully." << std::endl;
wxLogMessage("Makerlab Binary Write to %s", download_file.ToStdString());
+ return true;
+}
+
+void WebViewPanel::OpenMakerlab3mf(std::string Base64Buf, std::string FileName)
+{
+ //Save
+ wxString SavePath, SaveFile;
+ bool bRet = SaveBase64ToLocal(Base64Buf, FileName, "3mf", SavePath, SaveFile);
+ if (!bRet) return;
+
//Open File
- download_file = download_file.utf8_string();
- wxGetApp().request_open_project(download_file.ToStdString());
+ SaveFile = SaveFile.utf8_string();
+ wxGetApp().request_open_project(SaveFile.ToStdString());
//Remove File
//boost::filesystem::remove(download_file.ToStdString());
}
+void WebViewPanel::SaveMakerlabStl(int SequenceID, std::string Base64Buf, std::string FileName)
+{
+ // Save
+ wxString SavePath, SaveFile;
+ bool bRet = SaveBase64ToLocal(Base64Buf, FileName, "stl", SavePath, SaveFile);
+
+ // Response
+ json JFile;
+ JFile["sequence_id"] = SequenceID;
+ JFile["command"] = "homepage_makerlab_stl_download";
+ JFile["file_name"] = FileName;
+ JFile["result"] = bRet ? "success" : "fail";
+
+ std::string strJS = JFile.dump(-1, ' ', false, json::error_handler_t::ignore);
+
+ wxGetApp().CallAfter([this, strJS] {
+ if (!m_browserML) return;
+
+ WebView::RunScript(m_browserML, strJS);
+ });
+}
+
+void WebViewPanel::UpdateMakerlabStatus( )
+{
+ if (m_browserML == nullptr) return;
+
+ wxString ml_currenturl;
+ if (m_MakerLab_LastUrl != "") {
+ ml_currenturl = m_MakerLab_LastUrl;
+ } else {
+ ml_currenturl = m_browserML->GetCurrentURL();
+ if (ml_currenturl == "about:blank") {
+ SetMakerlabUrl("");
+ ml_currenturl = m_MakerLab_LastUrl;
+ }
+ }
+
+ if (wxGetApp().is_user_login())
+ {
+ NetworkAgent *agent = GUI::wxGetApp().getAgent();
+ if (agent == nullptr) {
+ wxString UrlDisconnect = MakeDisconnectUrl("makerlab");
+ m_browserML->LoadURL(UrlDisconnect);
+ return;
+ }
+
+ std::string newticket;
+ int ret = agent->request_bind_ticket(&newticket);
+ if (ret == 0)
+ {
+ GetJumpUrl(login, newticket, ml_currenturl, ml_currenturl);
+ m_browserML->LoadURL(ml_currenturl);
+ m_MakerLab_LastUrl = "";
+ }
+ else {
+ wxString UrlDisconnect = MakeDisconnectUrl("makerlab");
+ m_browserML->LoadURL(UrlDisconnect);
+ }
+ }
+ else
+ {
+ GetJumpUrl(false, "", ml_currenturl, ml_currenturl);
+ m_browserML->LoadURL(ml_currenturl);
+ m_MakerLab_LastUrl = "";
+ }
+}
+
unsigned char ToHex(unsigned char x) { return x > 9 ? x + 55 : x + 48; }
unsigned char FromHex(unsigned char x)
@@ -1658,27 +1723,29 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh)
wxString strlang = wxGetApp().current_language_code_safe();
- if (modelname.compare("makerlab") == 0)
+ if (modelname.compare("makersupply") == 0)
+ {
+ std::string strRegion = wxGetApp().app_config->get_country_code();
+ wxString MakerSupplyUrl;
+ if (strRegion == "CN")
+ MakerSupplyUrl = "https://bambulab.tmall.com/category-1761686934.htm?from=bambustudio";
+ else
+ MakerSupplyUrl = "https://store.bambulab.com/collections/makers-supply?from=bambustudio";
+
+ wxLaunchDefaultBrowser(MakerSupplyUrl);
+ }
+ else if (modelname.compare("makerlab") == 0)
{
wxString FinalUrl;
- if (!m_MakerLabFirst)
- {
- if (m_MakerLab_LastUrl != "")
- FinalUrl = m_MakerLab_LastUrl;
- else
- {
- SetMakerlabUrl("");
-
- FinalUrl = m_MakerLab_LastUrl;
- }
- }
+ if (!m_MakerLabFirst)
+ {
+ UpdateMakerlabStatus();
+ }
else {
- if (m_MakerLab_LastUrl != "")
- FinalUrl = m_MakerLab_LastUrl;
+ if (m_MakerLab_LastUrl != "") m_browserML->LoadURL(m_MakerLab_LastUrl);
}
- m_browserML->LoadURL(FinalUrl);
m_MakerLabFirst = true;
m_MakerLab_LastUrl = "";
diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp
index ad0665b08..d5525caeb 100644
--- a/src/slic3r/GUI/WebViewDialog.hpp
+++ b/src/slic3r/GUI/WebViewDialog.hpp
@@ -143,6 +143,9 @@ public:
void SetMakerlabUrl(std::string url);
void OpenOneMakerlab(std::string url);
void OpenMakerlab3mf(std::string Base64Buf, std::string FileName);
+ bool SaveBase64ToLocal(std::string Base64Buf, std::string FileName,std::string FileTail, wxString &download_path, wxString &download_file);
+ void SaveMakerlabStl(int SequenceID,std::string Base64Buf, std::string FileName);
+ void UpdateMakerlabStatus();
//Common UI
void SetWebviewShow(wxString name, bool show);