From 4f7031ed49102db5a3e270677ac8cd3edd018448 Mon Sep 17 00:00:00 2001 From: Aaron Chen Date: Fri, 7 Jul 2023 11:23:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8config.js=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=99=BE=E5=BA=A6=E7=BB=9F=E8=AE=A1=E4=BB=A3=E7=A0=81=E5=B9=B6?= =?UTF-8?q?=E5=88=9B=E5=BB=BAenhanceApp.js=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vuepress/config.js | 14 ++++++++++++++ docs/.vuepress/enhanceApp.js | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 docs/.vuepress/enhanceApp.js 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(); + }); +};