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",