在config.js中添加百度统计代码并创建enhanceApp.js文件
This commit is contained in:
parent
bcdb6efd8c
commit
4f7031ed49
@ -3,6 +3,20 @@ module.exports = {
|
||||
description: "一个PHP程序在做FreeSWITCH相关的应用开发时积累的技术文档",
|
||||
dest: "dist",
|
||||
plugins: ["@vuepress/back-to-top"],
|
||||
head: [
|
||||
// 百度统计代码
|
||||
[
|
||||
"script",
|
||||
{},
|
||||
`var _hmt = _hmt || [];
|
||||
(function() {
|
||||
var hm = document.createElement("script");
|
||||
hm.src = "https://hm.baidu.com/hm.js?1eb7f71a234c2320b396cbc51c1f047e";
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();`,
|
||||
],
|
||||
],
|
||||
themeConfig: {
|
||||
lastUpdated: "上次更新",
|
||||
displayAllHeaders: false,
|
||||
|
14
docs/.vuepress/enhanceApp.js
Normal file
14
docs/.vuepress/enhanceApp.js
Normal file
@ -0,0 +1,14 @@
|
||||
export default ({ router }) => {
|
||||
// 路由切换事件处理
|
||||
router.beforeEach((to, from, next) => {
|
||||
// console.log("切换路由", to.fullPath, from.fullPath);
|
||||
//触发百度的pv统计
|
||||
if (typeof _hmt != "undefined") {
|
||||
if (to.path) {
|
||||
_hmt.push(["_trackPageview", to.fullPath]);
|
||||
// console.log("上报百度统计", to.fullPath);
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user