diff --git a/src/components/menus/MyChat.vue b/src/components/menus/MyChat.vue index 8c11febb7c3821219db2be957cb7bef374ee1332..59c59f6f6a6dc21489172639263738472f8b77cf 100644 --- a/src/components/menus/MyChat.vue +++ b/src/components/menus/MyChat.vue @@ -141,7 +141,7 @@ export default { async onDelete(id) { this.loading = true; const { data: res } = await axios.get( - "http://localhost:8888/chatbot/delete", + "http://120.79.36.53:8888/chatbot/delete", { params: { id: id, @@ -164,7 +164,7 @@ export default { async initCartList() { this.loading = true; const { data: res } = await axios.get( - "http://localhost:8888/chatbot/page", + "http://120.79.36.53:8888/chatbot/page", { params: { page: this.currentPage, diff --git a/src/components/user/AddChatDetail.vue b/src/components/user/AddChatDetail.vue index 2511455347f24d8ba3150908eb7ae2d070a83bde..9091fbfd21332ef12b5874a4b2fbe1eba9314890 100644 --- a/src/components/user/AddChatDetail.vue +++ b/src/components/user/AddChatDetail.vue @@ -38,24 +38,33 @@ export default { this.form.response = ""; }, async onSubmit() { - // 调用 axios 的 get 方法,请求列表数据 - const { data: res } = await axios.post("http://localhost:8888/chatbot", { + const data = { question: this.form.question, response: this.form.response, - }); - // 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中 - if (res.code === 200) { - this.$message.success("问题和答案新增成功"); - } + }; + axios + .post("http://120.79.36.53:8888/chatbot", data) + .then((response) => { + // 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中 + if (response.data.code === 200) { + this.$message.success({ + message: "问题和答案新增成功", + duration: 1000, + }); + this.goBack(); + } + }) + .catch((error) => { + // 处理错误 + this.$message.error("系统异常"); + }); }, goBack() { // 传递参数到前一个页面 const params = { // 参数名: 参数值 back: "back", - // baz: "qux", }; - // 使用 $router.push() 导航到前一个页面 this.$router.push({ path: "/home/chat", // 前一个页面的路径 diff --git a/src/components/user/MyChatDetail.vue b/src/components/user/MyChatDetail.vue index a5eafc3eb732c772b9fcf97c1696effb730ad736..d34def6d2eaf3afcd5791fdfb263c50250b52be1 100644 --- a/src/components/user/MyChatDetail.vue +++ b/src/components/user/MyChatDetail.vue @@ -68,7 +68,7 @@ export default { async initChatList() { // 调用 axios 的 get 方法,请求列表数据 const { data: res } = await axios.get( - "http://localhost:8888/chatbot/" + this.id + "http://120.79.36.53:8888/chatbot/" + this.id ); // 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中 if (res.code === 200) {