Files
cwd/docs/widget/index.html
anghunk 6d2e1659d0 feat(widget): 添加 postSlug 配置以支持多语言/多路径评论聚合
- 在配置面板和核心逻辑中新增 postSlug 字段,允许自定义评论标识符
- 更新前端配置文档,说明 postSlug 的用途和默认行为
- 当未配置 postSlug 时,默认仍使用 window.location.pathname
2026-02-09 17:23:21 +08:00

174 lines
3.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CWD - 开发预览</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: #f5f5f5;
padding: 40px 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
padding: 40px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
h1 {
margin-bottom: 20px;
color: #333;
font-size: 1.4rem;
}
.config-panel {
background: #f8f9fa;
padding: 20px;
border-radius: 6px;
margin-bottom: 30px;
}
.config-panel h3 {
margin-bottom: 15px;
font-size: 16px;
}
.config-item {
margin-bottom: 12px;
}
.config-item label {
display: block;
margin-bottom: 4px;
font-size: 13px;
color: #666;
}
.config-item input,
.config-item select {
width: 100%;
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 14px;
}
.config-actions {
display: flex;
gap: 10px;
margin-top: 15px;
}
.btn {
padding: 8px 16px;
border: none;
border-radius: 4px;
font-size: 14px;
cursor: pointer;
transition: background 0.2s;
}
.btn-primary {
background: #0969da;
color: white;
}
.btn-primary:hover {
background: #0864ca;
}
.btn-secondary {
background: #f0f0f0;
color: #333;
}
.btn-secondary:hover {
background: #e0e0e0;
}
.divider {
height: 1px;
background: #e0e0e0;
margin: 30px 0;
}
.demo-post {
margin-bottom: 40px;
}
.demo-post h2 {
font-size: 18px;
margin-bottom: 10px;
}
.demo-post p {
color: #666;
line-height: 1.6;
}
</style>
</head>
<body>
<div class="container">
<h1>CWD - 开发预览</h1>
<div class="config-panel">
<h3>配置面板</h3>
<div class="config-item">
<label>API 地址</label>
<input type="text" id="apiBaseUrl" value="http://localhost:8788" />
</div>
<div class="config-item">
<label>Site ID可选用于隔离不同站点/环境的评论)</label>
<input type="text" id="siteId" placeholder="例如blog、dev、zishu.me" />
</div>
<div class="config-item">
<label>自定义 postSlug可选留空则使用当前路径</label>
<input type="text" id="postSlug" placeholder="例如post-unique-id-001用于多语言/多路径聚合" />
</div>
<div class="config-item">
<label>主题</label>
<select id="theme">
<option value="light">浅色</option>
<option value="dark">深色</option>
</select>
</div>
<div class="config-actions">
<button class="btn btn-primary" onclick="initWidget()">保存</button>
<button class="btn btn-secondary" onclick="toggleTheme()">切换主题</button>
</div>
</div>
<div class="divider"></div>
<div class="demo-post">
<h2>这是一篇示例文章</h2>
<p>
这是一个演示 CWD Comments Widget 的示例页面。你可以在上方的配置面板中修改 API 地址和主题,
然后点击"应用配置"按钮重新加载评论组件。
</p>
</div>
<div class="divider"></div>
<!-- 评论组件容器 -->
<div id="comments"></div>
</div>
<script type="module" src="/src/dev.js"></script>
</body>
</html>