feat(analytics): 添加今日/本周/本月访问量统计功能

- 在访问统计概览中新增今日、本周、本月访问量数据展示
- 更新API文档和前端界面以支持新的统计维度
- 优化图表显示样式,减小数据点大小
- 调整统计网格布局适配移动端
This commit is contained in:
anghunk
2026-01-22 09:52:44 +08:00
parent 4550b3c972
commit 5164f2c490
6 changed files with 302 additions and 9 deletions

View File

@@ -86,6 +86,9 @@ export type CommentStatsResponse = {
export type VisitOverviewResponse = {
totalPv: number;
totalPages: number;
todayPv: number;
weekPv: number;
monthPv: number;
last30Days?: {
date: string;
total: number;

View File

@@ -31,6 +31,18 @@
<div class="stats-label">全站总访问量</div>
<div class="stats-value">{{ overview.totalPv }}</div>
</div>
<div class="stats-item">
<div class="stats-label">今日访问量</div>
<div class="stats-value">{{ overview.todayPv }}</div>
</div>
<div class="stats-item">
<div class="stats-label">本周访问量</div>
<div class="stats-value">{{ overview.weekPv }}</div>
</div>
<div class="stats-item">
<div class="stats-label">本月访问量</div>
<div class="stats-value">{{ overview.monthPv }}</div>
</div>
<div class="stats-item">
<div class="stats-label">有访问记录的页面数</div>
<div class="stats-value">{{ overview.totalPages }}</div>
@@ -127,6 +139,9 @@ const error = ref("");
const overview = ref<VisitOverviewResponse>({
totalPv: 0,
totalPages: 0,
todayPv: 0,
weekPv: 0,
monthPv: 0,
last30Days: [],
});
const items = ref<VisitPageItem[]>([]);
@@ -226,6 +241,9 @@ async function loadData() {
overview.value = {
totalPv: overviewRes.totalPv,
totalPages: overviewRes.totalPages,
todayPv: overviewRes.todayPv ?? 0,
weekPv: overviewRes.weekPv ?? 0,
monthPv: overviewRes.monthPv ?? 0,
last30Days: Array.isArray(overviewRes.last30Days)
? overviewRes.last30Days
: [],
@@ -337,7 +355,7 @@ function renderChart() {
color: "#0ea5e9",
},
symbol: "circle",
symbolSize: 6,
symbolSize: 3,
},
],
};
@@ -441,7 +459,7 @@ watch(
.stats-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 12px;
}
@@ -594,4 +612,10 @@ watch(
background-color: #0969da;
color: #ffffff;
}
@media (max-width: 768px) {
.stats-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
</style>

View File

@@ -224,7 +224,7 @@ function renderChart() {
color: "#0ea5e9",
},
symbol: "circle",
symbolSize: 6,
symbolSize: 3,
},
],
};