Files
cwd/docs/widget/index.html
anghunk 2453929455 feat(widget): 支持通过 siteId 隔离不同站点的评论数据
- 在配置界面添加 siteId 输入项,用于区分不同站点/环境的评论
- 更新 API 客户端,将 postSlug 参数改为 postUrl 以保持一致性
- 在开发配置中默认添加 siteId 字段,并同步到存储和初始化逻辑
2026-02-09 14:15:16 +08:00

169 lines
3.4 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;
}
.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>主题</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>