From 00ac1ce3941b4416aef1e6b3358177dbcfaccb93 Mon Sep 17 00:00:00 2001 From: anghunk Date: Thu, 12 Feb 2026 10:11:08 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E8=87=B30.1.4=E5=B9=B6=E6=9B=B4=E6=96=B0=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=A1=86=E6=9E=B6=E9=9B=86=E6=88=90=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将主项目及所有子模块的package.json版本号从0.1.4-rc-2更新为正式版0.1.4 - 重写前端配置指南,为Vue3、Vue2和React提供清晰的模块化集成示例 - 移除旧的Vue单文件组件封装示例,推荐使用npm包直接导入的方式 --- cwd-admin/package.json | 2 +- cwd-api/package.json | 2 +- docs/guide/frontend-config.md | 111 +++++++++++++++++++++------------- docs/widget/package.json | 2 +- package.json | 2 +- 5 files changed, 74 insertions(+), 45 deletions(-) diff --git a/cwd-admin/package.json b/cwd-admin/package.json index 74f3ff7..dd43a14 100644 --- a/cwd-admin/package.json +++ b/cwd-admin/package.json @@ -1,6 +1,6 @@ { "name": "cwd-admin", - "version": "0.1.4-rc-2", + "version": "0.1.4", "type": "module", "scripts": { "dev": "vite", diff --git a/cwd-api/package.json b/cwd-api/package.json index d8db68a..e7fbf54 100644 --- a/cwd-api/package.json +++ b/cwd-api/package.json @@ -1,6 +1,6 @@ { "name": "cwd-api", - "version": "0.1.4-rc-2", + "version": "0.1.4", "scripts": { "deploy": "node scripts/index.js && wrangler deploy", "dev": "wrangler dev", diff --git a/docs/guide/frontend-config.md b/docs/guide/frontend-config.md index 7c24787..ccdb5a7 100644 --- a/docs/guide/frontend-config.md +++ b/docs/guide/frontend-config.md @@ -165,48 +165,77 @@ comments.updateConfig({ ``` -### Vue +### Vue3 -在 Vue 单文件组件里封装。 - -`CommentsWidget.vue`: +安装 `npm i cwd-widget` ```html - - - +
``` + +```js +import CWDComments from "cwd-widget"; + +onMounted(() => { + // 初始化评论组件 + const comments = new CWDComments({ + el: '#comments', + apiBaseUrl: 'https://your-api.example.com', + }); + comments.mount(); +}); +``` + +### Vue2 + +安装 `npm i cwd-widget` + +```html +
+``` + +```js +import CWDComments from "cwd-widget"; + +// 放在 mounted 钩子中初始化评论组件 +mounted() { + const comments = new CWDComments({ + el: "#comments", + apiBaseUrl: "https://your-api.example.com", + }); + comments.mount(); +}, +``` + +### React + +安装 `npm i cwd-widget` + +```js +import { useEffect, useRef } from "react"; +import CWDComments, { CWDCommentsConfig } from "cwd-widget"; + +function Comments() { + const containerRef = useRef(null); + + useEffect(() => { + if (!containerRef.current) return; + + const config: CWDCommentsConfig = { + el: containerRef.current, + apiBaseUrl: "https://your-api.example.com", + }; + + const comments = new CWDComments(config); + comments.mount(); + + return () => { + comments.unmount(); + }; + }, []); + + return
; +} + +export default Comments; +``` \ No newline at end of file diff --git a/docs/widget/package.json b/docs/widget/package.json index 64be1e7..7edb0ea 100644 --- a/docs/widget/package.json +++ b/docs/widget/package.json @@ -1,6 +1,6 @@ { "name": "cwd-widget", - "version": "0.1.4-rc-2", + "version": "0.1.4", "description": "Server-free, extremely fast and secure, plug-and-play commenting system based on Cloudflare Workers and the Global Edge Network.", "type": "module", "author": "anghunk", diff --git a/package.json b/package.json index a897daf..91ee765 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cwd", - "version": "0.1.4-rc-2", + "version": "0.1.4", "license": "Apache-2.0", "repository": { "type": "git",