diff --git a/loader/components/home/classification/index.js b/loader/components/home/classification/index.js index 41ceadb..31f90b6 100644 --- a/loader/components/home/classification/index.js +++ b/loader/components/home/classification/index.js @@ -49,8 +49,20 @@ export default { this.$emit("changeSearchParameter", { key: "", tags: this.tags }); }, // Select a single tag - selectClassify(index) { + selectClassify(event, index) { const existIndex = this.selectedList.findIndex((x) => x === index); + if (event.ctrlKey) { + if (existIndex != -1) { + this.selectedList.splice(existIndex, 1); + const tagIndex = this.tags.findIndex((x) => x === this.list[index].name); + this.tags.splice(tagIndex, 1); + } else { + this.selectedList.push(index); + this.tags.push(this.list[index].name); + } + this.$emit("changeSearchParameter", { key: "", tags: this.tags }); + return; + } // 无ctrl: 单选, 当已存在时取消所有, 若当前已选多项时单击先取消所有再选择当前 if (this.tags.length > 1 || existIndex == -1) { this.selectedList = [index]; @@ -89,7 +101,7 @@ export default { template: `
ALL
-
+
{{item.name}}
diff --git a/loader/components/home/model/detail/basicInf/index.js b/loader/components/home/model/detail/basicInf/index.js index 35aa389..a348073 100644 --- a/loader/components/home/model/detail/basicInf/index.js +++ b/loader/components/home/model/detail/basicInf/index.js @@ -20,6 +20,13 @@ export default { //Timestamp conversion timestampConversion(timeStamp) { const date = new Date(Number(timeStamp)); + return date.toLocaleString([], { + year: "numeric", + month: "2-digit", + day: "2-digit", + hour: "2-digit", + minute: "2-digit", + }); return date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate() + " " + date.getHours() + ": " + date.getMinutes(); }, // Delete tag @@ -73,6 +80,12 @@ export default { return true; }, }, + filters: { + // 保留小数位数->str + numberRound(num, decimal = 2) { + return Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal); + }, + }, template: `
diff --git a/loader/components/home/model/detail/index.js b/loader/components/home/model/detail/index.js index fb82e17..3beecd7 100644 --- a/loader/components/home/model/detail/index.js +++ b/loader/components/home/model/detail/index.js @@ -140,12 +140,6 @@ export default { this.menuIndex = index; }, }, - filters: { - // 保留小数位数->str - numberRound(num, decimal = 2) { - return Math.round(num * Math.pow(10, decimal)) / Math.pow(10, decimal); - }, - }, template: `
diff --git a/loader/components/home/model/detail/workflow/index.js b/loader/components/home/model/detail/workflow/index.js index c2b799f..c09e952 100644 --- a/loader/components/home/model/detail/workflow/index.js +++ b/loader/components/home/model/detail/workflow/index.js @@ -56,39 +56,40 @@ export default { saveWorkflow(name) { // 随机生成 if (!name) name = `wk-${Math.random().toString(36).substring(2, 10)}`; + var node = this.node; var data = window.parent.app.graph.serialize(); var request = new XMLHttpRequest(); - request.timeout = 500; // 超时 + // request.timeout = 500; // 超时 request.open("post", "/cs/save_workflow", true); request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); request.onload = () => { if (request.status != 200) return; var resp = JSON.parse(request.responseText); if (resp?.saved) { - this.node.CSupdateModelConfig(this.model.name); + node.CSupdateModelConfig(this.model.name); this.$message(name + " " + this.$t("home.modelDetail.workflow.saveSuccess")); } else { this.$message(name + " " + this.$t("home.modelDetail.workflow.saveFail")); } }; - request.ontimeout = () => { - this.$message(name + " " + this.$t("home.modelDetail.workflow.saveTimeout")); - }; - let mtype = this.node.CSgetModelWidgetType(); + // request.ontimeout = () => { + // this.$message(name + " " + this.$t("home.modelDetail.workflow.saveTimeout")); + // }; + let mtype = node.CSgetModelWidgetType(); let body = { mtype: mtype, mname: this.model?.name, data, name }; request.send(JSON.stringify(body)); }, // Copy workflow - async copyText(item) { + copyWorkflow(item) { var request = new XMLHttpRequest(); request.timeout = 500; // 超时 request.open("post", "/cs/fetch_workflow", true); request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); - request.onload = () => { + request.onload = async () => { if (request.status != 200) return; var resp = JSON.parse(request.responseText); if (resp) { - navigator.clipboard.writeText(request.responseText); + await navigator.clipboard.writeText(request.responseText); this.$message(item.name + " " + this.$t("home.modelDetail.workflow.copySuccess")); } else { this.$message(item.name + " " + this.$t("home.modelDetail.workflow.copyFail")); @@ -102,9 +103,10 @@ export default { request.send(JSON.stringify(body)); }, // Delete workflow - deleteItem(index, item) { + deleteWorkflow(index, item) { + // 异步, 且取消超时等待 var request = new XMLHttpRequest(); - request.timeout = 500; // 超时 + // request.timeout = 500; // 超时 request.open("post", "/cs/remove_workflow", true); request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); request.onload = () => { @@ -117,15 +119,41 @@ export default { this.$message(item.name + " " + this.$t("home.modelDetail.workflow.deleteFail")); } }; + // request.ontimeout = () => { + // this.$message(item.name + " " + this.$t("home.modelDetail.workflow.deleteTimeout")); + // }; + let mtype = this.node.CSgetModelWidgetType(); + let body = { mtype: mtype, mname: this.model?.name, workflow: item.workflow, name: item.name }; + request.send(JSON.stringify(body)); + }, + // Import + importWorkflow(item) { + var request = new XMLHttpRequest(); + request.timeout = 500; // 超时 + request.open("post", "/cs/fetch_workflow", true); + request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); + request.onload = async () => { + if (request.status != 200) return; + var resp = JSON.parse(request.responseText); + if (resp) { + try { + if (resp.hasOwnProperty("workflow")) resp = resp.workflow; + await window.parent.app.loadGraphData(resp); + this.$message(item.name + " " + this.$t("home.modelDetail.workflow.importSuccess")); + } catch (e) { + this.$message(item.name + " " + this.$t("home.modelDetail.workflow.importFail") + `: ${e}`); + } + } else { + this.$message(item.name + " " + this.$t("home.modelDetail.workflow.importFail")); + } + }; request.ontimeout = () => { - this.$message(item.name + " " + this.$t("home.modelDetail.workflow.deleteTimeout")); + this.$message(item.name + " " + this.$t("home.modelDetail.workflow.importTimeout")); }; let mtype = this.node.CSgetModelWidgetType(); let body = { mtype: mtype, mname: this.model?.name, workflow: item.workflow, name: item.name }; request.send(JSON.stringify(body)); }, - // Import - import(item) {}, }, template: `
@@ -143,9 +171,9 @@ export default {
{{item.name}}
- - - + + +
diff --git a/loader/enterLoader.js b/loader/enterLoader.js index 166cf7a..d505aff 100644 --- a/loader/enterLoader.js +++ b/loader/enterLoader.js @@ -38,6 +38,7 @@ function message(event) { if (event.data.type === "close_loader_page") { let page = getPage(); page.style.display = "none"; + window.CSvm.node = null; // reset node // document.body.removeChild(document.getElementById("loader_iframe")); } } diff --git a/loader/static/js/i18n.js b/loader/static/js/i18n.js index 234cf0b..9dcb6f5 100644 --- a/loader/static/js/i18n.js +++ b/loader/static/js/i18n.js @@ -142,6 +142,9 @@ const message = { deleteSuccess: "删除成功", deleteFail: "删除失败", deleteTimeout: "删除超时", + importSuccess: "导入成功", + importFail: "导入失败", + importTimeout: "导入超时", }, useButtonText: "使用此模型", }, @@ -317,6 +320,9 @@ const message = { deleteSuccess: "Delete success", deleteFail: "Delete failed", deleteTimeout: "Delete timeout", + importSuccess: "Import success", + importFail: "Import failed", + importTimeout: "Import timeout", }, useButtonText: "Use model", }, @@ -493,6 +499,9 @@ const message = { deleteSuccess: "刪除成功", deleteFail: "刪除失敗", deleteTimeout: "刪除超时", + importSuccess: "導入成功", + importFail: "導入失敗", + importTimeout: "導入超時", }, useButtonText: "使用此模型", },