fix(widget): 修复页面访问量获取失败的问题
- 前端 trackVisit 现在传递 siteId 参数 - 后端 getPagePv 查询时处理 site_id 为空或 NULL 的情况
This commit is contained in:
@@ -122,16 +122,20 @@ export function createApiClient(config) {
|
||||
|
||||
async function trackVisit() {
|
||||
try {
|
||||
const body = {
|
||||
postSlug: config.postUrl || config.postSlug,
|
||||
postTitle: config.postTitle,
|
||||
postUrl: config.postUrl
|
||||
};
|
||||
if (config.siteId) {
|
||||
body.siteId = config.siteId;
|
||||
}
|
||||
await fetch(`${baseUrl}/api/analytics/visit`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
postSlug: config.postUrl || config.postSlug,
|
||||
postTitle: config.postTitle,
|
||||
postUrl: config.postUrl
|
||||
})
|
||||
body: JSON.stringify(body)
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user