/*! * name: vue-baidu-analytics * version: v2.2.0 * author: chengpeiquan */ !(function (t, e) { 'object' == typeof exports && 'undefined' != typeof module ? e(exports) : 'function' == typeof define && define.amd ? define(['exports'], e) : e( ((t = 'undefined' != typeof globalThis ? globalThis : t || self).baiduAnalytics = {}) ) })(this, function (t) { 'use strict' var e = (function () { function t(t, e) { void 0 === t && (t = ''), void 0 === e && (e = !1), (this.siteId = t), (this.isDebug = e) } return ( (t.prototype.init = function () { var t window._hmt = window._hmt ? window._hmt : [] var e = document.createElement('script') ;(e.async = !0), (e.src = 'https://hm.baidu.com/hm.js?' + this.siteId), null === (t = document.querySelector('head')) || void 0 === t || t.appendChild(e), 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.startsWith('http')) ) { var e = t.split('/'), i = e[0] + '//' + e[2] t = t.replace(i, '') } 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, e, i, n) { if ('string' != typeof t || 'string' != typeof e || !t || !e) throw new Error( '[vue-baidu-analytics] Missing necessary category and operation information, and must be of type string.' ) ;(i && 'string' == typeof i) || (i = ''), Number(n) || (n = 1), this.setAccount(), window._hmt.push(['_trackEvent', t, e, i, n]), this.isDebug && console.log( '[vue-baidu-analytics] track event done.\nsiteId: ' + this.siteId + '\ncategory: ' + t + '\naction: ' + e + '\nlabel: ' + i + '\nvalue: ' + n ) }), t ) })(), i = (function () { function t(t, e) { ;(this.siteIdList = (function (t, e, i) { if (i || 2 === arguments.length) for (var n, o = 0, s = e.length; o < s; o++) (!n && o in e) || (n || (n = Array.prototype.slice.call(e, 0, o)), (n[o] = e[o])) return t.concat(n || e) })([], t)), (this.isDebug = e) } return ( (t.prototype.init = function () { var t = this this.siteIdList.forEach(function (i) { new e(i, t.isDebug).init() }) }), (t.prototype.pv = function (t) { var i = this this.siteIdList.forEach(function (n) { new e(n, i.isDebug).trackPageview(t) }) }), (t.prototype.event = function (t, i, n, o) { var s = this this.siteIdList.forEach(function (r) { new e(r, s.isDebug).trackEvent(t, i, n, o) }) }), t ) })(), n = { pushBAIDU: {} } ;(t.default = function (t, e) { var o = e.router, s = e.siteIdList, r = e.isDebug, a = void 0 !== r && r if ('undefined' != typeof document && 'undefined' != typeof window) { if (!s) throw new Error( '[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics siteId.' ) var u = new i(s, a) switch ( ((n.pushBAIDU = u), (function (t) { var e = 2, i = String(t.version) return ( '2.' === i.slice(0, 2) && (e = 2), '3.' === i.slice(0, 2) && (e = 3), e ) })(t) || 2) ) { case 2: t.prototype.$pushBAIDU = u break case 3: t.config.globalProperties.$pushBAIDU = u } s && Array.isArray(s) && u.init(), o && o.afterEach(function () { var t = window.location.href u.pv(t) }) } }), (t.usePush = function () { return { pv: function (t) { return n.pushBAIDU.pv(t) }, event: function (t, e, i, o) { return n.pushBAIDU.event(t, e, i, o) }, } }), Object.defineProperty(t, '__esModule', { value: !0 }) }) //# sourceMappingURL=vue-baidu-analytics.min.js.map