Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add comment and remove debug console.log #1083

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading