mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
added baidu tongji
This commit is contained in:
12
frontend/src/admin/baidu.ts
Normal file
12
frontend/src/admin/baidu.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
// baidu tongji
|
||||
export const initBaiduTonji = () => {
|
||||
if (localStorage.getItem('useStats') !== '0') {
|
||||
window._hmt = window._hmt || [];
|
||||
(function () {
|
||||
const hm = document.createElement('script');
|
||||
hm.src = 'https://hm.baidu.com/hm.js?c35e3a563a06caee2524902c81975add';
|
||||
const s = document.getElementsByTagName('script')[0];
|
||||
s?.parentNode?.insertBefore(hm, s);
|
||||
})();
|
||||
}
|
||||
};
|
||||
1
frontend/src/interfaces/global.d.ts
vendored
1
frontend/src/interfaces/global.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
interface Window {
|
||||
initCanvas?: Function;
|
||||
resetCanvas?: Function;
|
||||
_hmt?: Array;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,13 @@ import 'normalize.css/normalize.css';
|
||||
import 'font-awesome/css/font-awesome.min.css';
|
||||
import 'element-plus/lib/theme-chalk/index.css';
|
||||
import '@/styles/index.scss';
|
||||
import {initBaiduTonji} from '@/admin/baidu';
|
||||
|
||||
library.add(fab, far, fas);
|
||||
|
||||
// baidu tongji
|
||||
initBaiduTonji();
|
||||
|
||||
createApp(App)
|
||||
.use(store)
|
||||
.use(router)
|
||||
|
||||
@@ -10,6 +10,7 @@ import user from '@/router/user';
|
||||
import tag from '@/router/tag';
|
||||
import token from '@/router/token';
|
||||
import {initRouterAuth} from '@/router/auth';
|
||||
import {sendPv} from '@/utils/admin';
|
||||
|
||||
export const routes: Array<RouteRecordRaw> = [
|
||||
...login,
|
||||
@@ -48,6 +49,12 @@ const router = createRouter({
|
||||
routes,
|
||||
});
|
||||
|
||||
router.afterEach(async (to, from, next) => {
|
||||
if (to.path) {
|
||||
sendPv(to.path);
|
||||
}
|
||||
});
|
||||
|
||||
initRouterAuth(router);
|
||||
|
||||
export default router;
|
||||
|
||||
11
frontend/src/utils/admin.ts
Normal file
11
frontend/src/utils/admin.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export const sendPv = (page: any) => {
|
||||
if (localStorage.getItem('useStats') !== '0') {
|
||||
window._hmt?.push(['_trackPageview', page]);
|
||||
}
|
||||
};
|
||||
|
||||
export const sendEv = (category: string, eventName: string, optLabel: string, optValue: string) => {
|
||||
if (localStorage.getItem('useStats') !== '0') {
|
||||
window._hmt?.push(['_trackEvent', category, eventName, optLabel, optValue]);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user