From 3317e4be690ed25e18d2c618b4279607bb40000b Mon Sep 17 00:00:00 2001 From: "zorro.zhang" Date: Thu, 31 Oct 2024 15:21:41 +0800 Subject: [PATCH] NEW: PrintHistory and Model Info JIRA: none Change-Id: Ie86677010972568655f99a6b49ede32c5772b912 --- resources/web/data/text.js | 200 ++++- resources/web/homepage3/css/common.css | 24 +- resources/web/homepage3/css/dark.css | 40 + resources/web/homepage3/css/home.css | 167 +++- resources/web/homepage3/css/left.css | 6 + resources/web/homepage3/css/online.css | 42 +- resources/web/homepage3/css/recent.css | 1 - resources/web/homepage3/css/rightcommon.css | 2 +- resources/web/homepage3/disconnect.html | 2 +- resources/web/homepage3/home.html | 159 +++- resources/web/homepage3/img/device.svg | 15 + resources/web/homepage3/img/left_ph.svg | 8 + resources/web/homepage3/img/ph.svg | 23 + resources/web/homepage3/img/refresh.svg | 3 + resources/web/homepage3/img/search.svg | 3 + resources/web/homepage3/img/search_dark.svg | 3 + resources/web/homepage3/img/time.svg | 12 + resources/web/homepage3/js/home.js | 210 ++++- resources/web/homepage3/js/test.js | 929 ++++++++++++++++++++ resources/web/homepage3/left.html | 4 + resources/web/include/globalapi.js | 26 +- resources/web/model/index.html | 2 - resources/web/model/model.css | 1 - resources/web/model/model.js | 16 +- src/slic3r/GUI/GUI_App.cpp | 39 +- src/slic3r/GUI/Project.cpp | 45 +- src/slic3r/GUI/Project.hpp | 4 +- src/slic3r/GUI/WebGuideDialog.cpp | 8 +- src/slic3r/GUI/WebUserLoginDialog.cpp | 6 - src/slic3r/GUI/WebUserLoginDialog.hpp | 2 - src/slic3r/GUI/WebViewDialog.cpp | 264 +++++- src/slic3r/GUI/WebViewDialog.hpp | 20 +- 32 files changed, 2165 insertions(+), 121 deletions(-) create mode 100644 resources/web/homepage3/img/device.svg create mode 100644 resources/web/homepage3/img/left_ph.svg create mode 100644 resources/web/homepage3/img/ph.svg create mode 100644 resources/web/homepage3/img/refresh.svg create mode 100644 resources/web/homepage3/img/search.svg create mode 100644 resources/web/homepage3/img/search_dark.svg create mode 100644 resources/web/homepage3/img/time.svg diff --git a/resources/web/data/text.js b/resources/web/data/text.js index 73fc72e91..4822d901c 100644 --- a/resources/web/data/text.js +++ b/resources/web/data/text.js @@ -107,7 +107,15 @@ var LangText={ "t113": "You may change your choice in preference anytime.", "t114": "Home", "t115": "Batch", - "t116": "Retry" + "t116": "Retry", + "t117": "Print History", + "t118": "Printing", + "t119": "Success", + "t120": "Canceled", + "t121": "Search", + "t122": "Search online models", + "t123": "Plate", + "t124": "" }, "zh_CN": { "t1": "欢迎使用Bambu Studio", @@ -218,6 +226,14 @@ var LangText={ "t114": "首页", "t115": "批量处理", "t116": "重试", + "t117": "打印历史", + "t118": "正在打印", + "t119": "成功", + "t120": "已取消", + "t121": "搜索", + "t122": "搜索在线模型", + "t123": "第", + "t124": " 盘", "wk1": "快速入门指南", "wk2": "本文介绍了Bambu Studio的最基本用法。它指导用户配置软件,创建项目,并逐步完成第一个打印任务。", "wk3": "基于项目的工作流", @@ -343,7 +359,15 @@ var LangText={ "t113": "好みはいつでも変更できます.", "t114": "トップページ", "t115": "バッチ", - "t116": "[再試行]" + "t116": "[再試行]", + "t117": "印刷履歴", + "t118": "印刷中", + "t119": "成功", + "t120": "キャンセルされた", + "t121": "検索", + "t122": "オンラインモデルを検索する", + "t123": "シート材", + "t124": "" }, "it_IT": { "t1": "Benvenuti allo Studio Bambu", @@ -453,7 +477,15 @@ var LangText={ "t113": "Puoi cambiare la tua scelta in qualsiasi momento.", "t114": "Home", "t115": "Lotto", - "t116": "Riprova" + "t116": "Riprova", + "t117": "Storico di stampa", + "t118": "Stampa in corso", + "t119": "Successo", + "t120": "annullato", + "t121": "Ricerca", + "t122": "Cerca modelli online", + "t123": "piatto", + "t124": "" }, "fr_FR": { "t1": "Bienvenue chez Bambu Studio", @@ -563,7 +595,15 @@ var LangText={ "t113": "Vous pouvez modifier vos préférences à tout moment.", "t114": "Accueil", "t115": "Un lot de", - "t116": "Retenter" + "t116": "Retenter", + "t117": "Historique d'impression", + "t118": "Impression en cours", + "t119": "Succès", + "t120": "annulé", + "t121": "Recherche", + "t122": "Rechercher des modèles en ligne", + "t123": "assiette", + "t124": "" }, "de_DE": { "t1": "Willkommen im Bambu Studio", @@ -673,7 +713,15 @@ var LangText={ "t113": "Sie können Ihre Wahl jederzeit ändern.", "t114": "Startseite", "t115": "Charge", - "t116": "Erneut versuchen" + "t116": "Erneut versuchen", + "t117": "Druckverlauf", + "t118": "Wird gedruckt", + "t119": "Erfolg", + "t120": "storniert", + "t121": "Suche", + "t122": "Suche Online-Modelle", + "t123": "Teller", + "t124": "" }, "hu_HU": { "t1": "Üdvözöljük a Bambu Stúdióban", @@ -783,7 +831,15 @@ var LangText={ "t113": "Bármikor megváltoztathatja a preferenciáját.", "t114": "honlap", "t115": "Tétel", - "t116": "Újrapróbálkozás" + "t116": "Újrapróbálkozás", + "t117": "Nyomtatási előzmények", + "t118": "Nyomtatás folyamatban", + "t119": "Siker", + "t120": "törölt", + "t121": "Keresés", + "t122": "Online modellek keresése", + "t123": "tányér", + "t124": "" }, "es_ES": { "t1": "Bienvenido a Bambu Studio", @@ -893,7 +949,15 @@ var LangText={ "t113": "Puede cambiar sus preferencias en cualquier momento.", "t114": "Página de inicio", "t115": "Un lote", - "t116": "Reintentar" + "t116": "Reintentar", + "t117": "Historial de impresión", + "t118": "Imprimiendo", + "t119": "Éxito", + "t120": "cancelado", + "t121": "Búsqueda", + "t122": "Buscar modelos en línea", + "t123": "plato", + "t124": "" }, "sv_SE": { "t1": "Välkommen till Bambu Studio", @@ -1003,7 +1067,15 @@ var LangText={ "t113": "Du kan ändra ditt val när som helst.", "t114": "startsida", "t115": "Batch", - "t116": "Försök igen" + "t116": "Försök igen", + "t117": "Utskriftshistorik", + "t118": "Skrivs ut", + "t119": "Lyckad", + "t120": "avbruten", + "t121": "Sök", + "t122": "Sök online-modeller", + "t123": "fat", + "t124": "" }, "cs_CZ": { "t1": "Vítejte v Bambu Studio", @@ -1113,7 +1185,15 @@ var LangText={ "t113": "Své preference můžete kdykoliv změnit.", "t114": "domovská stránka", "t115": "Šarže", - "t116": "Zkuste to znovu" + "t116": "Zkuste to znovu", + "t117": "Historie tisku", + "t118": "Tisk probíhá", + "t119": "Úspěch", + "t120": "zrušený", + "t121": "Hledat", + "t122": "Hledat online modely", + "t123": "talíř", + "t124": "" }, "nl_NL": { "t1": "Welkom bij Bambu Studio", @@ -1223,7 +1303,15 @@ var LangText={ "t113": "U kunt uw keuze op elk gewenst moment wijzigen.", "t114": "startpagina", "t115": "Batch", - "t116": "Probeer het opnieuw" + "t116": "Probeer het opnieuw", + "t117": "Afdrukhistoriek", + "t118": "Aan het printen", + "t119": "Succes", + "t120": "geannuleerd", + "t121": "Zoeken", + "t122": "Zoek online modellen", + "t123": "bord", + "t124": "" }, "uk_UA": { "t1": "Вітаємо в Bambu Studio!", @@ -1333,7 +1421,15 @@ var LangText={ "t113": "Ви можете змінити свої переваги в будь-який час.", "t114": "Головна сторінка", "t115": "Одна партія", - "t116": "Спробувати знову" + "t116": "Спробувати знову", + "t117": "Історія друку", + "t118": "Друкується", + "t119": "Успіх", + "t120": "скасований", + "t121": "Пошук", + "t122": "Пошук онлайн-моделей", + "t123": "тарілка", + "t124": "" }, "ru_RU": { "t1": "Приветствуем в Bambu Studio!", @@ -1443,7 +1539,15 @@ var LangText={ "t113": "Вы можете изменить свои предпочтения в любое время.", "t114": "Главная страница", "t115": "Одна партия", - "t116": "Повторить попытку" + "t116": "Повторить попытку", + "t117": "История печати", + "t118": "Печатается", + "t119": "Успех", + "t120": "отмененный", + "t121": "Поиск", + "t122": "Поиск онлайн-моделей", + "t123": "тарелка", + "t124": "" }, "tr_TR": { "t1": "Bambu Stüdyo'ya Hoş Geldiniz", @@ -1553,7 +1657,15 @@ var LangText={ "t113": "ercihlerinizde istediğiniz zaman seçiminizi değiştirebilirsiniz.", "t114": "Ana Sayfa", "t115": "Toplu", - "t116": "Yeniden Dene" + "t116": "Yeniden Dene", + "t117": "Yazdırma geçmişi", + "t118": "Yazdırılıyor", + "t119": "Başarılı", + "t120": "iptal edildi", + "t121": "Arama", + "t122": "Çevrimiçi modelleri arayın", + "t123": "tabak", + "t124": "" }, "pt_BR": { "t1": "Bem-vindo ao Bambu Studio", @@ -1663,7 +1775,15 @@ var LangText={ "t113": "Você pode alterar sua escolha nas Preferências a qualquer momento", "t114": "Inicio", "t115": "Lote", - "t116": "Retentar" + "t116": "Retentar", + "t117": "Histórico de impressão", + "t118": "Imprimindo", + "t119": "Sucesso", + "t120": "cancelado", + "t121": "Pesquisa", + "t122": "Procurar modelos online", + "t123": "prato", + "t124": "" }, "ko_KR": { "t1": "Bambu Studio에 오신 것을 환영합니다", @@ -1773,7 +1893,15 @@ var LangText={ "t113": "언제든지 환경 설정에서 선택을 변경할 수 있습니다.", "t114": "홈", "t115": "일괄 처리", - "t116": "재시도" + "t116": "재시도", + "t117": "인쇄 기록", + "t118": "인쇄 중", + "t119": "성공", + "t120": "취소된", + "t121": "검색", + "t122": "온라인 모델을 검색하다", + "t123": "접시", + "t124": "" }, "pl_PL": { "t1": "Witamy w Bambu Studio", @@ -1883,7 +2011,15 @@ var LangText={ "t113": "Opcja można zmienić w preferencjach w dowolnym momencie.", "t114": "Strona główna", "t115": "Wartość zbiorcza", - "t116": "Ponów" + "t116": "Ponów", + "t117": "Historia druku", + "t118": "Drukuje się", + "t119": "Sukces", + "t120": "anulowany", + "t121": "Wyszukiwanie", + "t122": "Wyszukaj modele online", + "t123": "talerz", + "t124": "" } }; @@ -1926,3 +2062,35 @@ function TranslatePage() } } } + +function GetCurrentTextByKey( key ) +{ + let strLang=GetQueryString("lang"); + if(strLang!=null) + { + //setCookie(LANG_COOKIE_NAME,strLang,LANG_COOKIE_EXPIRESECOND,'/'); + localStorage.setItem(LANG_COOKIE_NAME,strLang); + } + else + { + //strLang=getCookie(LANG_COOKIE_NAME); + strLang=localStorage.getItem(LANG_COOKIE_NAME); + } + + //alert(strLang); + + if( !LangText.hasOwnProperty(strLang) ) + strLang="en"; + + let strText=''; + if( LangText[strLang].hasOwnProperty(key) ) + { + strText=LangText[strLang][key]; + } + else if(strLang!='en' && LangText['en'].hasOwnProperty(key) ) + { + strText=LangText['en'][key]; + } + + return strText; +} diff --git a/resources/web/homepage3/css/common.css b/resources/web/homepage3/css/common.css index e43ae4347..c7fbf4505 100644 --- a/resources/web/homepage3/css/common.css +++ b/resources/web/homepage3/css/common.css @@ -15,6 +15,7 @@ html, body { padding:0px; border: 0px; margin: 0px; + background-color: #FFF; } /*---字体----*/ @@ -91,8 +92,14 @@ html, body { #MenuArea { display:flex; - justify-content: flex-end; margin-bottom: 24px; + flex-direction:row-reverse; +} + +#MenuBtnBlock +{ + display:flex; + margin-left: 60px; } .Menu_Btn @@ -109,6 +116,13 @@ html, body { width: 18px; } +.Menu_Btn span +{ + display: inline-block; + width: 100%; + white-space: nowrap; +} + /*---弹性内容块---*/ .GuideBlock { @@ -121,7 +135,7 @@ html, body { { width: calc(50% - 20px); } - .SingleGuideBar :nth-child(n+3) + .SingleGuideBar > :nth-child(n+3) { display: none; } @@ -133,7 +147,7 @@ html, body { { width: calc(33% - 20px); } - .SingleGuideBar :nth-child(n+4) + .SingleGuideBar > :nth-child(n+4) { display: none; } @@ -144,7 +158,7 @@ html, body { { width: calc(25% - 20px); } - .SingleGuideBar :nth-child(n+5) + .SingleGuideBar > :nth-child(n+5) { display: none; } @@ -155,7 +169,7 @@ html, body { { width: calc(20% - 20px); } - .SingleGuideBar :nth-child(n+6) + .SingleGuideBar > :nth-child(n+6) { display: none; } diff --git a/resources/web/homepage3/css/dark.css b/resources/web/homepage3/css/dark.css index a5ef25d4f..3852059a3 100644 --- a/resources/web/homepage3/css/dark.css +++ b/resources/web/homepage3/css/dark.css @@ -107,3 +107,43 @@ html,body { filter: invert(1); } + +#HotModel_Search_Bar +{ + border: 1px solid #323A3D; + background-color: #36363A; +} + +#HotModel_Search_InputArea +{ + background-color: #36363A; +} + +#HotModel_Search_Input +{ + background-color: #36363A; + caret-color: white; + color: #FFFFFF; +} + +#HotModel_Search_Btn img +{ + filter: invert(100%) brightness(100); +} + +/*----Makerlab-----*/ +.MakerlabItem +{ + border: none; +} + +/*---Print History----*/ +.PrintHistoryImg img +{ + border: 1px solid #474747; +} + +#PrintHistory_Refresh_Btn +{ + filter: invert(80%) brightness(20); +} diff --git a/resources/web/homepage3/css/home.css b/resources/web/homepage3/css/home.css index 0c1dc2598..537a816be 100644 --- a/resources/web/homepage3/css/home.css +++ b/resources/web/homepage3/css/home.css @@ -32,14 +32,14 @@ body word-break: break-all; position: relative; cursor: pointer; - border-radius: 8px; + border-radius: 8px; + border: 1px solid #EEEEEE; } .MakerlabImg img { width: 100%; aspect-radio: 16/9; - border-radius: 8px 8px 0px 0px; } .MakerlabTextBlock @@ -71,4 +71,165 @@ body { font-size: 10px; color: #ACACAC; -} \ No newline at end of file +} + + +/*------Print History------*/ +#PrintHistoryArea +{ + display: none; + min-height: 100px; +} + +#PrintHistory_Refresh_Btn +{ + margin-left: 30px; + cursor: pointer; + filter: brightness(3); + width: 24px; +} + +#PrintHistory_Refresh_Btn:hover +{ + width: 27px; +} + +#PrintHistoryList +{ + display: flex; +} + +.PrintHistoryItem +{ + position: relative; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + word-break: break-all; + position: relative; + cursor: pointer; +} + +.PrintHistoryImg img +{ + border-radius: 12px; + width: calc(100% - 2px); + aspect-ratio: 4/3; + object-fit:contain; + border: 1px solid #EEEEEE; +} + +.PrintHistoryTextBlock +{ + display: flex; + flex-direction: column; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.PrintHistoryName +{ + font-size: 14px; + font-weight: 700; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.PrintHistory_Line2 +{ + display: flex; + flex-direction: row; + align-items: center; + font-size: 12px; +} + +.PrintHistory_Line2 img +{ + width: 14px; + height: 14px; + margin-right: 4px; +} + +.PH_PrintTime +{ + width: 50px; + margin-right: 4px; +} + +.PH_DeviceName +{ + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.PrintHistoryInfo +{ + display: flex; + justify-content: space-between; +} + +.PrintHistoryPlate +{ + display: flex; + font-size: 12px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.PH_PlateName +{ + flex-grow: 1; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} + +.PH_PrintDate +{ + margin-left: 4px; +} + + +.PrintHistoryStatus +{ + margin-left: 6px; + font-size: 12px; + font-weight: 700; +} + +.PH_Status_Printing +{ + color: #FF6F00; +} + +.PH_Status_Fail +{ + color: #D01B1B; +} + +.PH_Status_Success +{ + color: #00AE42; +} + +.PH_Gcode_Icon +{ + background-color: #5C5C5C; + display: inline-block; + padding: 6px 12px; + width: Hug (61px)px; + height: Hug (28px)px; + gap: 10px; + border-radius: 12px 0px 4px 0px; + opacity: 0px; + color: #FFFFFF; + position: absolute; + top: 1px; + left: 1px; + font-weight: 700; +} + diff --git a/resources/web/homepage3/css/left.css b/resources/web/homepage3/css/left.css index b65ec3573..29542e9c7 100644 --- a/resources/web/homepage3/css/left.css +++ b/resources/web/homepage3/css/left.css @@ -215,6 +215,12 @@ body display: none; } +.BtnItem[menu="printhistory"] +{ + display: none; +} + + .JumpIcon { display: none; diff --git a/resources/web/homepage3/css/online.css b/resources/web/homepage3/css/online.css index cfed7f41c..b0b2e05d4 100644 --- a/resources/web/homepage3/css/online.css +++ b/resources/web/homepage3/css/online.css @@ -59,8 +59,7 @@ { display:flex; flex-direction: column; - cursor: pointer; - border-radius: 8px; + cursor: pointer; } .HotModel_PrevBlock @@ -160,3 +159,42 @@ align-items: center; } +/*-----Search Bar------*/ +#HotModel_Search_Bar +{ + display: none; + align-items: center; + border-radius: 22px; + border: 1px solid #EEEEEE; + flex-grow: 1; + background-color: #FFFFFF; +} + +#HotModel_Search_InputArea +{ + background-color: #FFF; + display: flex; + align-items: center; + flex-grow: 1; + padding: 0px 22px 0px 0px; + border-radius: 22px 0px 0px 22px; +} + +#HotModel_Search_Input +{ + height: 30px; + flex-grow: 1; + outline: none; + font-size: 16px; +} + + +#HotModel_Search_Btn +{ + width: 60px; + height: 100%; + border-radius: 0px 22px 22px 0px; + display: flex; + align-items: center; + justify-content: center; +} diff --git a/resources/web/homepage3/css/recent.css b/resources/web/homepage3/css/recent.css index f32deabc7..8f33aa33f 100644 --- a/resources/web/homepage3/css/recent.css +++ b/resources/web/homepage3/css/recent.css @@ -102,7 +102,6 @@ word-break: break-all; position: relative; cursor: pointer; - border-radius: 8px; } .FileMask diff --git a/resources/web/homepage3/css/rightcommon.css b/resources/web/homepage3/css/rightcommon.css index df1de8a22..1a9262a63 100644 --- a/resources/web/homepage3/css/rightcommon.css +++ b/resources/web/homepage3/css/rightcommon.css @@ -1,7 +1,7 @@ html { - background-color: #F8F8F8; + background-color: #FFF; padding: 28px 36px; display: flex; justify-content: center; diff --git a/resources/web/homepage3/disconnect.html b/resources/web/homepage3/disconnect.html index 48c3c75d0..9f4e6d7e0 100644 --- a/resources/web/homepage3/disconnect.html +++ b/resources/web/homepage3/disconnect.html @@ -22,7 +22,7 @@
Network disconnect, please check and try again later.
-
Retry
+
Retry
diff --git a/resources/web/homepage3/home.html b/resources/web/homepage3/home.html index 6c1d11792..81789be1c 100644 --- a/resources/web/homepage3/home.html +++ b/resources/web/homepage3/home.html @@ -18,20 +18,30 @@ - - + + @@ -101,7 +111,7 @@
Online Models
MORE >
- +
+
+--> + +
+
+
+ +
Print History
+ +
+
MORE >
+
+ +
+ + + +
+
+ diff --git a/resources/web/homepage3/img/device.svg b/resources/web/homepage3/img/device.svg new file mode 100644 index 000000000..fcfc37fa8 --- /dev/null +++ b/resources/web/homepage3/img/device.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/resources/web/homepage3/img/left_ph.svg b/resources/web/homepage3/img/left_ph.svg new file mode 100644 index 000000000..a7dc8c6a9 --- /dev/null +++ b/resources/web/homepage3/img/left_ph.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/resources/web/homepage3/img/ph.svg b/resources/web/homepage3/img/ph.svg new file mode 100644 index 000000000..896c3ed1b --- /dev/null +++ b/resources/web/homepage3/img/ph.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/web/homepage3/img/refresh.svg b/resources/web/homepage3/img/refresh.svg new file mode 100644 index 000000000..934161bf8 --- /dev/null +++ b/resources/web/homepage3/img/refresh.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/web/homepage3/img/search.svg b/resources/web/homepage3/img/search.svg new file mode 100644 index 000000000..be31c055d --- /dev/null +++ b/resources/web/homepage3/img/search.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/web/homepage3/img/search_dark.svg b/resources/web/homepage3/img/search_dark.svg new file mode 100644 index 000000000..ed41ba2ef --- /dev/null +++ b/resources/web/homepage3/img/search_dark.svg @@ -0,0 +1,3 @@ + + + diff --git a/resources/web/homepage3/img/time.svg b/resources/web/homepage3/img/time.svg new file mode 100644 index 000000000..ee5ad72f2 --- /dev/null +++ b/resources/web/homepage3/img/time.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/resources/web/homepage3/js/home.js b/resources/web/homepage3/js/home.js index 084d25667..bd2a6648d 100644 --- a/resources/web/homepage3/js/home.js +++ b/resources/web/homepage3/js/home.js @@ -4,6 +4,7 @@ var m_HotModelList=null; var m_ForUModelList=null; var m_MakerlabList=null; +var m_PrintHistoryList=null; function OnHomeInit() { @@ -13,8 +14,26 @@ function OnHomeInit() SendMsg_GetRecentFile(); SendMsg_GetStaffPick(); SendMsg_GetMakerlabList(); + SendMsg_GetPrintHistory(); + document.getElementById('HotModel_Search_Input').onkeydown = function (event) { + if (event.key === 'Enter') { + OnSearchOnline(); + } + + event.defaultPrevented(); + }; + + let ModelSearchTip=GetCurrentTextByKey('t122'); + $('#HotModel_Search_Input').prop('placeholder', ModelSearchTip); + + //Test //ShowMakerlabList(Test_MakerlabList['list']); + + //$('#PrintHistoryArea').show(); + //ShowPrintHistory(Test_PrintTaskList['hits']); + + //Show4UPick(Test_4UModelList['hits']); } //Recent详情页面的状态 @@ -31,9 +50,25 @@ function OnRecentInit() Set_RecentFile_Delete_Checkbox_Event(); } +var m_LineMenuName=''; function OnLineInit() { TranslatePage(); + m_LineMenuName=GetQueryString("menu"); +} + +function OnLineRetry() +{ + if(m_LineMenuName!="" && m_LineMenuName!=null) + SwitchContent(m_LineMenuName); +} + +function ShowLineWarn( bShow ) +{ + if(bShow) + $('#WarnMainArea').show(); + else + $('#WarnMainArea').hide(); } //------最佳打开文件的右键菜单功能---------- @@ -103,6 +138,7 @@ function Set_RecentFile_MouseRightBtn_Event() function HandleStudio( pVal ) { let strCmd = pVal['command']; + //alert(strCmd); if(strCmd=='get_recent_projects') { @@ -195,6 +231,43 @@ function HandleStudio( pVal ) OnHomeInit(); } + else if(strCmd=='printhistory_task_show') + { + if( m_PrintHistoryList!=null && pVal['hits'].length>0 ) + { + let SS1=JSON.stringify(pVal['list']); + let SS2=JSON.stringify(m_PrintHistoryList); + + if( SS1==SS2 ) + { + alert("PrintHistory is Same. Ignore"); + return; + } + } + + m_PrintHistoryList=pVal['hits']; + + ShowPrintHistory(m_PrintHistoryList); + } + else if(strCmd=='homepage_leftmenu_show') + { + let MenuName=pVal['menu']; + let nShow=pVal['show']*1; + + if(MenuName=='printhistory') + { + if(nShow==1) + { + $('#PrintHistoryArea').show(); + } + else + { + $('#PrintHistoryArea').hide(); + m_PrintHistoryList=null; + $('#PrintHistoryList').html(''); + } + } + } } function OnBoardChange( strMenu ) @@ -210,7 +283,10 @@ function OnBoardChange( strMenu ) SendMsg_GetStaffPick(); if( m_MakerlabList==null || m_MakerlabList.length==0 ) - SendMsg_GetMakerlabList(); + SendMsg_GetMakerlabList(); + + if( m_PrintHistoryList==null ) + SendMsg_GetPrintHistory(); } else if(strMenu=='recent') { @@ -663,6 +739,7 @@ function ShowStaffPick( ModelList ) $('#HotModelList').html(strPickHtml); InitStaffPick(); $('#HotModelArea').show(); + $('#HotModel_Search_Bar').css('display','flex'); } function Show4UPick( ModelList ) @@ -721,6 +798,7 @@ function Show4UPick( ModelList ) $('#HotModelList').html(strPickHtml); InitStaffPick(); $('#HotModelArea').show(); + $('#HotModel_Search_Bar').css('display','flex'); } function OpenOneStaffPickModel( ModelID ) @@ -736,6 +814,20 @@ function OpenOneStaffPickModel( ModelID ) } +function OnSearchOnline(event) +{ + let strKW=$('#HotModel_Search_Input').val().trim(); + if(strKW=='' ) + return; + + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_online_search"; + tSend['keyword']=strKW; + + SendWXMessage( JSON.stringify(tSend) ); +} + //----------MakerLab------------ function IsChinese() { @@ -818,6 +910,122 @@ function OnOpenOneMakerlab( ChildUrl ) SendWXMessage( JSON.stringify(tSend) ); } +//-----------Print History------------ +function SendMsg_GetPrintHistory() +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_printhistory_get"; + + SendWXMessage( JSON.stringify(tSend) ); +} + +function convertTimeFormat(timeStr) +{ + const date = new Date(timeStr); + const year = date.getFullYear(); // 取后两位年份 + const day = date.getDate(); + const month = date.getMonth() + 1; + const hours = date.getHours(); + const minutes = date.getMinutes(); + return `${year}/${month.toString().padStart(2, '0')}/${day.toString().padStart(2, '0')} ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`; +} + + +//只更新HTML内容,不控制显示/隐藏 +function ShowPrintHistory( TaskList ) +{ + let TaskTotal=TaskList.length; + + let strTaskHtml=''; + for(let a=0;a=3600) + { + strCostTime=Math.round( (CostTime/3600)*10 )/10+'h'; + } + else if(CostTime>=60) + { + strCostTime=Math.floor( CostTime/60 )+'min'; + } + else + strCostTime=CostTime+'s'; + + let PlateName=' '+OneTask['plateIndex']+''; + if( OneTask['plateName'].trim()!='' ) + PlateName+=' - '+OneTask['plateName'].trim(); + + let StartTime=convertTimeFormat( OneTask['startTime'] ); + + let isPublicProfile =OneTask['isPublicProfile']; + let sMode=OneTask['mode']; + + strTaskHtml+= + '
'+ + '
'+ + '
'+ + '
'+TaskName+'
'+ + '
'+ + ' '+strCostTime+''+ + ' '+DeviceName+''+ + '
'+ + '
'+ + '
'+ + '
'+PlateName+'
'+ + '
('+StartTime+')
'+ + '
'; + switch(Status) + { + case 2: + strTaskHtml+='
Success
'; + break; + case 3: + strTaskHtml+='
Canceled
'; + break; + default: + strTaskHtml+='
Printing
'; + break; + } + strTaskHtml+= + '
'+ + '
'; + if( isPublicProfile==false && sMode!='cloud_slice' ) + strTaskHtml+='
Gcode
'; + + strTaskHtml+='
'; + } + + $('#PrintHistoryList').html(strTaskHtml); + TranslatePage(); +} + +function OnOpenPrintHistory( TaskID ) +{ + var tSend={}; + tSend['sequence_id']=Math.round(new Date() / 1000); + tSend['command']="homepage_printhistory_click"; + tSend['taskid']=TaskID*1; + + SendWXMessage( JSON.stringify(tSend) ); +} //---------------Global----------------- window.postMessage = HandleStudio; diff --git a/resources/web/homepage3/js/test.js b/resources/web/homepage3/js/test.js index d5506b9f3..e29e92c98 100644 --- a/resources/web/homepage3/js/test.js +++ b/resources/web/homepage3/js/test.js @@ -54,4 +54,933 @@ var Test_MakerlabList={ } } ] +}; + +var Test_PrintTaskList={ + "command": "printhistory_task_show", + "total": 15, + "hits": [ + { + "id": 3622536, + "designId": 374186, + "designTitle": "首发模型0914 1409 --0918 12:00改为独家", + "designTitleTranslated": "Exclusive model debut 0914 1409 --0918 12:00", + "instanceId": 32755, + "modelId": "CNQ72af310210f64b", + "title": "首发变独家", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/CNQ72af310210f64b/4007130/instance/plate_1.png", + "status": 3, + "feedbackStatus": 1, + "startTime": "2024-09-20T09:56:22Z", + "endTime": "2024-09-20T09:56:32Z", + "weight": 0, + "length": 0, + "costTime": 0, + "profileId": 4007130, + "plateIndex": 1, + "plateName": "", + "deviceId": "03W09A380900239", + "amsDetailMapping": [ + { + "ams": 0, + "sourceColor": "FFFFFFFF", + "targetColor": "", + "filamentId": "", + "filamentType": "PLA", + "targetFilamentType": "PLA", + "weight": 0 + } + ], + "mode": "cloud_slice", + "isPublicProfile": true, + "isPrintable": true, + "isDelete": false, + "deviceModel": "X1E", + "deviceName": "3DP-03W-239", + "bedType": "Cool Plate" + }, + { + "id": 3622535, + "designId": 374186, + "designTitle": "首发模型0914 1409 --0918 12:00改为独家", + "designTitleTranslated": "Exclusive model debut 0914 1409 --0918 12:00", + "instanceId": 32755, + "modelId": "CNQ72af310210f64b", + "title": "首发变独家", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/CNQ72af310210f64b/4007130/instance/plate_1.png", + "status": 3, + "feedbackStatus": 1, + "startTime": "2024-09-20T09:55:42Z", + "endTime": "2024-09-20T09:56:00Z", + "weight": 0, + "length": 0, + "costTime": 0, + "profileId": 4007130, + "plateIndex": 1, + "plateName": "", + "deviceId": "03W09A380900239", + "amsDetailMapping": [ + { + "ams": 0, + "sourceColor": "FFFFFFFF", + "targetColor": "", + "filamentId": "", + "filamentType": "PLA", + "targetFilamentType": "PLA", + "weight": 0 + } + ], + "mode": "cloud_slice", + "isPublicProfile": true, + "isPrintable": true, + "isDelete": false, + "deviceModel": "X1E", + "deviceName": "3DP-03W-239", + "bedType": "Cool Plate" + }, + { + "id": 3622505, + "designId": 374186, + "designTitle": "首发模型0914 1409 --0918 12:00改为独家", + "designTitleTranslated": "Exclusive model debut 0914 1409 --0918 12:00", + "instanceId": 32755, + "modelId": "CNQ72af310210f64b", + "title": "首发变独家", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/cache/1/CNQ72af310210f64b/4007130/3mf/3/REP1/Metadata/plate_3.png", + "status": 2, + "feedbackStatus": 1, + "startTime": "2024-09-20T06:38:33Z", + "endTime": "2024-09-20T08:27:56Z", + "weight": 53.54, + "length": 1766, + "costTime": 6376, + "profileId": 4007130, + "plateIndex": 3, + "plateName": "", + "deviceId": "03W09A380900239", + "amsDetailMapping": [ + { + "ams": 0, + "sourceColor": "FFFFFFFF", + "targetColor": "FFFFFFFF", + "filamentId": "", + "filamentType": "PLA", + "targetFilamentType": "PLA", + "weight": 53.54 + } + ], + "mode": "cloud_slice", + "isPublicProfile": true, + "isPrintable": true, + "isDelete": false, + "deviceModel": "X1E", + "deviceName": "3DP-03W-239", + "bedType": "Cool Plate" + }, + { + "id": 3622504, + "designId": 374186, + "designTitle": "首发模型0914 1409 --0918 12:00改为独家", + "designTitleTranslated": "Exclusive model debut 0914 1409 --0918 12:00", + "instanceId": 32755, + "modelId": "CNQ72af310210f64b", + "title": "首发变独家", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/cache/1/CNQ72af310210f64b/4007130/3mf/3/%23A0E20EFF/REP1/Metadata/plate_3.png", + "status": 2, + "feedbackStatus": 1, + "startTime": "2024-09-20T06:38:18Z", + "endTime": "2024-09-20T08:38:35Z", + "weight": 56.09, + "length": 1766, + "costTime": 7131, + "profileId": 4007130, + "plateIndex": 3, + "plateName": "", + "deviceId": "00W00A242600023", + "amsDetailMapping": [ + { + "ams": 1, + "sourceColor": "FFFFFFFF", + "targetColor": "A0E20EFF", + "filamentId": "", + "filamentType": "PLA", + "targetFilamentType": "PLA", + "weight": 56.09 + } + ], + "mode": "cloud_slice", + "isPublicProfile": true, + "isPrintable": true, + "isDelete": false, + "deviceModel": "X1", + "deviceName": "025", + "bedType": "Cool Plate" + }, + { + "id": 3622499, + "designId": 374186, + "designTitle": "首发模型0914 1409 --0918 12:00改为独家", + "designTitleTranslated": "Exclusive model debut 0914 1409 --0918 12:00", + "instanceId": 32755, + "modelId": "CNQ72af310210f64b", + "title": "首发变独家", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/cache/1/CNQ72af310210f64b/4007130/3mf/3/REP1/Metadata/plate_3.png", + "status": 2, + "feedbackStatus": 1, + "startTime": "2024-09-20T04:12:14Z", + "endTime": "2024-09-20T06:02:16Z", + "weight": 53.54, + "length": 1766, + "costTime": 6376, + "profileId": 4007130, + "plateIndex": 3, + "plateName": "", + "deviceId": "03W09A380900239", + "amsDetailMapping": [ + { + "ams": 0, + "sourceColor": "FFFFFFFF", + "targetColor": "FFFFFFFF", + "filamentId": "", + "filamentType": "PLA", + "targetFilamentType": "PLA", + "weight": 53.54 + } + ], + "mode": "cloud_slice", + "isPublicProfile": true, + "isPrintable": true, + "isDelete": false, + "deviceModel": "X1E", + "deviceName": "3DP-03W-239", + "bedType": "Cool Plate" + } + ] +} + +var Test_4UModelList={ + "hits": [ + { + "id": 374202, + "title": "0920 可定制", + "titleTranslated": "0920 Customizable", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/CNQc553e8906eaff0/design/2024-09-20_7cf6087c009.jpg", + "likeCount": 0, + "collectionCount": 1, + "shareCount": 0, + "printCount": 0, + "downloadCount": 0, + "commentCount": 0, + "readCount": 0, + "designCreator": { + "uid": 1074649781, + "name": "xiaohuan.li888888888888888888888888888", + "avatar": "https://public-us-cdn.bambulab.net/avatar/9a12d850-539a-11ef-bcfb-2953b84d62de.jpg", + "fanCount": 6, + "followCount": 6, + "createTime": "2023-08-29T07:06:16Z", + "certificated": true, + "handle": "xiaohuan.li6667", + "level": 30, + "gradeType": 4 + }, + "createTime": "2024-09-20T03:10:43Z", + "nsfw": false, + "hotScore": 794, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": true, + "pickReason": "", + "isPrintable": true, + "isOfficial": false, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": true, + "contest": { + "contestId": 124, + "rank": 0, + "status": 1, + "contestName": "0718 contest", + "contestStatus": 0, + "comment": "" + }, + "source": 4, + "customizedByMakerLab": true, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 0, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"4|0.93\"],\"rk\":\"-0.04|0\"}", + "modelId": "CNQc553e8906eaff0" + }, + { + "id": 374215, + "title": "jeep", + "titleTranslated": "", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/CNQ5da5ab69430323/design/2024-09-20_ef0049a4b5026.jpg", + "likeCount": 0, + "collectionCount": 1, + "shareCount": 0, + "printCount": 0, + "downloadCount": 1, + "commentCount": 1, + "readCount": 0, + "designCreator": { + "uid": 415112594, + "name": "Yifan Wu", + "avatar": "https://public-dev-cdn.bambulab.net/avatar/415112594/2023-05-06_1f35259225fad.jpg", + "fanCount": 14, + "followCount": 14, + "createTime": "2022-04-07T09:52:23Z", + "certificated": false, + "handle": "wuyifan", + "level": 11, + "gradeType": 1 + }, + "createTime": "2024-09-20T12:00:13Z", + "nsfw": false, + "hotScore": 2726, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": false, + "pickReason": "", + "isPrintable": true, + "isOfficial": false, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": true, + "contest": { + "contestId": 0, + "rank": 0, + "status": 0, + "contestName": "", + "contestStatus": 0, + "comment": "" + }, + "source": 7, + "customizedByMakerLab": false, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 3, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"7|1\"],\"rk\":\"-0.11|1\"}", + "modelId": "CNQ5da5ab69430323" + }, + { + "id": 374216, + "title": "小迷宫", + "titleTranslated": "mini maze", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/DSM00000000374216/design/2024-09-20_e31bc38f1cef9.webp", + "likeCount": 0, + "collectionCount": 0, + "shareCount": 0, + "printCount": 0, + "downloadCount": 2, + "commentCount": 0, + "readCount": 0, + "designCreator": { + "uid": 415112594, + "name": "Yifan Wu", + "avatar": "https://public-dev-cdn.bambulab.net/avatar/415112594/2023-05-06_1f35259225fad.jpg", + "fanCount": 14, + "followCount": 14, + "createTime": "2022-04-07T09:52:23Z", + "certificated": false, + "handle": "wuyifan", + "level": 11, + "gradeType": 1 + }, + "createTime": "2024-09-20T12:44:02Z", + "nsfw": false, + "hotScore": 1891, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": false, + "pickReason": "", + "isPrintable": true, + "isOfficial": false, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": true, + "contest": { + "contestId": 0, + "rank": 0, + "status": 0, + "contestName": "", + "contestStatus": 0, + "comment": "" + }, + "source": 7, + "customizedByMakerLab": false, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 1, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"7|0.92\"],\"rk\":\"-0.17|2\"}", + "modelId": "CNQ581249e18cec42" + }, + { + "id": 374218, + "title": "运营开启独家未达标用户", + "titleTranslated": "The following content requires translation:\nExclusive unmet user operations have been initiated.", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/CNQf2d9054da20bfe/design/2024-09-23_d4d635adef548.jpg", + "likeCount": 0, + "collectionCount": 0, + "shareCount": 0, + "printCount": 0, + "downloadCount": 11, + "commentCount": 0, + "readCount": 0, + "designCreator": { + "uid": 1375262870, + "name": "XNCS025", + "avatar": "https://oss-cdn.bambulab.com/default-avatar.png", + "fanCount": 1, + "followCount": 1, + "createTime": "2023-03-07T02:14:57Z", + "certificated": false, + "handle": "XNCS025", + "level": 4, + "gradeType": 0 + }, + "createTime": "2024-09-23T07:17:13Z", + "nsfw": false, + "hotScore": 2447, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": false, + "pickReason": "", + "isPrintable": true, + "isOfficial": false, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": true, + "contest": { + "contestId": 0, + "rank": 0, + "status": 0, + "contestName": "", + "contestStatus": 0, + "comment": "" + }, + "source": 7, + "customizedByMakerLab": false, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 0, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"7|0.96\"],\"rk\":\"-0.21|3\"}", + "modelId": "CNQf2d9054da20bfe" + }, + { + "id": 374229, + "title": "测试一下定时任务", + "titleTranslated": "Test the scheduled task", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/CNQe4b47ef2e53023/design/2024-09-23_ed5de35b423cc.webp", + "likeCount": 0, + "collectionCount": 0, + "shareCount": 0, + "printCount": 2, + "downloadCount": 2, + "commentCount": 0, + "readCount": 0, + "designCreator": { + "uid": 1812646376, + "name": "银鱼test2", + "avatar": "https://public-cdn.bblmw.com/default/avatar.png", + "fanCount": 1, + "followCount": 1, + "createTime": "2024-09-12T07:02:50Z", + "certificated": false, + "handle": "user_1812646376", + "level": 10, + "gradeType": 1 + }, + "createTime": "2024-09-23T10:42:15Z", + "nsfw": false, + "hotScore": 1442, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": false, + "pickReason": "", + "isPrintable": true, + "isOfficial": false, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": false, + "contest": { + "contestId": 0, + "rank": 0, + "status": 0, + "contestName": "", + "contestStatus": 0, + "comment": "" + }, + "source": 7, + "customizedByMakerLab": false, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 0, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"7|0.88\"],\"rk\":\"-0.22|4\"}", + "modelId": "CNQe4b47ef2e53023" + }, + { + "id": 371892, + "title": "测试竞赛", + "titleTranslated": "", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/DSM00000000371892/design/2024-03-28_6875c4e16c667.jpg", + "likeCount": 1, + "collectionCount": 1, + "shareCount": 0, + "printCount": 0, + "downloadCount": 1, + "commentCount": 0, + "readCount": 0, + "designCreator": { + "uid": 3185390264, + "name": "fang.nie", + "avatar": "https://public-dev-cdn.bambulab.net/avatar/3185390264/2024-02-26_fc5558ccc29f1.jpg", + "fanCount": 6, + "followCount": 6, + "createTime": "2022-05-11T07:56:50Z", + "certificated": false, + "handle": "fang.nie", + "level": 8, + "gradeType": 1 + }, + "createTime": "2024-03-28T07:59:10Z", + "nsfw": false, + "hotScore": 0, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": true, + "pickReason": "", + "isPrintable": false, + "isOfficial": false, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": false, + "contest": { + "contestId": 75, + "rank": 0, + "status": 1, + "contestName": "0306进行中的竞赛", + "contestStatus": 0, + "comment": "" + }, + "source": 4, + "customizedByMakerLab": false, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 0, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"4|1\"],\"rk\":\"-0.28|5\"}", + "modelId": "" + }, + { + "id": 374114, + "title": "打印时长超过20小时", + "titleTranslated": "Printing duration exceeds 20 hours", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/CNQf47c4b034a745c/design/2024-08-30_2606102d038c5.webp", + "likeCount": 0, + "collectionCount": 0, + "shareCount": 0, + "printCount": 0, + "downloadCount": 0, + "commentCount": 0, + "readCount": 0, + "designCreator": { + "uid": 3345032319, + "name": "Summer_lights", + "avatar": "https://public-cdn.bambulab.com/default/avatar.png", + "fanCount": 2, + "followCount": 2, + "createTime": "2023-08-04T08:43:14Z", + "certificated": true, + "handle": "Summer_lights", + "level": 7, + "gradeType": 1 + }, + "createTime": "2024-08-30T02:52:40Z", + "nsfw": false, + "hotScore": 0, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": true, + "pickReason": "", + "isPrintable": true, + "isOfficial": false, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": false, + "contest": { + "contestId": 0, + "rank": 0, + "status": 0, + "contestName": "", + "contestStatus": 0, + "comment": "" + }, + "source": 4, + "customizedByMakerLab": false, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 0, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"4|0.86\"],\"rk\":\"-0.4|6\"}", + "modelId": "CNQf47c4b034a745c" + }, + { + "id": 374044, + "title": "恐龙模型", + "titleTranslated": "Dinosaur Model", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/DSM00000000374044/design/2024-08-08_0cade4e99b18c.png", + "likeCount": 2, + "collectionCount": 2, + "shareCount": 0, + "printCount": 0, + "downloadCount": 1, + "commentCount": 10, + "readCount": 0, + "designCreator": { + "uid": 3603343695, + "name": "龙井~qa", + "avatar": "https://public-dev-cdn.bambulab.net/avatar/3603343695/2023-11-01_f32d53e210073.jpg", + "fanCount": 12, + "followCount": 12, + "createTime": "2022-08-01T07:37:47Z", + "certificated": false, + "handle": "user_3603343695", + "level": 10, + "gradeType": 1 + }, + "createTime": "2024-08-08T08:09:44Z", + "nsfw": false, + "hotScore": 163, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": true, + "pickReason": "", + "isPrintable": true, + "isOfficial": true, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": false, + "contest": { + "contestId": 0, + "rank": 0, + "status": 0, + "contestName": "", + "contestStatus": 0, + "comment": "" + }, + "source": 4, + "customizedByMakerLab": false, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 4, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"4|0.79\"],\"rk\":\"-0.43|7\"}", + "modelId": "CNQ1ff72338b76e42" + }, + { + "id": 374224, + "title": "testing1", + "titleTranslated": "", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/CNQ6d8c4e451cb1cb/design/2024-09-23_523ae314284da.webp", + "likeCount": 0, + "collectionCount": 0, + "shareCount": 0, + "printCount": 0, + "downloadCount": 0, + "commentCount": 0, + "readCount": 0, + "designCreator": { + "uid": 899054757, + "name": "user_899054757", + "avatar": "https://public-us-cdn.bambulab.net/avatar/bfe3d810-798b-11ef-bd70-27bc07e67d92.jpg", + "fanCount": 0, + "followCount": 0, + "createTime": "2024-09-20T09:19:40Z", + "certificated": false, + "handle": "user_899054757", + "level": 6, + "gradeType": 0 + }, + "createTime": "2024-09-23T09:48:17Z", + "nsfw": false, + "hotScore": 0, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": false, + "pickReason": "", + "isPrintable": true, + "isOfficial": false, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": false, + "contest": { + "contestId": 0, + "rank": 0, + "status": 0, + "contestName": "", + "contestStatus": 0, + "comment": "" + }, + "source": 7, + "customizedByMakerLab": false, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 0, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"7|0.56\"],\"rk\":\"-0.43|8\"}", + "modelId": "CNQ6d8c4e451cb1cb" + }, + { + "id": 374227, + "title": "test2", + "titleTranslated": "", + "cover": "https://public-dev-cdn.bambulab.net/makerworld/model/DSM00000000374227/design/2024-09-23_ff06b8ab9e468.jpg", + "likeCount": 0, + "collectionCount": 0, + "shareCount": 0, + "printCount": 0, + "downloadCount": 0, + "commentCount": 0, + "readCount": 0, + "designCreator": { + "uid": 899054757, + "name": "user_899054757", + "avatar": "https://public-us-cdn.bambulab.net/avatar/bfe3d810-798b-11ef-bd70-27bc07e67d92.jpg", + "fanCount": 0, + "followCount": 0, + "createTime": "2024-09-20T09:19:40Z", + "certificated": false, + "handle": "user_899054757", + "level": 6, + "gradeType": 0 + }, + "createTime": "2024-09-23T09:51:22Z", + "nsfw": false, + "hotScore": 0, + "status": 1, + "hasCollect": false, + "hasLike": false, + "hasDislike": false, + "isStaffPicked": false, + "pickReason": "", + "isPrintable": false, + "isOfficial": false, + "isPointRedeemable": false, + "pointRedeemDetail": { + "price": 0, + "sku": "", + "status": 0 + }, + "isExclusive": false, + "contest": { + "contestId": 0, + "rank": 0, + "status": 0, + "contestName": "", + "contestStatus": 0, + "comment": "" + }, + "source": 7, + "customizedByMakerLab": false, + "preset": { + "type": "", + "filamentConfig": null, + "printerConfig": null, + "processConfig": null, + "printerSettings": null, + "file": { + "name": "", + "size": 0, + "url": "" + } + }, + "coverLandscape": "", + "coverPortrait": "", + "boostCnt": 0, + "bomsNeeded": false, + "bannerTitle": "", + "ext": "{\"rc\":[\"7|0.68\"],\"rk\":\"-0.49|9\"}", + "modelId": "" + } + ], + "seed": 1149157380, + "surplus": 32 }; \ No newline at end of file diff --git a/resources/web/homepage3/left.html b/resources/web/homepage3/left.html index b67230366..57dda2817 100644 --- a/resources/web/homepage3/left.html +++ b/resources/web/homepage3/left.html @@ -59,6 +59,10 @@
New
+
+
+
Print History
+
User Manual
diff --git a/resources/web/include/globalapi.js b/resources/web/include/globalapi.js index 58b53fa2f..bef926755 100644 --- a/resources/web/include/globalapi.js +++ b/resources/web/include/globalapi.js @@ -62,7 +62,7 @@ function GetFullDate() return tDate; } - +//return YYYY-MM-DD function Unixtimestamp2Date( nSecond ) { var d=new Date(nSecond*1000); @@ -93,6 +93,18 @@ function Unixtimestamp2Date( nSecond ) return tDate.strdate; } +function DateToUnixstamp( strDate ) +{ + const date = new Date(strDate); + return Math.floor(date.getTime() / 1000); +} + +function DateToUnixstampMS( strDate ) +{ + const date = new Date(strDate); + return date.getTime(); +} + //------------Array Function------------- Array.prototype.in_array = function (e) { @@ -468,10 +480,16 @@ function DisableHotkey( b_CtrlP ) if (e.shiftKey && e.metaKey) OutputKey(e.keyCode, false, true, true); - if (window.event) { - try { e.keyCode = 0; } catch (e) { } - e.returnValue = false; + //F1--F12 + if ( e.keyCode>=112 && e.keyCode<=123 ) + { + e.preventDefault(); } + +// if (window.event) { +// try { e.keyCode = 0; } catch (e) { } +// e.returnValue = false; +// } }; window.addEventListener('mousewheel', function (event) { diff --git a/resources/web/model/index.html b/resources/web/model/index.html index 24bf34be2..4e55ab1f9 100644 --- a/resources/web/model/index.html +++ b/resources/web/model/index.html @@ -22,8 +22,6 @@ - -
no model information
diff --git a/resources/web/model/model.css b/resources/web/model/model.css index 7422f5e3c..7bee7db91 100644 --- a/resources/web/model/model.css +++ b/resources/web/model/model.css @@ -4,7 +4,6 @@ padding: 0px; border: 0px; font-family: "system-ui", "Segoe UI", Roboto, Oxygen, Ubuntu, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-sans; - user-select: none; } html diff --git a/resources/web/model/model.js b/resources/web/model/model.js index 2f74237f5..e4e0a9e3b 100644 --- a/resources/web/model/model.js +++ b/resources/web/model/model.js @@ -144,6 +144,14 @@ function Request3MFInfo() SendWXMessage( JSON.stringify(tSend) ); } +function HtmlDecodeFrom3MF(strInput) +{ + const el = document.createElement('textarea'); + el.innerHTML = strInput; + el.innerHTML = el.value; + return el.value; +} + function HandleStudio(pVal) { let strCmd=pVal['command']; @@ -213,6 +221,7 @@ function ShowModelInfo( pModel ) let UploadType=pModel.upload_type.toLowerCase(); let sLicence=pModel.license.toUpperCase(); let sModelDesc=decodeURIComponent(pModel.description); + sModelDesc=HtmlDecodeFrom3MF( sModelDesc ); if( pModel.hasOwnProperty('model_id') ) { @@ -275,8 +284,8 @@ function ShowModelInfo( pModel ) $('#ModelLicenceImg').hide(); break; } - - $('#Model_Desc').html( html_decode(sModelDesc) ); + + $('#Model_Desc').html( sModelDesc ); let ModelPreviewList=pModel.preview_img; let TotalPreview=ModelPreviewList.length; @@ -490,11 +499,12 @@ function ShowProfilelInfo( pProfile ) let sProfileName=decodeURIComponent(pProfile.name); let sProfileAuthor=decodeURIComponent(pProfile.author); let sProfileDesc=decodeURIComponent(pProfile.description); + sProfileDesc=HtmlDecodeFrom3MF(sProfileDesc); $('#ProfileName').html(sProfileName); $('#ProfileAuthor').html(sProfileAuthor); - $('#Profile_Desc').html( html_decode(sProfileDesc) ); + $('#Profile_Desc').html( sProfileDesc ); let ProfilePreviewList=pProfile.preview_img; let TotalPreview=ProfilePreviewList.length; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index f298c13ef..c99cd0243 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4205,17 +4205,6 @@ std::string GUI_App::handle_web_request(std::string cmd) } } } - else if (command_str.compare("homepage_open_ccabin") == 0) { - if (root.get_child_optional("data") != boost::none) { - pt::ptree data_node = root.get_child("data"); - boost::optional path = data_node.get_optional("file"); - if (path.has_value()) { - std::string Fullpath = resources_dir() + "/web/homepage/model/" + path.value(); - - this->request_open_project(Fullpath); - } - } - } else if (command_str.compare("common_openurl") == 0) { boost::optional path = root.get_optional("url"); if (path.has_value()) { @@ -4287,6 +4276,34 @@ std::string GUI_App::handle_web_request(std::string cmd) } } } + else if (command_str.compare("homepage_online_search") == 0) { + if (root.get_child_optional("keyword") != boost::none) + { + std::string strKW = root.get_optional("keyword").value(); + + if (mainframe && mainframe->m_webview) + { + mainframe->m_webview->OpenMakerworldSearchPage(strKW); + } + } + } + else if (command_str.compare("homepage_printhistory_click") == 0) { + if (root.get_child_optional("taskid") != boost::none) { + int nTaskID = root.get("taskid"); + + if (mainframe && mainframe->m_webview) + { + mainframe->m_webview->SetPrintHistoryTaskID(nTaskID); + mainframe->m_webview->SwitchLeftMenu("printhistory"); + } + } + } + else if (command_str.compare("homepage_printhistory_get")==0) + { + if (mainframe && mainframe->m_webview) { + mainframe->m_webview->ShowUserPrintTask(true); + } + } } } catch (...) { diff --git a/src/slic3r/GUI/Project.cpp b/src/slic3r/GUI/Project.cpp index e7273e2ee..c99c9de9e 100644 --- a/src/slic3r/GUI/Project.cpp +++ b/src/slic3r/GUI/Project.cpp @@ -29,6 +29,8 @@ #include "MainFrame.hpp" #include +#include + namespace Slic3r { namespace GUI { wxDEFINE_EVENT(EVT_PROJECT_RELOAD, wxCommandEvent); @@ -61,7 +63,7 @@ ProjectPanel::ProjectPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, m_browser->Bind(wxEVT_WEBVIEW_NAVIGATED, &ProjectPanel::on_navigated, this); m_browser->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &ProjectPanel::OnScriptMessage, this, m_browser->GetId()); Bind(wxEVT_WEBVIEW_NAVIGATING, &ProjectPanel::onWebNavigating, this, m_browser->GetId()); - + Bind(wxEVT_WEBVIEW_NEWWINDOW, &ProjectPanel::OnNewWindow, this); Bind(EVT_PROJECT_RELOAD, &ProjectPanel::on_reload, this); SetSizer(main_sizer); @@ -71,6 +73,42 @@ ProjectPanel::ProjectPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, ProjectPanel::~ProjectPanel() {} +std::string trim(const std::string &str, const std::string &charsToTrim) +{ + std::regex pattern("^[" + charsToTrim + "]+|[" + charsToTrim + "]+$"); + return std::regex_replace(str, pattern, ""); +} + +/** + * On new window, we veto to stop extra windows appearing + */ +void ProjectPanel::OnNewWindow(wxWebViewEvent &evt) +{ + BOOST_LOG_TRIVIAL(trace) << __FUNCTION__ << ": " << evt.GetURL().ToUTF8().data(); + wxString flag = " (other)"; + + if (evt.GetNavigationAction() == wxWEBVIEW_NAV_ACTION_USER) { flag = " (user)"; } + + if (wxGetApp().get_mode() == comDevelop) + wxLogMessage("%s", "New window; url='" + evt.GetURL() + "'" + flag); + + // If we handle new window events then just load them in local browser + wxString tmpUrl = evt.GetURL(); + + if (tmpUrl.StartsWith("File://") || tmpUrl.StartsWith("file://")) + { + std::regex pattern("%22http.+%22"); + std::smatch matches; + std::string UrlTmp = tmpUrl.ToStdString(); + if (std::regex_search(UrlTmp, matches, pattern)) { tmpUrl = trim(matches[0].str(), "%22"); } + } + + if (boost::starts_with(tmpUrl, "http://") || boost::starts_with(tmpUrl, "https://")) { + m_browser->Stop(); + evt.Veto(); + wxLaunchDefaultApplication(tmpUrl); + } +} void ProjectPanel::onWebNavigating(wxWebViewEvent& evt) { @@ -109,8 +147,6 @@ void ProjectPanel::on_reload(wxCommandEvent& evt) description = model.model_info->description; update_type = model.model_info->origin; - - if (model.design_info && !model.design_info->DesignerId.empty()) { if (m_model_id_map.count(model.design_info->DesignerId) > 0) { @@ -121,7 +157,6 @@ void ProjectPanel::on_reload(wxCommandEvent& evt) m_model_id_map[model.design_info->DesignerId] = model_id; } } - try { if (!model.model_info->copyright.empty()) { @@ -277,8 +312,6 @@ void ProjectPanel::OnScriptMessage(wxWebViewEvent& evt) } } } - - } else if (strCmd == "debug_info") { //wxString msg = j["msg"]; diff --git a/src/slic3r/GUI/Project.hpp b/src/slic3r/GUI/Project.hpp index ab9f96ad2..6e594b7be 100644 --- a/src/slic3r/GUI/Project.hpp +++ b/src/slic3r/GUI/Project.hpp @@ -67,7 +67,6 @@ private: wxString m_root_dir; std::map m_model_id_map; static inline int m_sequence_id = 8000; - public: ProjectPanel(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, long style = wxTAB_TRAVERSAL); @@ -78,7 +77,8 @@ public: void on_reload(wxCommandEvent& evt); void on_size(wxSizeEvent& event); void on_navigated(wxWebViewEvent& event); - + void OnNewWindow(wxWebViewEvent &evt); + void msw_rescale(); void update_model_data(); void clear_model_info(); diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 14f6a155e..a8d81fa35 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -926,7 +926,7 @@ bool GuideFrame::run() int main_frame_display_index = wxDisplay::GetFromWindow(wxGetApp().mainframe); int guide_display_index = wxDisplay::GetFromWindow(this); if (main_frame_display_index != guide_display_index) { - wxDisplay display = wxDisplay(main_frame_display_index); + wxDisplay display(wxGetApp().mainframe); wxRect screenRect = display.GetGeometry(); int guide_x = screenRect.x + (screenRect.width - this->GetSize().GetWidth()) / 2; int guide_y = screenRect.y + (screenRect.height - this->GetSize().GetHeight()) / 2; @@ -1133,7 +1133,7 @@ int GuideFrame::LoadProfile() wxString strVendor = from_u8(iter->path().string()).BeforeLast('.'); strVendor = strVendor.AfterLast( '\\'); - strVendor = strVendor.AfterLast('\/'); + strVendor = strVendor.AfterLast('/'); wxString strExtension = from_u8(iter->path().string()).AfterLast('.').Lower(); if (w2s(strVendor) == PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json") == 0) @@ -1152,7 +1152,7 @@ int GuideFrame::LoadProfile() //cout << iter->path().string() << endl; wxString strVendor = from_u8(iter->path().string()).BeforeLast('.'); strVendor = strVendor.AfterLast( '\\'); - strVendor = strVendor.AfterLast('\/'); + strVendor = strVendor.AfterLast('/'); wxString strExtension = from_u8(iter->path().string()).AfterLast('.').Lower(); if (w2s(strVendor) != PresetBundle::BBL_BUNDLE && strExtension.CmpNoCase("json")==0) @@ -1459,7 +1459,7 @@ std::string GuideFrame::w2s(wxString sSrc) void GuideFrame::GetStardardFilePath(std::string &FilePath) { StrReplace(FilePath, "\\", w2s(wxString::Format("%c", boost::filesystem::path::preferred_separator))); - StrReplace(FilePath, "\/", w2s(wxString::Format("%c", boost::filesystem::path::preferred_separator))); + StrReplace(FilePath, "/", w2s(wxString::Format("%c", boost::filesystem::path::preferred_separator))); } //bool GuideFrame::LoadFile(std::string jPath, std::string &sContent) diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index 92c279758..af2161034 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -272,13 +272,7 @@ void ZUserLogin::OnScriptMessage(wxWebViewEvent &evt) json j = json::parse(into_u8(str_input)); wxString strCmd = j["command"]; - - if (strCmd == "autotest_token") - { - m_AutotestToken = j["data"]["token"]; - } if (strCmd == "user_login") { - j["data"]["autotest_token"] = m_AutotestToken; wxGetApp().handle_script_message(j.dump()); Close(); } diff --git a/src/slic3r/GUI/WebUserLoginDialog.hpp b/src/slic3r/GUI/WebUserLoginDialog.hpp index ff3631496..b0dca3511 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.hpp +++ b/src/slic3r/GUI/WebUserLoginDialog.hpp @@ -70,8 +70,6 @@ private: wxString TargetUrl; wxWebView *m_browser; - std::string m_AutotestToken; - #if wxUSE_WEBVIEW_IE wxMenuItem *m_script_object_el; wxMenuItem *m_script_date_el; diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 622376638..7eb3d6f94 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -96,22 +96,7 @@ WebViewPanel::WebViewPanel(wxWindow *parent) //Create Webview Panel m_home_web = new wxBoxSizer(wxHORIZONTAL); - // Create the webview - m_browser = WebView::CreateWebView(this, UrlRight); - if (m_browser == nullptr) { - wxLogError("Could not init m_browser"); - return; - } - - m_browserMW = WebView::CreateWebView(this, "about:blank"); - if (m_browserMW == nullptr) { - wxLogError("Could not init m_browserMW"); - return; - } - m_browserMW->Hide(); - SetMakerworldModelID(""); - m_onlinefirst = false; - + // LeftMenu webview m_leftfirst = false; m_browserLeft = WebView::CreateWebView(this, UrlLeft); if (m_browserLeft == nullptr) { @@ -122,9 +107,38 @@ WebViewPanel::WebViewPanel(wxWindow *parent) m_browserLeft->SetMinSize(wxSize(FromDIP(224), -1)); m_browserLeft->SetMaxSize(wxSize(FromDIP(224), -1)); + // Create the webview + m_browser = WebView::CreateWebView(this, UrlRight); + if (m_browser == nullptr) { + wxLogError("Could not init m_browser"); + return; + } + + // Makerworld webview + m_browserMW = WebView::CreateWebView(this, "about:blank"); + if (m_browserMW == nullptr) { + wxLogError("Could not init m_browserMW"); + return; + } + m_browserMW->Hide(); + SetMakerworldModelID(""); + m_onlinefirst = false; + + // PrintHistory webview + m_browserPH = WebView::CreateWebView(this, "about:blank"); + if (m_browserPH == nullptr) { + wxLogError("Could not init m_browserPH"); + return; + } + m_browserPH->Hide(); + SetPrintHistoryTaskID(0); + m_printhistoryfirst = 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); topsizer->Add(m_home_web,1, wxEXPAND | wxALL, 0); @@ -277,6 +291,9 @@ void WebViewPanel::ResetWholePage() m_Region = tmp_Region; + //loginstatus + m_loginstatus = -1; + //left if (m_browserLeft != nullptr && m_leftfirst) m_browserLeft->Reload(); @@ -291,6 +308,19 @@ void WebViewPanel::ResetWholePage() //online SetMakerworldModelID(""); m_onlinefirst = false; + + //PrintHistory + SetPrintHistoryTaskID(0); + m_printhistoryfirst = false; +} + +wxString WebViewPanel::MakeDisconnectUrl(std::string MenuName) +{ + wxString UrlDisconnect = wxString::Format("file://%s/web/homepage3/disconnect.html?menu=%s", from_u8(resources_dir()), MenuName); + wxString strlang = wxGetApp().current_language_code_safe(); + if (strlang != "") { UrlDisconnect = wxString::Format("file://%s/web/homepage3/disconnect.html?menu=%s&lang=%s", from_u8(resources_dir()), MenuName, strlang); } + + return UrlDisconnect; } void WebViewPanel::load_url(wxString& url) @@ -482,21 +512,32 @@ void WebViewPanel::OnFreshLoginStatus(wxTimerEvent &event) if (mainframe && mainframe->m_webview == this) Slic3r::GUI::wxGetApp().get_login_info(); - if (wxGetApp().is_user_login()) { - if (m_loginstatus != 1) + std::string phShow = wxGetApp().app_config->get("app", "show_print_history"); + + if (wxGetApp().is_user_login()) + { + if (m_loginstatus != 1) { m_loginstatus = 1; if (m_onlinefirst) UpdateMakerworldLoginStatus(); } + + if (m_TaskInfo == "" && m_browser && phShow != "false") + { + SetPrintHistoryTaskID(0); + ShowUserPrintTask(true); + } } else { if (m_loginstatus != 0) { m_loginstatus = 0; if (m_onlinefirst) SetMakerworldPageLoginStatus(false); - } + } + + if (m_TaskInfo != "" && m_browser) ShowUserPrintTask(false); } } @@ -811,7 +852,12 @@ void WebViewPanel::UpdateMakerworldLoginStatus() std::string newticket; int ret = agent->request_bind_ticket(&newticket); - if (ret==0) SetMakerworldPageLoginStatus(true, newticket); + if (ret==0) + SetMakerworldPageLoginStatus(true, newticket); + else { + wxString UrlDisconnect = MakeDisconnectUrl("online"); + m_browserMW->LoadURL(UrlDisconnect); + } } @@ -884,6 +930,76 @@ int WebViewPanel::get_model_mall_detail_url(std::string *url, std::string id) return 0; } +void WebViewPanel::ShowUserPrintTask(bool bShow) +{ + std::string phShow = wxGetApp().app_config->get("app", "show_print_history"); + if (bShow && phShow == "false") bShow = false; + + if (bShow) + { + NetworkAgent *agent = GUI::wxGetApp().getAgent(); + if (agent && agent->is_user_login()) { + static long long PrintTaskMs = 0; + + auto now = std::chrono::system_clock::now(); + long long TmpMs = std::chrono::duration_cast(now.time_since_epoch()).count(); + long long nInterval = TmpMs - PrintTaskMs; + if (nInterval < 2000) return; + PrintTaskMs = TmpMs; + + BBL::TaskQueryParams task_query_params; + task_query_params.limit = 5; + task_query_params.offset = 0; + int result = agent->get_user_tasks(task_query_params, &m_TaskInfo); + BOOST_LOG_TRIVIAL(trace) << "task_manager: get_task_list task_info=" << m_TaskInfo; + if (result == 0) { + try { + json j = json::parse(m_TaskInfo); + BOOST_LOG_TRIVIAL(trace) << "task_manager: get_task_list task count =" << j["hits"].size(); + + auto body2 = from_u8(m_TaskInfo); + body2.insert(1, "\"command\": \"printhistory_task_show\", "); + RunScript(wxString::Format("window.postMessage(%s)", body2)); + + SetLeftMenuShow("printhistory", 1); + + return; + } catch (...) {} + } + else + m_TaskInfo = ""; + } + } + else + { + //Hide Left Menu + SetLeftMenuShow("printhistory", 0); + m_TaskInfo = ""; + + //Hide WebBrowser + if (m_contentname == "printhistory") SwitchLeftMenu("home"); + + //refresh url + auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code()); + + wxString language_code = wxGetApp().current_language_code().BeforeFirst('_'); + language_code = language_code.ToStdString(); + + wxString mw_OffUrl = (boost::format("%1%%2%/studio/print-history?from=bambustudio") % host % language_code.mb_str()).str(); + wxString Finalurl = wxString::Format("%sapi/sign-out?to=%s", host, UrlEncode("about:blank")); + + m_browserPH->LoadURL(Finalurl); + SetPrintHistoryTaskID(0); + m_TaskInfo = ""; + + //First Enter False + m_printhistoryfirst = false; + } + + return; +} + + void WebViewPanel::update_mode() { GetSizer()->Show(size_t(0), wxGetApp().app_config->get("internal_developer_mode") == "true"); @@ -1305,30 +1421,54 @@ 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_online_LastUrl = m_browserMW->GetCurrentURL(); if (m_contentname == "online") { wxString errurl = evt.GetURL(); - wxString UrlRight = wxString::Format("file://%s/web/homepage3/disconnect.html", from_u8(resources_dir())); - - wxString strlang = wxGetApp().current_language_code_safe(); - if (strlang != "") { - UrlRight = wxString::Format("file://%s/web/homepage3/disconnect.html?lang=%s", from_u8(resources_dir()), strlang); - } - - m_browserMW->LoadURL(UrlRight); + wxString UrlDisconnect = MakeDisconnectUrl("online"); + m_browserMW->LoadURL(UrlDisconnect); SetWebviewShow("online", true); SetWebviewShow("right", false); + SetWebviewShow("printhistory", false); + } + } + + if (evt.GetInt() == wxWEBVIEW_NAV_ERR_CONNECTION && evt.GetId() == m_browserPH->GetId()) { + m_print_history_LastUrl = m_browserPH->GetCurrentURL(); + + if (m_contentname == "printhistory") { + wxString errurl = evt.GetURL(); + + wxString UrlDisconnect = MakeDisconnectUrl("printhistory"); + m_browserPH->LoadURL(UrlDisconnect); + + SetWebviewShow("printhistory", true); + SetWebviewShow("online", false); + SetWebviewShow("right", false); } } UpdateState(); } +void WebViewPanel::OpenMakerworldSearchPage(std::string KeyWord) +{ + if (KeyWord.empty()) return; + + auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code()); + + wxString language_code = wxGetApp().current_language_code().BeforeFirst('_'); + language_code = language_code.ToStdString(); + + m_online_LastUrl = (boost::format("%1%%2%/studio/webview/search?keyword=%3%&from=bambustudio") % host % language_code.mb_str() % UrlEncode(KeyWord)).str(); + + SwitchLeftMenu("online"); +} + void WebViewPanel::SetMakerworldModelID(std::string ModelID) { auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code()); @@ -1342,6 +1482,19 @@ void WebViewPanel::SetMakerworldModelID(std::string ModelID) m_online_LastUrl = (boost::format("%1%%2%/studio/webview?from=bambustudio") % host % language_code.mb_str()).str(); } +void WebViewPanel::SetPrintHistoryTaskID(int TaskID) +{ + auto host = wxGetApp().get_model_http_url(wxGetApp().app_config->get_country_code()); + + wxString language_code = wxGetApp().current_language_code().BeforeFirst('_'); + language_code = language_code.ToStdString(); + + if (TaskID != 0) + m_print_history_LastUrl = (boost::format("%1%%2%/studio/print-history/%3%?from=bambustudio") % host % language_code.mb_str() % TaskID).str(); + else + m_print_history_LastUrl = (boost::format("%1%%2%/studio/print-history?from=bambustudio") % host % language_code.mb_str()).str(); +} + void WebViewPanel::SwitchWebContent(std::string modelname, int refresh) { m_contentname = modelname; @@ -1357,6 +1510,8 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh) wxString FinalUrl = LabUrl; NetworkAgent *agent = GUI::wxGetApp().getAgent(); if (agent && agent->is_user_login()) { + std::string BambuHost=agent->get_bambulab_host(); + std::string newticket; int ret = agent->request_bind_ticket(&newticket); if (ret == 0) GetJumpUrl(true, newticket, FinalUrl, FinalUrl); @@ -1390,6 +1545,7 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh) SetWebviewShow("online", true); SetWebviewShow("right", false); + SetWebviewShow("printhistory", false); GetSizer()->Layout(); @@ -1397,6 +1553,44 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh) wxGetApp().app_config->set_str("homepage", "online_clicked", "1"); wxGetApp().app_config->save(); wxGetApp().CallAfter([this] { ShowMenuNewTag("online", "0"); }); + + } else if (modelname.compare("printhistory") == 0) { + + if (!m_printhistoryfirst) + { + NetworkAgent *agent = GUI::wxGetApp().getAgent(); + if (agent == nullptr) return; + + std::string BambuHost = agent->get_bambulab_host(); + wxString FinalUrl = m_print_history_LastUrl; + std::string newticket; + int ret = agent->request_bind_ticket(&newticket); + if (ret == 0) { + GetJumpUrl(true, newticket, FinalUrl, FinalUrl); + m_browserPH->LoadURL(FinalUrl); + + m_print_history_LastUrl = ""; + m_printhistoryfirst = true; + } else { + wxString UrlDisconnect = MakeDisconnectUrl("printhistory"); + m_browserPH->LoadURL(UrlDisconnect); + } + } else { + if (m_print_history_LastUrl != "") { + m_browserPH->LoadURL(m_print_history_LastUrl); + + m_print_history_LastUrl = ""; + } else { + + } + } + + SetWebviewShow("online", false); + SetWebviewShow("right", false); + SetWebviewShow("printhistory", true); + + GetSizer()->Layout(); + } else if (modelname.compare("home") == 0 || modelname.compare("recent") == 0 || modelname.compare("manual") == 0) { if (!m_browser) return; @@ -1410,12 +1604,11 @@ void WebViewPanel::SwitchWebContent(std::string modelname, int refresh) WebView::RunScript(m_browser, strJS); - CallAfter([this]{ - SetWebviewShow("online", false); - SetWebviewShow("right", true); + SetWebviewShow("online", false); + SetWebviewShow("printhistory", false); + SetWebviewShow("right", true); - GetSizer()->Layout(); - }); + GetSizer()->Layout(); } } @@ -1498,6 +1691,7 @@ void WebViewPanel::SetLeftMenuShow(std::string menuname, int show) wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true)); WebView::RunScript(m_browserLeft, strJS); + WebView::RunScript(m_browser, strJS); } void WebViewPanel::SetWebviewShow(wxString name, bool show) @@ -1509,6 +1703,8 @@ void WebViewPanel::SetWebviewShow(wxString name, bool show) TmpWeb = m_browser; else if (name == "online") TmpWeb = m_browserMW; + else if (name == "printhistory") + TmpWeb = m_browserPH; if (TmpWeb != nullptr) { diff --git a/src/slic3r/GUI/WebViewDialog.hpp b/src/slic3r/GUI/WebViewDialog.hpp index 9fe813839..48099595c 100644 --- a/src/slic3r/GUI/WebViewDialog.hpp +++ b/src/slic3r/GUI/WebViewDialog.hpp @@ -97,10 +97,14 @@ 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); @@ -120,6 +124,9 @@ public: void get_makerlab_list(std::function callback); 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 = ""); @@ -136,12 +143,15 @@ private: wxWebView* m_browser; 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 - //std::string m_online_spec_id; // Online Page Spec_ID - wxString m_online_type; //recommend & browse - wxString m_online_LastUrl; //PageLastError Url + 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; wxBoxSizer *bSizer_toolbar; wxButton * m_button_back;