feat(analytics): 添加点赞统计功能并修复页面URL处理

- 在admin.ts中添加LikeStats相关类型定义和API接口
- 在AnalyticsVisitView.vue中添加点赞排行榜展示
- 修改CWDComments.js中postUrl的生成逻辑,使用origin+pathname代替href
This commit is contained in:
anghunk
2026-01-22 18:47:43 +08:00
parent 26e1ab5c61
commit d42fe6629f
3 changed files with 117 additions and 9 deletions

View File

@@ -111,6 +111,17 @@ export type DomainListResponse = {
domains: string[];
};
export type LikeStatsItem = {
pageSlug: string;
pageTitle: string | null;
pageUrl: string | null;
likes: number;
};
export type LikeStatsResponse = {
items: LikeStatsItem[];
};
export async function loginAdmin(name: string, password: string): Promise<string> {
const res = await post<AdminLoginResponse>('/admin/login', { name, password });
const key = res.data.key;
@@ -273,3 +284,7 @@ export function fetchVisitPages(domain?: string, order?: 'pv' | 'latest'): Promi
export function fetchDomainList(): Promise<DomainListResponse> {
return get<DomainListResponse>('/admin/stats/domains');
}
export function fetchLikeStats(): Promise<LikeStatsResponse> {
return get<LikeStatsResponse>('/admin/likes/stats');
}