mirror of
https://github.com/analyticsjs/vue-baidu-analytics.git
synced 2025-04-05 07:52:44 +08:00
feat: now, the vue router is optional
This commit is contained in:
parent
cb18c6892e
commit
69ecd02121
2
dist/main.d.ts
vendored
2
dist/main.d.ts
vendored
@ -22,4 +22,4 @@ export declare function usePush(): {
|
||||
export default function install(
|
||||
Vue: Vue,
|
||||
{ router, siteIdList, isDebug }: Partial<Options>
|
||||
): false | undefined
|
||||
): void
|
||||
|
11
dist/vue-baidu-analytics.js
vendored
11
dist/vue-baidu-analytics.js
vendored
@ -246,14 +246,7 @@
|
||||
/**
|
||||
* 一些环境和参数的检查
|
||||
*/
|
||||
if (typeof document === 'undefined' || typeof window === 'undefined') {
|
||||
return false
|
||||
}
|
||||
if (!router) {
|
||||
throw new Error(
|
||||
'[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.'
|
||||
)
|
||||
}
|
||||
if (typeof document === 'undefined' || typeof window === 'undefined') return
|
||||
if (!siteIdList) {
|
||||
throw new Error(
|
||||
'[vue-baidu-analytics] Missing tracking domain ID, add at least one of baidu analytics siteId.'
|
||||
@ -286,6 +279,7 @@
|
||||
/**
|
||||
* 路由切换时执行PV上报
|
||||
*/
|
||||
if (router) {
|
||||
router.afterEach(function () {
|
||||
// 获取要上报的链接(当前版本不需要拼接了)
|
||||
var PAGE_URL = window.location.href
|
||||
@ -293,6 +287,7 @@
|
||||
pushBAIDU.pv(PAGE_URL)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = install
|
||||
exports.usePush = usePush
|
||||
|
2
dist/vue-baidu-analytics.js.map
vendored
2
dist/vue-baidu-analytics.js.map
vendored
File diff suppressed because one or more lines are too long
25
dist/vue-baidu-analytics.min.js
vendored
25
dist/vue-baidu-analytics.min.js
vendored
@ -16,21 +16,7 @@
|
||||
)
|
||||
})(this, function (t) {
|
||||
'use strict'
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */ var e =
|
||||
(function () {
|
||||
var e = (function () {
|
||||
function t(t, e) {
|
||||
void 0 === t && (t = ''),
|
||||
void 0 === e && (e = !1),
|
||||
@ -139,12 +125,7 @@
|
||||
s = e.siteIdList,
|
||||
r = e.isDebug,
|
||||
a = void 0 !== r && r
|
||||
if ('undefined' == typeof document || 'undefined' == typeof window)
|
||||
return !1
|
||||
if (!o)
|
||||
throw new Error(
|
||||
'[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.'
|
||||
)
|
||||
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.'
|
||||
@ -169,10 +150,12 @@
|
||||
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 {
|
||||
|
2
dist/vue-baidu-analytics.min.js.map
vendored
2
dist/vue-baidu-analytics.min.js.map
vendored
File diff suppressed because one or more lines are too long
12
src/main.ts
12
src/main.ts
@ -49,15 +49,7 @@ export default function install(
|
||||
/**
|
||||
* 一些环境和参数的检查
|
||||
*/
|
||||
if (typeof document === 'undefined' || typeof window === 'undefined') {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!router) {
|
||||
throw new Error(
|
||||
'[vue-baidu-analytics] Must pass a Vue-Router instance to vue-baidu-analytics.'
|
||||
)
|
||||
}
|
||||
if (typeof document === 'undefined' || typeof window === 'undefined') return
|
||||
|
||||
if (!siteIdList) {
|
||||
throw new Error(
|
||||
@ -95,6 +87,7 @@ export default function install(
|
||||
/**
|
||||
* 路由切换时执行PV上报
|
||||
*/
|
||||
if (router) {
|
||||
router.afterEach(() => {
|
||||
// 获取要上报的链接(当前版本不需要拼接了)
|
||||
const PAGE_URL: string = window.location.href
|
||||
@ -102,4 +95,5 @@ export default function install(
|
||||
// 上报数据
|
||||
pushBAIDU.pv(PAGE_URL)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user