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,