mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-20 07:11:12 -06:00
NEW:the model mall is opened using the default browser
Change-Id: I9f855288486196b2a7c72c51bee8cfcf408ceab8
This commit is contained in:
parent
7eb3aa8104
commit
311d9c3481
5 changed files with 128 additions and 63 deletions
|
@ -1296,6 +1296,32 @@ std::string GUI_App::get_http_url(std::string country_code)
|
|||
return url;
|
||||
}
|
||||
|
||||
std::string GUI_App::get_model_http_url(std::string country_code)
|
||||
{
|
||||
std::string url;
|
||||
if (country_code == "US") {
|
||||
url = "https://makerhub.bambu-lab.com/";
|
||||
}
|
||||
else if (country_code == "CN") {
|
||||
url = "https://makerhub.bambu-lab.com/zh/";
|
||||
}
|
||||
else if (country_code == "ENV_CN_DEV") {
|
||||
url = "https://makerhub-dev.bambu-lab.com/";
|
||||
}
|
||||
else if (country_code == "ENV_CN_QA") {
|
||||
url = "https://makerhub-qa.bambu-lab.com/";
|
||||
}
|
||||
else if (country_code == "ENV_CN_PRE") {
|
||||
url = "https://makerhub-pre.bambu-lab.com/";
|
||||
}
|
||||
else {
|
||||
url = "https://makerhub.bambu-lab.com/";
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
std::string GUI_App::get_plugin_url(std::string name, std::string country_code)
|
||||
{
|
||||
std::string url = get_http_url(country_code);
|
||||
|
@ -5409,45 +5435,94 @@ void GUI_App::load_url(wxString url)
|
|||
|
||||
void GUI_App::open_mall_page_dialog()
|
||||
{
|
||||
std::string url;
|
||||
std::string host_url;
|
||||
std::string model_url;
|
||||
std::string link_url;
|
||||
|
||||
int result = -1;
|
||||
|
||||
//model api url
|
||||
host_url = get_model_http_url(app_config->get_country_code());
|
||||
|
||||
//model url
|
||||
|
||||
wxString language_code = this->current_language_code().BeforeFirst('_');
|
||||
model_url += (language_code.ToStdString() + "/models");
|
||||
|
||||
if (getAgent() && mainframe) {
|
||||
getAgent()->get_model_mall_home_url(&url);
|
||||
|
||||
if (!m_mall_home_dialog) {
|
||||
m_mall_home_dialog = new ModelMallDialog();
|
||||
m_mall_home_dialog->go_to_mall(url);
|
||||
}
|
||||
else {
|
||||
if (m_mall_home_dialog->IsIconized())
|
||||
m_mall_home_dialog->Iconize(false);
|
||||
//login already
|
||||
if (getAgent()->is_user_login()) {
|
||||
std::string ticket;
|
||||
result = getAgent()->request_bind_ticket(&ticket);
|
||||
|
||||
//m_mall_home_dialog->go_to_mall(url);
|
||||
}
|
||||
m_mall_home_dialog->Raise();
|
||||
m_mall_home_dialog->Show();
|
||||
if(result == 0){
|
||||
link_url = host_url + "api/sign-in/ticket?to=" + host_url + url_encode(model_url) + "&ticket=" + ticket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
link_url = host_url + model_url;
|
||||
}
|
||||
|
||||
wxLaunchDefaultBrowser(link_url);
|
||||
}
|
||||
|
||||
void GUI_App::open_publish_page_dialog()
|
||||
{
|
||||
std::string url;
|
||||
std::string host_url;
|
||||
std::string model_url;
|
||||
std::string link_url;
|
||||
|
||||
int result = -1;
|
||||
|
||||
//model api url
|
||||
host_url = get_model_http_url(app_config->get_country_code());
|
||||
|
||||
//publish url
|
||||
wxString language_code = this->current_language_code().BeforeFirst('_');
|
||||
model_url += (language_code.ToStdString() + "/my/models/publish");
|
||||
|
||||
if (getAgent() && mainframe) {
|
||||
getAgent()->get_model_publish_url(&url);
|
||||
|
||||
if (!m_mall_publish_dialog) {
|
||||
m_mall_publish_dialog = new ModelMallDialog();
|
||||
m_mall_publish_dialog->go_to_mall(url);
|
||||
}
|
||||
else {
|
||||
if (m_mall_publish_dialog->IsIconized())
|
||||
m_mall_publish_dialog->Iconize(false);
|
||||
//login already
|
||||
if (getAgent()->is_user_login()) {
|
||||
std::string ticket;
|
||||
result = getAgent()->request_bind_ticket(&ticket);
|
||||
|
||||
//m_mall_publish_dialog->go_to_publish(url);
|
||||
if (result == 0) {
|
||||
link_url = host_url + "api/sign-in/ticket?to=" + host_url + url_encode(model_url) + "&ticket=" + ticket;
|
||||
}
|
||||
}
|
||||
m_mall_publish_dialog->Raise();
|
||||
m_mall_publish_dialog->Show();
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
link_url = host_url + model_url;
|
||||
}
|
||||
|
||||
wxLaunchDefaultBrowser(link_url);
|
||||
}
|
||||
|
||||
std::string GUI_App::url_encode(const std::string& value) {
|
||||
std::ostringstream escaped;
|
||||
escaped.fill('0');
|
||||
escaped << std::hex;
|
||||
for (std::string::const_iterator i = value.begin(), n = value.end(); i != n; ++i) {
|
||||
std::string::value_type c = (*i);
|
||||
|
||||
// Keep alphanumeric and other accepted characters intact
|
||||
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
|
||||
escaped << c;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Any other characters are percent-encoded
|
||||
escaped << std::uppercase;
|
||||
escaped << '%' << std::setw(2) << int((unsigned char)c);
|
||||
escaped << std::nouppercase;
|
||||
}
|
||||
return escaped.str();
|
||||
}
|
||||
|
||||
void GUI_App::remove_mall_system_dialog()
|
||||
|
@ -5456,12 +5531,6 @@ void GUI_App::remove_mall_system_dialog()
|
|||
m_mall_publish_dialog->Destroy();
|
||||
delete m_mall_publish_dialog;
|
||||
}
|
||||
|
||||
|
||||
if (m_mall_home_dialog != nullptr) {
|
||||
m_mall_home_dialog->Destroy();
|
||||
delete m_mall_home_dialog;
|
||||
}
|
||||
}
|
||||
|
||||
void GUI_App::run_script(wxString js)
|
||||
|
|
|
@ -509,7 +509,6 @@ public:
|
|||
|
||||
std::string m_mall_model_download_url;
|
||||
std::string m_mall_model_download_name;
|
||||
ModelMallDialog* m_mall_home_dialog{ nullptr };
|
||||
ModelMallDialog* m_mall_publish_dialog{ nullptr };
|
||||
|
||||
void set_download_model_url(std::string url) {m_mall_model_download_url = url;}
|
||||
|
@ -519,6 +518,7 @@ public:
|
|||
|
||||
void load_url(wxString url);
|
||||
void open_mall_page_dialog();
|
||||
std::string url_encode(const std::string& value);
|
||||
void open_publish_page_dialog();
|
||||
void remove_mall_system_dialog();
|
||||
void run_script(wxString js);
|
||||
|
@ -586,6 +586,7 @@ public:
|
|||
int download_plugin(std::string name, std::string package_name, InstallProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr);
|
||||
int install_plugin(std::string name, std::string package_name, InstallProgressFn pro_fn = nullptr, WasCancelledFn cancel_fn = nullptr);
|
||||
std::string get_http_url(std::string country_code);
|
||||
std::string get_model_http_url(std::string country_code);
|
||||
bool is_compatibility_version();
|
||||
bool check_networking_version();
|
||||
void cancel_networking_install();
|
||||
|
|
|
@ -113,10 +113,10 @@ void ProjectPanel::on_reload(wxCommandEvent& evt)
|
|||
|
||||
json j;
|
||||
j["model"]["license"] = license;
|
||||
j["model"]["name"] = url_encode(model_name);
|
||||
j["model"]["author"] = url_encode(model_author);;
|
||||
j["model"]["cover_img"] = url_encode(cover_file);
|
||||
j["model"]["description"] = url_encode(description);
|
||||
j["model"]["name"] = wxGetApp().url_encode(model_name);
|
||||
j["model"]["author"] = wxGetApp().url_encode(model_author);;
|
||||
j["model"]["cover_img"] = wxGetApp().url_encode(cover_file);
|
||||
j["model"]["description"] = wxGetApp().url_encode(description);
|
||||
j["model"]["preview_img"] = files["Model Pictures"];
|
||||
j["model"]["upload_type"] = update_type;
|
||||
|
||||
|
@ -124,10 +124,10 @@ void ProjectPanel::on_reload(wxCommandEvent& evt)
|
|||
j["file"]["Assembly"] = files["Assembly Guide"];
|
||||
j["file"]["Other"] = files["Others"];
|
||||
|
||||
j["profile"]["name"] = url_encode(p_name);
|
||||
j["profile"]["author"] = url_encode(p_author);
|
||||
j["profile"]["description"] = url_encode(p_description);
|
||||
j["profile"]["cover_img"] = url_encode(p_cover_file);
|
||||
j["profile"]["name"] = wxGetApp().url_encode(p_name);
|
||||
j["profile"]["author"] = wxGetApp().url_encode(p_author);
|
||||
j["profile"]["description"] = wxGetApp().url_encode(p_description);
|
||||
j["profile"]["cover_img"] = wxGetApp().url_encode(p_cover_file);
|
||||
j["profile"]["preview_img"] = files["Profile Pictures"];
|
||||
|
||||
json m_Res = json::object();
|
||||
|
@ -287,7 +287,7 @@ std::map<std::string, std::vector<json>> ProjectPanel::Reload(wxString aux_path)
|
|||
wxStat(file_name, &strucStat);
|
||||
wxFileOffset filelen = strucStat.st_size;
|
||||
|
||||
pfile_obj["filename"] = url_encode(file_path_obj.filename().string().c_str());
|
||||
pfile_obj["filename"] = wxGetApp().url_encode(file_path_obj.filename().string().c_str());
|
||||
pfile_obj["size"] = formatBytes((unsigned long)filelen);
|
||||
|
||||
//image
|
||||
|
@ -303,7 +303,7 @@ std::map<std::string, std::vector<json>> ProjectPanel::Reload(wxString aux_path)
|
|||
break;
|
||||
}
|
||||
else {
|
||||
pfile_obj["filepath"] = url_encode(file_path);
|
||||
pfile_obj["filepath"] = wxGetApp().url_encode(file_path);
|
||||
m_paths_list[folder.ToStdString()].push_back(pfile_obj);
|
||||
break;
|
||||
}
|
||||
|
@ -382,27 +382,6 @@ std::string ProjectPanel::url_decode(string text) {
|
|||
return escaped.str();
|
||||
}
|
||||
|
||||
std::string ProjectPanel::url_encode(const std::string& value) {
|
||||
std::ostringstream escaped;
|
||||
escaped.fill('0');
|
||||
escaped << std::hex;
|
||||
for (std::string::const_iterator i = value.begin(), n = value.end(); i != n; ++i) {
|
||||
std::string::value_type c = (*i);
|
||||
|
||||
// Keep alphanumeric and other accepted characters intact
|
||||
if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') {
|
||||
escaped << c;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Any other characters are percent-encoded
|
||||
escaped << std::uppercase;
|
||||
escaped << '%' << std::setw(2) << int((unsigned char)c);
|
||||
escaped << std::nouppercase;
|
||||
}
|
||||
return escaped.str();
|
||||
}
|
||||
|
||||
bool ProjectPanel::Show(bool show)
|
||||
{
|
||||
if (show) update_model_data();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue