diff --git a/resources/web/data/text.js b/resources/web/data/text.js index b0cd59c3e..cf11ee13b 100644 --- a/resources/web/data/text.js +++ b/resources/web/data/text.js @@ -104,7 +104,10 @@ var LangText={ "t110":"Custom Filaments", "t111":"Create New", "t112":"Join the Program", - "t113":"You may change your choice in preference anytime." + "t113":"You may change your choice in preference anytime.", + "t114":"Home", + "t115":"Batch", + "t116":"Retry" }, "zh_CN": { "t1": "欢迎使用Bambu Studio", @@ -212,6 +215,9 @@ var LangText={ "t111":"新建", "t112":"加入该计划", "t113":"您可以随时更改您的偏好。", + "t114":"首页", + "t115":"批量处理", + "t116": "重试", "wk1": "快速入门指南", "wk2": "本文介绍了Bambu Studio的最基本用法。它指导用户配置软件,创建项目,并逐步完成第一个打印任务。", "wk3": "基于项目的工作流", @@ -334,7 +340,10 @@ var LangText={ "t110":"カスタムフィラメント", "t111":"新規作成", "t112":"この計画に参加する", - "t113":"好みはいつでも変更できます." + "t113":"好みはいつでも変更できます.", + "t114":"トップページ", + "t115":"バッチ", + "t116": "[再試行]" }, "it_IT": { "t1": "Benvenuti allo Studio Bambu", @@ -441,7 +450,10 @@ var LangText={ "t110":"Filamenti Personalizzati", "t111":"Crea Nuovo", "t112":"Partecipa al programma", - "t113":"Puoi cambiare la tua scelta in qualsiasi momento." + "t113":"Puoi cambiare la tua scelta in qualsiasi momento.", + "t114":"Home", + "t115":"Lotto", + "t116":"Riprova" }, "fr_FR": { "t1": "Bienvenue chez Bambu Studio", @@ -548,7 +560,10 @@ var LangText={ "t110":"Filaments Personnalisés", "t111":"Créer Nouveau", "t112":"Rejoignez le programme", - "t113":"Vous pouvez modifier vos préférences à tout moment." + "t113":"Vous pouvez modifier vos préférences à tout moment.", + "t114":"Accueil", + "t115":"Un lot de", + "t116":"Retenter" }, "de_DE": { "t1": "Willkommen im Bambu Studio", @@ -655,7 +670,10 @@ var LangText={ "t110":"Benutzerdefinierte Filamente", "t111":"Neu erstellen", "t112":"Teilnahme am Programm", - "t113":"Sie können Ihre Wahl jederzeit ändern." + "t113":"Sie können Ihre Wahl jederzeit ändern.", + "t114":"Startseite", + "t115":"Charge", + "t116":"Erneut versuchen" }, "hu_HU": { "t1": "Üdvözöljük a Bambu Stúdióban", @@ -762,7 +780,10 @@ var LangText={ "t110":"Egyedi Filamentek", "t111":"Új Létrehozása", "t112":"Csatlakozás a programhoz", - "t113":"Bármikor megváltoztathatja a preferenciáját." + "t113":"Bármikor megváltoztathatja a preferenciáját.", + "t114":"honlap", + "t115":"Tétel", + "t116":"Újrapróbálkozás" }, "es_ES": { "t1": "Bienvenido a Bambu Studio", @@ -869,7 +890,10 @@ var LangText={ "t110":"Filamenti Personalizzati", "t111":"Crea Nuovo", "t112":"Unirse al programa", - "t113":"Puede cambiar sus preferencias en cualquier momento." + "t113":"Puede cambiar sus preferencias en cualquier momento.", + "t114":"Página de inicio", + "t115":"Un lote", + "t116":"Reintentar" }, "sv_SE": { "t1": "Välkommen till Bambu Studio", @@ -976,7 +1000,10 @@ var LangText={ "t110":"Anpassade filament", "t111":"Skapa ny", "t112":"Gå med i programmet", - "t113":"Du kan ändra ditt val när som helst." + "t113":"Du kan ändra ditt val när som helst.", + "t114":"startsida", + "t115":"Batch", + "t116":"Försök igen" }, "cs_CZ": { "t1": "Vítejte v Bambu Studio", @@ -1083,7 +1110,10 @@ var LangText={ "t110":"Samostatné materiály", "t111":"Nové", "t112":"Připojte se k programu", - "t113":"Své preference můžete kdykoliv změnit.", + "t113":"Své preference můžete kdykoliv změnit.", + "t114":"domovská stránka", + "t115":"Šarže", + "t116":"Zkuste to znovu" }, "nl_NL": { "t1": "Welkom bij Bambu Studio", @@ -1190,7 +1220,10 @@ var LangText={ "t110":"Aangepaste filamenten", "t111":"Nieuw maken", "t112":"Deelnemen aan het programma", - "t113":"U kunt uw keuze op elk gewenst moment wijzigen." + "t113":"U kunt uw keuze op elk gewenst moment wijzigen.", + "t114":"startpagina", + "t115":"Batch", + "t116":"Probeer het opnieuw" }, "ru_RU": { "t1": "Приветствуем в Bambu Studio!", @@ -1297,7 +1330,10 @@ var LangText={ "t110":"Пользовательские прутки", "t111":"Создать новый", "t112":"Присоединяйтесь к программе", - "t113":"Вы можете изменить свои предпочтения в любое время." + "t113":"Вы можете изменить свои предпочтения в любое время.", + "t114":"Главная страница", + "t115":"Одна партия", + "t116":"Повторить попытку" } }; @@ -1323,7 +1359,7 @@ function TranslatePage() if( !LangText.hasOwnProperty(strLang) ) strLang="en"; - + let AllNode=$(".trans"); let nTotal=AllNode.length; for(let n=0;n + + + + + +homepage + + + + + + + + + + + + + + +
+
+
Network disconnect, please check and try again later.
+
Retry
+
+ + + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/home.html b/resources/web/homepage2/home.html new file mode 100644 index 000000000..f0d014563 --- /dev/null +++ b/resources/web/homepage2/home.html @@ -0,0 +1,332 @@ + + + + + + +homepage + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ +
Recent Files
+
+
MORE >
+
+
+ +
+
+ +
+
+
+
clear
+
+
+
+
open in explorer
+
+
+ + +
+
+
+ +
Online Models
+
+
MORE >
+
+
+
+ +
For You
+
+
MORE >
+
+
+ +
+
+ + +
+
+
+ +
Makerlab
+
+
MORE >
+
+
+ +
+
+ + + + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/img/3d_text.png b/resources/web/homepage2/img/3d_text.png new file mode 100644 index 000000000..123256467 Binary files /dev/null and b/resources/web/homepage2/img/3d_text.png differ diff --git a/resources/web/homepage2/img/a.jpg b/resources/web/homepage2/img/a.jpg new file mode 100644 index 000000000..5fd010204 Binary files /dev/null and b/resources/web/homepage2/img/a.jpg differ diff --git a/resources/web/homepage2/img/b.jpg b/resources/web/homepage2/img/b.jpg new file mode 100644 index 000000000..a8c8933bc Binary files /dev/null and b/resources/web/homepage2/img/b.jpg differ diff --git a/resources/web/homepage2/img/batch.svg b/resources/web/homepage2/img/batch.svg new file mode 100644 index 000000000..81f2373dd --- /dev/null +++ b/resources/web/homepage2/img/batch.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/web/homepage2/img/c.jpg b/resources/web/homepage2/img/c.jpg new file mode 100644 index 000000000..50c5883ca Binary files /dev/null and b/resources/web/homepage2/img/c.jpg differ diff --git a/resources/web/homepage2/img/cancel.svg b/resources/web/homepage2/img/cancel.svg new file mode 100644 index 000000000..53cf92e36 --- /dev/null +++ b/resources/web/homepage2/img/cancel.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/web/homepage2/img/checkbox.svg b/resources/web/homepage2/img/checkbox.svg new file mode 100644 index 000000000..0c14bd54f --- /dev/null +++ b/resources/web/homepage2/img/checkbox.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/web/homepage2/img/checkbox_hover.svg b/resources/web/homepage2/img/checkbox_hover.svg new file mode 100644 index 000000000..5740e17a7 --- /dev/null +++ b/resources/web/homepage2/img/checkbox_hover.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/web/homepage2/img/clear.svg b/resources/web/homepage2/img/clear.svg new file mode 100644 index 000000000..5dbf08f9e --- /dev/null +++ b/resources/web/homepage2/img/clear.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/web/homepage2/img/d.png b/resources/web/homepage2/img/d.png new file mode 100644 index 000000000..bddeb8cc4 Binary files /dev/null and b/resources/web/homepage2/img/d.png differ diff --git a/resources/web/homepage2/img/delete.svg b/resources/web/homepage2/img/delete.svg new file mode 100644 index 000000000..72d26ab3d --- /dev/null +++ b/resources/web/homepage2/img/delete.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/web/homepage2/img/delete2.svg b/resources/web/homepage2/img/delete2.svg new file mode 100644 index 000000000..7c4784b27 --- /dev/null +++ b/resources/web/homepage2/img/delete2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/web/homepage2/img/disconnect.svg b/resources/web/homepage2/img/disconnect.svg new file mode 100644 index 000000000..f076acedc --- /dev/null +++ b/resources/web/homepage2/img/disconnect.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/img/fire.svg b/resources/web/homepage2/img/fire.svg new file mode 100644 index 000000000..7cec5b583 --- /dev/null +++ b/resources/web/homepage2/img/fire.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/img/foru.svg b/resources/web/homepage2/img/foru.svg new file mode 100644 index 000000000..6e82f8793 --- /dev/null +++ b/resources/web/homepage2/img/foru.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/resources/web/homepage2/img/high_speed_print_at_quality.png b/resources/web/homepage2/img/high_speed_print_at_quality.png new file mode 100644 index 000000000..5d4546eb0 Binary files /dev/null and b/resources/web/homepage2/img/high_speed_print_at_quality.png differ diff --git a/resources/web/homepage2/img/i1.png b/resources/web/homepage2/img/i1.png new file mode 100644 index 000000000..1903609b3 Binary files /dev/null and b/resources/web/homepage2/img/i1.png differ diff --git a/resources/web/homepage2/img/i2.png b/resources/web/homepage2/img/i2.png new file mode 100644 index 000000000..55a2e74fb Binary files /dev/null and b/resources/web/homepage2/img/i2.png differ diff --git a/resources/web/homepage2/img/i3.png b/resources/web/homepage2/img/i3.png new file mode 100644 index 000000000..dad76d16f Binary files /dev/null and b/resources/web/homepage2/img/i3.png differ diff --git a/resources/web/homepage2/img/i4.png b/resources/web/homepage2/img/i4.png new file mode 100644 index 000000000..81aa876ce Binary files /dev/null and b/resources/web/homepage2/img/i4.png differ diff --git a/resources/web/homepage2/img/i5.png b/resources/web/homepage2/img/i5.png new file mode 100644 index 000000000..1663e06a5 Binary files /dev/null and b/resources/web/homepage2/img/i5.png differ diff --git a/resources/web/homepage2/img/i6.png b/resources/web/homepage2/img/i6.png new file mode 100644 index 000000000..8d4cbaba0 Binary files /dev/null and b/resources/web/homepage2/img/i6.png differ diff --git a/resources/web/homepage2/img/left_home.svg b/resources/web/homepage2/img/left_home.svg new file mode 100644 index 000000000..bc7a57cf5 --- /dev/null +++ b/resources/web/homepage2/img/left_home.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/web/homepage2/img/left_manual.svg b/resources/web/homepage2/img/left_manual.svg new file mode 100644 index 000000000..03e90cc8e --- /dev/null +++ b/resources/web/homepage2/img/left_manual.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/resources/web/homepage2/img/left_ml.svg b/resources/web/homepage2/img/left_ml.svg new file mode 100644 index 000000000..d2b036772 --- /dev/null +++ b/resources/web/homepage2/img/left_ml.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/resources/web/homepage2/img/left_online.svg b/resources/web/homepage2/img/left_online.svg new file mode 100644 index 000000000..27a72008c --- /dev/null +++ b/resources/web/homepage2/img/left_online.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/web/homepage2/img/left_recent.svg b/resources/web/homepage2/img/left_recent.svg new file mode 100644 index 000000000..6e21fb323 --- /dev/null +++ b/resources/web/homepage2/img/left_recent.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/web/homepage2/img/ml.svg b/resources/web/homepage2/img/ml.svg new file mode 100644 index 000000000..b4b053a3d --- /dev/null +++ b/resources/web/homepage2/img/ml.svg @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/img/ml1.jpg b/resources/web/homepage2/img/ml1.jpg new file mode 100644 index 000000000..29744086d Binary files /dev/null and b/resources/web/homepage2/img/ml1.jpg differ diff --git a/resources/web/homepage2/img/ml2.jpg b/resources/web/homepage2/img/ml2.jpg new file mode 100644 index 000000000..1327c1bea Binary files /dev/null and b/resources/web/homepage2/img/ml2.jpg differ diff --git a/resources/web/homepage2/img/ml3.jpg b/resources/web/homepage2/img/ml3.jpg new file mode 100644 index 000000000..f55823f8c Binary files /dev/null and b/resources/web/homepage2/img/ml3.jpg differ diff --git a/resources/web/homepage2/img/multi_color_printing.png b/resources/web/homepage2/img/multi_color_printing.png new file mode 100644 index 000000000..9ec64dbbd Binary files /dev/null and b/resources/web/homepage2/img/multi_color_printing.png differ diff --git a/resources/web/homepage2/img/online.svg b/resources/web/homepage2/img/online.svg new file mode 100644 index 000000000..319067548 --- /dev/null +++ b/resources/web/homepage2/img/online.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/img/open_folder.svg b/resources/web/homepage2/img/open_folder.svg new file mode 100644 index 000000000..b4eb1197d --- /dev/null +++ b/resources/web/homepage2/img/open_folder.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/web/homepage2/img/open_folder2.svg b/resources/web/homepage2/img/open_folder2.svg new file mode 100644 index 000000000..c5c3a6c84 --- /dev/null +++ b/resources/web/homepage2/img/open_folder2.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/web/homepage2/img/project_based_workflow.png b/resources/web/homepage2/img/project_based_workflow.png new file mode 100644 index 000000000..b1fb82250 Binary files /dev/null and b/resources/web/homepage2/img/project_based_workflow.png differ diff --git a/resources/web/homepage2/img/project_new.svg b/resources/web/homepage2/img/project_new.svg new file mode 100644 index 000000000..cadbd1d48 --- /dev/null +++ b/resources/web/homepage2/img/project_new.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/resources/web/homepage2/img/project_open.svg b/resources/web/homepage2/img/project_open.svg new file mode 100644 index 000000000..879cec57b --- /dev/null +++ b/resources/web/homepage2/img/project_open.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/resources/web/homepage2/img/quick_start.png b/resources/web/homepage2/img/quick_start.png new file mode 100644 index 000000000..a0e7a2e12 Binary files /dev/null and b/resources/web/homepage2/img/quick_start.png differ diff --git a/resources/web/homepage2/img/remote_control_and_monitoring.png b/resources/web/homepage2/img/remote_control_and_monitoring.png new file mode 100644 index 000000000..fe4eece38 Binary files /dev/null and b/resources/web/homepage2/img/remote_control_and_monitoring.png differ diff --git a/resources/web/homepage2/img/remove.svg b/resources/web/homepage2/img/remove.svg new file mode 100644 index 000000000..19d9eb241 --- /dev/null +++ b/resources/web/homepage2/img/remove.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/img/remove2.svg b/resources/web/homepage2/img/remove2.svg new file mode 100644 index 000000000..7c913c001 --- /dev/null +++ b/resources/web/homepage2/img/remove2.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/img/setting_guide_of_slicing_parameters.png b/resources/web/homepage2/img/setting_guide_of_slicing_parameters.png new file mode 100644 index 000000000..c042767fc Binary files /dev/null and b/resources/web/homepage2/img/setting_guide_of_slicing_parameters.png differ diff --git a/resources/web/homepage2/img/step.png b/resources/web/homepage2/img/step.png new file mode 100644 index 000000000..face61d22 Binary files /dev/null and b/resources/web/homepage2/img/step.png differ diff --git a/resources/web/homepage2/img/t2.svg b/resources/web/homepage2/img/t2.svg new file mode 100644 index 000000000..a7864b126 --- /dev/null +++ b/resources/web/homepage2/img/t2.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/resources/web/homepage2/img/wiki.png b/resources/web/homepage2/img/wiki.png new file mode 100644 index 000000000..c6a19f469 Binary files /dev/null and b/resources/web/homepage2/img/wiki.png differ diff --git a/resources/web/homepage2/img/wiki2.png b/resources/web/homepage2/img/wiki2.png new file mode 100644 index 000000000..7a867d41a Binary files /dev/null and b/resources/web/homepage2/img/wiki2.png differ diff --git a/resources/web/homepage2/img/wiki3.png b/resources/web/homepage2/img/wiki3.png new file mode 100644 index 000000000..f5a52c2e3 Binary files /dev/null and b/resources/web/homepage2/img/wiki3.png differ diff --git a/resources/web/homepage2/img/xia.svg b/resources/web/homepage2/img/xia.svg new file mode 100644 index 000000000..f9fb0a03e --- /dev/null +++ b/resources/web/homepage2/img/xia.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/resources/web/homepage2/img/zan.svg b/resources/web/homepage2/img/zan.svg new file mode 100644 index 000000000..471ea3d4b --- /dev/null +++ b/resources/web/homepage2/img/zan.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/web/homepage2/js/home.js b/resources/web/homepage2/js/home.js new file mode 100644 index 000000000..770562612 --- /dev/null +++ b/resources/web/homepage2/js/home.js @@ -0,0 +1,773 @@ +//var TestData={"sequence_id":"0","command":"get_recent_projects","response":[{"path":"D:\\work\\Models\\Toy\\3d-puzzle-cube-model_files\\3d-puzzle-cube.3mf","time":"2022\/3\/24 20:33:10"},{"path":"D:\\work\\Models\\Art\\Carved Stone Vase - remeshed+drainage\\Carved Stone Vase.3mf","time":"2022\/3\/24 17:11:51"},{"path":"D:\\work\\Models\\Art\\Kity & Cat\\Cat.3mf","time":"2022\/3\/24 17:07:55"},{"path":"D:\\work\\Models\\Toy\\鐩村墤.3mf","time":"2022\/3\/24 17:06:02"},{"path":"D:\\work\\Models\\Toy\\minimalistic-dual-tone-whistle-model_files\\minimalistic-dual-tone-whistle.3mf","time":"2022\/3\/22 21:12:22"},{"path":"D:\\work\\Models\\Toy\\spiral-city-model_files\\spiral-city.3mf","time":"2022\/3\/22 18:58:37"},{"path":"D:\\work\\Models\\Toy\\impossible-dovetail-puzzle-box-model_files\\impossible-dovetail-puzzle-box.3mf","time":"2022\/3\/22 20:08:40"}]}; + +var m_HotModelList=null; +var m_ForUModelList=null; + +function OnHomeInit() +{ + //-----Official----- + TranslatePage(); + + SendMsg_GetRecentFile(); + SendMsg_GetStaffPick(); + SendMsg_GetMakerlabList(); + + //ShowMakerlabList(Test_MakerlabList['list']); +} + +//Recent详情页面的状态 +var Recent_Normal=1; +var Recent_BatchDelete=2; + +var RecentPage_Mode=Recent_Normal; + +function OnRecentInit() +{ + TranslatePage(); + + SendMsg_GetRecentFile(); + Set_RecentFile_Delete_Checkbox_Event(); +} + +function OnLineInit() +{ + TranslatePage(); + + SendMsg_GetStaffPick(); +} + +//------最佳打开文件的右键菜单功能---------- +var RightBtnFilePath=''; + +var MousePosX=0; +var MousePosY=0; +var sImages = {}; + +function Set_RecentFile_MouseRightBtn_Event() +{ + $(".FileItem").mousedown( + function(e) + { + //FilePath + RightBtnFilePath=$(this).attr('fpath'); + + if(e.which == 3){ + //鼠标点击了右键+$(this).attr('ff') ); + ShowRecnetFileContextMenu(); + }else if(e.which == 2){ + //鼠标点击了中键 + }else if(e.which == 1){ + //鼠标点击了左键 + OnOpenRecentFile( encodeURI(RightBtnFilePath) ); + } + }); + + $(document).bind("contextmenu",function(e){ + //在这里书写代码,构建个性右键化菜单 + return false; + }); + + $(document).mousemove( function(e){ + MousePosX=e.pageX; + MousePosY=e.pageY; + + let ContextMenuWidth=$('#recnet_context_menu').width(); + let ContextMenuHeight=$('#recnet_context_menu').height(); + + let DocumentWidth=$(document).width(); + let DocumentHeight=$(document).height(); + + //$("#DebugText").text( ContextMenuWidth+' - '+ContextMenuHeight+'
'+ + // DocumentWidth+' - '+DocumentHeight+'
'+ + // MousePosX+' - '+MousePosY +'
' ); + } ); + + + $(document).click( function(){ + var e = e || window.event; +        var elem = e.target || e.srcElement; +        while (elem) { + if (elem.id && elem.id == 'recnet_context_menu') { +                    return; + } + elem = elem.parentNode; + } + + $("#recnet_context_menu").hide(); + } ); + + +} + + +function HandleStudio( pVal ) +{ + let strCmd = pVal['command']; + + if(strCmd=='get_recent_projects') + { + ShowRecentFileList(pVal['response']); + } + else if( strCmd=="studio_set_mallurl" ) + { + SetMallUrl( pVal['data']['url'] ); + } + else if( strCmd=="studio_clickmenu" ) + { + let strName=pVal['data']['menu']; + + GotoMenu(strName); + } + else if( strCmd=="network_plugin_installtip" ) + { + let nShow=pVal["show"]*1; + + if(nShow==1) + { + $("#NoPluginTip").show(); + $("#NoPluginTip").css("display","flex"); + } + else + { + $("#NoPluginTip").hide(); + } + } + else if( strCmd=="modelmall_model_advise_get") + { + //alert('hot'); + if( m_HotModelList!=null ) + { + let SS1=JSON.stringify(pVal['hits']); + let SS2=JSON.stringify(m_HotModelList); + + if( SS1==SS2 ) + return; + } + + $("#Online_Models_Bar").css('display','flex'); + $("#ForU_Models_Bar").css('display','none'); + + m_HotModelList=pVal['hits']; + ShowStaffPick( m_HotModelList ); + } + else if( strCmd=="modelmall_model_customized_get") + { + //alert('hot'); + if( m_ForUModelList!=null ) + { + let SS1=JSON.stringify(pVal['hits']); + let SS2=JSON.stringify(m_ForUModelList); + + if( SS1==SS2 ) + return; + } + + $("#Online_Models_Bar").css('display','none'); + $("#ForU_Models_Bar").css('display','flex'); + + m_ForUModelList=pVal['hits']; + Show4UPick( m_ForUModelList ); + } + else if(strCmd=='homepage_makerlab_get') + { + ShowMakerlabList(pVal['list']); + } +} + +function SwtichLeftMenu( strMenu ) +{ + //SendWX + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_leftmenu_switch"; + tSend['menu']=strMenu; + + SendWXMessage( JSON.stringify(tSend) ); +} + +function SetMallUrl( strUrl ) +{ + $("#MallWeb").prop("src",strUrl); +} + + +function ShowRecentFileList( pList ) +{ + let nTotal=pList.length; + + let strHtml=''; + for(let n=0;n0?sPath.lastIndexOf('\\'):sPath.lastIndexOf('\/'); + //let sShortName=sPath.substring(index+1,sPath.length); + + let TmpHtml='
'+ + ''+ + '
No Image
'+ + '
'+sName+'
'+ + '
'+sTime+'
'+ + '
'+ + '
'+ + '
'; + + strHtml+=TmpHtml; + } + + $("#FileList").html(strHtml); + + Set_RecentFile_MouseRightBtn_Event(); + UpdateRecentClearBtnDisplay(); + Set_RecentFile_Delete_Checkbox_Event(); +} + +function ShowRecnetFileContextMenu() +{ + if( RecentPage_Mode!=Recent_Normal ) + return; + + $("#recnet_context_menu").offset({top: 10000, left:-10000}); + $('#recnet_context_menu').show(); + + let ContextMenuWidth=$('#recnet_context_menu').width(); + let ContextMenuHeight=$('#recnet_context_menu').height(); + + let DocumentWidth=$(document).width(); + let DocumentHeight=$(document).height(); + + let RealX=MousePosX; + let RealY=MousePosY; + + if( MousePosX + ContextMenuWidth + 24 >DocumentWidth ) + RealX=DocumentWidth-ContextMenuWidth-24; + if( MousePosY+ContextMenuHeight+24>DocumentHeight ) + RealY=DocumentHeight-ContextMenuHeight-24; + + $("#recnet_context_menu").offset({top: RealY, left:RealX}); +} + +/*-------RecentFile MX Message------*/ +function SendMsg_GetLoginInfo() +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="get_login_info"; + + SendWXMessage( JSON.stringify(tSend) ); +} + + +function SendMsg_GetRecentFile() +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="get_recent_projects"; + + SendWXMessage( JSON.stringify(tSend) ); +} + +function OnClickModelDepot() +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_modeldepot"; + + SendWXMessage( JSON.stringify(tSend) ); +} + +function OnClickNewProject() +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_newproject"; + + SendWXMessage( JSON.stringify(tSend) ); +} + +function OnClickOpenProject() +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_openproject"; + + SendWXMessage( JSON.stringify(tSend) ); +} + +function OnOpenRecentFile( strPath ) +{ + if( RecentPage_Mode!=Recent_Normal ) + return; + + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_open_recentfile"; + tSend['data']={}; + tSend['data']['path']=decodeURI(strPath); + + SendWXMessage( JSON.stringify(tSend) ); +} + +function OnDeleteRecentFile( ) +{ + //Clear in UI + $("#recnet_context_menu").hide(); + + let AllFile=$(".FileItem"); + let nFile=AllFile.length; + for(let p=0;p0 ) + { + $("#Menu_Clear").show(); + $('#Menu_Batch').show(); + } + else + { + $("#Menu_Clear").hide(); + $('#Menu_Batch').hide(); + } +} + +function OnExploreRecentFile( ) +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_explore_recentfile"; + tSend['data']={}; + tSend['data']['path']=decodeURI(RightBtnFilePath); + + SendWXMessage( JSON.stringify(tSend) ); + + $("#recnet_context_menu").hide(); +} + +function BeginDownloadNetworkPlugin() +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="begin_network_plugin_download"; + + SendWXMessage( JSON.stringify(tSend) ); +} + +function OutputKey(keyCode, isCtrlDown, isShiftDown, isCmdDown) { + var tSend = {}; + tSend['sequence_id'] = Math.round(new Date() / 1000); + tSend['command'] = "get_web_shortcut"; + tSend['key_event'] = {}; + tSend['key_event']['key'] = keyCode; + tSend['key_event']['ctrl'] = isCtrlDown; + tSend['key_event']['shift'] = isShiftDown; + tSend['key_event']['cmd'] = isCmdDown; + + SendWXMessage(JSON.stringify(tSend)); +} + +function SendMsg_GetMakerlabList() +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_makerlab_get"; + + SendWXMessage( JSON.stringify(tSend) ); +} + +function SwitchContent(strMenu) +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_leftmenu_clicked"; + tSend['menu']=strMenu; + + SendWXMessage( JSON.stringify(tSend) ); +} + +function OnBatchDelete() +{ + //切换页面工作模式 + RecentPage_Mode=Recent_BatchDelete; + + $('#Menu_Batch').hide(); + $('#Menu_Clear').hide(); + + $('#Menu_Delete').css('display','flex'); + $('#Menu_Cancel').css('display','flex'); + + $('.FileCheckBox.FileCheckBox_checked').removeClass('FileCheckBox_checked'); + $('.FileCheckBox').show(); +} + +function OnCancelDelete() +{ + //切换页面工作模式 + RecentPage_Mode=Recent_Normal; + + $('#Menu_Batch').css('display','flex'); + $('#Menu_Clear').css('display','flex'); + + $('#Menu_Delete').hide(); + $('#Menu_Cancel').hide(); + + + $('.FileCheckBox.FileCheckBox_checked').removeClass('FileCheckBox_checked'); + $('.FileCheckBox').hide(); + $('.FileMask').hide(); +} + +function OnMultiDelete() +{ + let ChooseFiles=$('.FileCheckBox.FileCheckBox_checked'); + let nChoose=ChooseFiles.length; + + var tBatchDel={}; + tBatchDel['sequence_id']=Math.round(new Date() / 1000); + tBatchDel['command']="homepage_delete_recentfile"; + tBatchDel['data']={}; + + for(let n=0;n=1000*1000*1000 ) + { + nNew=Math.round(number/(1000*1000*1000)*10)/10; + nNew=nNew+'b'; + } + else if( number>=1000*1000 ) + { + nNew=Math.round(number/(1000*1000)*10)/10; + nNew=nNew+'m'; + } + if( number>=1000 ) + { + nNew=Math.round(number/(1000)*10)/10; + nNew=nNew+'k'; + } + + return nNew; +} + +function ShowStaffPick( ModelList ) +{ + let PickTotal=ModelList.length; + if(PickTotal==0) + { + $('#HotModelList').html(''); + $('#HotModelArea').hide(); + + return; + } + + let strPickHtml=''; + for(let a=0;a'+ + '
'+ + ' '+ + '
'+ + '
'+ + '
'+ + ' '+ + '
'+ + '
'+ + '
'+ModelName+'
'+ + '
'+ + '
'+DesignerName+'
'+ + '
'+ + '
'+NumZan+'
'+ + '
'+NumDownload+'
'+ + '
'+ + '
'+ + '
'+ + '
'+ + ''; + } + + $('#HotModelList').html(strPickHtml); + InitStaffPick(); + $('#HotModelArea').show(); +} + +function Show4UPick( ModelList ) +{ + let PickTotal=ModelList.length; + if(PickTotal==0) + { + $('#HotModelList').html(''); + $('#HotModelArea').hide(); + + return; + } + + let strPickHtml=''; + for(let a=0;a'+ + '
'+ + ' '+ + '
'+ + '
'+ + '
'+ + ' '+ + '
'+ + '
'+ + '
'+ModelName+'
'+ + '
'+ + '
'+DesignerName+'
'+ + '
'+ + '
'+NumZan+'
'+ + '
'+NumDownload+'
'+ + '
'+ + '
'+ + '
'+ + '
'+ + ''; + } + + $('#HotModelList').html(strPickHtml); + InitStaffPick(); + $('#HotModelArea').show(); +} + +function OpenOneStaffPickModel( ModelID ) +{ + //alert(ModelID); + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="modelmall_model_open"; + tSend['data']={}; + tSend['data']['id']=ModelID; + + SendWXMessage( JSON.stringify(tSend) ); +} + + +//----------MakerLab------------ +function IsChinese() +{ + let strLang=GetQueryString("lang"); + if(strLang!=null) + { + } + else + { + strLang=localStorage.getItem(LANG_COOKIE_NAME); + } + + if(strLang!=null) + return strLang.includes('zh') + else + return false; +} + +function ShowMakerlabList( LabList ) +{ + let LabTotal=LabList.length; + if(LabTotal==0) + { + $('#LabList').html(''); + $('#MakerlabArea').hide(); + + return; + } + + let bCN=IsChinese(); + + let strLabHtml=''; + for(let a=0;a'+ + '
'+ + '
'+ + '
'+LabName+'
'+ + '
'+LabDesc+'
'+ + '
'+LabAuthor+'
'+ + '
'; + } + + $('#LabList').html(strLabHtml); + $('#MakerlabArea').show(); +} + +function OnOpenOneMakerlab( ChildUrl ) +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_makerlab_open"; + tSend['url']=ChildUrl; + + SendWXMessage( JSON.stringify(tSend) ); +} + + +//---------------Global----------------- +window.postMessage = HandleStudio; diff --git a/resources/web/homepage2/js/left.js b/resources/web/homepage2/js/left.js new file mode 100644 index 000000000..a5812b91b --- /dev/null +++ b/resources/web/homepage2/js/left.js @@ -0,0 +1,189 @@ +//var TestData={"sequence_id":"0","command":"get_recent_projects","response":[{"path":"D:\\work\\Models\\Toy\\3d-puzzle-cube-model_files\\3d-puzzle-cube.3mf","time":"2022\/3\/24 20:33:10"},{"path":"D:\\work\\Models\\Art\\Carved Stone Vase - remeshed+drainage\\Carved Stone Vase.3mf","time":"2022\/3\/24 17:11:51"},{"path":"D:\\work\\Models\\Art\\Kity & Cat\\Cat.3mf","time":"2022\/3\/24 17:07:55"},{"path":"D:\\work\\Models\\Toy\\鐩村墤.3mf","time":"2022\/3\/24 17:06:02"},{"path":"D:\\work\\Models\\Toy\\minimalistic-dual-tone-whistle-model_files\\minimalistic-dual-tone-whistle.3mf","time":"2022\/3\/22 21:12:22"},{"path":"D:\\work\\Models\\Toy\\spiral-city-model_files\\spiral-city.3mf","time":"2022\/3\/22 18:58:37"},{"path":"D:\\work\\Models\\Toy\\impossible-dovetail-puzzle-box-model_files\\impossible-dovetail-puzzle-box.3mf","time":"2022\/3\/22 20:08:40"}]}; + +var m_HotModelList=null; + +function OnInit() +{ + //-----Official----- + TranslatePage(); + + SendMsg_GetLoginInfo(); + GotoMenu( 'home' ); +} + +function HandleStudio( pVal ) +{ + let strCmd = pVal['command']; + + + if(strCmd=='studio_userlogin') + { + SetLoginInfo(pVal['data']['avatar'],pVal['data']['name']); + } + else if(strCmd=='studio_useroffline') + { + SetUserOffline(); + } + else if(strCmd=='homepage_leftmenu_clicked') + { + let NewMenu=pVal['menu']; + //alert('LeftMenu Clicked:'+strMenu ); + + GotoMenu(NewMenu); + } + else if(strCmd=='homepage_leftmenu_newtag') + { + let NewMenu=pVal['menu']; + let nShow=pVal['show']; + + ShowMenuNewTag(NewMenu,nShow); + } + else if(strCmd=='homepage_leftmenu_show') + { + let NewMenu=pVal['menu']; + let nShow=pVal['show']; + + ShowMenuBtn(NewMenu,nShow); + } +} + +var NowMenu=''; +function GotoMenu( strMenu ) +{ + ShowMenuNewTag(strMenu,0); + + if(NowMenu==strMenu) + return; + + NowMenu=strMenu; + + let MenuList=$(".BtnItem"); + let nAll=MenuList.length; + + for(let n=0;n + + + + + +homepage + + + + + + + + + + + + + + + +
+
+
+
+
login/register
+
+ +
+
+ +
+
+
log out
+
+ + + +
+ +
+
+
+
Home
+
+
+
+
Recent
+
+
+
+
Online Models
+
New
+
+
+
+
Makerlab
+
New
+
+
+
+
User Manual
+
+
+
+ + + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/manual.html b/resources/web/homepage2/manual.html new file mode 100644 index 000000000..48a64b4eb --- /dev/null +++ b/resources/web/homepage2/manual.html @@ -0,0 +1,113 @@ + + + + + + +homepage + + + + + + + + + + + + + + + +
+
+
+
Quick Start
+
This article introduces the most basic usage of Bambu Studio. It guides users to configure software, create projects, and complete the first printing task step by step.
+
+
+
+
Project Based Workflow
+
Bambu Studio has put forward a leading workflow to truly achieve an “all in one” project. Based on the mainstream 3MF project format, it provides a series of revolutionary new features, such as Multi-Plate Support, a Project Resource Manager, and Assembly/Part View. It greatly improves the efficiency of both creators and regular users.
+
+
+
+
High Speed Print at Quality
+
It is challenging to print at high speed while maintaining high quality. Bambu Studio makes this happen. + "Arch Move" makes the toolhead move smoothly and reduces the machine's vibration. The smart cooling is based on fine-tuned cooling parameters for each filament type. + "Auto slow down" for overhang walls works to prevent deformation at high speeds.
+
+
+
+
Multi-Color Printing
+
Bambu Studio provides versatile colorizing tools to make a colorful model. You can freely add/remove filaments in a project and colorize your model with different brushes. Before printing, each filament will be auto-mapped to an AMS slot, not needing to manually change the spool placement in the AMS.
+
+
+
+
Setting Guide of Slicing Parameters
+
The parameter management features in Bambu Studio provide very flexible and powerful control over the slicing process. This article introduces the organization of parameters and provides some skills on taking full advantage of these capabilities.
+
+
+
+
Remote Control & Monitoring
+
Bambu Studio support sending print job to your printer over WAN/LAN network, controlling & monitoring every aspect of your 3D printer and printing jobs. If you have more than one printer, you can easily switch between them in the device list.
+
+
+
+
STEP Format
+
Compared with STL, STEP brings more effective information. Thanks to the high accuracy of STEP, a lot of extrusion paths can be generated as arcs. STEP also includes the assembly relationship of each part of a model, which can be used to restore the assembly view after a model is split.
+
+
+
+
3D Text
+
With 3D Text tool, users can easily create various 3D text shapes in the project, making the model more personalized. Bambu Studio provides dozens of fonts and supports bold and italic styles to give text greater flexibility.
+
+
+ + + + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/online.html b/resources/web/homepage2/online.html new file mode 100644 index 000000000..b94439e25 --- /dev/null +++ b/resources/web/homepage2/online.html @@ -0,0 +1,236 @@ + + + + + + +homepage + + + + + + + + + + + + + + +
+
+
+ +
Online Models
+
+
MORE >
+
+
+
+ +
For You
+
+
MORE >
+
+
+
+
+ +
+
+
+ +
+
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaa
+
+
1.7m
+
2.8k
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaa
+
+
1.7m
+
2.8k
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaa
+
+
1.7m
+
2.8k
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaa
+
+
1.7m
+
2.8k
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaa
+
+
1.7m
+
2.8k
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaa
+
+
1.7m
+
2.8k
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaa
+
+
1.7m
+
2.8k
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaa
+
+
1.7m
+
2.8k
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+
+
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaa
+
+
1.7m
+
2.8k
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/recent.html b/resources/web/homepage2/recent.html new file mode 100644 index 000000000..63e9f505f --- /dev/null +++ b/resources/web/homepage2/recent.html @@ -0,0 +1,179 @@ + + + + + + +homepage + + + + + + + + + + + + + + + + + + +
+
+
+ +
Recently opened
+
+
+ + + + +
+
+
+ +
+
+ +
+
+
+
clear
+
+
+
+
open in explorer
+
+
+ + + + + + + + + + + + + + + + diff --git a/resources/web/homepage2/test.html b/resources/web/homepage2/test.html new file mode 100644 index 000000000..dc515385f --- /dev/null +++ b/resources/web/homepage2/test.html @@ -0,0 +1,31 @@ + + + + + +homepage + + + + + + + +
+
+
+ + + + + + + + + + + + + + + diff --git a/resources/web/model/index.html b/resources/web/model/index.html index 739f6d445..24bf34be2 100644 --- a/resources/web/model/index.html +++ b/resources/web/model/index.html @@ -23,7 +23,8 @@ -
+ +
no model information
@@ -50,7 +51,7 @@
-
Model name
:
xxxxxxxxxx
+
Model name
:
xxxxxxxxxx
Model Author:xxxxxxx
diff --git a/resources/web/model/model.css b/resources/web/model/model.css index e34963e96..a0595d629 100644 --- a/resources/web/model/model.css +++ b/resources/web/model/model.css @@ -125,7 +125,8 @@ body { overflow:hidden; white-space: nowrap; - text-overflow: ellipsis; + text-overflow: ellipsis; + margin-left: 6px; } @@ -241,6 +242,13 @@ body align-items: flex-end; } +.NameCanClick +{ + color: #00AE42; + text-decoration: underline; + cursor: pointer; +} + #Model_Preview_Image { height: 480px; diff --git a/resources/web/model/model.js b/resources/web/model/model.js index 73958122a..401f1845c 100644 --- a/resources/web/model/model.js +++ b/resources/web/model/model.js @@ -1,6 +1,8 @@ var ModelSwiper=null; var ProfileSwiper=null; +var m_ModelID=null; + function OnInit() { console.log(" 页面加载完成 "); @@ -153,7 +155,13 @@ function HandleStudio(pVal) else if(strCmd=='clear_3mf_info') { ShowProjectInfo( null ); - } + } + else if(strCmd=='3mf_detail_set_modelid') + { + let ModelID=pVal['model_id']; + + UpdateModelID( ModelID ); + } } function ShowProjectInfo( p3MF ) @@ -166,11 +174,12 @@ function ShowProjectInfo( p3MF ) } //Check Data + let nModelID=p3MF.hasOwnProperty('model_id')?p3MF['model_id']:0; let pModel=p3MF['model']; let pFile=p3MF['file']; let pProfile=p3MF['profile']; - ShowModelInfo( pModel ); + ShowModelInfo( pModel,nModelID ); ShowFileInfo( pFile ); ShowProfilelInfo(pProfile); @@ -197,7 +206,7 @@ function ShowProjectInfo( p3MF ) AddScrollEvent(); } -function ShowModelInfo( pModel ) +function ShowModelInfo( pModel, nID ) { //==========Model Info========== let sModelName=decodeURIComponent(pModel.name); @@ -206,6 +215,9 @@ function ShowModelInfo( pModel ) let sLicence=pModel.license.toUpperCase(); let sModelDesc=decodeURIComponent(pModel.description); + if( pModel.hasOwnProperty('model_id') ) + UpdateModelID( pModel['model_id'] ); + SendWXDebugInfo("Model Name: "+sModelName); $('#ModelName').html(sModelName); @@ -580,9 +592,33 @@ function OnClickOpenImage( F_ID ) $("img#"+F_ID).click(); } - - - +function UpdateModelID( ModelId ) +{ + m_ModelID=ModelId; + if( ModelId!='' ) + { + if( !$('#ModelName').hasClass('NameCanClick') ) + $('#ModelName').addClass('NameCanClick'); + } + else + { + $('#ModelName').removeClass('NameCanClick'); + } +} + +function JumpToWeb() +{ + if(m_ModelID=='') + return; + + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="modelmall_model_open"; + tSend['data']={}; + tSend['data']['id']=m_ModelID+''; + + SendWXMessage( JSON.stringify(tSend) ); +} diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index c32b8e131..1174b9251 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3825,13 +3825,13 @@ void GUI_App::get_login_info() if (m_agent->is_user_login()) { std::string login_cmd = m_agent->build_login_cmd(); wxString strJS = wxString::Format("window.postMessage(%s)", login_cmd); - GUI::wxGetApp().run_script(strJS); + GUI::wxGetApp().run_script_left(strJS); } else { m_agent->user_logout(); std::string logout_cmd = m_agent->build_logout_cmd(); wxString strJS = wxString::Format("window.postMessage(%s)", logout_cmd); - GUI::wxGetApp().run_script(strJS); + GUI::wxGetApp().run_script_left(strJS); } } } @@ -3975,7 +3975,7 @@ std::string GUI_App::handle_web_request(std::string cmd) else if (command_str.compare("modelmall_model_advise_get") == 0) { if (mainframe && this->app_config->get("staff_pick_switch") == "true") { if (mainframe->m_webview) { - mainframe->m_webview->SendDesignStaffpick(has_model_mall()); + mainframe->m_webview->SendDesignStaffpick(has_model_mall()); } } } @@ -4086,6 +4086,44 @@ std::string GUI_App::handle_web_request(std::string cmd) if (path.has_value()) { wxLaunchDefaultBrowser(path.value()); } + } + else if (command_str.compare("homepage_leftmenu_clicked") == 0) { + if (root.get_child_optional("menu") != boost::none) { + std::string strMenu = root.get_optional("menu").value(); + int nRefresh = root.get_child_optional("refresh") == boost::none ? 0 : root.get_optional("refresh").value(); + + if (mainframe->m_webview) { + mainframe->m_webview->SwitchWebContent(strMenu, nRefresh); + } + } + } + else if (command_str.compare("homepage_leftmenu_switch") == 0) { + if (root.get_child_optional("menu") != boost::none) { + std::string strMenu = root.get_optional("menu").value(); + + if (mainframe->m_webview) { mainframe->m_webview->SwitchLeftMenu(strMenu); } + } + } + else if (command_str.compare("homepage_makerlab_get") == 0) { + if (mainframe->m_webview) { mainframe->m_webview->SendMakerlabList(); } + } + else if (command_str.compare("homepage_makerlab_open") == 0) { + if (root.get_child_optional("url") != boost::none) { + std::string strUrl = root.get_optional("url").value(); + + if (mainframe->m_webview) { mainframe->m_webview->OpenOneMakerlab(strUrl); } + } + } + else if (command_str.compare("makerworld_model_open") == 0) + { + if (root.get_child_optional("model") != boost::none) { + pt::ptree data_node = root.get_child("model"); + boost::optional path = data_node.get_optional("url"); + if (path.has_value()) + { + wxGetApp().request_model_download(path.value()); + } + } } } } @@ -6206,6 +6244,12 @@ void GUI_App::run_script(wxString js) return mainframe->RunScript(js); } +void GUI_App::run_script_left(wxString js) +{ + if (mainframe) + return mainframe->RunScriptLeft(js); +} + Notebook* GUI_App::tab_panel() const { if (mainframe) diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index f517b5c43..aa99cae9f 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -554,6 +554,7 @@ public: void open_publish_page_dialog(); void remove_mall_system_dialog(); void run_script(wxString js); + void run_script_left(wxString js); bool is_adding_script_handler() { return m_adding_script_handler; } void set_adding_script_handler(bool status) { m_adding_script_handler = status; } diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index f5cc31580..b1312400e 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -3724,6 +3724,12 @@ void MainFrame::RunScript(wxString js) m_webview->RunScript(js); } +void MainFrame::RunScriptLeft(wxString js) +{ + if (m_webview != nullptr) + m_webview->RunScriptLeft(js); +} + void MainFrame::technology_changed() { // upadte DiffDlg diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index da8071bc1..a32085d4d 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -342,6 +342,7 @@ public: bool is_printer_view() const; void refresh_plugin_tips(); void RunScript(wxString js); + void RunScriptLeft(wxString js); void show_device(bool bBBLPrinter); // OrcaSlicer calibration diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 5b6972afc..71d36a6df 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -32,16 +32,20 @@ namespace GUI { END_EVENT_TABLE() - WebViewPanel::WebViewPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize) { - wxString url = wxString::Format("file://%s/web/homepage/index.html", from_u8(resources_dir())); - wxString strlang = wxGetApp().current_language_code_safe(); - if (strlang != "") - url = wxString::Format("file://%s/web/homepage/index.html?lang=%s", from_u8(resources_dir()), strlang); + wxString UrlLeft = wxString::Format("file://%s/web/homepage2/left.html", from_u8(resources_dir())); + wxString UrlRight = wxString::Format("file://%s/web/homepage2/home.html", from_u8(resources_dir())); - wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL); + wxString strlang = wxGetApp().current_language_code_safe(); + if (strlang != "") + { + UrlLeft = wxString::Format("file://%s/web/homepage2/left.html?lang=%s", from_u8(resources_dir()), strlang); + UrlRight = wxString::Format("file://%s/web/homepage2/home.html?lang=%s", from_u8(resources_dir()), strlang); + } + + topsizer = new wxBoxSizer(wxVERTICAL); #if !BBL_RELEASE_TO_PUBLIC // Create the button @@ -82,26 +86,49 @@ WebViewPanel::WebViewPanel(wxWindow *parent) // Create the info panel m_info = new wxInfoBar(this); topsizer->Add(m_info, wxSizerFlags().Expand()); + + //Create Webview Panel + m_home_web = new wxBoxSizer(wxHORIZONTAL); + // Create the webview - m_browser = WebView::CreateWebView(this, url); + m_browserLeft = WebView::CreateWebView(this, UrlLeft); + //m_browserRight->SetBackgroundColour(*wxYELLOW); + if (m_browserLeft == nullptr) { + wxLogError("Could not init m_browser"); + return; + } + m_browserLeft->SetSize(wxSize(FromDIP(224), -1)); + m_browserLeft->SetMinSize(wxSize(FromDIP(224), -1)); + m_browserLeft->SetMaxSize(wxSize(FromDIP(224), -1)); + //m_browser->Hide(); + + m_browser = WebView::CreateWebView(this, UrlRight); + //m_browserRight->SetBackgroundColour(*wxRED); if (m_browser == nullptr) { wxLogError("Could not init m_browser"); return; } - m_browser->Hide(); - SetSizer(topsizer); - topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1)); - - // Log backend information - /* m_browser->GetUserAgent() may lead crash - if (wxGetApp().get_mode() == comDevelop) { - wxLogMessage(wxWebView::GetBackendVersionInfo().ToString()); - wxLogMessage("Backend: %s Version: %s", m_browser->GetClassInfo()->GetClassName(), - wxWebView::GetBackendVersionInfo().ToString()); - wxLogMessage("User Agent: %s", m_browser->GetUserAgent()); + 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(); + //std::string mwurl = (boost::format("%1%?from=bambustudio") % host).str(); + m_browserMW = WebView::CreateWebView(this, mwurl); + if (m_browserMW == nullptr) { + wxLogError("Could not init m_browserMW"); + return; } - */ + + m_browserMW->Hide(); + + 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); + + topsizer->Add(m_home_web,1, wxEXPAND | wxALL, 0); + + SetSizer(topsizer); // Create the Tools menu m_tools_menu = new wxMenu(); @@ -221,8 +248,9 @@ WebViewPanel::WebViewPanel(wxWindow *parent) m_LoginUpdateTimer = nullptr; Bind(wxEVT_SHOW, [this](auto &e) { - if (e.IsShown() && m_has_pending_staff_pick) + if (e.IsShown() && m_has_pending_staff_pick) { SendDesignStaffpick(true); + } }); } @@ -421,9 +449,28 @@ void WebViewPanel::OnClose(wxCloseEvent& evt) void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event) { + static int loginstatus = -1; + + wxString mwnow = m_browserMW->GetCurrentURL(); + auto mainframe = Slic3r::GUI::wxGetApp().mainframe; if (mainframe && mainframe->m_webview == this) Slic3r::GUI::wxGetApp().get_login_info(); + + if (wxGetApp().is_user_login()) { + if (loginstatus != 1) + { + loginstatus = 1; + + UpdateMakerworldLoginStatus(); + } + } else { + if (loginstatus != 0) { + loginstatus = 0; + + SetMakerworldPageLoginStatus(false); + } + } } void WebViewPanel::SendRecentList(int images) @@ -441,46 +488,152 @@ void WebViewPanel::SendRecentList(int images) void WebViewPanel::SendDesignStaffpick(bool on) { - if (on) { - if (!IsShownOnScreen()) { - m_has_pending_staff_pick = true; - return; + try { + if (on) { + if (!IsShownOnScreen()) { + m_has_pending_staff_pick = true; + return; + } + + //For U Pick + NetworkAgent *agent = GUI::wxGetApp().getAgent(); + if (agent && agent->is_user_login()) { + get_user_mw_4u_config([this](std::string body) { + if (body.empty() || body.front() != '{') { + BOOST_LOG_TRIVIAL(warning) << "get_mw_user_preference failed " + body; + return; + } + CallAfter([this, body] { + json jPrefer = json::parse(body); + + int nRecommendStatus = jPrefer["recommendStatus"]; + if (nRecommendStatus != 1 && nRecommendStatus != 3) + { + // Default : Staff Pick + get_design_staffpick(0, 10, [this](std::string body) { + if (body.empty() || body.front() != '{') { + BOOST_LOG_TRIVIAL(warning) << "get_design_staffpick failed " + body; + return; + } + CallAfter([this, body] { + auto body2 = from_u8(body); + body2.insert(1, "\"command\": \"modelmall_model_advise_get\", "); + RunScript(wxString::Format("window.postMessage(%s)", body2)); + + //Show Online Menu + SetLeftMenuShow("online", 1); + }); + }); + } else { + //For U Pick + get_4u_staffpick(0, 10, [this](std::string body) { + if (body.empty() || body.front() != '{') { + BOOST_LOG_TRIVIAL(warning) << "get_mw_user_4ulist failed " + body; + return; + } + CallAfter([this, body] { + auto body2 = from_u8(body); + body2.insert(1, "\"command\": \"modelmall_model_customized_get\", "); + RunScript(wxString::Format("window.postMessage(%s)", body2)); + + //Show Online Menu + SetLeftMenuShow("online", 1); + }); + }); + } + }); + }); + + } + else + { + // Default : Staff Pick + get_design_staffpick(0, 10, [this](std::string body) { + if (body.empty() || body.front() != '{') { + BOOST_LOG_TRIVIAL(warning) << "get_design_staffpick failed " + body; + return; + } + CallAfter([this, body] { + auto body2 = from_u8(body); + body2.insert(1, "\"command\": \"modelmall_model_advise_get\", "); + RunScript(wxString::Format("window.postMessage(%s)", body2)); + + //Show Online Menu + SetLeftMenuShow("online", 1); + }); + }); + } + } else { + std::string body2 = "{\"total\":0, \"hits\":[]}"; + body2.insert(1, "\"command\": \"modelmall_model_advise_get\", "); + RunScript(wxString::Format("window.postMessage(%s)", body2)); } - get_design_staffpick(0, 60, [this](std::string body) { + } catch (nlohmann::detail::parse_error &err) { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse got a nlohmann::detail::parse_error, reason = " << err.what(); + return; + } catch (std::exception &e) { + // wxMessageBox(e.what(), "", MB_OK); + // wxLogMessage("GUIDE: LoadFamily Error: %s", e.what()); + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse got exception: " << e.what(); + return; + } + + m_has_pending_staff_pick = false; +} + +void WebViewPanel::SendMakerlabList( ) +{ + try { + get_makerlab_list([this](std::string body) { if (body.empty() || body.front() != '{') { - BOOST_LOG_TRIVIAL(warning) << "get_design_staffpick failed " + body; + BOOST_LOG_TRIVIAL(warning) << "get_makerlab_list failed " + body; return; } CallAfter([this, body] { auto body2 = from_u8(body); - body2.insert(1, "\"command\": \"modelmall_model_advise_get\", "); + body2.insert(1, "\"command\": \"homepage_makerlab_get\", "); RunScript(wxString::Format("window.postMessage(%s)", body2)); + + SetLeftMenuShow("makerlab", 1); }); }); - } else { - std::string body2 = "{\"total\":0, \"hits\":[]}"; - body2.insert(1, "\"command\": \"modelmall_model_advise_get\", "); - RunScript(wxString::Format("window.postMessage(%s)", body2)); + } catch (nlohmann::detail::parse_error &err) { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse got a nlohmann::detail::parse_error, reason = " << err.what(); + return; + } catch (std::exception &e) { + // wxMessageBox(e.what(), "", MB_OK); + // wxLogMessage("GUIDE: LoadFamily Error: %s", e.what()); + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": parse got exception: " << e.what(); + return; } + m_has_pending_staff_pick = false; } -void WebViewPanel::OpenModelDetail(std::string id, NetworkAgent *agent) -{ - std::string url; - if ((agent ? agent->get_model_mall_detail_url(&url, id) : get_model_mall_detail_url(&url, id)) == 0) - { - if (url.find("?") != std::string::npos) - { - url += "&from=bambustudio"; - } else { - url += "?from=bambustudio"; - } - - wxLaunchDefaultBrowser(url); - } +//void WebViewPanel::OpenModelDetail(std::string id, NetworkAgent *agent) +//{ +// std::string url; +// if ((agent ? agent->get_model_mall_detail_url(&url, id) : get_model_mall_detail_url(&url, id)) == 0) +// { +// if (url.find("?") != std::string::npos) +// { +// url += "&from=bambustudio"; +// } else { +// url += "?from=bambustudio"; +// } +// +// wxLaunchDefaultBrowser(url); +// } +//} + +void WebViewPanel::OpenModelDetail(std::string id, NetworkAgent *agent) +{ + SwitchLeftMenu("online"); + + m_online_spec_id = id; } + void WebViewPanel::SendLoginInfo() { if (wxGetApp().getAgent()) { @@ -526,6 +679,137 @@ void WebViewPanel::get_design_staffpick(int offset, int limit, std::function callback) +{ + std::string url = wxGetApp().get_http_url(wxGetApp().app_config->get_country_code(), "v1/operation-service/makerlabhomepage"); + + Http http = Http::get(url); + http.header("accept", "application/json") + .header("Content-Type", "application/json") + .on_complete([this, callback](std::string body, unsigned status) { callback(body); }) + .on_error([this, callback](std::string body, std::string error, unsigned status) { callback(body + error); }) + .perform(); +} + +unsigned char ToHex(unsigned char x) { return x > 9 ? x + 55 : x + 48; } + +unsigned char FromHex(unsigned char x) +{ + unsigned char y; + if (x >= 'A' && x <= 'Z') + y = x - 'A' + 10; + else if (x >= 'a' && x <= 'z') + y = x - 'a' + 10; + else if (x >= '0' && x <= '9') + y = x - '0'; + else + assert(0); + return y; +} + +std::string UrlEncode(const std::string &str) +{ + std::string strTemp = ""; + size_t length = str.length(); + for (size_t i = 0; i < length; i++) { + if (isalnum((unsigned char) str[i]) || (str[i] == '-') || (str[i] == '_') || (str[i] == '.') || (str[i] == '~')) + strTemp += str[i]; + else if (str[i] == ' ') + strTemp += "+"; + else { + strTemp += '%'; + strTemp += ToHex((unsigned char) str[i] >> 4); + strTemp += ToHex((unsigned char) str[i] % 16); + } + } + return strTemp; +} + +std::string UrlDecode(const std::string &str) +{ + std::string strTemp = ""; + size_t length = str.length(); + for (size_t i = 0; i < length; i++) { + if (str[i] == '+') + strTemp += ' '; + else if (str[i] == '%') { + assert(i + 2 < length); + unsigned char high = FromHex((unsigned char) str[++i]); + unsigned char low = FromHex((unsigned char) str[++i]); + strTemp += high * 16 + low; + } else + strTemp += str[i]; + } + return strTemp; +} + +//void WebViewPanel::UpdateMakerworldLoginStatus() { +// NetworkAgent *agent = GUI::wxGetApp().getAgent(); +// if (agent == nullptr) return; +// +// int ret = agent->get_login_ticket([this](std::string body) { +// if (body.empty() || body.front() != '{') { +// BOOST_LOG_TRIVIAL(warning) << "get_login_ticket failed " + body; +// +// SetMakerworldPageLoginStatus(false); +// +// return; +// } +// CallAfter([this, body] { +// json jticket = json::parse(body); +// +// std::string ticket = jticket["ticket"]; +// +// SetMakerworldPageLoginStatus(true, ticket); +// }); +// } +// ); +//} + +void WebViewPanel::UpdateMakerworldLoginStatus() +{ + NetworkAgent *agent = GUI::wxGetApp().getAgent(); + if (agent == nullptr) return; + + std::string newticket; + int ret = agent->request_bind_ticket(&newticket); + if (ret==0) SetMakerworldPageLoginStatus(true, newticket); +} + + +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(); + wxString mw_jumpurl = ""; + + if ( login ) + { + mw_jumpurl = wxString::Format("%sapi/sign-in/ticket?to=%s&ticket=%s", h, UrlEncode(std::string(mw_currenturl.mb_str())), ticket); + } + else { + mw_jumpurl = wxString::Format("%sapi/sign-out?to=%s", h, UrlEncode(std::string(mw_currenturl.mb_str()))); + } + + m_browserMW->LoadURL(mw_jumpurl); +} + + +void WebViewPanel::get_user_mw_4u_config(std::function callback) { + NetworkAgent *agent = GUI::wxGetApp().getAgent(); + if (agent) + int ret = agent->get_mw_user_preference(callback); +} + +void WebViewPanel::get_4u_staffpick(int seed, int limit, std::function callback) +{ + NetworkAgent *agent = GUI::wxGetApp().getAgent(); + if (agent) + int ret = agent->get_mw_user_4ulist(seed,limit,callback); +} + int WebViewPanel::get_model_mall_detail_url(std::string *url, std::string id) { // https://makerhub-qa.bambu-lab.com/en/models/2077 @@ -552,13 +836,34 @@ void WebViewPanel::OnNavigationRequest(wxWebViewEvent& evt) BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << evt.GetTarget().ToUTF8().data(); const wxString &url = evt.GetURL(); if (url.StartsWith("File://") || url.StartsWith("file://")) { - if (!url.Contains("/web/homepage/index.html")) { + if (!url.Contains("/web/homepage2/")) { auto file = wxURL::Unescape(wxURL(url).GetPath()); #ifdef _WIN32 if (file.StartsWith('/')) file = file.Mid(1); #endif wxGetApp().plater()->load_files(wxArrayString{1, &file}); + evt.Veto(); + return; + } + } + else { + wxString surl = url; + if (surl.find("?") != std::string::npos) { + surl = surl.substr(0, surl.find("?")).Lower(); + } + + if (surl.EndsWith(".zip") || + surl.EndsWith(".pdf") || + surl.EndsWith(".stl") || + surl.EndsWith(".3mf") || + surl.EndsWith(".xlsx") || + surl.EndsWith(".xls") || + surl.EndsWith(".txt") + ) + { + wxLaunchDefaultBrowser(url); + evt.Veto(); return; } @@ -591,7 +896,16 @@ void WebViewPanel::OnNavigationRequest(wxWebViewEvent& evt) */ void WebViewPanel::OnNavigationComplete(wxWebViewEvent& evt) { - m_browser->Show(); + if (evt.GetId() == m_browserMW->GetId()) { + m_onlinefirst = true; + + if (m_contentname == "online") { // conf save + m_browser->Hide(); + m_browserMW->Show(); + } + } + + //m_browser->Show(); Layout(); BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << evt.GetTarget().ToUTF8().data(); if (wxGetApp().get_mode() == comDevelop) @@ -607,11 +921,14 @@ void WebViewPanel::OnDocumentLoaded(wxWebViewEvent& evt) { BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << evt.GetTarget().ToUTF8().data(); // Only notify if the document is the main frame, not a subframe - if (evt.GetURL() == m_browser->GetCurrentURL()) + if (evt.GetURL() == m_browser->GetCurrentURL()) { + if (wxGetApp().get_mode() == comDevelop) wxLogMessage("%s", "Document loaded; url='" + evt.GetURL() + "'"); + } + else if (evt.GetURL() == m_browserLeft->GetCurrentURL()) { - if (wxGetApp().get_mode() == comDevelop) - wxLogMessage("%s", "Document loaded; url='" + evt.GetURL() + "'"); + } + UpdateState(); } @@ -745,6 +1062,18 @@ void WebViewPanel::RunScript(const wxString& javascript) WebView::RunScript(m_browser, javascript); } +void WebViewPanel::RunScriptLeft(const wxString &javascript) +{ + // Remember the script we run in any case, so the next time the user opens + // the "Run Script" dialog box, it is shown there for convenient updating. + m_javascript = javascript; + + if (!m_browserLeft) return; + + WebView::RunScript(m_browserLeft, javascript); +} + + void WebViewPanel::OnRunScriptString(wxCommandEvent& WXUNUSED(evt)) { RunScript("setCount(345);"); @@ -902,9 +1231,166 @@ void WebViewPanel::OnError(wxWebViewEvent& evt) 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()) + { + m_onlinefirst = false; + + if (m_contentname == "online") + { + wxString errurl = evt.GetURL(); + + wxString UrlRight = wxString::Format("file://%s/web/homepage2/disconnect.html", from_u8(resources_dir())); + + wxString strlang = wxGetApp().current_language_code_safe(); + if (strlang != "") { + UrlRight = wxString::Format("file://%s/web/homepage2/disconnect.html?lang=%s", from_u8(resources_dir()), strlang); + } + + m_browser->LoadURL(UrlRight); + m_browser->Show(); + m_browserMW->Hide(); + } + } + UpdateState(); } +void WebViewPanel::SwitchWebContent(std::string modelname,int refresh) +{ + m_contentname = modelname; + + static bool bFirst = false; + if (bFirst == false) { + bFirst = true; + CheckMenuNewTag(); + } + + 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(); + + wxLaunchDefaultBrowser(LabUrl); + + //conf save + wxGetApp().app_config->set_str("homepage", "makerlab_clicked", "1"); + wxGetApp().app_config->save(); + + return; + } + else if (modelname.compare("online") == 0) { + 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(); + + m_onlinefirst = true; + m_browserMW->LoadURL(mwurl); + + m_online_spec_id = ""; + } + else { + if (m_onlinefirst == false) { + m_onlinefirst = true; + refresh = 1; // Force Refresh + + m_browserMW->Reload(); + } else { + if (refresh == 1) + m_browserMW->Reload(); + else { + m_browserMW->Show(); + m_browser->Hide(); + } + } + } + + GetSizer()->Layout(); + + // conf save + wxGetApp().app_config->set_str("homepage", "makerlab_clicked", "1"); + wxGetApp().app_config->save(); + } + else if (modelname.compare("home") == 0 || modelname.compare("recent") == 0 || modelname.compare("manual") == 0 ) + { + wxString UrlRight = wxString::Format("file://%s/web/homepage2/%s.html", from_u8(resources_dir()), modelname); + if (strlang != "") + UrlRight = wxString::Format("%s?lang=%s", UrlRight, strlang); + + if (m_browser != NULL) m_browser->LoadURL(UrlRight); + + m_browserMW->Hide(); + m_browser->Show(); + } +} + +void WebViewPanel::SwitchLeftMenu(std::string strMenu) +{ + if (!m_browserLeft) return; + + json m_Res = json::object(); + m_Res["command"] = "homepage_leftmenu_clicked"; + m_Res["sequence_id"] = "10001"; + m_Res["menu"] = strMenu; + + // wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', false, json::error_handler_t::ignore)); + wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true)); + + 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%") % host % url).str(); + + wxLaunchDefaultBrowser(LabUrl); +} + + +void WebViewPanel::CheckMenuNewTag() { + std::string sClick = wxGetApp().app_config->get("homepage", "online_clicked"); + ShowMenuNewTag("online", sClick); + + sClick = wxGetApp().app_config->get("homepage", "makerlab_clicked"); + ShowMenuNewTag("makerlab", sClick); +} + +void WebViewPanel::ShowMenuNewTag(std::string menuname, std::string show) +{ + if (!m_browserLeft) return; + + if (menuname != "online" && menuname != "makerlab") return; + + json m_Res = json::object(); + m_Res["command"] = "homepage_leftmenu_newtag"; + m_Res["sequence_id"] = "10001"; + m_Res["menu"] = menuname; + + + if (show != "1") + m_Res["show"] = 1; + else + m_Res["show"] = 0; + + wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true)); + WebView::RunScript(m_browserLeft, strJS); +} + +void WebViewPanel::SetLeftMenuShow(std::string menuname, int show) +{ + if (!m_browserLeft) return; + + json m_Res = json::object(); + m_Res["command"] = "homepage_leftmenu_show"; + m_Res["sequence_id"] = "10001"; + m_Res["menu"] = menuname; + m_Res["show"] = show; + + wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true)); + WebView::RunScript(m_browserLeft, strJS); +} + SourceViewDialog::SourceViewDialog(wxWindow* parent, wxString source) : wxDialog(parent, wxID_ANY, "Source Code", diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp index 3a91ced64..e1c9d9f6b 100644 --- a/src/slic3r/GUI/WebViewDialog.hpp +++ b/src/slic3r/GUI/WebViewDialog.hpp @@ -66,6 +66,7 @@ public: void OnRedo(wxCommandEvent& evt); void OnMode(wxCommandEvent& evt); void RunScript(const wxString& javascript); + void RunScriptLeft(const wxString &javascript); void OnRunScriptString(wxCommandEvent& evt); void OnRunScriptInteger(wxCommandEvent& evt); void OnRunScriptDouble(wxCommandEvent& evt); @@ -93,19 +94,43 @@ public: void OnFreshLoginStatus(wxTimerEvent &event); public: + void SwitchWebContent(std::string modelname, int refresh=0); + void SwitchLeftMenu(std::string strMenu); + void OpenOneMakerlab(std::string url); + + 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); void SendLoginInfo(); void ShowNetpluginTip(); void get_design_staffpick(int offset, int limit, std::function callback); + void get_user_mw_4u_config(std::function callback); + void get_4u_staffpick(int seed, int limit, std::function callback); + void get_makerlab_list(std::function callback); int get_model_mall_detail_url(std::string *url, std::string id); + void UpdateMakerworldLoginStatus(); + void SetMakerworldPageLoginStatus(bool login, wxString ticket = ""); + void update_mode(); private: + wxBoxSizer *topsizer; + + wxBoxSizer* m_home_web; wxWebView* m_browser; + wxWebView* m_browserLeft; + wxWebView * m_browserMW; + std::string m_contentname; + bool m_onlinefirst; + std::string m_online_spec_id; + wxBoxSizer *bSizer_toolbar; wxButton * m_button_back; wxButton * m_button_forward; diff --git a/src/slic3r/Utils/NetworkAgent.cpp b/src/slic3r/Utils/NetworkAgent.cpp index 1277995c4..fa2c2c2c4 100644 --- a/src/slic3r/Utils/NetworkAgent.cpp +++ b/src/slic3r/Utils/NetworkAgent.cpp @@ -116,6 +116,8 @@ func_get_oss_config NetworkAgent::get_oss_config_ptr = nullptr; func_put_rating_picture_oss NetworkAgent::put_rating_picture_oss_ptr = nullptr; func_get_model_mall_rating_result NetworkAgent::get_model_mall_rating_result_ptr = nullptr; +func_get_mw_user_preference NetworkAgent::get_mw_user_preference_ptr = nullptr; +func_get_mw_user_4ulist NetworkAgent::get_mw_user_4ulist_ptr = nullptr; NetworkAgent::NetworkAgent(std::string log_dir) { @@ -257,8 +259,8 @@ int NetworkAgent::initialize_network_module(bool using_backup) get_slice_info_ptr = reinterpret_cast(get_network_function("bambu_network_get_slice_info")); query_bind_status_ptr = reinterpret_cast(get_network_function("bambu_network_query_bind_status")); modify_printer_name_ptr = reinterpret_cast(get_network_function("bambu_network_modify_printer_name")); - get_camera_url_ptr = reinterpret_cast(get_network_function("bambu_network_get_camera_url")); - get_design_staffpick_ptr = reinterpret_cast(get_network_function("bambu_network_get_design_staffpick")); + get_camera_url_ptr = reinterpret_cast(get_network_function("bambu_network_get_camera_url")); + get_design_staffpick_ptr = reinterpret_cast(get_network_function("bambu_network_get_design_staffpick")); start_publish_ptr = reinterpret_cast(get_network_function("bambu_network_start_publish")); get_profile_3mf_ptr = reinterpret_cast(get_network_function("bambu_network_get_profile_3mf")); get_model_publish_url_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_publish_url")); @@ -277,6 +279,9 @@ int NetworkAgent::initialize_network_module(bool using_backup) put_rating_picture_oss_ptr = reinterpret_cast(get_network_function("bambu_network_put_rating_picture_oss")); get_model_mall_rating_result_ptr = reinterpret_cast(get_network_function("bambu_network_get_model_mall_rating")); + get_mw_user_preference_ptr = reinterpret_cast(get_network_function("bambu_network_get_mw_user_preference")); + get_mw_user_4ulist_ptr = reinterpret_cast(get_network_function("bambu_network_get_mw_user_4ulist")); + return 0; } @@ -390,6 +395,9 @@ int NetworkAgent::unload_network_module() put_rating_picture_oss_ptr = nullptr; put_model_mall_rating_url_ptr = nullptr; get_model_mall_rating_result_ptr = nullptr; + + get_mw_user_preference_ptr = nullptr; + get_mw_user_4ulist_ptr = nullptr; return 0; } @@ -1197,6 +1205,27 @@ int NetworkAgent::get_design_staffpick(int offset, int limit, std::function callback) +{ + int ret = 0; + if (network_agent && get_mw_user_preference_ptr) { + ret = get_mw_user_preference_ptr(network_agent,callback); + if (ret) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret; + } + return ret; +} + + +int NetworkAgent::get_mw_user_4ulist(int seed, int limit, std::function callback) +{ + int ret = 0; + if (network_agent && get_mw_user_4ulist_ptr) { + ret = get_mw_user_4ulist_ptr(network_agent,seed, limit, callback); + if (ret) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%") % network_agent % ret; + } + return ret; +} + int NetworkAgent::start_publish(PublishParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn, std::string *out) { int ret = 0; diff --git a/src/slic3r/Utils/NetworkAgent.hpp b/src/slic3r/Utils/NetworkAgent.hpp index 8847d4efb..61a96314d 100644 --- a/src/slic3r/Utils/NetworkAgent.hpp +++ b/src/slic3r/Utils/NetworkAgent.hpp @@ -98,6 +98,8 @@ typedef int (*func_put_rating_picture_oss)( void *agent, std::string &config, std::string &pic_oss_path, std::string model_id, int profile_id, unsigned int &http_code, std::string &http_error); typedef int (*func_get_model_mall_rating_result)(void *agent, int job_id, std::string &rating_result, unsigned int &http_code, std::string &http_error); +typedef int (*func_get_mw_user_preference)(void *agent, std::function callback); +typedef int (*func_get_mw_user_4ulist)(void *agent, int seed, int limit, std::function callback); //the NetworkAgent class class NetworkAgent @@ -201,6 +203,10 @@ public: int put_rating_picture_oss(std::string &config, std::string &pic_oss_path, std::string model_id, int profile_id, unsigned int &http_code, std::string &http_error); int get_model_mall_rating_result(int job_id, std::string &rating_result, unsigned int &http_code, std::string &http_error); bool get_track_enable() { return enable_track; } + + int get_mw_user_preference(std::function callback); + int get_mw_user_4ulist(int seed, int limit, std::function callback); + private: bool enable_track = false; void* network_agent { nullptr }; @@ -293,6 +299,9 @@ private: static func_get_oss_config get_oss_config_ptr; static func_put_rating_picture_oss put_rating_picture_oss_ptr; static func_get_model_mall_rating_result get_model_mall_rating_result_ptr; + + static func_get_mw_user_preference get_mw_user_preference_ptr; + static func_get_mw_user_4ulist get_mw_user_4ulist_ptr; }; }