完成驳回通知邮件功能
This commit is contained in:
7
src/api/Email.ts
Normal file
7
src/api/Email.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import Request from '@/utils/request'
|
||||||
|
import { DismissEmail } from '@/types/app/email'
|
||||||
|
|
||||||
|
// 发送驳回邮件
|
||||||
|
export const sendDismissEmailAPI = async (data: DismissEmail) => {
|
||||||
|
return await Request<string>("POST", `/email/dismiss`, { data });
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ import Empty from "@/components/Empty";
|
|||||||
|
|
||||||
import { useWebStore } from '@/stores';
|
import { useWebStore } from '@/stores';
|
||||||
import TextArea from "antd/es/input/TextArea";
|
import TextArea from "antd/es/input/TextArea";
|
||||||
|
import { sendDismissEmailAPI } from "@/api/Email";
|
||||||
|
|
||||||
type Menu = "comment" | "link" | "wall";
|
type Menu = "comment" | "link" | "wall";
|
||||||
|
|
||||||
@@ -58,12 +59,58 @@ const ListItem = ({ item, type, fetchData }: ListItemProps) => {
|
|||||||
message.success('🎉 留言驳回成功');
|
message.success('🎉 留言驳回成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(dismissInfo);
|
|
||||||
|
|
||||||
setIsModalOpen(false)
|
setIsModalOpen(false)
|
||||||
fetchData(type);
|
fetchData(type);
|
||||||
|
setDismissInfo("")
|
||||||
|
|
||||||
|
// 发送驳回通知邮件
|
||||||
|
sendDismissEmail()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 发送驳回通知邮件
|
||||||
|
const sendDismissEmail = () => {
|
||||||
|
// 类型名称
|
||||||
|
let email_info = {
|
||||||
|
name: "",
|
||||||
|
type: "",
|
||||||
|
url: ""
|
||||||
|
}
|
||||||
|
switch (type) {
|
||||||
|
case "link":
|
||||||
|
email_info = {
|
||||||
|
name: item.title,
|
||||||
|
type: "友链",
|
||||||
|
url: `${web.url}/friend`,
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "comment":
|
||||||
|
email_info = {
|
||||||
|
name: item.name,
|
||||||
|
type: "评论",
|
||||||
|
url: `${web.url}/article/${item.articleId}`,
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "wall":
|
||||||
|
email_info = {
|
||||||
|
name: item.name,
|
||||||
|
type: "留言",
|
||||||
|
url: `${web.url}/wall/all`,
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendDismissEmailAPI({
|
||||||
|
to: item.email,
|
||||||
|
content: dismissInfo,
|
||||||
|
recipient: email_info.name,
|
||||||
|
subject: `${email_info.type}驳回通知`,
|
||||||
|
time: dayjs(Date.now()).format('YYYY年MM月DD日 HH:mm'),
|
||||||
|
type: email_info.type,
|
||||||
|
url: email_info.url
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={item.id}>
|
<div key={item.id}>
|
||||||
<div className="text-center text-xs text-[#e0e0e0] mb-4">
|
<div className="text-center text-xs text-[#e0e0e0] mb-4">
|
||||||
|
|||||||
24
src/types/app/email.d.ts
vendored
Normal file
24
src/types/app/email.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
export interface Email {
|
||||||
|
/*邮件接收者 */
|
||||||
|
to?: string;
|
||||||
|
/*邮件标题 */
|
||||||
|
subject: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CommentEmail extends Email {
|
||||||
|
content: string;
|
||||||
|
reviewers: string;
|
||||||
|
subject: string;
|
||||||
|
time: string;
|
||||||
|
title: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DismissEmail extends Email {
|
||||||
|
content: string;
|
||||||
|
recipient: string;
|
||||||
|
subject: string;
|
||||||
|
time: string;
|
||||||
|
type: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
@@ -3,8 +3,8 @@ import { Modal, notification } from "antd";
|
|||||||
import { useUserStore } from "@/stores";
|
import { useUserStore } from "@/stores";
|
||||||
|
|
||||||
// 配置项目API域名
|
// 配置项目API域名
|
||||||
// export const baseURL = "http://localhost:9003/api";
|
export const baseURL = "http://localhost:9003/api";
|
||||||
export const baseURL = "https://api.liuyuyang.net/api";
|
// export const baseURL = "https://api.liuyuyang.net/api";
|
||||||
|
|
||||||
// 创建 axios 实例
|
// 创建 axios 实例
|
||||||
export const instance = axios.create({
|
export const instance = axios.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user