From 94653bfac8116f806f3c136215ad72d18b8bdd4c Mon Sep 17 00:00:00 2001 From: anghunk Date: Wed, 14 Jan 2026 13:31:16 +0800 Subject: [PATCH] =?UTF-8?q?docs(config):=20=E9=87=8D=E6=9E=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E6=A1=A3=E7=BB=93=E6=9E=84=E5=B9=B6=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E5=89=8D=E7=AB=AF=E4=BD=BF=E7=94=A8=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=20-=20=E5=88=A0=E9=99=A4=20widget/CONFIG.md=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0=E7=BB=9F=E4=B8=80=E5=88=B0?= =?UTF-8?q?=20docs/guide/frontend-config.md=20-=20=E7=AE=80=E5=8C=96=20wid?= =?UTF-8?q?get/README.md=EF=BC=8C=E7=A7=BB=E9=99=A4=E8=AF=A6=E7=BB=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=A4=BA=E4=BE=8B=E5=B9=B6=E6=8C=87=E5=90=91?= =?UTF-8?q?=E5=AE=8C=E6=95=B4=E6=96=87=E6=A1=A3=E9=93=BE=E6=8E=A5=20-=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=89=8D=E7=AB=AF=E9=85=8D=E7=BD=AE=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=EF=BC=8C=E4=BC=98=E5=8C=96=E6=B3=A8=E9=87=8A=E5=B9=B6?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=86=97=E4=BD=99=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/guide/frontend-config.md | 13 ++---- widget/CONFIG.md | 78 ----------------------------------- widget/README.md | 15 +------ 3 files changed, 4 insertions(+), 102 deletions(-) delete mode 100644 widget/CONFIG.md diff --git a/docs/guide/frontend-config.md b/docs/guide/frontend-config.md index d905ef0..1195f06 100644 --- a/docs/guide/frontend-config.md +++ b/docs/guide/frontend-config.md @@ -15,16 +15,9 @@ ```html diff --git a/widget/CONFIG.md b/widget/CONFIG.md deleted file mode 100644 index 2fefd7c..0000000 --- a/widget/CONFIG.md +++ /dev/null @@ -1,78 +0,0 @@ -# CWDComments 配置参数 - -## 前端 Widget 配置 - -在初始化 `CWDComments` 实例时,可以传入以下配置参数: - -```javascript -const comments = new CWDComments({ - el: '#comments', - apiBaseUrl: 'https://your-api.example.com', - postSlug: 'my-post', - postTitle: '文章标题', - postUrl: 'https://example.com/my-post', - theme: 'light', - pageSize: 20, - avatarPrefix: 'https://gravatar.com/avatar', - adminEmail: 'admin@example.com', - adminBadge: '博主' -}); -comments.mount(); -``` - -### 参数说明 - -| 参数 | 类型 | 必填 | 默认值 | 说明 | -| -------------- | ----------------------- | ---- | ----------------------------- | ------------------------- | -| `el` | `string \| HTMLElement` | 是 | - | 挂载元素选择器或 DOM 元素 | -| `apiBaseUrl` | `string` | 是 | - | API 基础地址 | -| `postSlug` | `string` | 是 | - | 文章唯一标识符 | -| `postTitle` | `string` | 否 | - | 文章标题,用于邮件通知 | -| `postUrl` | `string` | 否 | - | 文章 URL,用于邮件通知 | -| `theme` | `'light' \| 'dark'` | 否 | `'light'` | 主题模式 | -| `pageSize` | `number` | 否 | `20` | 每页显示评论数 | -| `avatarPrefix` | `string` | 否 | `https://gravatar.com/avatar` | 头像服务前缀 | -| `adminEmail` | `string` | 否 | - | 博主邮箱,用于显示博主标识 | -| `adminBadge` | `string` | 否 | `博主` | 博主标识文字 | - -### 头像服务前缀示例 - -常用的 Gravatar 镜像服务: - -| 服务 | 前缀地址 | -| --------------- | -------------------------------- | -| Gravatar 官方 | `https://gravatar.com/avatar` | -| Cravatar (国内) | `https://gravatar.com/avatar` | -| 自定义镜像 | `https://your-mirror.com/avatar` | - -## 后端环境变量 - -在 Cloudflare Workers 中配置以下环境变量: - -| 变量名 | 说明 | 必填 | -| ------------------- | ------------------------------- | ---- | -| `ADMIN_NAME` | 管理员用户名 | 是 | -| `ADMIN_PASSWORD` | 管理员密码 | 是 | -| `ALLOW_ORIGIN` | CORS 白名单(逗号分隔多个域名) | 是 | -| `RESEND_API_KEY` | Resend 邮件服务 API 密钥 | 否 | -| `RESEND_FROM_EMAIL` | 发件邮箱地址 | 否 | -| `EMAIL_ADDRESS` | 站长接收通知的邮箱 | 否 | - -## 实例方法 - -| 方法 | 说明 | -| ---------------------- | ------------------------------ | -| `mount()` | 挂载组件到 DOM | -| `unmount()` | 卸载组件 | -| `updateConfig(config)` | 更新配置(支持动态切换主题等) | -| `getConfig()` | 获取当前配置 | - -### 示例 - -```javascript -// 动态切换主题 -comments.updateConfig({ theme: 'dark' }); - -// 切换文章 -comments.updateConfig({ postSlug: 'another-post' }); -``` diff --git a/widget/README.md b/widget/README.md index 2f79efc..adcd5b9 100644 --- a/widget/README.md +++ b/widget/README.md @@ -2,17 +2,4 @@ ## 使用方法 -```html - -
- - - - -``` \ No newline at end of file +文档:[https://cwd-comments.zishu.me/guide/frontend-config.html](https://cwd-comments.zishu.me/guide/frontend-config.html)