From 327e19497ba79f7a97867cfdac49c7b935033da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Liu=20=E5=AE=87=E9=98=B3?= Date: Mon, 21 Oct 2024 16:37:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/Email.ts | 7 ++++++- src/pages/Comment/index.tsx | 14 +++++++++++++- src/types/app/comment.d.ts | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/api/Email.ts b/src/api/Email.ts index cf82de8..7053492 100644 --- a/src/api/Email.ts +++ b/src/api/Email.ts @@ -1,5 +1,10 @@ import Request from '@/utils/request' -import { DismissEmail } from '@/types/app/email' +import { CommentEmail, DismissEmail } from '@/types/app/email' + +// 发送评论邮件 +export const sendCommentEmailAPI = async (data: CommentEmail) => { + return await Request("POST", `/email/comment`, { data }); +} // 发送驳回邮件 export const sendDismissEmailAPI = async (data: DismissEmail) => { diff --git a/src/pages/Comment/index.tsx b/src/pages/Comment/index.tsx index 723b315..6cb6f81 100644 --- a/src/pages/Comment/index.tsx +++ b/src/pages/Comment/index.tsx @@ -11,13 +11,14 @@ import { useWebStore, useUserStore } from '@/stores' import dayjs from 'dayjs'; import TextArea from 'antd/es/input/TextArea'; +import { sendCommentEmailAPI } from '@/api/Email'; const CommentPage = () => { const web = useWebStore(state => state.web) const user = useUserStore(state => state.user) const [loading, setLoading] = useState(false); - const [comment, setComment] = useState(); + const [comment, setComment] = useState({} as Comment); const [list, setList] = useState([]); const [isCommentModalOpen, setIsCommentModalOpen] = useState(false); @@ -143,6 +144,17 @@ const CommentPage = () => { setIsReplyModalOpen(false) setReplyInfo("") getCommentList() + + // 发送邮件通知 + await sendCommentEmailAPI({ + content: comment.content, + reviewers: comment.name, + subject: comment.articleTitle!, + title: comment.articleTitle!, + url: location.href, + time: dayjs(Date.now()).format('YYYY年MM月DD日 HH:mm'), + to: comment.id !== comment.articleId ? comment.email : undefined + }) } return ( diff --git a/src/types/app/comment.d.ts b/src/types/app/comment.d.ts index b4b9bd6..25969c3 100644 --- a/src/types/app/comment.d.ts +++ b/src/types/app/comment.d.ts @@ -6,7 +6,7 @@ export interface Comment { url: string, content: string, articleId: number, - articleTitle?: number, + articleTitle?: string, commentId: number, auditStatus: number createTime: string,