Skip to content

Commit

Permalink
add comment and remove debug console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
mobeicanyue committed Apr 1, 2024
1 parent 861c2ca commit 12615c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ web_analytics: # 网页访问统计
google:
measurement_id:

# Umami Analyticssrc 和 data-website-id 是必填项,其他可选
# Umami Analytics, src and data-website-id are required, others are optional
# Umami Analytics 仅支持自部署。src 和 data-website-id 是必填项,其他可选
# Umami Analytics, only Self-host support, src and data-website-id are required, others are optional
umami:
# umami js 文件地址,需要在 umami 后台创建站点后获取
# umami js file url, get after create website in umami
Expand Down
6 changes: 4 additions & 2 deletions source/js/umami-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const request_header = {
},
};

// 获取站点统计数据
async function siteStats() {
try {
const response = await fetch(`${request_url}?${params}`, request_header);
Expand Down Expand Up @@ -68,14 +69,13 @@ async function siteStats() {
}
}

// 获取页面浏览量
async function pageStats(path) {
try {
const response = await fetch(`${request_url}?${params}&url=${path}`, request_header);
const data = await response.json();
const pageViews = data.pageviews.value;

console.log(data)

let viewCtn = document.querySelector("#umami-page-views-container");
if (viewCtn) {
let ele = document.querySelector("#umami-page-views");
Expand All @@ -92,7 +92,9 @@ async function pageStats(path) {

siteStats();

// 获取页面容器
let viewCtn = document.querySelector("#umami-page-views-container");
// 如果页面容器存在,则获取页面浏览量
if (viewCtn) {
let path = window.location.pathname;
let target = decodeURI(path.replace(/\/*(index.html)?$/, "/"));
Expand Down

0 comments on commit 12615c6

Please sign in to comment.