Files
cwd/docs/widget/index.html
anghunk e2db5daecb feat(widget): 添加页面访问量显示功能
- 新增公开 API GET /api/analytics/pv 获取页面访问量
- 前端组件初始化时自动填充 #cwd-page-pv 容器
- 支持数字格式化(如 1.2k、1.5M)
- 将版本号更新至 0.1.8
2026-03-16 13:57:57 +08:00

175 lines
3.7 KiB
HTML
Raw Permalink 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>
<div id="cwd-page-pv">0</div>
<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>