From a6a33df3559c274d6569dee763c27c1f271962fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E9=98=B3?= Date: Mon, 9 Dec 2024 15:17:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=91=E5=B8=83=E6=96=87=E7=AB=A0=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/pages/Article/index.tsx | 19 ++++++++++------- src/pages/Cate/index.tsx | 12 +++++++---- .../Create/components/PublishForm/index.tsx | 6 +++--- src/pages/Work/index.tsx | 21 ++++++++++++------- src/types/app/comment.d.ts | 2 +- 6 files changed, 37 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index fd3b3c6..2ef1d5b 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "author": { "name": "YuYang", "email": "liuyuyang1024@yeah.net", - "url": "https://blog.liuyuyang.net" + "url": "https://liuyuyang.net" }, "dependencies": { "@bytemd/plugin-gemoji": "^1.21.0", diff --git a/src/pages/Article/index.tsx b/src/pages/Article/index.tsx index b518b74..fbeac10 100644 --- a/src/pages/Article/index.tsx +++ b/src/pages/Article/index.tsx @@ -39,14 +39,17 @@ const ArticlePage = () => { const delArticleData = async (id: number) => { setLoading(true); - // 普通删除:可从回收站恢复 - await delArticleDataAPI(id, true); - await getArticleList(); - form.resetFields() - setCurrent(1) - notification.success({ message: '🎉 删除文章成功' }) - - setLoading(false); + try { + // 普通删除:可从回收站恢复 + await delArticleDataAPI(id, true); + await getArticleList(); + form.resetFields() + setCurrent(1) + notification.success({ message: '🎉 删除文章成功' }) + setLoading(false); + } catch (error) { + setLoading(false); + } }; // 标签颜色 diff --git a/src/pages/Cate/index.tsx b/src/pages/Cate/index.tsx index b5c8c98..3cb4ac9 100644 --- a/src/pages/Cate/index.tsx +++ b/src/pages/Cate/index.tsx @@ -20,7 +20,7 @@ const CatePage = () => { const getCateList = async () => { const { data } = await getCateListAPI(); data.sort((a, b) => a.order - b.order) - + setList(data as Cate[]); setLoading(false); }; @@ -55,9 +55,13 @@ const CatePage = () => { const delCateData = async (id: number) => { setLoading(true); - await delCateDataAPI(id); - message.success('🎉 删除分类成功'); - getCateList(); + try { + await delCateDataAPI(id); + message.success('🎉 删除分类成功'); + getCateList(); + } catch (error) { + setLoading(false); + } }; const submit = async () => { diff --git a/src/pages/Create/components/PublishForm/index.tsx b/src/pages/Create/components/PublishForm/index.tsx index 4ac2170..a21cdf1 100644 --- a/src/pages/Create/components/PublishForm/index.tsx +++ b/src/pages/Create/components/PublishForm/index.tsx @@ -149,7 +149,7 @@ const PublishForm = ({ data, closeModel }: { data: Article, closeModel: () => vo ...values, content: data.content, tagIds: tagIds.join(','), - isDraft: 0, + isDraft: isDraft ? 1 : 0, config: { status: values.status, password: values.password @@ -249,9 +249,9 @@ const PublishForm = ({ data, closeModel }: { data: Article, closeModel: () => vo {/* 草稿和编辑状态下不再显示保存草稿按钮 */} - {(!isDraftParams && !id) && ( + {((isDraftParams && id) || !id) && ( - + )} diff --git a/src/pages/Work/index.tsx b/src/pages/Work/index.tsx index b656565..da0ab49 100644 --- a/src/pages/Work/index.tsx +++ b/src/pages/Work/index.tsx @@ -60,7 +60,7 @@ const ListItem = ({ item, type, fetchData }: ListItemProps) => { content: replyInfo, commentId: item?.id!, auditStatus: 1, - email: user.email, + email: user.email ? user.email : null, name: user.name, articleId: item?.articleId!, createTime: new Date().getTime().toString(), @@ -83,9 +83,9 @@ const ListItem = ({ item, type, fetchData }: ListItemProps) => { } else if (type === "wall") { await delWallDataAPI(item.id); } - + // 有内容就发送驳回通知邮件,反之直接删除 - if(dismissInfo.trim().length) await sendDismissEmail() + if (dismissInfo.trim().length) await sendDismissEmail() message.success('🎉 驳回成功'); setIsModalOpen(false) @@ -180,11 +180,16 @@ const ListItem = ({ item, type, fetchData }: ListItemProps) => {
[setIsModalOpen(true), setBtnType("reply")] }, - { key: 'dismiss', label: "驳回", onClick: () => [setIsModalOpen(true), , setBtnType("dismiss")] } - ] + items: type === "comment" + ? [ + { key: 'ok', label: "通过", onClick: handleApproval }, + { key: 'reply', label: "回复", onClick: () => [setIsModalOpen(true), setBtnType("reply")] }, + { key: 'dismiss', label: "驳回", onClick: () => [setIsModalOpen(true), , setBtnType("dismiss")] } + ] + : [ + { key: 'ok', label: "通过", onClick: handleApproval }, + { key: 'dismiss', label: "驳回", onClick: () => [setIsModalOpen(true), , setBtnType("dismiss")] } + ] }}>
diff --git a/src/types/app/comment.d.ts b/src/types/app/comment.d.ts index 25969c3..a75068a 100644 --- a/src/types/app/comment.d.ts +++ b/src/types/app/comment.d.ts @@ -2,7 +2,7 @@ export interface Comment { id?: number, name: string, avatar: string, - email: string, + email: string | null, url: string, content: string, articleId: number,