From 776a81ccf1ef69a68c9209d84c8615e6281397e8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 11 Sep 2024 10:25:43 +0800 Subject: [PATCH 1/3] 'gengxin' --- .../message/components/messageContent.vue | 73 ++++++++++++++----- .../views/message/components/sendMessage.vue | 4 +- .../src/views/message/index.vue | 4 +- .../news/components/newsContentManage.vue | 20 ++--- .../src/views/news/index.vue | 3 +- .../.env.development | 1 + .../src/api/news.ts | 26 +++++++ 7 files changed, 98 insertions(+), 33 deletions(-) create mode 100644 teaching_integration_platform_template/src/api/news.ts diff --git a/teaching_integration_platform_admin_template/src/views/message/components/messageContent.vue b/teaching_integration_platform_admin_template/src/views/message/components/messageContent.vue index 22a514f..89d1716 100644 --- a/teaching_integration_platform_admin_template/src/views/message/components/messageContent.vue +++ b/teaching_integration_platform_admin_template/src/views/message/components/messageContent.vue @@ -150,25 +150,62 @@ const disappoint = ()=>{ addPerson.value = false } //发送信息 +// const send = async () => { +// await ElMessageBox.confirm('您确定发送这条信息吗', '温馨提示', { +// confirmButtonText: '确认', +// cancelButtonText: '取消', +// type: 'warning', +// }) +// await SendMessageApi({ +// receiverId: inputPerson.value.toString(), +// courseId:inputCourseId.value.toString(), +// title:inputText.value, +// content:textarea.value, +// senderId:userStore.data.id +// }).then(()=>{ +// ElMessage({ +// message:'发送成功', +// type:'success' +// }) +// }) +// } const send = async () => { - await ElMessageBox.confirm('您确定发送这条信息吗', '温馨提示', { - confirmButtonText: '确认', - cancelButtonText: '取消', - type: 'warning', - }) - await SendMessageApi({ - receiverId: inputPerson.value.toString(), - courseId:inputCourseId.value.toString(), - title:inputText.value, - content:textarea.value, - senderId:userStore.data.id - }).then(()=>{ - ElMessage({ - message:'发送成功', - type:'success' - }) - }) -} + try { + // 显示确认框 + await ElMessageBox.confirm('您确定发送这条信息吗', '温馨提示', { + confirmButtonText: '确认', + cancelButtonText: '取消', + type: 'warning', + }); + + // 发送消息 + await SendMessageApi({ + receiverId: inputPerson.value.toString(), + courseId: inputCourseId.value.toString(), + title: inputText.value, + content: textarea.value, + senderId: userStore.data.id, + }).then(() => { + ElMessage({ + message: '发送成功', + type: 'success', + }); + }); + } catch (error) { + // 处理确认框取消的情况或其他错误 + if (error.type === 'cancel') { + // 用户取消了发送 + return; + } + + // 发送失败时的提示 + ElMessage.error({ + message: '发送失败', + type: 'error', + }); + console.error('发送失败:', error); + } +};