From e0be92b1fef66448c25ff53d25cc7df82fe9db7c Mon Sep 17 00:00:00 2001 From: anghunk Date: Thu, 22 Jan 2026 22:26:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=AF=84=E8=AE=BA):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=BC=80=E5=85=B3=E7=AE=A1=E7=90=86=E5=8F=8A?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E7=82=B9=E8=B5=9E=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在管理后台添加功能开关页面,支持控制评论点赞和文章点赞功能的开启/关闭 - 优化评论点赞功能,支持取消点赞和本地存储点赞状态 - 更新点赞UI样式,提升用户体验 - 添加相关API接口和文档说明 --- cwd-admin/src/api/admin.ts | 16 ++ cwd-admin/src/router/index.ts | 6 + cwd-admin/src/views/FeatureSettingsView.vue | 262 ++++++++++++++++++++ cwd-admin/src/views/LayoutView.vue | 12 + cwd-api/src/api/admin/featureSettings.ts | 38 +++ cwd-api/src/index.ts | 10 +- cwd-api/src/utils/featureSettings.ts | 92 +++++++ docs/api/public.md | 137 +++++++++- docs/widget/src/components/CommentItem.js | 194 +++++++++++---- docs/widget/src/components/CommentList.js | 2 + docs/widget/src/components/Component.js | 35 ++- docs/widget/src/core/CWDComments.js | 64 ++--- docs/widget/src/core/api.js | 5 +- docs/widget/src/core/store.js | 11 +- docs/widget/src/styles/main.css | 42 ++-- 15 files changed, 806 insertions(+), 120 deletions(-) create mode 100644 cwd-admin/src/views/FeatureSettingsView.vue create mode 100644 cwd-api/src/api/admin/featureSettings.ts create mode 100644 cwd-api/src/utils/featureSettings.ts diff --git a/cwd-admin/src/api/admin.ts b/cwd-admin/src/api/admin.ts index 881ad3e..d037d74 100644 --- a/cwd-admin/src/api/admin.ts +++ b/cwd-admin/src/api/admin.ts @@ -123,6 +123,11 @@ export type LikeStatsResponse = { items: LikeStatsItem[]; }; +export type FeatureSettingsResponse = { + enableCommentLike: boolean; + enableArticleLike: boolean; +}; + export async function loginAdmin(name: string, password: string): Promise { const res = await post('/admin/login', { name, password }); const key = res.data.key; @@ -289,3 +294,14 @@ export function fetchDomainList(): Promise { export function fetchLikeStats(): Promise { return get('/admin/likes/stats'); } + +export function fetchFeatureSettings(): Promise { + return get('/admin/settings/features'); +} + +export function saveFeatureSettings(data: { + enableCommentLike?: boolean; + enableArticleLike?: boolean; +}): Promise<{ message: string }> { + return put<{ message: string }>('/admin/settings/features', data); +} diff --git a/cwd-admin/src/router/index.ts b/cwd-admin/src/router/index.ts index 155a8d1..3814ffe 100644 --- a/cwd-admin/src/router/index.ts +++ b/cwd-admin/src/router/index.ts @@ -3,6 +3,7 @@ import LoginView from '../views/LoginView.vue'; import LayoutView from '../views/LayoutView.vue'; import CommentsView from '../views/CommentsView.vue'; import SettingsView from '../views/SettingsView.vue'; +import FeatureSettingsView from '../views/FeatureSettingsView.vue'; import DataView from '../views/DataView.vue'; import StatsView from '../views/StatsView.vue'; import AnalyticsVisitView from '../views/AnalyticsVisitView.vue'; @@ -41,6 +42,11 @@ const routes: RouteRecordRaw[] = [ name: 'settings', component: SettingsView }, + { + path: 'settings/features', + name: 'feature-settings', + component: FeatureSettingsView + }, { path: 'data', name: 'data', diff --git a/cwd-admin/src/views/FeatureSettingsView.vue b/cwd-admin/src/views/FeatureSettingsView.vue new file mode 100644 index 0000000..54bf836 --- /dev/null +++ b/cwd-admin/src/views/FeatureSettingsView.vue @@ -0,0 +1,262 @@ + + + + + diff --git a/cwd-admin/src/views/LayoutView.vue b/cwd-admin/src/views/LayoutView.vue index 31ce60a..b2ae561 100644 --- a/cwd-admin/src/views/LayoutView.vue +++ b/cwd-admin/src/views/LayoutView.vue @@ -97,6 +97,13 @@ > 网站设置 +