import { onMounted } from "vue" ; import { useRouter } from "vue-router" ; declare const _hmt ; declare global { interface Window { _hmt ? : typeof _hmt ; } } export const useBaiduTongji = ( id ) : void => { const baScript = document . createElement ( "script" ) ; baScript . src = `https://hm.baidu.com/hm.js?${ id }` ; baScript . async = true ; if ( ! document . head . contains ( baScript ) ) document . head . appendChild ( baScript ) ; window . _hmt = window . _hmt || [ ] ; onMounted ( ( ) => { const router = useRouter ( ) ; router . afterEach ( ( to ) => { _hmt . push ( [ "_trackPageview" , to . fullPath ] ) ; } ) ; } ) ; } ;