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

@@ -23,7 +23,7 @@ export class CWDComments {
* 以下字段由组件自动推导或从后端读取,无需通过 config 传入:
* - postSlugwindow.location.origin + window.location.pathname
* - postTitledocument.title 或 postSlug
* - postUrlwindow.location.href
* - postUrlwindow.location.origin + window.location.pathname
* - avatarPrefix/adminEmail/adminBadge通过 /api/config/comments 接口获取
*/
constructor(config) {
@@ -35,7 +35,7 @@ export class CWDComments {
this.config.postTitle = document.title || this.config.postSlug;
}
if (typeof window !== 'undefined') {
this.config.postUrl = window.location.href;
this.config.postUrl = window.location.origin + window.location.pathname;
}
this.hostElement = this._resolveElement(config.el);
this.shadowRoot = null;
@@ -522,7 +522,7 @@ export class CWDComments {
this.config.postTitle = document.title || this.config.postSlug;
}
if (typeof window !== 'undefined') {
this.config.postUrl = window.location.href;
this.config.postUrl = window.location.origin + window.location.pathname;
}
// 更新主题