From aa5172eb841b0c916bd94bad558eda49d836ae83 Mon Sep 17 00:00:00 2001 From: anghunk Date: Wed, 21 Jan 2026 10:03:00 +0800 Subject: [PATCH] =?UTF-8?q?feat(comments):=20=E6=B7=BB=E5=8A=A0=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E9=BB=91=E5=90=8D=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实现评论系统的邮箱黑名单功能,包括: 1. 在API中添加邮箱黑名单检查逻辑 2. 在管理后台添加邮箱黑名单设置界面 3. 支持在评论列表中直接屏蔽邮箱 4. 添加相关API接口处理邮箱黑名单操作 --- cwd-comments-admin/src/api/admin.ts | 6 ++ cwd-comments-admin/src/views/CommentsView.vue | 34 ++++++++- cwd-comments-admin/src/views/SettingsView.vue | 72 ++++++++++++------- .../src/api/public/postComment.ts | 11 +++ cwd-comments-api/src/index.ts | 68 +++++++++++++++++- 5 files changed, 161 insertions(+), 30 deletions(-) diff --git a/cwd-comments-admin/src/api/admin.ts b/cwd-comments-admin/src/api/admin.ts index 26dc39d..e91e3f9 100644 --- a/cwd-comments-admin/src/api/admin.ts +++ b/cwd-comments-admin/src/api/admin.ts @@ -44,6 +44,7 @@ export type CommentSettingsResponse = { adminKeySet?: boolean; requireReview?: boolean; blockedIps?: string[]; + blockedEmails?: string[]; }; export type EmailNotifySettingsResponse = { @@ -139,6 +140,7 @@ export function saveCommentSettings(data: { adminKey?: string; requireReview?: boolean; blockedIps?: string[]; + blockedEmails?: string[]; }): Promise<{ message: string }> { return put<{ message: string }>('/admin/settings/comments', data); } @@ -147,6 +149,10 @@ export function blockIp(ip: string): Promise<{ message: string }> { return post<{ message: string }>('/admin/comments/block-ip', { ip }); } +export function blockEmail(email: string): Promise<{ message: string }> { + return post<{ message: string }>('/admin/comments/block-email', { email }); +} + export function exportComments(): Promise { return get('/admin/comments/export'); } diff --git a/cwd-comments-admin/src/views/CommentsView.vue b/cwd-comments-admin/src/views/CommentsView.vue index b5792a1..9326662 100644 --- a/cwd-comments-admin/src/views/CommentsView.vue +++ b/cwd-comments-admin/src/views/CommentsView.vue @@ -36,7 +36,15 @@ />
{{ item.name }}
-
{{ item.email }}
+
+ +
{{ formatDate(item.created) }}
{{ item.ipAddress }} @@ -180,6 +188,7 @@ import { deleteComment, updateCommentStatus, blockIp, + blockEmail, } from "../api/admin"; const comments = ref([]); @@ -311,6 +320,21 @@ async function handleBlockIp(item: CommentItem) { } } +async function handleBlockEmail(item: CommentItem) { + if (!item.email) { + return; + } + if (!window.confirm(`确认将邮箱 ${item.email} 加入黑名单吗?`)) { + return; + } + try { + const res = await blockEmail(item.email); + window.alert(res.message || "已加入邮箱黑名单"); + } catch (e: any) { + error.value = e.message || "屏蔽邮箱失败"; + } +} + onMounted(() => { loadComments(); }); @@ -479,6 +503,14 @@ onMounted(() => { margin-bottom: 2px; } +.cell-email-text { + cursor: pointer; +} + +.cell-email-text:hover { + text-decoration: underline; +} + .cell-content-text { font-size: 13px; line-height: 1.5; diff --git a/cwd-comments-admin/src/views/SettingsView.vue b/cwd-comments-admin/src/views/SettingsView.vue index 1a01f1b..1c809fb 100644 --- a/cwd-comments-admin/src/views/SettingsView.vue +++ b/cwd-comments-admin/src/views/SettingsView.vue @@ -39,27 +39,9 @@

安全设置

-
- - -
-
- - -
-
+
设置后前台使用管理员邮箱评论需输入此密钥。
+
+ + +
+
+ + +
+
+ + +
+