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: "使用此模型",
},