diff --git a/src/renderer/helper/index.ts b/src/renderer/helper/index.ts index 70001d3a..b8205435 100644 --- a/src/renderer/helper/index.ts +++ b/src/renderer/helper/index.ts @@ -50,6 +50,9 @@ const emitter = mitt<{ "apidoc/tabs/addOrDeleteTab": void, "apidoc/getBaseInfo": ApidocProjectBaseInfoState, "searchItem/change": string, + "tabs/saveTabSuccess": void, + "tabs/saveTabError": void, + "tabs/cancelSaveTab": void, }>() export const event = emitter; diff --git a/src/renderer/pages/modules/apidoc/doc-edit/dialog/save-doc/save-doc.vue b/src/renderer/pages/modules/apidoc/doc-edit/dialog/save-doc/save-doc.vue index 0d2b58dc..79b211bc 100644 --- a/src/renderer/pages/modules/apidoc/doc-edit/dialog/save-doc/save-doc.vue +++ b/src/renderer/pages/modules/apidoc/doc-edit/dialog/save-doc/save-doc.vue @@ -51,6 +51,7 @@ import { TreeNodeOptions } from "element-plus/es/components/tree/src/tree.type"; import { router } from "@/router"; import { axios } from "@/api/api" import { store } from "@/store"; +import { event } from "@/helper"; type FormInfo = { name: string, //接口名称 @@ -106,6 +107,7 @@ onMounted(() => { }) const handleClose = () => { emit("update:modelValue", false) + event.emit("tabs/cancelSaveTab") } const handleSaveDoc = () => { const docInfo = JSON.parse(JSON.stringify(store.state["apidoc/apidoc"].apidoc)) @@ -123,12 +125,12 @@ const handleSaveDoc = () => { store.commit("apidoc/apidoc/changeApidocId", res.data); store.commit("apidoc/apidoc/changeApidocName", formInfo.value.name); store.commit("apidoc/tabs/changeTabInfoById", { - id: docInfo._id, + id: store.state["apidoc/apidoc"].savedDocId, field: "label", value: formInfo.value.name, }) store.commit("apidoc/tabs/changeTabInfoById", { - id: docInfo._id, + id: store.state["apidoc/apidoc"].savedDocId, field: "_id", value: res.data, }) @@ -138,10 +140,12 @@ const handleSaveDoc = () => { field: "saved", value: true, }) + event.emit("tabs/saveTabSuccess") }) emit("update:modelValue", false) }).catch((err) => { console.error(err); + event.emit("tabs/saveTabError") }).finally(() => { loading.value = false; });