diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 08c9fa7..f4e96a7 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -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, diff --git a/docs/.vuepress/enhanceApp.js b/docs/.vuepress/enhanceApp.js new file mode 100644 index 0000000..3c0d4a8 --- /dev/null +++ b/docs/.vuepress/enhanceApp.js @@ -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(); + }); +};