const BAIDU_HM_ID = '1cafaa94863718681ae361aa0b209ce7' export default defineNuxtPlugin(() => { window._hmt = window._hmt || [] useHead({ script: [ { key: 'baidu-hm', src: `https://hm.baidu.com/hm.js?${BAIDU_HM_ID}`, async: true, }, ], }) const router = useRouter() let lastFullPath = router.currentRoute.value.fullPath router.afterEach((to, _from, failure) => { if (failure || to.fullPath === lastFullPath) return lastFullPath = to.fullPath window._hmt.push(['_trackPageview', to.fullPath]) }) })