Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CI / CI OK (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Deploy Website on push / Rerun on failure (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
31 lines
559 B
TypeScript
31 lines
559 B
TypeScript
import type { Router } from 'vue-router';
|
||
|
||
declare global {
|
||
interface Window {
|
||
_hmt: any[];
|
||
}
|
||
}
|
||
|
||
const HM_ID = import.meta.env.VITE_APP_BAIDU_CODE;
|
||
|
||
/**
|
||
* 设置百度统计
|
||
* @param router
|
||
*/
|
||
function setupBaiduTongJi(router: Router) {
|
||
// 如果没有配置百度统计的 ID,则不进行设置
|
||
if (!HM_ID) {
|
||
return;
|
||
}
|
||
|
||
// _hmt:用于 router push
|
||
window._hmt = window._hmt || [];
|
||
|
||
router.afterEach((to) => {
|
||
// 添加到 _hmt 中
|
||
window._hmt.push(['_trackPageview', to.fullPath]);
|
||
});
|
||
}
|
||
|
||
export { setupBaiduTongJi };
|