提交 | 用户 | 时间
|
820397
|
1 |
import router from '@/router' |
H |
2 |
|
|
3 |
// 用于 router push |
|
4 |
window._hmt = window._hmt || [] |
|
5 |
// HM_ID |
|
6 |
const HM_ID = import.meta.env.VITE_APP_BAIDU_CODE |
|
7 |
;(function () { |
|
8 |
// 有值的时候,才开启 |
|
9 |
if (!HM_ID) { |
|
10 |
return |
|
11 |
} |
|
12 |
const hm = document.createElement('script') |
|
13 |
hm.src = 'https://hm.baidu.com/hm.js?' + HM_ID |
|
14 |
const s = document.getElementsByTagName('script')[0] |
|
15 |
s.parentNode.insertBefore(hm, s) |
|
16 |
})() |
|
17 |
|
|
18 |
router.afterEach(function (to) { |
|
19 |
if (!HM_ID) { |
|
20 |
return |
|
21 |
} |
|
22 |
_hmt.push(['_trackPageview', to.fullPath]) |
|
23 |
}) |