diff --git a/src/main.js b/src/main.js index e377af7..34530f4 100644 --- a/src/main.js +++ b/src/main.js @@ -99,3 +99,12 @@ new Vue({ store, render: h => h(App) }) + +var _hmt = _hmt || []; +window._hmt = _hmt; +(function() { + var hm = document.createElement("script"); + hm.src = "https://hm.baidu.com/hm.js?8611b8753c9d6bb71fd882dc61e4adf2"; + var s = document.getElementsByTagName("script")[0]; + s.parentNode.insertBefore(hm, s); +})(); diff --git a/src/permission.js b/src/permission.js index 1055d6a..b2d28bd 100644 --- a/src/permission.js +++ b/src/permission.js @@ -12,6 +12,11 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] router.beforeEach((to, from, next) => { NProgress.start() + if (window._hmt) { + if (to.path) { + window._hmt.push(['_trackPageview', '/#' + to.fullPath]); + } + } if (getToken()) { to.meta.title && store.dispatch('settings/setTitle', to.meta.title) /* has token*/