Files
cwd/docs/.vitepress/components/footerDoc.vue
anghunk f4e6bf45d3 fix(文档): 修复评论组件ID并统一主页样式
- 将评论组件ID从'zcomments'改为更通用的'comments'
- 为主页评论区域添加样式约束
- 统一主页标题字符串引号格式
2026-01-20 10:43:34 +08:00

39 lines
928 B
Vue

<template>
<div id="comments" ref="commentsRoot"></div>
</template>
<script setup>
import { onMounted, ref } from "vue";
const commentsRoot = ref(null);
onMounted(async () => {
if (!commentsRoot.value || typeof window === "undefined") return;
const apiBaseUrl = "https://cwd-comments-api.anghunk.workers.dev";
if (!apiBaseUrl) return;
if (!window.CWDComments) {
await new Promise((resolve, reject) => {
const script = document.createElement("script");
script.src = "https://cwd-comments.zishu.me/cwd-comments.js";
script.async = true;
script.onload = () => resolve();
script.onerror = (e) => reject(e);
document.head.appendChild(script);
}).catch(() => {});
}
if (!window.CWDComments) return;
const comments = new window.CWDComments({
el: commentsRoot.value,
apiBaseUrl,
postSlug: window.location.pathname,
});
comments.mount();
});
</script>