NEW: Home Add Makerlab page
JIRA: none Change-Id: Ia842b7de9bd452bdcb5fd6d7e009961b8c04584d (cherry picked from commit 27590be491caeffd3c95ce6becb52cacfb7a174c)
This commit is contained in:
parent
ada57e7175
commit
6fe4d54ca2
|
@ -94,6 +94,7 @@ html, body {
|
|||
display:flex;
|
||||
margin-bottom: 24px;
|
||||
flex-direction:row-reverse;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#MenuBtnBlock
|
||||
|
|
|
@ -86,6 +86,12 @@ html,body
|
|||
box-shadow: 0px 0px 3px #DCDCDC;
|
||||
}
|
||||
|
||||
#HotModel_Search_Btn img
|
||||
{
|
||||
filter: brightness(78%);
|
||||
}
|
||||
|
||||
|
||||
/*----User Manual------*/
|
||||
.UG_DESC
|
||||
{
|
||||
|
@ -116,18 +122,17 @@ html,body
|
|||
|
||||
#HotModel_Search_Bar
|
||||
{
|
||||
border: 1px solid #323A3D;
|
||||
background-color: #36363A;
|
||||
border: 1px solid #5C5C5C;
|
||||
background-color: #242428;
|
||||
}
|
||||
|
||||
#HotModel_Search_InputArea
|
||||
{
|
||||
background-color: #36363A;
|
||||
}
|
||||
|
||||
#HotModel_Search_Input
|
||||
{
|
||||
background-color: #36363A;
|
||||
background-color: #242428;
|
||||
caret-color: white;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
@ -154,3 +159,16 @@ html,body
|
|||
{
|
||||
filter: invert(80%) brightness(20);
|
||||
}
|
||||
|
||||
/*-----Hide Button-----*/
|
||||
#HideBtn
|
||||
{
|
||||
background-image: url('../img/arrow_light_left.svg');
|
||||
border: 1px solid rgba(48, 48, 51, 1);
|
||||
background-color: rgba(48, 48, 51, 1);
|
||||
}
|
||||
|
||||
#HideBtn:hover
|
||||
{
|
||||
background-color: rgba(70, 70, 71, 1);
|
||||
}
|
||||
|
|
|
@ -97,14 +97,10 @@ body
|
|||
display: flex;
|
||||
justify-content: center;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
#LoginBtn
|
||||
{
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
#LoginBtn:hover
|
||||
#Login1:hover #LoginBtn
|
||||
{
|
||||
font-size:17px;
|
||||
}
|
||||
|
@ -220,19 +216,6 @@ body
|
|||
display: none;
|
||||
}
|
||||
|
||||
|
||||
.JumpIcon
|
||||
{
|
||||
display: none;
|
||||
margin-left:6px;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.BtnItem[menu="makerlab"]:hover .JumpIcon
|
||||
{
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.BtnItem:hover
|
||||
{
|
||||
background-color: #E0FCEB;
|
||||
|
@ -278,3 +261,27 @@ body
|
|||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/*-----Hide Button-----*/
|
||||
#HideBtn
|
||||
{
|
||||
position: absolute;
|
||||
height: 60px;
|
||||
width: 12px;
|
||||
right: 1px;
|
||||
top: calc(50% - 30px);
|
||||
cursor: pointer;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-image: url('../img/arrow_dark_left.svg');
|
||||
border-left: 1px solid rgba(238, 238, 238, 1);
|
||||
border-top: 1px solid rgba(238, 238, 238, 1);
|
||||
border-bottom: 1px solid rgba(238, 238, 238, 1);
|
||||
border-radius: 4px 0px 0px 4px;
|
||||
}
|
||||
|
||||
#HideBtn:hover
|
||||
{
|
||||
background-color: rgba(238, 238, 238, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
/*----Login----*/
|
||||
#LoginBtn
|
||||
{
|
||||
display:none;
|
||||
}
|
||||
|
||||
#Icon1
|
||||
{
|
||||
margin-right: 0px;
|
||||
}
|
||||
|
||||
#UserAvatarIcon
|
||||
{
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
#UserName
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
#LogoutBtn
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.BtnItem
|
||||
{
|
||||
padding: 0px;
|
||||
justify-content:center;
|
||||
}
|
||||
|
||||
.BtnText
|
||||
{
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.BtnIcon
|
||||
{
|
||||
margin:0px;
|
||||
}
|
||||
|
||||
#NoPluginTip
|
||||
{
|
||||
display:none!important;
|
||||
}
|
||||
/*-----Left Menu-------*/
|
||||
.JumpIcon
|
||||
{
|
||||
display: none!important;
|
||||
}
|
||||
|
||||
.BtnNewIcon
|
||||
{
|
||||
display: none!important;
|
||||
}
|
||||
|
||||
/*-----Hide Button-----*/
|
||||
#HideBtn
|
||||
{
|
||||
transform: scaleX(-1);
|
||||
border-radius: 0px 4px 4px 0px;
|
||||
}
|
|
@ -167,14 +167,15 @@
|
|||
display: none;
|
||||
align-items: center;
|
||||
border-radius: 22px;
|
||||
border: 1px solid #EEEEEE;
|
||||
border: 1px solid #C2C2C2;
|
||||
flex-grow: 1;
|
||||
background-color: #FFFFFF;
|
||||
background-color: #F7F7F7;
|
||||
padding-right: 12px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
#HotModel_Search_InputArea
|
||||
{
|
||||
background-color: #FFF;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
|
@ -188,6 +189,7 @@
|
|||
flex-grow: 1;
|
||||
outline: none;
|
||||
font-size: 16px;
|
||||
background-color: #F7F7F7;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<svg width="8" height="13" viewBox="0 0 8 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7 0.857422L4.23097 5.29941C3.82728 5.94699 3.82728 6.76785 4.23097 7.41544L7 11.8574" stroke="#828282" stroke-linecap="round"/>
|
||||
<path d="M4.42859 0.857422L1.65956 5.29941C1.25587 5.94699 1.25587 6.76785 1.65956 7.41544L4.42859 11.8574" stroke="#828282" stroke-linecap="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 389 B |
|
@ -0,0 +1,4 @@
|
|||
<svg width="8" height="13" viewBox="0 0 8 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1 1L3.76903 5.44198C4.17272 6.08957 4.17272 6.91043 3.76903 7.55802L1 12" stroke="#828282" stroke-linecap="round"/>
|
||||
<path d="M3.57144 1L6.34047 5.44198C6.74416 6.08957 6.74416 6.91043 6.34047 7.55802L3.57144 12" stroke="#828282" stroke-linecap="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 365 B |
|
@ -0,0 +1,4 @@
|
|||
<svg width="8" height="13" viewBox="0 0 8 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7 0.652344L4.23097 5.09433C3.82728 5.74191 3.82728 6.56278 4.23097 7.21036L7 11.6523" stroke="#ACACAC" stroke-linecap="round"/>
|
||||
<path d="M4.42859 0.652344L1.65956 5.09433C1.25587 5.74191 1.25587 6.56278 1.65956 7.21036L4.42859 11.6523" stroke="#ACACAC" stroke-linecap="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 389 B |
|
@ -0,0 +1,4 @@
|
|||
<svg width="8" height="13" viewBox="0 0 8 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1 0.652344L3.76903 5.09433C4.17272 5.74191 4.17272 6.56278 3.76903 7.21036L1 11.6523" stroke="#ACACAC" stroke-linecap="round"/>
|
||||
<path d="M3.57141 0.652344L6.34044 5.09433C6.74413 5.74191 6.74413 6.56278 6.34044 7.21036L3.57141 11.6523" stroke="#ACACAC" stroke-linecap="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 389 B |
|
@ -84,7 +84,7 @@ function GotoMenu( strMenu )
|
|||
|
||||
if( $(OneBtn).attr("menu")==strMenu )
|
||||
{
|
||||
if(strMenu!=='makerlab')
|
||||
//if(strMenu!=='makerlab')
|
||||
{
|
||||
$(".BtnItem").removeClass("BtnItemSelected");
|
||||
$(OneBtn).addClass("BtnItemSelected");
|
||||
|
@ -220,5 +220,21 @@ function BeginDownloadNetworkPlugin()
|
|||
SendWXMessage( JSON.stringify(tSend) );
|
||||
}
|
||||
|
||||
var WidthBoundary=168;
|
||||
function ChangeLeftWidth()
|
||||
{
|
||||
var tSend={};
|
||||
tSend['sequence_id']=Math.round(new Date() / 1000);
|
||||
tSend['command']="homepage_leftmenu_change_width";
|
||||
|
||||
let NowWidth=window.innerWidth;
|
||||
if(NowWidth<=WidthBoundary)
|
||||
tSend['width']=224;
|
||||
else
|
||||
tSend['width']=64;
|
||||
|
||||
SendWXMessage( JSON.stringify(tSend) );
|
||||
}
|
||||
|
||||
//---------------Global-----------------
|
||||
window.postMessage = HandleStudio;
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Cache-Control" content="max-age=7200" />
|
||||
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,user-scalable=no">
|
||||
<title>homepage</title>
|
||||
<link rel="stylesheet" type="text/css" href="./css/common.css" />
|
||||
<link rel="stylesheet" type="text/css" href="./css/left.css" />
|
||||
<link rel="stylesheet" type="text/css" href="./css/left_mini.css" media="screen and (max-width: 168px)" />
|
||||
<link rel="stylesheet" type="text/css" href="./css/dark.css" />
|
||||
|
||||
<script type="text/javascript" src="../include/jquery-2.1.1.min.js"></script>
|
||||
|
@ -20,9 +21,9 @@
|
|||
<body class="ZScrol" onLoad="OnInit()">
|
||||
<div id="LeftBoard">
|
||||
<div id="LoginArea">
|
||||
<div id="Login1">
|
||||
<div id="Login1" onClick="OnLoginOrRegister()">
|
||||
<div id="Icon1"><img id="BBLIcon" src="../image/logo2.png" /></div>
|
||||
<div id="LoginBtn" class="TextS1" style="font-weight: 700;" onClick="OnLoginOrRegister()"><span class="trans" tid="t26">login</span>/<span class="trans" tid="t27">register</span></div>
|
||||
<div id="LoginBtn" class="TextS1" style="font-weight: 700;"><span class="trans" tid="t26">login</span>/<span class="trans" tid="t27">register</span></div>
|
||||
</div>
|
||||
|
||||
<div id="Login2">
|
||||
|
@ -56,7 +57,6 @@
|
|||
<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="printhistory" class="BtnItem" onClick="GotoMenu('printhistory')">
|
||||
|
@ -70,6 +70,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="HideBtn" onClick="ChangeLeftWidth()"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -4081,6 +4081,13 @@ std::string GUI_App::handle_web_request(std::string cmd)
|
|||
#endif
|
||||
}
|
||||
else if (command_str.compare("homepage_login_or_register") == 0) {
|
||||
//Check Plugin
|
||||
bool bValid = is_compatibility_version();
|
||||
if (!bValid) {
|
||||
CallAfter([this] { handle_web_request("{\"sequence_id\":1,\"command\":\"homepage_need_networkplugin\"}");
|
||||
});
|
||||
return "";
|
||||
}
|
||||
|
||||
if (root.get_child_optional("makerworld_model_id") != boost::none) {
|
||||
boost::optional<std::string> ModelID = root.get_optional<std::string>("makerworld_model_id");
|
||||
|
@ -4318,6 +4325,33 @@ std::string GUI_App::handle_web_request(std::string cmd)
|
|||
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<int>("width");
|
||||
|
||||
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<std::string>("3mf").value();
|
||||
|
||||
std::string str3MFName = "makerlab";
|
||||
if (root.get_child_optional("3mf_name") != boost::none)
|
||||
{
|
||||
std::string strTmp = from_u8(root.get_optional<std::string>("3mf_name").value()).ToStdString();
|
||||
if (strTmp != "") str3MFName = strTmp;
|
||||
}
|
||||
|
||||
if (mainframe && mainframe->m_webview)
|
||||
{
|
||||
mainframe->m_webview->OpenMakerlab3mf(str3MFBase64,str3MFName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
#include <boost/beast/core/detail/base64.hpp>
|
||||
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/toolbar.h>
|
||||
|
@ -144,11 +145,22 @@ WebViewPanel::WebViewPanel(wxWindow *parent)
|
|||
SetPrintHistoryTaskID(0);
|
||||
m_printhistoryfirst = false;
|
||||
|
||||
// MakerLab webview
|
||||
m_browserML = WebView::CreateWebView(this, "about:blank");
|
||||
if (m_browserML == nullptr) {
|
||||
wxLogError("Could not init m_browserML");
|
||||
return;
|
||||
}
|
||||
m_browserML->Hide();
|
||||
SetMakerlabUrl("");
|
||||
m_MakerLabFirst = false;
|
||||
|
||||
// Position
|
||||
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);
|
||||
m_home_web->Add(m_browserPH, 1, wxEXPAND | wxALL, 0);
|
||||
m_home_web->Add(m_browserML, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
topsizer->Add(m_home_web,1, wxEXPAND | wxALL, 0);
|
||||
|
||||
|
@ -312,6 +324,10 @@ void WebViewPanel::ResetWholePage()
|
|||
//PrintHistory
|
||||
SetPrintHistoryTaskID(0);
|
||||
m_printhistoryfirst = false;
|
||||
|
||||
//MakerLab
|
||||
m_MakerLabFirst = false;
|
||||
SetMakerlabUrl("");
|
||||
}
|
||||
|
||||
wxString WebViewPanel::MakeDisconnectUrl(std::string MenuName)
|
||||
|
@ -521,7 +537,16 @@ void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event)
|
|||
m_loginstatus = 1;
|
||||
|
||||
if (m_onlinefirst)
|
||||
{
|
||||
UpdateMakerworldLoginStatus();
|
||||
}
|
||||
|
||||
if (m_MakerLabFirst)
|
||||
{
|
||||
SetMakerlabUrl("");
|
||||
m_browserML->LoadURL(m_MakerLab_LastUrl);
|
||||
m_MakerLab_LastUrl = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (m_TaskInfo == "" && m_browser && phShow != "false")
|
||||
|
@ -535,6 +560,12 @@ void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event)
|
|||
|
||||
if (m_onlinefirst)
|
||||
SetMakerworldPageLoginStatus(false);
|
||||
|
||||
if (m_MakerLabFirst) {
|
||||
SetMakerlabUrl("");
|
||||
m_browserML->LoadURL(m_MakerLab_LastUrl);
|
||||
m_MakerLab_LastUrl = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (m_TaskInfo != "" && m_browser) ShowUserPrintTask(false);
|
||||
|
@ -778,6 +809,112 @@ void WebViewPanel::get_makerlab_list(std::function<void(std::string)> callback)
|
|||
.perform();
|
||||
}
|
||||
|
||||
void WebViewPanel::SetMakerlabUrl(std::string url) {
|
||||
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
|
||||
std::string LabUrl;
|
||||
if (url == "")
|
||||
LabUrl = (boost::format("%1%makerlab?from=bambustudio") % host).str();
|
||||
else
|
||||
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)
|
||||
{
|
||||
NetworkAgent *agent = GUI::wxGetApp().getAgent();
|
||||
if (!agent) return;
|
||||
|
||||
if (!agent->is_user_login()) wxGetApp().ShowUserLogin(true);
|
||||
|
||||
if (agent->is_user_login()) {
|
||||
SetMakerlabUrl(url);
|
||||
|
||||
SwitchLeftMenu("makerlab");
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string GenerateRandomString(int length)
|
||||
{
|
||||
std::string randomString;
|
||||
srand(static_cast<unsigned int>(time(nullptr)));
|
||||
for (int i = 0; i < length; ++i) {
|
||||
int randomAscii = rand() % 26 + 65; // 65 - 90的ASCII码范围为可打印字符
|
||||
randomString += static_cast<char>(randomAscii);
|
||||
}
|
||||
return randomString;
|
||||
}
|
||||
|
||||
void WebViewPanel::OpenMakerlab3mf(std::string Base64Buf, std::string FileName)
|
||||
{
|
||||
int nSize = wxBase64DecodedSize(Base64Buf.length());
|
||||
char *DstBuf = new char[nSize+1];
|
||||
memset(DstBuf, 0, nSize + 1);
|
||||
|
||||
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; // 月份范围是0 - 11,需要加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;
|
||||
std::string dateTimeString = ss.str();
|
||||
|
||||
// Write 3MF to Disk
|
||||
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";
|
||||
|
||||
std::ofstream outFile(download_file.ToStdString(), std::ios::binary);
|
||||
if (!outFile) {
|
||||
delete DstBuf;
|
||||
std::cerr << "Error opening file for writing." << std::endl;
|
||||
return;
|
||||
}
|
||||
outFile.write(DstBuf, nWrite);
|
||||
if (!outFile) {
|
||||
delete DstBuf;
|
||||
std::cerr << "Error writing to file." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
delete DstBuf;
|
||||
outFile.close();
|
||||
std::cout << "Data written to file successfully." << std::endl;
|
||||
wxLogMessage("Makerlab Binary Write to %s", download_file.ToStdString());
|
||||
|
||||
//Open File
|
||||
download_file = download_file.utf8_string();
|
||||
wxGetApp().request_open_project(download_file.ToStdString());
|
||||
|
||||
//Remove File
|
||||
//boost::filesystem::remove(download_file.ToStdString());
|
||||
}
|
||||
|
||||
unsigned char ToHex(unsigned char x) { return x > 9 ? x + 55 : x + 48; }
|
||||
|
||||
unsigned char FromHex(unsigned char x)
|
||||
|
@ -1431,6 +1568,7 @@ void WebViewPanel::OnError(wxWebViewEvent& evt)
|
|||
wxString UrlDisconnect = MakeDisconnectUrl("online");
|
||||
m_browserMW->LoadURL(UrlDisconnect);
|
||||
|
||||
SetWebviewShow("makerlab", false);
|
||||
SetWebviewShow("online", true);
|
||||
SetWebviewShow("right", false);
|
||||
SetWebviewShow("printhistory", false);
|
||||
|
@ -1446,12 +1584,29 @@ void WebViewPanel::OnError(wxWebViewEvent& evt)
|
|||
wxString UrlDisconnect = MakeDisconnectUrl("printhistory");
|
||||
m_browserPH->LoadURL(UrlDisconnect);
|
||||
|
||||
SetWebviewShow("makerlab", false);
|
||||
SetWebviewShow("printhistory", true);
|
||||
SetWebviewShow("online", false);
|
||||
SetWebviewShow("right", false);
|
||||
}
|
||||
}
|
||||
|
||||
if (evt.GetInt() == wxWEBVIEW_NAV_ERR_CONNECTION && evt.GetId() == m_browserML->GetId()) {
|
||||
m_MakerLab_LastUrl = m_browserML->GetCurrentURL();
|
||||
|
||||
if (m_contentname == "makerlab") {
|
||||
wxString errurl = evt.GetURL();
|
||||
|
||||
wxString UrlDisconnect = MakeDisconnectUrl("makerlab");
|
||||
m_browserML->LoadURL(UrlDisconnect);
|
||||
|
||||
SetWebviewShow("makerlab", true);
|
||||
SetWebviewShow("printhistory", false);
|
||||
SetWebviewShow("online", false);
|
||||
SetWebviewShow("right", false);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
|
@ -1503,21 +1658,34 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh)
|
|||
|
||||
wxString strlang = wxGetApp().current_language_code_safe();
|
||||
|
||||
if (modelname.compare("makerlab") == 0) {
|
||||
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
|
||||
std::string LabUrl = (boost::format("%1%makerlab?from=bambustudio") % host).str();
|
||||
if (modelname.compare("makerlab") == 0)
|
||||
{
|
||||
wxString FinalUrl;
|
||||
|
||||
wxString FinalUrl = LabUrl;
|
||||
NetworkAgent *agent = GUI::wxGetApp().getAgent();
|
||||
if (agent && agent->is_user_login()) {
|
||||
std::string BambuHost=agent->get_bambulab_host();
|
||||
if (!m_MakerLabFirst)
|
||||
{
|
||||
if (m_MakerLab_LastUrl != "")
|
||||
FinalUrl = m_MakerLab_LastUrl;
|
||||
else
|
||||
{
|
||||
SetMakerlabUrl("");
|
||||
|
||||
std::string newticket;
|
||||
int ret = agent->request_bind_ticket(&newticket);
|
||||
if (ret == 0) GetJumpUrl(true, newticket, FinalUrl, FinalUrl);
|
||||
FinalUrl = m_MakerLab_LastUrl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_MakerLab_LastUrl != "")
|
||||
FinalUrl = m_MakerLab_LastUrl;
|
||||
}
|
||||
|
||||
wxLaunchDefaultBrowser(FinalUrl);
|
||||
m_browserML->LoadURL(FinalUrl);
|
||||
m_MakerLabFirst = true;
|
||||
m_MakerLab_LastUrl = "";
|
||||
|
||||
SetWebviewShow("makerlab", true);
|
||||
SetWebviewShow("online", false);
|
||||
SetWebviewShow("right", false);
|
||||
SetWebviewShow("printhistory", false);
|
||||
|
||||
// conf save
|
||||
wxGetApp().app_config->set_str("homepage", "makerlab_clicked", "1");
|
||||
|
@ -1544,11 +1712,10 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh)
|
|||
}
|
||||
|
||||
SetWebviewShow("online", true);
|
||||
SetWebviewShow("makerlab", false);
|
||||
SetWebviewShow("right", false);
|
||||
SetWebviewShow("printhistory", false);
|
||||
|
||||
GetSizer()->Layout();
|
||||
|
||||
// conf save
|
||||
wxGetApp().app_config->set_str("homepage", "online_clicked", "1");
|
||||
wxGetApp().app_config->save();
|
||||
|
@ -1588,8 +1755,7 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh)
|
|||
SetWebviewShow("online", false);
|
||||
SetWebviewShow("right", false);
|
||||
SetWebviewShow("printhistory", true);
|
||||
|
||||
GetSizer()->Layout();
|
||||
SetWebviewShow("makerlab", false);
|
||||
|
||||
} else if (modelname.compare("home") == 0 || modelname.compare("recent") == 0 || modelname.compare("manual") == 0) {
|
||||
if (!m_browser) return;
|
||||
|
@ -1607,9 +1773,10 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh)
|
|||
SetWebviewShow("online", false);
|
||||
SetWebviewShow("printhistory", false);
|
||||
SetWebviewShow("right", true);
|
||||
|
||||
GetSizer()->Layout();
|
||||
SetWebviewShow("makerlab", false);
|
||||
}
|
||||
|
||||
GetSizer()->Layout();
|
||||
}
|
||||
|
||||
void WebViewPanel::SwitchLeftMenu(std::string strMenu)
|
||||
|
@ -1627,22 +1794,6 @@ void WebViewPanel::SwitchLeftMenu(std::string strMenu)
|
|||
WebView::RunScript(m_browserLeft, strJS);
|
||||
}
|
||||
|
||||
void WebViewPanel::OpenOneMakerlab(std::string url) {
|
||||
auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code());
|
||||
std::string LabUrl = (boost::format("%1%%2%?from=bambustudio") % host % url).str();
|
||||
|
||||
wxString FinalUrl = LabUrl;
|
||||
NetworkAgent *agent = GUI::wxGetApp().getAgent();
|
||||
if (agent && agent->is_user_login()) {
|
||||
std::string newticket;
|
||||
int ret = agent->request_bind_ticket(&newticket);
|
||||
if (ret == 0) GetJumpUrl(true, newticket, FinalUrl, FinalUrl);
|
||||
}
|
||||
|
||||
wxLaunchDefaultBrowser(FinalUrl);
|
||||
}
|
||||
|
||||
|
||||
void WebViewPanel::CheckMenuNewTag() {
|
||||
std::string sClick = wxGetApp().app_config->get("homepage", "online_clicked");
|
||||
if (sClick.compare("1")==0)
|
||||
|
@ -1694,6 +1845,12 @@ void WebViewPanel::SetLeftMenuShow(std::string menuname, int show)
|
|||
WebView::RunScript(m_browser, strJS);
|
||||
}
|
||||
|
||||
void WebViewPanel::SetLeftMenuWidth(int nWidth) {
|
||||
m_browserLeft->SetSize(wxSize(FromDIP(nWidth), -1));
|
||||
m_browserLeft->SetMinSize(wxSize(FromDIP(nWidth), -1));
|
||||
m_browserLeft->SetMaxSize(wxSize(FromDIP(nWidth), -1));
|
||||
}
|
||||
|
||||
void WebViewPanel::SetWebviewShow(wxString name, bool show)
|
||||
{
|
||||
wxWebView *TmpWeb = nullptr;
|
||||
|
@ -1705,6 +1862,8 @@ void WebViewPanel::SetWebviewShow(wxString name, bool show)
|
|||
TmpWeb = m_browserMW;
|
||||
else if (name == "printhistory")
|
||||
TmpWeb = m_browserPH;
|
||||
else if (name == "makerlab")
|
||||
TmpWeb = m_browserML;
|
||||
|
||||
if (TmpWeb != nullptr)
|
||||
{
|
||||
|
|
|
@ -96,40 +96,64 @@ public:
|
|||
public:
|
||||
void ResetWholePage();
|
||||
|
||||
void SetMakerworldModelID(std::string ModelID);
|
||||
void OpenMakerworldSearchPage(std::string KeyWord);
|
||||
void SetPrintHistoryTaskID(int TaskID);
|
||||
void SwitchWebContent(std::string modelname, int refresh=0);
|
||||
void SwitchLeftMenu(std::string strMenu);
|
||||
void OpenOneMakerlab(std::string url);
|
||||
|
||||
wxString MakeDisconnectUrl(std::string MenuName);
|
||||
|
||||
void CheckMenuNewTag();
|
||||
void ShowMenuNewTag(std::string menuname, std::string show);
|
||||
void SetLeftMenuShow(std::string menuname, int show);
|
||||
|
||||
void SendRecentList(int images);
|
||||
void SendDesignStaffpick(bool on);
|
||||
void SendMakerlabList();
|
||||
void OpenModelDetail(std::string id, NetworkAgent *agent);
|
||||
// Login
|
||||
void SendLoginInfo();
|
||||
void ShowNetpluginTip();
|
||||
|
||||
void SetWebviewShow(wxString name, bool show);
|
||||
//MW
|
||||
void SetMakerworldModelID(std::string ModelID);
|
||||
void OpenMakerworldSearchPage(std::string KeyWord);
|
||||
void SetPrintHistoryTaskID(int TaskID);
|
||||
|
||||
//DisconnectPage
|
||||
wxString MakeDisconnectUrl(std::string MenuName);
|
||||
|
||||
//LeftMenu
|
||||
std::string m_contentname; // CurrentMenu
|
||||
bool m_leftfirst; // Left First Loaded
|
||||
void CheckMenuNewTag();
|
||||
void ShowMenuNewTag(std::string menuname, std::string show);
|
||||
void SetLeftMenuShow(std::string menuname, int show);
|
||||
void SetLeftMenuWidth(int nWidth);
|
||||
void SwitchWebContent(std::string modelname, int refresh = 0);
|
||||
void SwitchLeftMenu(std::string strMenu);
|
||||
|
||||
//Recent File
|
||||
void SendRecentList(int images);
|
||||
|
||||
//Online
|
||||
bool m_onlinefirst; // Online Page First Load
|
||||
wxString m_online_type; // recommend & browse
|
||||
wxString m_online_LastUrl; // PageLastError Url
|
||||
|
||||
void SendDesignStaffpick(bool on);
|
||||
void get_design_staffpick(int offset, int limit, std::function<void(std::string)> callback);
|
||||
void get_user_mw_4u_config(std::function<void(std::string)> callback);
|
||||
void get_4u_staffpick(int seed, int limit, std::function<void(std::string)> callback);
|
||||
void get_makerlab_list(std::function<void(std::string)> callback);
|
||||
void OpenModelDetail(std::string id, NetworkAgent *agent);
|
||||
int get_model_mall_detail_url(std::string *url, std::string id);
|
||||
|
||||
std::string m_TaskInfo;
|
||||
void ShowUserPrintTask(bool bShow);
|
||||
|
||||
void UpdateMakerworldLoginStatus();
|
||||
void SetMakerworldPageLoginStatus(bool login, wxString ticket = "");
|
||||
|
||||
//Makerlab
|
||||
bool m_MakerLabFirst;
|
||||
wxString m_MakerLab_LastUrl;
|
||||
void SendMakerlabList();
|
||||
void get_makerlab_list(std::function<void(std::string)> callback);
|
||||
void SetMakerlabUrl(std::string url);
|
||||
void OpenOneMakerlab(std::string url);
|
||||
void OpenMakerlab3mf(std::string Base64Buf, std::string FileName);
|
||||
|
||||
//Common UI
|
||||
void SetWebviewShow(wxString name, bool show);
|
||||
|
||||
//PrintHistory
|
||||
std::string m_TaskInfo;
|
||||
bool m_printhistoryfirst; // print history first load
|
||||
wxString m_print_history_LastUrl;
|
||||
void ShowUserPrintTask(bool bShow);
|
||||
|
||||
//
|
||||
bool GetJumpUrl(bool login, wxString ticket, wxString targeturl, wxString &finalurl);
|
||||
|
||||
void update_mode();
|
||||
|
@ -144,15 +168,9 @@ private:
|
|||
wxWebView* m_browserLeft;
|
||||
wxWebView * m_browserMW;
|
||||
wxWebView *m_browserPH; //PrintHistory
|
||||
std::string m_contentname;
|
||||
bool m_leftfirst; //Left First Loaded
|
||||
bool m_onlinefirst; //Online Page First Load
|
||||
bool m_printhistoryfirst; //print history first load
|
||||
//std::string m_online_spec_id; // Online Page Spec_ID
|
||||
wxString m_online_type; //recommend & browse
|
||||
wxString m_online_LastUrl; //PageLastError Url
|
||||
wxString m_print_history_LastUrl;
|
||||
wxWebView *m_browserML; //MakerLab
|
||||
|
||||
//Basic Browser
|
||||
wxBoxSizer *bSizer_toolbar;
|
||||
wxButton * m_button_back;
|
||||
wxButton * m_button_forward;
|
||||
|
|
Loading…
Reference in New Issue