From 05b9425245455a474a9949321e8f35cb81be909c Mon Sep 17 00:00:00 2001 From: anghunk Date: Tue, 20 Jan 2026 14:58:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E6=B7=BB=E5=8A=A0=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E7=99=BD=E5=90=8D=E5=8D=95=E5=8A=9F=E8=83=BD=E5=B9=B6?= =?UTF-8?q?=E6=94=AF=E6=8C=81Artalk=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在评论设置中添加域名白名单配置,限制组件调用 - 支持从Artalk系统导入评论数据 - 完善Twikoo和Artalk数据结构的映射处理 - 在组件端实现域名白名单检查逻辑 --- cwd-comments-admin/src/api/admin.ts | 2 + cwd-comments-admin/src/views/DataView.vue | 17 ++++-- cwd-comments-admin/src/views/SettingsView.vue | 12 +++++ .../src/api/admin/importComments.ts | 53 ++++++++++++++++--- cwd-comments-api/src/index.ts | 27 ++++++++-- widget/src/core/CWDComments.js | 23 ++++++++ 6 files changed, 119 insertions(+), 15 deletions(-) diff --git a/cwd-comments-admin/src/api/admin.ts b/cwd-comments-admin/src/api/admin.ts index 1bc8389..315a0a7 100644 --- a/cwd-comments-admin/src/api/admin.ts +++ b/cwd-comments-admin/src/api/admin.ts @@ -39,6 +39,7 @@ export type CommentSettingsResponse = { adminBadge: string | null; avatarPrefix: string | null; adminEnabled: boolean; + allowedDomains?: string[]; }; export type EmailNotifySettingsResponse = { @@ -122,6 +123,7 @@ export function saveCommentSettings(data: { adminBadge?: string; avatarPrefix?: string; adminEnabled?: boolean; + allowedDomains?: string[]; }): Promise<{ message: string }> { return put<{ message: string }>('/admin/settings/comments', data); } diff --git a/cwd-comments-admin/src/views/DataView.vue b/cwd-comments-admin/src/views/DataView.vue index a2a834c..06cfdec 100644 --- a/cwd-comments-admin/src/views/DataView.vue +++ b/cwd-comments-admin/src/views/DataView.vue @@ -27,7 +27,8 @@
@@ -188,8 +189,8 @@ async function handleFileChange(event: Event) { // 检测前缀逻辑 let missingCount = 0; for (const item of comments) { - // 优先检查 Twikoo 字段 href,其次检查 CWD 字段 post_slug - const url = item.href || item.post_slug; + // 优先检查 Twikoo 字段 href,其次 Artalk 字段 page_key,最后 CWD 字段 post_slug + const url = item.href || item.page_key || item.post_slug; if (url && typeof url === "string") { if (!url.startsWith("http://") && !url.startsWith("https://")) { missingCount++; @@ -250,6 +251,16 @@ async function confirmPrefix() { } } + // Artalk + if (newItem.page_key && typeof newItem.page_key === "string") { + if ( + !newItem.page_key.startsWith("http://") && + !newItem.page_key.startsWith("https://") + ) { + newItem.page_key = joinUrl(prefix, newItem.page_key); + } + } + // CWD if (newItem.post_slug && typeof newItem.post_slug === "string") { if ( diff --git a/cwd-comments-admin/src/views/SettingsView.vue b/cwd-comments-admin/src/views/SettingsView.vue index 5d9fdc8..babec69 100644 --- a/cwd-comments-admin/src/views/SettingsView.vue +++ b/cwd-comments-admin/src/views/SettingsView.vue @@ -31,6 +31,15 @@ +
+ + +