You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
547 B

  1. // Baidu 统计 integration
  2. import router from './router'
  3. window._hmt = window._hmt || []; // 用于 router push
  4. const HM_ID = process.env.VUE_APP_BAIDU_CODE || ''; // 有值的时候,才开启
  5. (function() {
  6. if (!HM_ID) {
  7. return;
  8. }
  9. const hm = document.createElement("script")
  10. hm.src = "https://hm.baidu.com/hm.js?" + HM_ID
  11. const s = document.getElementsByTagName("script")[0]
  12. s.parentNode.insertBefore(hm, s)
  13. })()
  14. router.afterEach(function (to) {
  15. if (!HM_ID) {
  16. return;
  17. }
  18. _hmt.push(['_trackPageview', to.fullPath])
  19. })