From 2bbebe8b14f9538d19663129324a8913d041caa8 Mon Sep 17 00:00:00 2001 From: chengpeiquan Date: Mon, 11 Jan 2021 11:36:52 +0800 Subject: [PATCH 1/6] =?UTF-8?q?fix:=20Vue=203.0=20=E8=B7=AF=E7=94=B1mode?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- dist/modules/getRouterMode.d.ts | 2 ++ dist/vue-baidu-analytics.js | 21 ++++++++++++++++++--- dist/vue-baidu-analytics.js.map | 2 +- dist/vue-baidu-analytics.min.js | 4 ++-- dist/vue-baidu-analytics.min.js.map | 2 +- package.json | 2 +- src/main.ts | 10 +++++++++- src/modules/getRouterMode.ts | 26 ++++++++++++++++++++++++++ 9 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 dist/modules/getRouterMode.d.ts create mode 100644 src/modules/getRouterMode.ts diff --git a/README.md b/README.md index c8216e9..50bed15 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ npm install vue-baidu-analytics --save-dev 参数|是否必填|参数类型|参数说明 :-:|:-:|:-:|- router|是|object|Vue Router,本插件基于路由使用 -siteIdList|是|object Array|百度统计的站点id列表,item为站点id
只有一个站点需要上报就保留一个item即可 +siteIdList|是|string[]|百度统计的站点id列表,item为站点id
只有一个站点需要上报就保留一个item即可 isDebug|否|boolean|是否开启debug模式,默认 `false`
开启后会在控制台打印上报信息,**上线前记得关闭** ## 使用 diff --git a/dist/modules/getRouterMode.d.ts b/dist/modules/getRouterMode.d.ts new file mode 100644 index 0000000..d7a099f --- /dev/null +++ b/dist/modules/getRouterMode.d.ts @@ -0,0 +1,2 @@ +declare const getRouterMode: (vueVersion: number, router: any) => string; +export default getRouterMode; diff --git a/dist/vue-baidu-analytics.js b/dist/vue-baidu-analytics.js index 207c845..7b4396b 100644 --- a/dist/vue-baidu-analytics.js +++ b/dist/vue-baidu-analytics.js @@ -1,12 +1,12 @@ /** * name: vue-baidu-analytics - * version: v2.0.1 + * version: v2.0.2 * author: chengpeiquan */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.baiduAnalytics = factory()); + (global = global || self, global.baiduAnalytics = factory()); }(this, (function () { 'use strict'; var BAIDU = (function () { @@ -104,6 +104,20 @@ return version; }; + var getRouterMode = function (vueVersion, router) { + var mode = 'history'; + if (vueVersion === 2) { + mode = router.mode; + } + if (vueVersion === 3) { + var BASE = router.options.history.base || ''; + if (BASE.includes('#')) { + mode = 'hash'; + } + } + return mode; + }; + function install(Vue, _a) { var router = _a.router, siteIdList = _a.siteIdList, _b = _a.isDebug, isDebug = _b === void 0 ? false : _b; if (typeof document === 'undefined' || typeof window === 'undefined') { @@ -127,9 +141,10 @@ pushBAIDU.init(); } router.afterEach(function (to) { + var ROUTER_MODE = getRouterMode(VUE_VERSION, router); var PAGE_PATH_DIR_COUNT = window.location.pathname.split('/').length; var PAGE_PATH = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/'); - var PAGE_URL = router.mode === 'hash' ? PAGE_PATH + "/#" + to.fullPath : "" + PAGE_PATH + to.fullPath; + var PAGE_URL = ROUTER_MODE === 'hash' ? PAGE_PATH + "/#" + to.fullPath : "" + PAGE_PATH + to.fullPath; pushBAIDU.pv(PAGE_URL); }); } diff --git a/dist/vue-baidu-analytics.js.map b/dist/vue-baidu-analytics.js.map index e3222a5..a9b4c82 100644 --- a/dist/vue-baidu-analytics.js.map +++ b/dist/vue-baidu-analytics.js.map @@ -1 +1 @@ -{"version":3,"file":"vue-baidu-analytics.js","sources":["../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/modules/getVueVersion.ts","../src/main.ts"],"sourcesContent":["/** \r\n * 定义基础配置\r\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\r\n */\r\nclass BAIDU {\r\n siteId: string;\r\n isDebug: boolean;\r\n\r\n constructor (siteId: string = '', isDebug: boolean = false) {\r\n this.siteId = siteId;\r\n this.isDebug = isDebug;\r\n }\r\n\r\n /** \r\n * 初始化\r\n */\r\n init () {\r\n window._hmt = window._hmt ? window._hmt : [];\r\n const SCRIPT = document.createElement('script');\r\n SCRIPT['async'] = true;\r\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`;\r\n document.querySelector('head').appendChild(SCRIPT);\r\n\r\n if ( this.isDebug ) {\r\n console.log(`[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`);\r\n }\r\n }\r\n\r\n /** \r\n * 设置要响应的站点\r\n */\r\n setAccount () {\r\n window._hmt.push(['_setAccount', this.siteId]);\r\n }\r\n\r\n /** \r\n * 提交PV、UV\r\n */\r\n trackPageview (pageUrl: string) {\r\n // 如果页面链接没传或者无效链接,则默认为根域名\r\n if ( !pageUrl || typeof pageUrl !== 'string' ) {\r\n pageUrl = '/';\r\n }\r\n\r\n // 如果页面链接带上了域名,则需要过滤掉\r\n if ( pageUrl.includes('http') ) {\r\n const PAGE_CUT = pageUrl.split('/');\r\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`;\r\n pageUrl = pageUrl.replace(HOST_NAME, '');\r\n }\r\n\r\n // 设置响应id并提交数据\r\n this.setAccount();\r\n window._hmt.push(['_trackPageview', pageUrl]);\r\n\r\n if ( this.isDebug ) {\r\n console.log(`[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`);\r\n }\r\n }\r\n\r\n /** \r\n * 提交点击事件\r\n */\r\n trackEvent (category: string, action: string, label: string, value: number) {\r\n // 前两个是必填项\r\n if ( typeof category !== 'string' || typeof action !== 'string' || !category || !action ) {\r\n throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.');\r\n return false;\r\n }\r\n\r\n // 重置一些无效的默认值\r\n if ( !label || typeof label !== 'string' ) {\r\n label = '';\r\n }\r\n\r\n if ( !Number(value) ) {\r\n value = 1;\r\n }\r\n\r\n // 设置响应id并提交数据\r\n this.setAccount();\r\n window._hmt.push(['_trackEvent', category, action, label, value]);\r\n\r\n if ( this.isDebug ) {\r\n console.log(`[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`);\r\n }\r\n }\r\n}\r\n\r\nexport default BAIDU;","import BAIDU from '@m/baidu'\r\n\r\n/** \r\n * 定义推送操作\r\n */\r\nclass PushBAIDU {\r\n siteIdList: string[];\r\n isDebug: boolean;\r\n\r\n constructor (siteIdList: string[], isDebug: boolean) {\r\n this.siteIdList = siteIdList;\r\n this.isDebug = isDebug;\r\n }\r\n\r\n /** \r\n * 批量部署站点\r\n */\r\n init () {\r\n this.siteIdList.forEach( (siteId: string) => {\r\n const SITE = new BAIDU(siteId, this.isDebug);\r\n SITE.init();\r\n });\r\n }\r\n\r\n /** \r\n * 批量提交pv上报\r\n */\r\n pv (pageUrl: string) {\r\n this.siteIdList.forEach( (siteId: string) => {\r\n const SITE = new BAIDU(siteId, this.isDebug);\r\n SITE.trackPageview(pageUrl);\r\n });\r\n }\r\n\r\n /** \r\n * 批量提交事件上报\r\n */\r\n event (category: string, action: string, label: string, value: number) {\r\n this.siteIdList.forEach( (siteId: string) => {\r\n const SITE = new BAIDU(siteId, this.isDebug);\r\n SITE.trackEvent(category, action, label, value);\r\n });\r\n }\r\n\r\n}\r\n\r\nexport default PushBAIDU;","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;","import PushBAIDU from '@m/pushBAIDU'\r\nimport getVueVersion from '@m/getVueVersion'\r\n\r\n/** \r\n * 定义插件\r\n */\r\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\r\n\r\n /** \r\n * 一些环境和参数的检查\r\n */\r\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\r\n return false;\r\n }\r\n\r\n if ( !router ) {\r\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\r\n }\r\n\r\n if ( !siteIdList ) {\r\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.');\r\n }\r\n\r\n /** \r\n * 挂载推送的方法\r\n */\r\n const pushBAIDU: any = new PushBAIDU(siteIdList, isDebug);\r\n \r\n // 获取Vue版本(获取失败则默认为2)\r\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\r\n\r\n // 2.x可以直接挂载到原型上\r\n if ( VUE_VERSION === 2 ) {\r\n Vue.prototype.$pushBAIDU = pushBAIDU;\r\n }\r\n\r\n // 3.x必须使用这个方式来挂载\r\n if ( VUE_VERSION === 3 ) {\r\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\r\n }\r\n\r\n /** \r\n * 部署站点并初始化\r\n */\r\n if ( siteIdList ) {\r\n pushBAIDU.init();\r\n }\r\n\r\n /** \r\n * 路由切换时执行PV上报\r\n */\r\n router.afterEach( (to: To) => {\r\n const PAGE_PATH_DIR_COUNT = window.location.pathname.split('/').length;\r\n const PAGE_PATH = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/');\r\n const PAGE_URL = router.mode === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`;\r\n\r\n pushBAIDU.pv(PAGE_URL);\r\n });\r\n}"],"names":[],"mappings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,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;OACxB,CAAC,CAAC;EACL;;;;"} \ No newline at end of file +{"version":3,"file":"vue-baidu-analytics.js","sources":["../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/modules/getVueVersion.ts","../src/modules/getRouterMode.ts","../src/main.ts"],"sourcesContent":["/** \n * 定义基础配置\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\n */\nclass BAIDU {\n siteId: string;\n isDebug: boolean;\n\n constructor (siteId: string = '', isDebug: boolean = false) {\n this.siteId = siteId;\n this.isDebug = isDebug;\n }\n\n /** \n * 初始化\n */\n init () {\n window._hmt = window._hmt ? window._hmt : [];\n const SCRIPT = document.createElement('script');\n SCRIPT['async'] = true;\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`;\n document.querySelector('head').appendChild(SCRIPT);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`);\n }\n }\n\n /** \n * 设置要响应的站点\n */\n setAccount () {\n window._hmt.push(['_setAccount', this.siteId]);\n }\n\n /** \n * 提交PV、UV\n */\n trackPageview (pageUrl: string) {\n // 如果页面链接没传或者无效链接,则默认为根域名\n if ( !pageUrl || typeof pageUrl !== 'string' ) {\n pageUrl = '/';\n }\n\n // 如果页面链接带上了域名,则需要过滤掉\n if ( pageUrl.includes('http') ) {\n const PAGE_CUT = pageUrl.split('/');\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`;\n pageUrl = pageUrl.replace(HOST_NAME, '');\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackPageview', pageUrl]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`);\n }\n }\n\n /** \n * 提交点击事件\n */\n trackEvent (category: string, action: string, label: string, value: number) {\n // 前两个是必填项\n if ( typeof category !== 'string' || typeof action !== 'string' || !category || !action ) {\n throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.');\n return false;\n }\n\n // 重置一些无效的默认值\n if ( !label || typeof label !== 'string' ) {\n label = '';\n }\n\n if ( !Number(value) ) {\n value = 1;\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackEvent', category, action, label, value]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`);\n }\n }\n}\n\nexport default BAIDU;","import BAIDU from '@m/baidu'\n\n/** \n * 定义推送操作\n */\nclass PushBAIDU {\n siteIdList: string[];\n isDebug: boolean;\n\n constructor (siteIdList: string[], isDebug: boolean) {\n this.siteIdList = siteIdList;\n this.isDebug = isDebug;\n }\n\n /** \n * 批量部署站点\n */\n init () {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.init();\n });\n }\n\n /** \n * 批量提交pv上报\n */\n pv (pageUrl: string) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackPageview(pageUrl);\n });\n }\n\n /** \n * 批量提交事件上报\n */\n event (category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackEvent(category, action, label, value);\n });\n }\n\n}\n\nexport default PushBAIDU;","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;","/** \r\n * 获取Vue的版本\r\n * @param {number} vueVersion - vue版本号,2=Vue2.x, 3=Vue3.x\r\n * @param {object} router - vue路由\r\n * @return hash=hash模式、history=history模式\r\n */\r\nconst getRouterMode = (vueVersion: number, router: any): string => {\r\n let mode: string = 'history';\r\n\r\n // 2.x直接读取mode即可\r\n if ( vueVersion === 2 ) {\r\n mode = router.mode;\r\n }\r\n\r\n // 3.x需要判断一下\r\n if ( vueVersion === 3 ) {\r\n const BASE: string = router.options.history.base || '';\r\n if ( BASE.includes('#') ) {\r\n mode = 'hash';\r\n }\r\n }\r\n \r\n return mode;\r\n}\r\n\r\nexport default getRouterMode;","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\nimport getRouterMode from '@m/getRouterMode'\n\n/** \n * 定义插件\n */\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\n\n /** \n * 一些环境和参数的检查\n */\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\n return false;\n }\n\n if ( !router ) {\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\n }\n\n if ( !siteIdList ) {\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.');\n }\n\n /** \n * 挂载推送的方法\n */\n const pushBAIDU: any = new PushBAIDU(siteIdList, isDebug);\n \n // 获取Vue版本(获取失败则默认为2)\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\n\n // 2.x可以直接挂载到原型上\n if ( VUE_VERSION === 2 ) {\n Vue.prototype.$pushBAIDU = pushBAIDU;\n }\n\n // 3.x必须使用这个方式来挂载\n if ( VUE_VERSION === 3 ) {\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\n }\n\n /** \n * 部署站点并初始化\n */\n if ( siteIdList ) {\n pushBAIDU.init();\n }\n\n /** \n * 路由切换时执行PV上报\n */\n router.afterEach( (to: To) => {\n // 根据Vue版本获取路由模式\n const ROUTER_MODE: string = getRouterMode(VUE_VERSION, router);\n \n // 获取页面的url信息\n const PAGE_PATH_DIR_COUNT = window.location.pathname.split('/').length;\n const PAGE_PATH = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/');\n\n // 根据路由模式生成要上报的链接\n const PAGE_URL = ROUTER_MODE === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`;\n \n // 上报数据\n pushBAIDU.pv(PAGE_URL);\n });\n}"],"names":[],"mappings":";;;;;;;;;;;EAIA;MAIE,eAAa,MAAmB,EAAE,OAAwB;UAA7C,uBAAA,EAAA,WAAmB;UAAE,wBAAA,EAAA,eAAwB;UACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;UACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;OACxB;MAKD,oBAAI,GAAJ;UACE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;UAC7C,IAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;UAChD,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;UACvB,MAAM,CAAC,KAAK,CAAC,GAAG,gCAA8B,IAAI,CAAC,MAAQ,CAAC;UAC5D,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;UAEnD,IAAK,IAAI,CAAC,OAAO,EAAG;cAClB,OAAO,CAAC,GAAG,CAAC,yDAAuD,IAAI,CAAC,MAAQ,CAAC,CAAC;WACnF;OACF;MAKD,0BAAU,GAAV;UACE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;OAChD;MAKD,6BAAa,GAAb,UAAe,OAAe;UAE5B,IAAK,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ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CAAC;MAGpD,IAAK,WAAW,KAAK,CAAC,EAAG;UACvB,GAAG,CAAC,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC;OACtC;MAGD,IAAK,WAAW,KAAK,CAAC,EAAG;UACvB,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,SAAS,CAAC;OACpD;MAKD,IAAK,UAAU,EAAG;UAChB,SAAS,CAAC,IAAI,EAAE,CAAC;OAClB;MAKD,MAAM,CAAC,SAAS,CAAE,UAAC,EAAM;UAEvB,IAAM,WAAW,GAAW,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;UAG/D,IAAM,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;UACvE,IAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;UAGlG,IAAM,QAAQ,GAAG,WAAW,KAAK,MAAM,GAAM,SAAS,UAAK,EAAE,CAAC,QAAU,GAAG,KAAG,SAAS,GAAG,EAAE,CAAC,QAAU,CAAC;UAGxG,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;OACxB,CAAC,CAAC;EACL;;;;"} \ No newline at end of file diff --git a/dist/vue-baidu-analytics.min.js b/dist/vue-baidu-analytics.min.js index 8d2c041..e86998a 100644 --- a/dist/vue-baidu-analytics.min.js +++ b/dist/vue-baidu-analytics.min.js @@ -1,7 +1,7 @@ /** * name: vue-baidu-analytics - * version: v2.0.1 + * version: v2.0.2 * author: chengpeiquan */ - !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).baiduAnalytics=i()}(this,(function(){"use strict";var t=function(){function t(t,i){void 0===t&&(t=""),void 0===i&&(i=!1),this.siteId=t,this.isDebug=i}return t.prototype.init=function(){window._hmt=window._hmt?window._hmt:[];var t=document.createElement("script");t.async=!0,t.src="https://hm.baidu.com/hm.js?"+this.siteId,document.querySelector("head").appendChild(t),this.isDebug&&console.log("[vue-baidu-analytics] siteId load done.\nsiteId: "+this.siteId)},t.prototype.setAccount=function(){window._hmt.push(["_setAccount",this.siteId])},t.prototype.trackPageview=function(t){if(t&&"string"==typeof t||(t="/"),t.includes("http")){var i=t.split("/"),e=i[0]+"//"+i[2];t=t.replace(e,"")}this.setAccount(),window._hmt.push(["_trackPageview",t]),this.isDebug&&console.log("[vue-baidu-analytics] track pv done.\nsiteId: "+this.siteId+"\npageUrl: "+t)},t.prototype.trackEvent=function(t,i,e,n){if("string"!=typeof t||"string"!=typeof i||!t||!i)throw new Error("[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.");e&&"string"==typeof e||(e=""),Number(n)||(n=1),this.setAccount(),window._hmt.push(["_trackEvent",t,i,e,n]),this.isDebug&&console.log("[vue-baidu-analytics] track event done.\nsiteId: "+this.siteId+"\ncategory: "+t+"\naction: "+i+"\nlabel: "+e+"\nvalue: "+n)},t}(),i=function(){function i(t,i){this.siteIdList=t,this.isDebug=i}return i.prototype.init=function(){var i=this;this.siteIdList.forEach((function(e){new t(e,i.isDebug).init()}))},i.prototype.pv=function(i){var e=this;this.siteIdList.forEach((function(n){new t(n,e.isDebug).trackPageview(i)}))},i.prototype.event=function(i,e,n,o){var s=this;this.siteIdList.forEach((function(a){new t(a,s.isDebug).trackEvent(i,e,n,o)}))},i}();return function(t,e){var n=e.router,o=e.siteIdList,s=e.isDebug,a=void 0!==s&&s;if("undefined"==typeof document||"undefined"==typeof window)return!1;if(!n)throw new Error("[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.");if(!o)throw new Error("[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.");var r=new i(o,a),u=function(t){var i=2,e=String(t.version);return"2."===e.slice(0,2)&&(i=2),"3."===e.slice(0,2)&&(i=3),i}(t)||2;2===u&&(t.prototype.$pushBAIDU=r),3===u&&(t.config.globalProperties.$pushBAIDU=r),o&&r.init(),n.afterEach((function(t){var i=window.location.pathname.split("/").length,e=window.location.pathname.split("/").slice(0,i-1).join("/"),o="hash"===n.mode?e+"/#"+t.fullPath:""+e+t.fullPath;r.pv(o)}))}})); + !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t=t||self).baiduAnalytics=i()}(this,(function(){"use strict";var t=function(){function t(t,i){void 0===t&&(t=""),void 0===i&&(i=!1),this.siteId=t,this.isDebug=i}return t.prototype.init=function(){window._hmt=window._hmt?window._hmt:[];var t=document.createElement("script");t.async=!0,t.src="https://hm.baidu.com/hm.js?"+this.siteId,document.querySelector("head").appendChild(t),this.isDebug&&console.log("[vue-baidu-analytics] siteId load done.\nsiteId: "+this.siteId)},t.prototype.setAccount=function(){window._hmt.push(["_setAccount",this.siteId])},t.prototype.trackPageview=function(t){if(t&&"string"==typeof t||(t="/"),t.includes("http")){var i=t.split("/"),e=i[0]+"//"+i[2];t=t.replace(e,"")}this.setAccount(),window._hmt.push(["_trackPageview",t]),this.isDebug&&console.log("[vue-baidu-analytics] track pv done.\nsiteId: "+this.siteId+"\npageUrl: "+t)},t.prototype.trackEvent=function(t,i,e,n){if("string"!=typeof t||"string"!=typeof i||!t||!i)throw new Error("[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.");e&&"string"==typeof e||(e=""),Number(n)||(n=1),this.setAccount(),window._hmt.push(["_trackEvent",t,i,e,n]),this.isDebug&&console.log("[vue-baidu-analytics] track event done.\nsiteId: "+this.siteId+"\ncategory: "+t+"\naction: "+i+"\nlabel: "+e+"\nvalue: "+n)},t}(),i=function(){function i(t,i){this.siteIdList=t,this.isDebug=i}return i.prototype.init=function(){var i=this;this.siteIdList.forEach((function(e){new t(e,i.isDebug).init()}))},i.prototype.pv=function(i){var e=this;this.siteIdList.forEach((function(n){new t(n,e.isDebug).trackPageview(i)}))},i.prototype.event=function(i,e,n,o){var s=this;this.siteIdList.forEach((function(a){new t(a,s.isDebug).trackEvent(i,e,n,o)}))},i}();return function(t,e){var n=e.router,o=e.siteIdList,s=e.isDebug,a=void 0!==s&&s;if("undefined"==typeof document||"undefined"==typeof window)return!1;if(!n)throw new Error("[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.");if(!o)throw new Error("[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.");var r=new i(o,a),u=function(t){var i=2,e=String(t.version);return"2."===e.slice(0,2)&&(i=2),"3."===e.slice(0,2)&&(i=3),i}(t)||2;2===u&&(t.prototype.$pushBAIDU=r),3===u&&(t.config.globalProperties.$pushBAIDU=r),o&&r.init(),n.afterEach((function(t){var i=function(t,i){var e="history";return 2===t&&(e=i.mode),3===t&&(i.options.history.base||"").includes("#")&&(e="hash"),e}(u,n),e=window.location.pathname.split("/").length,o=window.location.pathname.split("/").slice(0,e-1).join("/"),s="hash"===i?o+"/#"+t.fullPath:""+o+t.fullPath;r.pv(s)}))}})); //# sourceMappingURL=vue-baidu-analytics.min.js.map diff --git a/dist/vue-baidu-analytics.min.js.map b/dist/vue-baidu-analytics.min.js.map index 8788bbb..a861687 100644 --- a/dist/vue-baidu-analytics.min.js.map +++ b/dist/vue-baidu-analytics.min.js.map @@ -1 +1 @@ -{"version":3,"file":"vue-baidu-analytics.min.js","sources":["../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/main.ts","../src/modules/getVueVersion.ts"],"sourcesContent":["/** \r\n * 定义基础配置\r\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\r\n */\r\nclass BAIDU {\r\n siteId: string;\r\n isDebug: boolean;\r\n\r\n constructor (siteId: string = '', isDebug: boolean = false) {\r\n this.siteId = siteId;\r\n this.isDebug = isDebug;\r\n }\r\n\r\n /** \r\n * 初始化\r\n */\r\n init () {\r\n window._hmt = window._hmt ? window._hmt : [];\r\n const SCRIPT = document.createElement('script');\r\n SCRIPT['async'] = true;\r\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`;\r\n document.querySelector('head').appendChild(SCRIPT);\r\n\r\n if ( this.isDebug ) {\r\n console.log(`[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`);\r\n }\r\n }\r\n\r\n /** \r\n * 设置要响应的站点\r\n */\r\n setAccount () {\r\n window._hmt.push(['_setAccount', this.siteId]);\r\n }\r\n\r\n /** \r\n * 提交PV、UV\r\n */\r\n trackPageview (pageUrl: string) {\r\n // 如果页面链接没传或者无效链接,则默认为根域名\r\n if ( !pageUrl || typeof pageUrl !== 'string' ) {\r\n pageUrl = '/';\r\n }\r\n\r\n // 如果页面链接带上了域名,则需要过滤掉\r\n if ( pageUrl.includes('http') ) {\r\n const PAGE_CUT = pageUrl.split('/');\r\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`;\r\n pageUrl = pageUrl.replace(HOST_NAME, '');\r\n }\r\n\r\n // 设置响应id并提交数据\r\n this.setAccount();\r\n window._hmt.push(['_trackPageview', pageUrl]);\r\n\r\n if ( this.isDebug ) {\r\n console.log(`[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`);\r\n }\r\n }\r\n\r\n /** \r\n * 提交点击事件\r\n */\r\n trackEvent (category: string, action: string, label: string, value: number) {\r\n // 前两个是必填项\r\n if ( typeof category !== 'string' || typeof action !== 'string' || !category || !action ) {\r\n throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.');\r\n return false;\r\n }\r\n\r\n // 重置一些无效的默认值\r\n if ( !label || typeof label !== 'string' ) {\r\n label = '';\r\n }\r\n\r\n if ( !Number(value) ) {\r\n value = 1;\r\n }\r\n\r\n // 设置响应id并提交数据\r\n this.setAccount();\r\n window._hmt.push(['_trackEvent', category, action, label, value]);\r\n\r\n if ( this.isDebug ) {\r\n console.log(`[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`);\r\n }\r\n }\r\n}\r\n\r\nexport default BAIDU;","import BAIDU from '@m/baidu'\r\n\r\n/** \r\n * 定义推送操作\r\n */\r\nclass PushBAIDU {\r\n siteIdList: string[];\r\n isDebug: boolean;\r\n\r\n constructor (siteIdList: string[], isDebug: boolean) {\r\n this.siteIdList = siteIdList;\r\n this.isDebug = isDebug;\r\n }\r\n\r\n /** \r\n * 批量部署站点\r\n */\r\n init () {\r\n this.siteIdList.forEach( (siteId: string) => {\r\n const SITE = new BAIDU(siteId, this.isDebug);\r\n SITE.init();\r\n });\r\n }\r\n\r\n /** \r\n * 批量提交pv上报\r\n */\r\n pv (pageUrl: string) {\r\n this.siteIdList.forEach( (siteId: string) => {\r\n const SITE = new BAIDU(siteId, this.isDebug);\r\n SITE.trackPageview(pageUrl);\r\n });\r\n }\r\n\r\n /** \r\n * 批量提交事件上报\r\n */\r\n event (category: string, action: string, label: string, value: number) {\r\n this.siteIdList.forEach( (siteId: string) => {\r\n const SITE = new BAIDU(siteId, this.isDebug);\r\n SITE.trackEvent(category, action, label, value);\r\n });\r\n }\r\n\r\n}\r\n\r\nexport default PushBAIDU;","import PushBAIDU from '@m/pushBAIDU'\r\nimport getVueVersion from '@m/getVueVersion'\r\n\r\n/** \r\n * 定义插件\r\n */\r\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\r\n\r\n /** \r\n * 一些环境和参数的检查\r\n */\r\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\r\n return false;\r\n }\r\n\r\n if ( !router ) {\r\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\r\n }\r\n\r\n if ( !siteIdList ) {\r\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.');\r\n }\r\n\r\n /** \r\n * 挂载推送的方法\r\n */\r\n const pushBAIDU: any = new PushBAIDU(siteIdList, isDebug);\r\n \r\n // 获取Vue版本(获取失败则默认为2)\r\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\r\n\r\n // 2.x可以直接挂载到原型上\r\n if ( VUE_VERSION === 2 ) {\r\n Vue.prototype.$pushBAIDU = pushBAIDU;\r\n }\r\n\r\n // 3.x必须使用这个方式来挂载\r\n if ( VUE_VERSION === 3 ) {\r\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\r\n }\r\n\r\n /** \r\n * 部署站点并初始化\r\n */\r\n if ( siteIdList ) {\r\n pushBAIDU.init();\r\n }\r\n\r\n /** \r\n * 路由切换时执行PV上报\r\n */\r\n router.afterEach( (to: To) => {\r\n const PAGE_PATH_DIR_COUNT = window.location.pathname.split('/').length;\r\n const PAGE_PATH = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/');\r\n const PAGE_URL = router.mode === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`;\r\n\r\n pushBAIDU.pv(PAGE_URL);\r\n });\r\n}","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;"],"names":["siteId","isDebug","this","BAIDU","window","_hmt","SCRIPT","document","createElement","querySelector","appendChild","console","log","push","pageUrl","includes","PAGE_CUT","split","HOST_NAME","replace","setAccount","category","action","label","value","Error","Number","siteIdList","PushBAIDU","forEach","_this","init","trackPageview","trackEvent","Vue","_a","router","_b","pushBAIDU","VUE_VERSION","version","String","slice","getVueVersion","prototype","$pushBAIDU","config","globalProperties","afterEach","to","PAGE_PATH_DIR_COUNT","location","pathname","length","PAGE_PATH","join","PAGE_URL","mode","fullPath","pv"],"mappings":";;;;;gPAIA,iBAIE,WAAaA,EAAqBC,gBAArBD,mBAAqBC,MAChCC,KAAKF,OAASA,EACdE,KAAKD,QAAUA,EA6EnB,OAvEEE,iBAAA,WACEC,OAAOC,KAAOD,OAAOC,KAAOD,OAAOC,KAAO,GAC1C,IAAMC,EAASC,SAASC,cAAc,UACtCF,EAAc,OAAI,EAClBA,EAAY,IAAI,8BAA8BJ,KAAKF,OACnDO,SAASE,cAAc,QAAQC,YAAYJ,GAEtCJ,KAAKD,SACRU,QAAQC,IAAI,uDAAuDV,KAAKF,SAO5EG,uBAAA,WACEC,OAAOC,KAAKQ,KAAK,CAAC,cAAeX,KAAKF,UAMxCG,0BAAA,SAAeW,GAOb,GALMA,GAA8B,iBAAZA,IACtBA,EAAU,KAIPA,EAAQC,SAAS,QAAU,CAC9B,IAAMC,EAAWF,EAAQG,MAAM,KACzBC,EAAeF,EAAS,QAAOA,EAAS,GAC9CF,EAAUA,EAAQK,QAAQD,EAAW,IAIvChB,KAAKkB,aACLhB,OAAOC,KAAKQ,KAAK,CAAC,iBAAkBC,IAE/BZ,KAAKD,SACRU,QAAQC,IAAI,oDAAoDV,KAAKF,uBAAsBc,IAO/FX,uBAAA,SAAYkB,EAAkBC,EAAgBC,EAAeC,GAE3D,GAAyB,iBAAbH,GAA4C,iBAAXC,IAAwBD,IAAaC,EAChF,MAAM,IAAIG,MAAM,2GAKZF,GAA0B,iBAAVA,IACpBA,EAAQ,IAGJG,OAAOF,KACXA,EAAQ,GAIVtB,KAAKkB,aACLhB,OAAOC,KAAKQ,KAAK,CAAC,cAAeQ,EAAUC,EAAQC,EAAOC,IAErDtB,KAAKD,SACRU,QAAQC,IAAI,sDAAsDV,KAAKF,sBAAqBqB,iBAAuBC,iBAAqBC,iBAAoBC,sB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OAAcL,EAAGS,SAAa,GAAGJ,EAAYL,EAAGS,SAE7FpB,EAAUqB,GAAGH"} \ No newline at end of file +{"version":3,"file":"vue-baidu-analytics.min.js","sources":["../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/main.ts","../src/modules/getVueVersion.ts","../src/modules/getRouterMode.ts"],"sourcesContent":["/** \n * 定义基础配置\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\n */\nclass BAIDU {\n siteId: string;\n isDebug: boolean;\n\n constructor (siteId: string = '', isDebug: boolean = false) {\n this.siteId = siteId;\n this.isDebug = isDebug;\n }\n\n /** \n * 初始化\n */\n init () {\n window._hmt = window._hmt ? window._hmt : [];\n const SCRIPT = document.createElement('script');\n SCRIPT['async'] = true;\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`;\n document.querySelector('head').appendChild(SCRIPT);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`);\n }\n }\n\n /** \n * 设置要响应的站点\n */\n setAccount () {\n window._hmt.push(['_setAccount', this.siteId]);\n }\n\n /** \n * 提交PV、UV\n */\n trackPageview (pageUrl: string) {\n // 如果页面链接没传或者无效链接,则默认为根域名\n if ( !pageUrl || typeof pageUrl !== 'string' ) {\n pageUrl = '/';\n }\n\n // 如果页面链接带上了域名,则需要过滤掉\n if ( pageUrl.includes('http') ) {\n const PAGE_CUT = pageUrl.split('/');\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`;\n pageUrl = pageUrl.replace(HOST_NAME, '');\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackPageview', pageUrl]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`);\n }\n }\n\n /** \n * 提交点击事件\n */\n trackEvent (category: string, action: string, label: string, value: number) {\n // 前两个是必填项\n if ( typeof category !== 'string' || typeof action !== 'string' || !category || !action ) {\n throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.');\n return false;\n }\n\n // 重置一些无效的默认值\n if ( !label || typeof label !== 'string' ) {\n label = '';\n }\n\n if ( !Number(value) ) {\n value = 1;\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackEvent', category, action, label, value]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`);\n }\n }\n}\n\nexport default BAIDU;","import BAIDU from '@m/baidu'\n\n/** \n * 定义推送操作\n */\nclass PushBAIDU {\n siteIdList: string[];\n isDebug: boolean;\n\n constructor (siteIdList: string[], isDebug: boolean) {\n this.siteIdList = siteIdList;\n this.isDebug = isDebug;\n }\n\n /** \n * 批量部署站点\n */\n init () {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.init();\n });\n }\n\n /** \n * 批量提交pv上报\n */\n pv (pageUrl: string) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackPageview(pageUrl);\n });\n }\n\n /** \n * 批量提交事件上报\n */\n event (category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackEvent(category, action, label, value);\n });\n }\n\n}\n\nexport default PushBAIDU;","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\nimport getRouterMode from '@m/getRouterMode'\n\n/** \n * 定义插件\n */\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\n\n /** \n * 一些环境和参数的检查\n */\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\n return false;\n }\n\n if ( !router ) {\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\n }\n\n if ( !siteIdList ) {\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.');\n }\n\n /** \n * 挂载推送的方法\n */\n const pushBAIDU: any = new PushBAIDU(siteIdList, isDebug);\n \n // 获取Vue版本(获取失败则默认为2)\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\n\n // 2.x可以直接挂载到原型上\n if ( VUE_VERSION === 2 ) {\n Vue.prototype.$pushBAIDU = pushBAIDU;\n }\n\n // 3.x必须使用这个方式来挂载\n if ( VUE_VERSION === 3 ) {\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\n }\n\n /** \n * 部署站点并初始化\n */\n if ( siteIdList ) {\n pushBAIDU.init();\n }\n\n /** \n * 路由切换时执行PV上报\n */\n router.afterEach( (to: To) => {\n // 根据Vue版本获取路由模式\n const ROUTER_MODE: string = getRouterMode(VUE_VERSION, router);\n \n // 获取页面的url信息\n const PAGE_PATH_DIR_COUNT = window.location.pathname.split('/').length;\n const PAGE_PATH = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/');\n\n // 根据路由模式生成要上报的链接\n const PAGE_URL = ROUTER_MODE === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`;\n \n // 上报数据\n pushBAIDU.pv(PAGE_URL);\n });\n}","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;","/** \r\n * 获取Vue的版本\r\n * @param {number} vueVersion - vue版本号,2=Vue2.x, 3=Vue3.x\r\n * @param {object} router - vue路由\r\n * @return hash=hash模式、history=history模式\r\n */\r\nconst getRouterMode = (vueVersion: number, router: any): string => {\r\n let mode: string = 'history';\r\n\r\n // 2.x直接读取mode即可\r\n if ( vueVersion === 2 ) {\r\n mode = router.mode;\r\n }\r\n\r\n // 3.x需要判断一下\r\n if ( vueVersion === 3 ) {\r\n const BASE: string = router.options.history.base || '';\r\n if ( BASE.includes('#') ) {\r\n mode = 'hash';\r\n }\r\n }\r\n \r\n return mode;\r\n}\r\n\r\nexport default getRouterMode;"],"names":["siteId","isDebug","this","BAIDU","window","_hmt","SCRIPT","document","createElement","querySelector","appendChild","console","log","push","pageUrl","includes","PAGE_CUT","split","HOST_NAME","replace","setAccount","category","action","label","value","Error","Number","siteIdList","PushBAIDU","forEach","_this","init","trackPageview","trackEvent","Vue","_a","router","_b","pushBAIDU","VUE_VERSION","version","String","slice","getVueVersion","prototype","$pushBAIDU","config","globalProperties","afterEach","to","ROUTER_MODE","vueVersion","mode","options","history","base","getRouterMode","PAGE_PATH_DIR_COUNT","location","pathname","length","PAGE_PATH","join","PAGE_URL","fullPath","pv"],"mappings":";;;;;sMAIA,iBAIE,WAAaA,EAAqBC,gBAArBD,mBAAqBC,MAChCC,KAAKF,OAASA,EACdE,KAAKD,QAAUA,EA6EnB,OAvEEE,iBAAA,WACEC,OAAOC,KAAOD,OAAOC,KAAOD,OAAOC,KAAO,GAC1C,IAAMC,EAASC,SAASC,cAAc,UACtCF,EAAc,OAAI,EAClBA,EAAY,IAAI,8BAA8BJ,KAAKF,OACnDO,SAASE,cAAc,QAAQC,YAAYJ,GAEtCJ,KAAKD,SACRU,QAAQC,IAAI,uDAAuDV,KAAKF,SAO5EG,uBAAA,WACEC,OAAOC,KAAKQ,KAAK,CAAC,cAAeX,KAAKF,UAMxCG,0BAAA,SAAeW,GAOb,GALMA,GAA8B,iBAAZA,IACtBA,EAAU,KAIPA,EAAQC,SAAS,QAAU,CAC9B,IAAMC,EAAWF,EAAQG,MAAM,KACzBC,EAAeF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AUD,EAAY1B,GAG3CsC,EC1Bc,SAACL,GACrB,IAAIM,EAAkB,EAGhBD,EAAsBE,OAAOP,EAAIM,SAYvC,MATiC,OAA5BD,EAAYG,MAAM,EAAG,KACxBF,EAAU,GAIqB,OAA5BD,EAAYG,MAAM,EAAG,KACxBF,EAAU,GAGLA,EDUqBG,CAAcT,IAAQ,EAG7B,IAAhBK,IACHL,EAAIU,UAAUC,WAAaP,GAIR,IAAhBC,IACHL,EAAIY,OAAOC,iBAAiBF,WAAaP,GAMtCX,GACHW,EAAUP,OAMZK,EAAOY,WAAW,SAACC,GAEjB,IAAMC,EEhDY,SAACC,EAAoBf,GACzC,IAAIgB,EAAe,UAenB,OAZoB,IAAfD,IACHC,EAAOhB,EAAOgB,MAII,IAAfD,IACkBf,EAAOiB,QAAQC,QAAQC,MAAQ,IAC1CxC,SAAS,OACjBqC,EAAO,QAIJA,EFgCuBI,CAAcjB,EAAaH,GAGjDqB,EAAsBrD,OAAOsD,SAASC,SAAS1C,MAAM,KAAK2C,OAC1DC,EAAYzD,OAAOsD,SAASC,SAAS1C,MAAM,KAAKyB,MAAM,EAAGe,EAAsB,GAAGK,KAAK,KAGvFC,EAA2B,SAAhBb,EAA4BW,OAAcZ,EAAGe,SAAa,GAAGH,EAAYZ,EAAGe,SAG7F1B,EAAU2B,GAAGF"} \ No newline at end of file diff --git a/package.json b/package.json index deb10bd..5fa9057 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-baidu-analytics", - "version": "2.0.1", + "version": "2.0.2", "description": "A data collection tool that supports reporting of single-page application data built by Vue 3.0 & 2.0 & VuePress, based on baidu statistics.", "main": "dist/vue-baidu-analytics.min.js", "types": "vue-baidu-analytics.d.ts", diff --git a/src/main.ts b/src/main.ts index 98b1dc8..9088f56 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import PushBAIDU from '@m/pushBAIDU' import getVueVersion from '@m/getVueVersion' +import getRouterMode from '@m/getRouterMode' /** * 定义插件 @@ -50,10 +51,17 @@ export default function install (Vue: Vue, { router, siteIdList, isDebug = false * 路由切换时执行PV上报 */ router.afterEach( (to: To) => { + // 根据Vue版本获取路由模式 + const ROUTER_MODE: string = getRouterMode(VUE_VERSION, router); + + // 获取页面的url信息 const PAGE_PATH_DIR_COUNT = window.location.pathname.split('/').length; const PAGE_PATH = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/'); - const PAGE_URL = router.mode === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`; + // 根据路由模式生成要上报的链接 + const PAGE_URL = ROUTER_MODE === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`; + + // 上报数据 pushBAIDU.pv(PAGE_URL); }); } \ No newline at end of file diff --git a/src/modules/getRouterMode.ts b/src/modules/getRouterMode.ts new file mode 100644 index 0000000..7231dcd --- /dev/null +++ b/src/modules/getRouterMode.ts @@ -0,0 +1,26 @@ +/** + * 获取Vue的版本 + * @param {number} vueVersion - vue版本号,2=Vue2.x, 3=Vue3.x + * @param {object} router - vue路由 + * @return hash=hash模式、history=history模式 + */ +const getRouterMode = (vueVersion: number, router: any): string => { + let mode: string = 'history'; + + // 2.x直接读取mode即可 + if ( vueVersion === 2 ) { + mode = router.mode; + } + + // 3.x需要判断一下 + if ( vueVersion === 3 ) { + const BASE: string = router.options.history.base || ''; + if ( BASE.includes('#') ) { + mode = 'hash'; + } + } + + return mode; +} + +export default getRouterMode; \ No newline at end of file From a1da25c8e4b6b3a851650263eca32a52e3b47708 Mon Sep 17 00:00:00 2001 From: chengpeiquan Date: Mon, 11 Jan 2021 11:40:13 +0800 Subject: [PATCH 2/6] Update variable type. --- src/main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 9088f56..0602e6a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -55,11 +55,11 @@ export default function install (Vue: Vue, { router, siteIdList, isDebug = false const ROUTER_MODE: string = getRouterMode(VUE_VERSION, router); // 获取页面的url信息 - const PAGE_PATH_DIR_COUNT = window.location.pathname.split('/').length; - const PAGE_PATH = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/'); + const PAGE_PATH_DIR_COUNT: number = window.location.pathname.split('/').length; + const PAGE_PATH: string = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/'); // 根据路由模式生成要上报的链接 - const PAGE_URL = ROUTER_MODE === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`; + const PAGE_URL: string = ROUTER_MODE === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`; // 上报数据 pushBAIDU.pv(PAGE_URL); From 263757f20ec4330c1771284ed0a6200e48ab0b32 Mon Sep 17 00:00:00 2001 From: chengpeiquan Date: Mon, 11 Jan 2021 11:41:36 +0800 Subject: [PATCH 3/6] Update README --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 5fa9057..0e0d783 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,9 @@ "vue 3.0 baidu", "vue 3.0 百度统计", "vue 3.0 analytics", + "vue3 baidu", + "vue3 百度统计", + "vue3 analytics", "spa analytics", "baidu统计", "vuepress统计", From cb63eaa601279d439dd9764f3c2b6d25a0b9fb5b Mon Sep 17 00:00:00 2001 From: chengpeiquan Date: Mon, 11 Jan 2021 11:42:05 +0800 Subject: [PATCH 4/6] Update package.json --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index 0e0d783..5fa9057 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,6 @@ "vue 3.0 baidu", "vue 3.0 百度统计", "vue 3.0 analytics", - "vue3 baidu", - "vue3 百度统计", - "vue3 analytics", "spa analytics", "baidu统计", "vuepress统计", From fedfa49e5e73b6b6a5bf4a210a428acf5d4a2ad0 Mon Sep 17 00:00:00 2001 From: chengpeiquan Date: Mon, 11 Jan 2021 11:42:43 +0800 Subject: [PATCH 5/6] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50bed15..c975eba 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ createApp(app) 'bbbbbbbbbbbbbbbbbbb', 'ccccccccccccccccccc' ], - isDebug: true + isDebug: false }) // 挂载到节点上 From 4aff1f5eac93b2381164705cbbe50a5135ddcc03 Mon Sep 17 00:00:00 2001 From: chengpeiquan Date: Mon, 11 Jan 2021 11:43:23 +0800 Subject: [PATCH 6/6] Release v2.0.2 --- dist/vue-baidu-analytics.js.map | 2 +- dist/vue-baidu-analytics.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/vue-baidu-analytics.js.map b/dist/vue-baidu-analytics.js.map index a9b4c82..ca7f1e0 100644 --- a/dist/vue-baidu-analytics.js.map +++ b/dist/vue-baidu-analytics.js.map @@ -1 +1 @@ -{"version":3,"file":"vue-baidu-analytics.js","sources":["../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/modules/getVueVersion.ts","../src/modules/getRouterMode.ts","../src/main.ts"],"sourcesContent":["/** \n * 定义基础配置\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\n */\nclass BAIDU {\n siteId: string;\n isDebug: boolean;\n\n constructor (siteId: string = '', isDebug: boolean = false) {\n this.siteId = siteId;\n this.isDebug = isDebug;\n }\n\n /** \n * 初始化\n */\n init () {\n window._hmt = window._hmt ? window._hmt : [];\n const SCRIPT = document.createElement('script');\n SCRIPT['async'] = true;\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`;\n document.querySelector('head').appendChild(SCRIPT);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`);\n }\n }\n\n /** \n * 设置要响应的站点\n */\n setAccount () {\n window._hmt.push(['_setAccount', this.siteId]);\n }\n\n /** \n * 提交PV、UV\n */\n trackPageview (pageUrl: string) {\n // 如果页面链接没传或者无效链接,则默认为根域名\n if ( !pageUrl || typeof pageUrl !== 'string' ) {\n pageUrl = '/';\n }\n\n // 如果页面链接带上了域名,则需要过滤掉\n if ( pageUrl.includes('http') ) {\n const PAGE_CUT = pageUrl.split('/');\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`;\n pageUrl = pageUrl.replace(HOST_NAME, '');\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackPageview', pageUrl]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`);\n }\n }\n\n /** \n * 提交点击事件\n */\n trackEvent (category: string, action: string, label: string, value: number) {\n // 前两个是必填项\n if ( typeof category !== 'string' || typeof action !== 'string' || !category || !action ) {\n throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.');\n return false;\n }\n\n // 重置一些无效的默认值\n if ( !label || typeof label !== 'string' ) {\n label = '';\n }\n\n if ( !Number(value) ) {\n value = 1;\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackEvent', category, action, label, value]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`);\n }\n }\n}\n\nexport default BAIDU;","import BAIDU from '@m/baidu'\n\n/** \n * 定义推送操作\n */\nclass PushBAIDU {\n siteIdList: string[];\n isDebug: boolean;\n\n constructor (siteIdList: string[], isDebug: boolean) {\n this.siteIdList = siteIdList;\n this.isDebug = isDebug;\n }\n\n /** \n * 批量部署站点\n */\n init () {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.init();\n });\n }\n\n /** \n * 批量提交pv上报\n */\n pv (pageUrl: string) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackPageview(pageUrl);\n });\n }\n\n /** \n * 批量提交事件上报\n */\n event (category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackEvent(category, action, label, value);\n });\n }\n\n}\n\nexport default PushBAIDU;","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;","/** \r\n * 获取Vue的版本\r\n * @param {number} vueVersion - vue版本号,2=Vue2.x, 3=Vue3.x\r\n * @param {object} router - vue路由\r\n * @return hash=hash模式、history=history模式\r\n */\r\nconst getRouterMode = (vueVersion: number, router: any): string => {\r\n let mode: string = 'history';\r\n\r\n // 2.x直接读取mode即可\r\n if ( vueVersion === 2 ) {\r\n mode = router.mode;\r\n }\r\n\r\n // 3.x需要判断一下\r\n if ( vueVersion === 3 ) {\r\n const BASE: string = router.options.history.base || '';\r\n if ( BASE.includes('#') ) {\r\n mode = 'hash';\r\n }\r\n }\r\n \r\n return mode;\r\n}\r\n\r\nexport default getRouterMode;","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\nimport getRouterMode from '@m/getRouterMode'\n\n/** \n * 定义插件\n */\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\n\n /** \n * 一些环境和参数的检查\n */\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\n return false;\n }\n\n if ( !router ) {\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\n }\n\n if ( !siteIdList ) {\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.');\n }\n\n /** \n * 挂载推送的方法\n */\n const pushBAIDU: any = new PushBAIDU(siteIdList, isDebug);\n \n // 获取Vue版本(获取失败则默认为2)\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\n\n // 2.x可以直接挂载到原型上\n if ( VUE_VERSION === 2 ) {\n Vue.prototype.$pushBAIDU = pushBAIDU;\n }\n\n // 3.x必须使用这个方式来挂载\n if ( VUE_VERSION === 3 ) {\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\n }\n\n /** \n * 部署站点并初始化\n */\n if ( siteIdList ) {\n pushBAIDU.init();\n }\n\n /** \n * 路由切换时执行PV上报\n */\n router.afterEach( (to: To) => {\n // 根据Vue版本获取路由模式\n const ROUTER_MODE: string = getRouterMode(VUE_VERSION, router);\n \n // 获取页面的url信息\n const PAGE_PATH_DIR_COUNT = window.location.pathname.split('/').length;\n const PAGE_PATH = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/');\n\n // 根据路由模式生成要上报的链接\n const PAGE_URL = ROUTER_MODE === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`;\n \n // 上报数据\n pushBAIDU.pv(PAGE_URL);\n });\n}"],"names":[],"mappings":";;;;;;;;;;;EAIA;MAIE,eAAa,MAAmB,EAAE,OAAwB;UAA7C,uBAAA,EAAA,WAAmB;UAAE,wBAAA,EAAA,eAAwB;UACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;UACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;OACxB;MAKD,oBAAI,GAAJ;UACE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;UAC7C,IAAM,MAAM,GAAG,QAAQ,CAAC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;UAGlG,IAAM,QAAQ,GAAG,WAAW,KAAK,MAAM,GAAM,SAAS,UAAK,EAAE,CAAC,QAAU,GAAG,KAAG,SAAS,GAAG,EAAE,CAAC,QAAU,CAAC;UAGxG,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;OACxB,CAAC,CAAC;EACL;;;;"} \ No newline at end of file +{"version":3,"file":"vue-baidu-analytics.js","sources":["../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/modules/getVueVersion.ts","../src/modules/getRouterMode.ts","../src/main.ts"],"sourcesContent":["/** \n * 定义基础配置\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\n */\nclass BAIDU {\n siteId: string;\n isDebug: boolean;\n\n constructor (siteId: string = '', isDebug: boolean = false) {\n this.siteId = siteId;\n this.isDebug = isDebug;\n }\n\n /** \n * 初始化\n */\n init () {\n window._hmt = window._hmt ? window._hmt : [];\n const SCRIPT = document.createElement('script');\n SCRIPT['async'] = true;\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`;\n document.querySelector('head').appendChild(SCRIPT);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`);\n }\n }\n\n /** \n * 设置要响应的站点\n */\n setAccount () {\n window._hmt.push(['_setAccount', this.siteId]);\n }\n\n /** \n * 提交PV、UV\n */\n trackPageview (pageUrl: string) {\n // 如果页面链接没传或者无效链接,则默认为根域名\n if ( !pageUrl || typeof pageUrl !== 'string' ) {\n pageUrl = '/';\n }\n\n // 如果页面链接带上了域名,则需要过滤掉\n if ( pageUrl.includes('http') ) {\n const PAGE_CUT = pageUrl.split('/');\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`;\n pageUrl = pageUrl.replace(HOST_NAME, '');\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackPageview', pageUrl]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`);\n }\n }\n\n /** \n * 提交点击事件\n */\n trackEvent (category: string, action: string, label: string, value: number) {\n // 前两个是必填项\n if ( typeof category !== 'string' || typeof action !== 'string' || !category || !action ) {\n throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.');\n return false;\n }\n\n // 重置一些无效的默认值\n if ( !label || typeof label !== 'string' ) {\n label = '';\n }\n\n if ( !Number(value) ) {\n value = 1;\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackEvent', category, action, label, value]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`);\n }\n }\n}\n\nexport default BAIDU;","import BAIDU from '@m/baidu'\n\n/** \n * 定义推送操作\n */\nclass PushBAIDU {\n siteIdList: string[];\n isDebug: boolean;\n\n constructor (siteIdList: string[], isDebug: boolean) {\n this.siteIdList = siteIdList;\n this.isDebug = isDebug;\n }\n\n /** \n * 批量部署站点\n */\n init () {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.init();\n });\n }\n\n /** \n * 批量提交pv上报\n */\n pv (pageUrl: string) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackPageview(pageUrl);\n });\n }\n\n /** \n * 批量提交事件上报\n */\n event (category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackEvent(category, action, label, value);\n });\n }\n\n}\n\nexport default PushBAIDU;","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;","/** \r\n * 获取Vue的版本\r\n * @param {number} vueVersion - vue版本号,2=Vue2.x, 3=Vue3.x\r\n * @param {object} router - vue路由\r\n * @return hash=hash模式、history=history模式\r\n */\r\nconst getRouterMode = (vueVersion: number, router: any): string => {\r\n let mode: string = 'history';\r\n\r\n // 2.x直接读取mode即可\r\n if ( vueVersion === 2 ) {\r\n mode = router.mode;\r\n }\r\n\r\n // 3.x需要判断一下\r\n if ( vueVersion === 3 ) {\r\n const BASE: string = router.options.history.base || '';\r\n if ( BASE.includes('#') ) {\r\n mode = 'hash';\r\n }\r\n }\r\n \r\n return mode;\r\n}\r\n\r\nexport default getRouterMode;","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\nimport getRouterMode from '@m/getRouterMode'\n\n/** \n * 定义插件\n */\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\n\n /** \n * 一些环境和参数的检查\n */\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\n return false;\n }\n\n if ( !router ) {\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\n }\n\n if ( !siteIdList ) {\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.');\n }\n\n /** \n * 挂载推送的方法\n */\n const pushBAIDU: any = new PushBAIDU(siteIdList, isDebug);\n \n // 获取Vue版本(获取失败则默认为2)\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\n\n // 2.x可以直接挂载到原型上\n if ( VUE_VERSION === 2 ) {\n Vue.prototype.$pushBAIDU = pushBAIDU;\n }\n\n // 3.x必须使用这个方式来挂载\n if ( VUE_VERSION === 3 ) {\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\n }\n\n /** \n * 部署站点并初始化\n */\n if ( siteIdList ) {\n pushBAIDU.init();\n }\n\n /** \n * 路由切换时执行PV上报\n */\n router.afterEach( (to: To) => {\n // 根据Vue版本获取路由模式\n const ROUTER_MODE: string = getRouterMode(VUE_VERSION, router);\n \n // 获取页面的url信息\n const PAGE_PATH_DIR_COUNT: number = window.location.pathname.split('/').length;\n const PAGE_PATH: string = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/');\n\n // 根据路由模式生成要上报的链接\n const PAGE_URL: string = ROUTER_MODE === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`;\n \n // 上报数据\n pushBAIDU.pv(PAGE_URL);\n });\n}"],"names":[],"mappings":";;;;;;;;;;;EAIA;MAIE,eAAa,MAAmB,EAAE,OAAwB;UAA7C,uBAAA,EAAA,WAAmB;UAAE,wBAAA,EAAA,eAAwB;UACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;UACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;OACxB;MAKD,oBAAI,GAAJ;UACE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;UAC7C,IAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;UAChD,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;UACvB,MAAM,CAAC,KAAK,CAAC,GAAG,gCAA8B,IAAI,CAAC,MAAQ,CAAC;UAC5D,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;UAEnD,IAAK,IAAI,CAAC,OAAO,EAAG;cAClB,OAAO,CAAC,GAAG,CAAC,yDAAuD,IAAI,CAAC,MAAQ,CAAC,CAAC;WACnF;OACF;MAKD,0BAAU,GAAV;UACE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAA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;OAC3G;MAKD,IAAM,SAAS,GAAQ,IAAI,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;MAG1D,IAAM,WAAW,GAAW,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;MAGpD,IAAK,WAAW,KAAK,CAAC,EAAG;UACvB,GAAG,CAAC,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC;OACtC;MAGD,IAAK,WAAW,KAAK,CAAC,EAAG;UACvB,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,UAAU,GAAG,SAAS,CAAC;OACpD;MAKD,IAAK,UAAU,EAAG;UAChB,SAAS,CAAC,IAAI,EAAE,CAAC;OAClB;MAKD,MAAM,CAAC,SAAS,CAAE,UAAC,EAAM;UAEvB,IAAM,WAAW,GAAW,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;UAG/D,IAAM,mBAAmB,GAAW,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;UAC/E,IAAM,SAAS,GAAW,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;UAG1G,IAAM,QAAQ,GAAW,WAAW,KAAK,MAAM,GAAM,SAAS,UAAK,EAAE,CAAC,QAAU,GAAG,KAAG,SAAS,GAAG,EAAE,CAAC,QAAU,CAAC;UAGhH,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;OACxB,CAAC,CAAC;EACL;;;;"} \ No newline at end of file diff --git a/dist/vue-baidu-analytics.min.js.map b/dist/vue-baidu-analytics.min.js.map index a861687..3c06e17 100644 --- a/dist/vue-baidu-analytics.min.js.map +++ b/dist/vue-baidu-analytics.min.js.map @@ -1 +1 @@ -{"version":3,"file":"vue-baidu-analytics.min.js","sources":["../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/main.ts","../src/modules/getVueVersion.ts","../src/modules/getRouterMode.ts"],"sourcesContent":["/** \n * 定义基础配置\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\n */\nclass BAIDU {\n siteId: string;\n isDebug: boolean;\n\n constructor (siteId: string = '', isDebug: boolean = false) {\n this.siteId = siteId;\n this.isDebug = isDebug;\n }\n\n /** \n * 初始化\n */\n init () {\n window._hmt = window._hmt ? window._hmt : [];\n const SCRIPT = document.createElement('script');\n SCRIPT['async'] = true;\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`;\n document.querySelector('head').appendChild(SCRIPT);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`);\n }\n }\n\n /** \n * 设置要响应的站点\n */\n setAccount () {\n window._hmt.push(['_setAccount', this.siteId]);\n }\n\n /** \n * 提交PV、UV\n */\n trackPageview (pageUrl: string) {\n // 如果页面链接没传或者无效链接,则默认为根域名\n if ( !pageUrl || typeof pageUrl !== 'string' ) {\n pageUrl = '/';\n }\n\n // 如果页面链接带上了域名,则需要过滤掉\n if ( pageUrl.includes('http') ) {\n const PAGE_CUT = pageUrl.split('/');\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`;\n pageUrl = pageUrl.replace(HOST_NAME, '');\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackPageview', pageUrl]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`);\n }\n }\n\n /** \n * 提交点击事件\n */\n trackEvent (category: string, action: string, label: string, value: number) {\n // 前两个是必填项\n if ( typeof category !== 'string' || typeof action !== 'string' || !category || !action ) {\n throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.');\n return false;\n }\n\n // 重置一些无效的默认值\n if ( !label || typeof label !== 'string' ) {\n label = '';\n }\n\n if ( !Number(value) ) {\n value = 1;\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackEvent', category, action, label, value]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`);\n }\n }\n}\n\nexport default BAIDU;","import BAIDU from '@m/baidu'\n\n/** \n * 定义推送操作\n */\nclass PushBAIDU {\n siteIdList: string[];\n isDebug: boolean;\n\n constructor (siteIdList: string[], isDebug: boolean) {\n this.siteIdList = siteIdList;\n this.isDebug = isDebug;\n }\n\n /** \n * 批量部署站点\n */\n init () {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.init();\n });\n }\n\n /** \n * 批量提交pv上报\n */\n pv (pageUrl: string) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackPageview(pageUrl);\n });\n }\n\n /** \n * 批量提交事件上报\n */\n event (category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackEvent(category, action, label, value);\n });\n }\n\n}\n\nexport default PushBAIDU;","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\nimport getRouterMode from '@m/getRouterMode'\n\n/** \n * 定义插件\n */\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\n\n /** \n * 一些环境和参数的检查\n */\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\n return false;\n }\n\n if ( !router ) {\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\n }\n\n if ( !siteIdList ) {\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.');\n }\n\n /** \n * 挂载推送的方法\n */\n const pushBAIDU: any = new PushBAIDU(siteIdList, isDebug);\n \n // 获取Vue版本(获取失败则默认为2)\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\n\n // 2.x可以直接挂载到原型上\n if ( VUE_VERSION === 2 ) {\n Vue.prototype.$pushBAIDU = pushBAIDU;\n }\n\n // 3.x必须使用这个方式来挂载\n if ( VUE_VERSION === 3 ) {\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\n }\n\n /** \n * 部署站点并初始化\n */\n if ( siteIdList ) {\n pushBAIDU.init();\n }\n\n /** \n * 路由切换时执行PV上报\n */\n router.afterEach( (to: To) => {\n // 根据Vue版本获取路由模式\n const ROUTER_MODE: string = getRouterMode(VUE_VERSION, router);\n \n // 获取页面的url信息\n const PAGE_PATH_DIR_COUNT = window.location.pathname.split('/').length;\n const PAGE_PATH = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/');\n\n // 根据路由模式生成要上报的链接\n const PAGE_URL = ROUTER_MODE === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`;\n \n // 上报数据\n pushBAIDU.pv(PAGE_URL);\n });\n}","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;","/** \r\n * 获取Vue的版本\r\n * @param {number} vueVersion - vue版本号,2=Vue2.x, 3=Vue3.x\r\n * @param {object} router - vue路由\r\n * @return hash=hash模式、history=history模式\r\n */\r\nconst getRouterMode = (vueVersion: number, router: any): string => {\r\n let mode: string = 'history';\r\n\r\n // 2.x直接读取mode即可\r\n if ( vueVersion === 2 ) {\r\n mode = router.mode;\r\n }\r\n\r\n // 3.x需要判断一下\r\n if ( vueVersion === 3 ) {\r\n const BASE: string = router.options.history.base || '';\r\n if ( BASE.includes('#') ) {\r\n mode = 'hash';\r\n }\r\n }\r\n \r\n return mode;\r\n}\r\n\r\nexport default getRouterMode;"],"names":["siteId","isDebug","this","BAIDU","window","_hmt","SCRIPT","document","createElement","querySelector","appendChild","console","log","push","pageUrl","includes","PAGE_CUT","split","HOST_NAME","replace","setAccount","category","action","label","value","Error","Number","siteIdList","PushBAIDU","forEach","_this","init","trackPageview","trackEvent","Vue","_a","router","_b","pushBAIDU","VUE_VERSION","version","String","slice","getVueVersion","prototype","$pushBAIDU","config","globalProperties","afterEach","to","ROUTER_MODE","vueVersion","mode","options","history","base","getRouterMode","PAGE_PATH_DIR_COUNT","location","pathname","length","PAGE_PATH","join","PAGE_URL","fullPath","pv"],"mappings":";;;;;sMAIA,iBAIE,WAAaA,EAAqBC,gBAArBD,mBAAqBC,MAChCC,KAAKF,OAASA,EACdE,KAAKD,QAAUA,EA6EnB,OAvEEE,iBAAA,WACEC,OAAOC,KAAOD,OAAOC,KAAOD,OAAOC,KAAO,GAC1C,IAAMC,EAASC,SAASC,cAAc,UACtCF,EAAc,OAAI,EAClBA,EAAY,IAAI,8BAA8BJ,KAAKF,OACnDO,SAASE,cAAc,QAAQC,YAAYJ,GAEtCJ,KAAKD,SACRU,QAAQC,IAAI,uDAAuDV,KAAKF,SAO5EG,uBAAA,WACEC,OAAOC,KAAKQ,KAAK,CAAC,cAAeX,KAAKF,UAMxCG,0BAAA,SAAeW,GAOb,GALMA,GAA8B,iBAAZA,IACtBA,EAAU,KAIPA,EAAQC,SAAS,QAAU,CAC9B,IAAMC,EAAWF,EAAQG,MAAM,KACzBC,EAAeF,EAAS,QAAOA,EAAS,GAC9CF,EAAUA,EAAQK,QAAQD,EAAW,IAIvChB,KAAKkB,aACLhB,OAAOC,KAAKQ,KAAK,CAAC,iBAAkBC,IAE/BZ,K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,KACxBF,EAAU,GAIqB,OAA5BD,EAAYG,MAAM,EAAG,KACxBF,EAAU,GAGLA,EDUqBG,CAAcT,IAAQ,EAG7B,IAAhBK,IACHL,EAAIU,UAAUC,WAAaP,GAIR,IAAhBC,IACHL,EAAIY,OAAOC,iBAAiBF,WAAaP,GAMtCX,GACHW,EAAUP,OAMZK,EAAOY,WAAW,SAACC,GAEjB,IAAMC,EEhDY,SAACC,EAAoBf,GACzC,IAAIgB,EAAe,UAenB,OAZoB,IAAfD,IACHC,EAAOhB,EAAOgB,MAII,IAAfD,IACkBf,EAAOiB,QAAQC,QAAQC,MAAQ,IAC1CxC,SAAS,OACjBqC,EAAO,QAIJA,EFgCuBI,CAAcjB,EAAaH,GAGjDqB,EAAsBrD,OAAOsD,SAASC,SAAS1C,MAAM,KAAK2C,OAC1DC,EAAYzD,OAAOsD,SAASC,SAAS1C,MAAM,KAAKyB,MAAM,EAAGe,EAAsB,GAAGK,KAAK,KAGvFC,EAA2B,SAAhBb,EAA4BW,OAAcZ,EAAGe,SAAa,GAAGH,EAAYZ,EAAGe,SAG7F1B,EAAU2B,GAAGF"} \ No newline at end of file +{"version":3,"file":"vue-baidu-analytics.min.js","sources":["../src/modules/baidu.ts","../src/modules/pushBAIDU.ts","../src/main.ts","../src/modules/getVueVersion.ts","../src/modules/getRouterMode.ts"],"sourcesContent":["/** \n * 定义基础配置\n * 官方文档 https://tongji.baidu.com/open/api/more?p=guide_overview\n */\nclass BAIDU {\n siteId: string;\n isDebug: boolean;\n\n constructor (siteId: string = '', isDebug: boolean = false) {\n this.siteId = siteId;\n this.isDebug = isDebug;\n }\n\n /** \n * 初始化\n */\n init () {\n window._hmt = window._hmt ? window._hmt : [];\n const SCRIPT = document.createElement('script');\n SCRIPT['async'] = true;\n SCRIPT['src'] = `https://hm.baidu.com/hm.js?${this.siteId}`;\n document.querySelector('head').appendChild(SCRIPT);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] siteId load done.\\nsiteId: ${this.siteId}`);\n }\n }\n\n /** \n * 设置要响应的站点\n */\n setAccount () {\n window._hmt.push(['_setAccount', this.siteId]);\n }\n\n /** \n * 提交PV、UV\n */\n trackPageview (pageUrl: string) {\n // 如果页面链接没传或者无效链接,则默认为根域名\n if ( !pageUrl || typeof pageUrl !== 'string' ) {\n pageUrl = '/';\n }\n\n // 如果页面链接带上了域名,则需要过滤掉\n if ( pageUrl.includes('http') ) {\n const PAGE_CUT = pageUrl.split('/');\n const HOST_NAME = `${PAGE_CUT[0]}//${PAGE_CUT[2]}`;\n pageUrl = pageUrl.replace(HOST_NAME, '');\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackPageview', pageUrl]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track pv done.\\nsiteId: ${this.siteId}\\npageUrl: ${pageUrl}`);\n }\n }\n\n /** \n * 提交点击事件\n */\n trackEvent (category: string, action: string, label: string, value: number) {\n // 前两个是必填项\n if ( typeof category !== 'string' || typeof action !== 'string' || !category || !action ) {\n throw new Error('[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.');\n return false;\n }\n\n // 重置一些无效的默认值\n if ( !label || typeof label !== 'string' ) {\n label = '';\n }\n\n if ( !Number(value) ) {\n value = 1;\n }\n\n // 设置响应id并提交数据\n this.setAccount();\n window._hmt.push(['_trackEvent', category, action, label, value]);\n\n if ( this.isDebug ) {\n console.log(`[vue-baidu-analytics] track event done.\\nsiteId: ${this.siteId}\\ncategory: ${category}\\naction: ${action}\\nlabel: ${label}\\nvalue: ${value}`);\n }\n }\n}\n\nexport default BAIDU;","import BAIDU from '@m/baidu'\n\n/** \n * 定义推送操作\n */\nclass PushBAIDU {\n siteIdList: string[];\n isDebug: boolean;\n\n constructor (siteIdList: string[], isDebug: boolean) {\n this.siteIdList = siteIdList;\n this.isDebug = isDebug;\n }\n\n /** \n * 批量部署站点\n */\n init () {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.init();\n });\n }\n\n /** \n * 批量提交pv上报\n */\n pv (pageUrl: string) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackPageview(pageUrl);\n });\n }\n\n /** \n * 批量提交事件上报\n */\n event (category: string, action: string, label: string, value: number) {\n this.siteIdList.forEach( (siteId: string) => {\n const SITE = new BAIDU(siteId, this.isDebug);\n SITE.trackEvent(category, action, label, value);\n });\n }\n\n}\n\nexport default PushBAIDU;","import PushBAIDU from '@m/pushBAIDU'\nimport getVueVersion from '@m/getVueVersion'\nimport getRouterMode from '@m/getRouterMode'\n\n/** \n * 定义插件\n */\nexport default function install (Vue: Vue, { router, siteIdList, isDebug = false }: Partial) {\n\n /** \n * 一些环境和参数的检查\n */\n if ( typeof document === 'undefined' || typeof window === 'undefined' ) {\n return false;\n }\n\n if ( !router ) {\n throw new Error('[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.');\n }\n\n if ( !siteIdList ) {\n throw new Error('[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics.');\n }\n\n /** \n * 挂载推送的方法\n */\n const pushBAIDU: any = new PushBAIDU(siteIdList, isDebug);\n \n // 获取Vue版本(获取失败则默认为2)\n const VUE_VERSION: number = getVueVersion(Vue) || 2;\n\n // 2.x可以直接挂载到原型上\n if ( VUE_VERSION === 2 ) {\n Vue.prototype.$pushBAIDU = pushBAIDU;\n }\n\n // 3.x必须使用这个方式来挂载\n if ( VUE_VERSION === 3 ) {\n Vue.config.globalProperties.$pushBAIDU = pushBAIDU;\n }\n\n /** \n * 部署站点并初始化\n */\n if ( siteIdList ) {\n pushBAIDU.init();\n }\n\n /** \n * 路由切换时执行PV上报\n */\n router.afterEach( (to: To) => {\n // 根据Vue版本获取路由模式\n const ROUTER_MODE: string = getRouterMode(VUE_VERSION, router);\n \n // 获取页面的url信息\n const PAGE_PATH_DIR_COUNT: number = window.location.pathname.split('/').length;\n const PAGE_PATH: string = window.location.pathname.split('/').slice(0, PAGE_PATH_DIR_COUNT - 1).join('/');\n\n // 根据路由模式生成要上报的链接\n const PAGE_URL: string = ROUTER_MODE === 'hash' ? `${PAGE_PATH}/#${to.fullPath}` : `${PAGE_PATH}${to.fullPath}`;\n \n // 上报数据\n pushBAIDU.pv(PAGE_URL);\n });\n}","/** \r\n * 获取Vue的版本\r\n * @return 2=Vue2.x, 3=Vue3.x\r\n */\r\nconst getVueVersion = (Vue: Vue): number => {\r\n let version: number = 2;\r\n\r\n // 获取Vue的版本号\r\n const VUE_VERSION: string = String(Vue.version);\r\n\r\n // Vue 2.x\r\n if ( VUE_VERSION.slice(0, 2) === '2.' ) {\r\n version = 2; \r\n }\r\n \r\n // Vue 3.x\r\n if ( VUE_VERSION.slice(0, 2) === '3.' ) {\r\n version = 3; \r\n }\r\n \r\n return version;\r\n}\r\n\r\nexport default getVueVersion;","/** \r\n * 获取Vue的版本\r\n * @param {number} vueVersion - vue版本号,2=Vue2.x, 3=Vue3.x\r\n * @param {object} router - vue路由\r\n * @return hash=hash模式、history=history模式\r\n */\r\nconst getRouterMode = (vueVersion: number, router: any): string => {\r\n let mode: string = 'history';\r\n\r\n // 2.x直接读取mode即可\r\n if ( vueVersion === 2 ) {\r\n mode = router.mode;\r\n }\r\n\r\n // 3.x需要判断一下\r\n if ( vueVersion === 3 ) {\r\n const BASE: string = router.options.history.base || '';\r\n if ( BASE.includes('#') ) {\r\n mode = 'hash';\r\n }\r\n }\r\n \r\n return mode;\r\n}\r\n\r\nexport default getRouterMode;"],"names":["siteId","isDebug","this","BAIDU","window","_hmt","SCRIPT","document","createElement","querySelector","appendChild","console","log","push","pageUrl","includes","PAGE_CUT","split","HOST_NAME","replace","setAccount","category","action","label","value","Error","Number","siteIdList","PushBAIDU","forEach","_this","init","trackPageview","trackEvent","Vue","_a","router","_b","pushBAIDU","VUE_VERSION","version","String","slice","getVueVersion","prototype","$pushBAIDU","config","globalProperties","afterEach","to","ROUTER_MODE","vueVersion","mode","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