File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -58,9 +58,30 @@ const teekConfig = defineTeekConfig({
5858 tryRequest : true ,
5959 tryCount : 5 ,
6060 tryIterationTime : 2000 ,
61+ siteView : true , // 是否开启首页的访问量和排名统计
62+ pageView : true , // 是否开启文章页的浏览量统计
63+ permalink : false , // 是否只统计永久链接的浏览量,如果为 false,则统计 VitePress 默认的文档目录链接
6164 } ,
6265 wordCount : true ,
6366 readingTime : true ,
67+ // // 自定义现有信息
68+ // overrideInfo: [
69+ // {
70+ // key: "lastActiveTime",
71+ // label: "活跃时间",
72+ // value: (_, currentValue) => (currentValue + "").replace("前", ""),
73+ // show: true,
74+ // },
75+ // ],
76+ // 自定义额外信息
77+ // appendInfo: [
78+ // {
79+ // key: "todayVisitCount",
80+ // label: "今日访问人数",
81+ // value: "获取中...",
82+ // show: true
83+ // },
84+ // ],
6485 } ,
6586
6687 vitePlugins : {
@@ -126,6 +147,30 @@ export default defineConfig({
126147 { } ,
127148 `typeof LA !== 'undefined' && LA.init({ id: "3LqfP8Icg0GeEvtn", ck: "3LqfP8Icg0GeEvtn", hashMode: true })` ,
128149 ] , // 51.la
150+ [
151+ "script" ,
152+ { } ,
153+ `
154+ // 重写布蒜子回调函数以获取今日访问人数
155+ window.BusuanziCallback = window.BusuanziCallback || function() {};
156+ const originalCallback = window.BusuanziCallback;
157+ window.BusuanziCallback = function(data) {
158+ if (data && data.today && data.today.SiteUv !== undefined) {
159+ // 更新今日访问人数显示
160+ setTimeout(() => {
161+ const todayVisitElements = document.querySelectorAll('[data-key="todayVisitCount"] .value');
162+ todayVisitElements.forEach(el => {
163+ if (el) el.textContent = data.today.SiteUv + ' 人';
164+ });
165+ }, 100);
166+ }
167+ // 调用原始回调函数
168+ if (typeof originalCallback === 'function') {
169+ originalCallback.apply(this, arguments);
170+ }
171+ };
172+ ` ,
173+ ] ,
129174 ] ,
130175 markdown : {
131176 // 开启行号
You can’t perform that action at this time.
0 commit comments