diff --git a/packages/uni-stat/dist/uni-cloud-stat.cjs.js b/packages/uni-stat/dist/uni-cloud-stat.cjs.js index 2847fb632456f5355b6524d9caae5e7a3abbed30..5daef9e39fabf64c55440b6732db99a92db6c849 100644 --- a/packages/uni-stat/dist/uni-cloud-stat.cjs.js +++ b/packages/uni-stat/dist/uni-cloud-stat.cjs.js @@ -1,11 +1,5 @@ 'use strict'; -var Vue = require('vue'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); - /** * 获取系统信息 */ @@ -1078,18 +1072,15 @@ class Report { } } -let vue = (Vue__default["default"].default || Vue__default["default"]); - class Stat extends Report { static getInstance() { - if (!vue.instance) { - vue.instance = new Stat(); + if (!uni.__stat_instance) { + uni.__stat_instance = new Stat(); } - return vue.instance + return uni.__stat_instance } constructor() { super(); - this.instance = null; } /** @@ -1235,45 +1226,37 @@ const lifecycle = { }; -function main() { - // console.log('--- 统计开启') +function main() { + // console.log('--- 统计开启') if (process.env.NODE_ENV === 'development') { uni.report = function(type, options) {}; } else { - // #ifdef VUE3 - uni.onCreateVueApp((app) => { - app.mixin(lifecycle); - uni.report = function(type, options) { - stat.sendEvent(type, options); - }; - }); - uni.onAppLaunch((options) => { - stat.launch(options); - // 小程序平台此时也无法获取getApp,统一在options中传递一个app mixin对象 - options.app.mixin(lifecycle); - uni.report = function (type, options) { - stat.sendEvent(type, options); - }; - }); - - if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { - uni.onAppHide(() => { - stat.appHide(get_page_vm()); - }); - uni.onAppShow(() => { - stat.appShow(get_page_vm()); - }); - } - // #endif - - // #ifndef VUE3 - const Vue = require('vue'); - (Vue.default || Vue).mixin(lifecycle); - uni.report = function(type, options) { - stat.sendEvent(type, options); - }; - // #endif - } + // #ifdef VUE3 + uni.onCreateVueApp((app) => { + app.mixin(lifecycle); + uni.report = function(type, options) { + stat.sendEvent(type, options); + }; + }); + + if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { + uni.onAppHide(() => { + stat.appHide(get_page_vm()); + }); + uni.onAppShow(() => { + stat.appShow(get_page_vm()); + }); + } + // #endif + + // #ifndef VUE3 + const Vue = require('vue'); + (Vue.default || Vue).mixin(lifecycle); + uni.report = function(type, options) { + stat.sendEvent(type, options); + }; + // #endif + } } main(); diff --git a/packages/uni-stat/dist/uni-cloud-stat.es.js b/packages/uni-stat/dist/uni-cloud-stat.es.js index e45529dd11b0bbcc863a4149847a1b7172585e51..ce737bbedc3bb66adc9b7a90f316324f75faa23e 100644 --- a/packages/uni-stat/dist/uni-cloud-stat.es.js +++ b/packages/uni-stat/dist/uni-cloud-stat.es.js @@ -1,5 +1,3 @@ -import Vue from 'vue'; - /** * 获取系统信息 */ @@ -1072,18 +1070,15 @@ class Report { } } -let vue = (Vue.default || Vue); - class Stat extends Report { static getInstance() { - if (!vue.instance) { - vue.instance = new Stat(); + if (!uni.__stat_instance) { + uni.__stat_instance = new Stat(); } - return vue.instance + return uni.__stat_instance } constructor() { super(); - this.instance = null; } /** @@ -1229,45 +1224,37 @@ const lifecycle = { }; -function main() { - // console.log('--- 统计开启') +function main() { + // console.log('--- 统计开启') if (process.env.NODE_ENV === 'development') { uni.report = function(type, options) {}; } else { - // #ifdef VUE3 - uni.onCreateVueApp((app) => { - app.mixin(lifecycle); - uni.report = function(type, options) { - stat.sendEvent(type, options); - }; - }); - uni.onAppLaunch((options) => { - stat.launch(options); - // 小程序平台此时也无法获取getApp,统一在options中传递一个app mixin对象 - options.app.mixin(lifecycle); - uni.report = function (type, options) { - stat.sendEvent(type, options); - }; - }); - - if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { - uni.onAppHide(() => { - stat.appHide(get_page_vm()); - }); - uni.onAppShow(() => { - stat.appShow(get_page_vm()); - }); - } - // #endif - - // #ifndef VUE3 - const Vue = require('vue'); - (Vue.default || Vue).mixin(lifecycle); - uni.report = function(type, options) { - stat.sendEvent(type, options); - }; - // #endif - } + // #ifdef VUE3 + uni.onCreateVueApp((app) => { + app.mixin(lifecycle); + uni.report = function(type, options) { + stat.sendEvent(type, options); + }; + }); + + if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { + uni.onAppHide(() => { + stat.appHide(get_page_vm()); + }); + uni.onAppShow(() => { + stat.appShow(get_page_vm()); + }); + } + // #endif + + // #ifndef VUE3 + const Vue = require('vue'); + (Vue.default || Vue).mixin(lifecycle); + uni.report = function(type, options) { + stat.sendEvent(type, options); + }; + // #endif + } } main(); diff --git a/packages/uni-stat/dist/uni-stat.cjs.js b/packages/uni-stat/dist/uni-stat.cjs.js index c8b340aac146b8cb1f551003ab9ba267143d0c89..cdbd785a45d932f534bfe85466ea17de9751bdc0 100644 --- a/packages/uni-stat/dist/uni-stat.cjs.js +++ b/packages/uni-stat/dist/uni-stat.cjs.js @@ -1,11 +1,5 @@ 'use strict'; -var Vue = require('vue'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue); - /** * 获取系统信息 */ @@ -1093,18 +1087,15 @@ class Report { } } -let vue = (Vue__default["default"].default || Vue__default["default"]); - class Stat extends Report { static getInstance() { - if (!vue.instance) { - vue.instance = new Stat(); + if (!uni.__stat_instance) { + uni.__stat_instance = new Stat(); } - return vue.instance + return uni.__stat_instance } constructor() { super(); - this.instance = null; } /** @@ -1250,45 +1241,37 @@ const lifecycle = { }; -function main() { - // console.log('--- 统计开启') +function main() { + // console.log('--- 统计开启') if (process.env.NODE_ENV === 'development') { uni.report = function(type, options) {}; } else { - // #ifdef VUE3 - uni.onCreateVueApp((app) => { - app.mixin(lifecycle); - uni.report = function(type, options) { - stat.sendEvent(type, options); - }; - }); - uni.onAppLaunch((options) => { - stat.launch(options); - // 小程序平台此时也无法获取getApp,统一在options中传递一个app mixin对象 - options.app.mixin(lifecycle); - uni.report = function (type, options) { - stat.sendEvent(type, options); - }; - }); - - if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { - uni.onAppHide(() => { - stat.appHide(get_page_vm()); - }); - uni.onAppShow(() => { - stat.appShow(get_page_vm()); - }); - } - // #endif - - // #ifndef VUE3 - const Vue = require('vue'); - (Vue.default || Vue).mixin(lifecycle); - uni.report = function(type, options) { - stat.sendEvent(type, options); - }; - // #endif - } + // #ifdef VUE3 + uni.onCreateVueApp((app) => { + app.mixin(lifecycle); + uni.report = function(type, options) { + stat.sendEvent(type, options); + }; + }); + + if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { + uni.onAppHide(() => { + stat.appHide(get_page_vm()); + }); + uni.onAppShow(() => { + stat.appShow(get_page_vm()); + }); + } + // #endif + + // #ifndef VUE3 + const Vue = require('vue'); + (Vue.default || Vue).mixin(lifecycle); + uni.report = function(type, options) { + stat.sendEvent(type, options); + }; + // #endif + } } main(); diff --git a/packages/uni-stat/dist/uni-stat.es.js b/packages/uni-stat/dist/uni-stat.es.js index 66e182447b71799c17091737f6660f99bb3fa484..5b8a43f6c42d9c26e79880d97fc2d8aa45342ed3 100644 --- a/packages/uni-stat/dist/uni-stat.es.js +++ b/packages/uni-stat/dist/uni-stat.es.js @@ -1,5 +1,3 @@ -import Vue from 'vue'; - /** * 获取系统信息 */ @@ -1087,18 +1085,15 @@ class Report { } } -let vue = (Vue.default || Vue); - class Stat extends Report { static getInstance() { - if (!vue.instance) { - vue.instance = new Stat(); + if (!uni.__stat_instance) { + uni.__stat_instance = new Stat(); } - return vue.instance + return uni.__stat_instance } constructor() { super(); - this.instance = null; } /** @@ -1244,45 +1239,37 @@ const lifecycle = { }; -function main() { - // console.log('--- 统计开启') +function main() { + // console.log('--- 统计开启') if (process.env.NODE_ENV === 'development') { uni.report = function(type, options) {}; } else { - // #ifdef VUE3 - uni.onCreateVueApp((app) => { - app.mixin(lifecycle); - uni.report = function(type, options) { - stat.sendEvent(type, options); - }; - }); - uni.onAppLaunch((options) => { - stat.launch(options); - // 小程序平台此时也无法获取getApp,统一在options中传递一个app mixin对象 - options.app.mixin(lifecycle); - uni.report = function (type, options) { - stat.sendEvent(type, options); - }; - }); - - if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { - uni.onAppHide(() => { - stat.appHide(get_page_vm()); - }); - uni.onAppShow(() => { - stat.appShow(get_page_vm()); - }); - } - // #endif - - // #ifndef VUE3 - const Vue = require('vue'); - (Vue.default || Vue).mixin(lifecycle); - uni.report = function(type, options) { - stat.sendEvent(type, options); - }; - // #endif - } + // #ifdef VUE3 + uni.onCreateVueApp((app) => { + app.mixin(lifecycle); + uni.report = function(type, options) { + stat.sendEvent(type, options); + }; + }); + + if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { + uni.onAppHide(() => { + stat.appHide(get_page_vm()); + }); + uni.onAppShow(() => { + stat.appShow(get_page_vm()); + }); + } + // #endif + + // #ifndef VUE3 + const Vue = require('vue'); + (Vue.default || Vue).mixin(lifecycle); + uni.report = function(type, options) { + stat.sendEvent(type, options); + }; + // #endif + } } main(); diff --git a/packages/uni-stat/package.json b/packages/uni-stat/package.json index 2f1f681eaa18c7a3c59754dfdbb526753980f771..fdbf1caea823256e13eb02c67c84d971bdc88567 100644 --- a/packages/uni-stat/package.json +++ b/packages/uni-stat/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-stat", - "version": "3.0.0-alpha-3040020220301001", + "version": "3.0.0-alpha-3040320220325006", "description": "@dcloudio/uni-stat", "main": "dist/uni-stat.es.js", "module": "dist/uni-stat.es.js", @@ -20,7 +20,7 @@ }, "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da", "dependencies": { - "@dcloudio/uni-cli-shared": "3.0.0-alpha-3040020220301001", + "@dcloudio/uni-cli-shared": "3.0.0-alpha-3040320220325006", "debug": "^4.3.3" }, "devDependencies": { diff --git a/packages/uni-stat/src/core/stat.js b/packages/uni-stat/src/core/stat.js index 66f981978be497fdd84d400f897d84ec7ce2b9b9..58cd9e36c087c65f282ff914218841d914a37cf1 100644 --- a/packages/uni-stat/src/core/stat.js +++ b/packages/uni-stat/src/core/stat.js @@ -1,6 +1,5 @@ import Report from './report.js' -import Vue from 'vue' -let vue = (Vue.default || Vue) + import { set_page_residence_time } from '../utils/pageTime.js' @@ -11,14 +10,13 @@ import { class Stat extends Report { static getInstance() { - if (!vue.instance) { - vue.instance = new Stat() + if (!uni.__stat_instance) { + uni.__stat_instance = new Stat() } - return vue.instance + return uni.__stat_instance } constructor() { super() - this.instance = null } /** diff --git a/packages/uni-stat/src/index.js b/packages/uni-stat/src/index.js index ee578875429a1ca5ed5e4d84641e44c08ebac27e..bb822e4dca7eae2ffbbdbf630d7382fca5b46fcd 100644 --- a/packages/uni-stat/src/index.js +++ b/packages/uni-stat/src/index.js @@ -1,7 +1,7 @@ import { - get_platform_name, + get_platform_name, get_page_vm -} from './utils/pageInfo.js' +} from './utils/pageInfo.js' import Stat from './core/stat.js' const stat = Stat.getInstance() @@ -45,45 +45,37 @@ const lifecycle = { } -function main() { - // console.log('--- 统计开启') +function main() { + // console.log('--- 统计开启') if (process.env.NODE_ENV === 'development') { uni.report = function(type, options) {} } else { - // #ifdef VUE3 - uni.onCreateVueApp((app) => { - app.mixin(lifecycle) - uni.report = function(type, options) { - stat.sendEvent(type, options) - } - }) - uni.onAppLaunch((options) => { - stat.launch(options) - // 小程序平台此时也无法获取getApp,统一在options中传递一个app mixin对象 - options.app.mixin(lifecycle) - uni.report = function (type, options) { - stat.sendEvent(type, options) - } - }) - - if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { - uni.onAppHide(() => { - stat.appHide(get_page_vm()); - }) - uni.onAppShow(() => { - stat.appShow(get_page_vm()); - }) - } - // #endif - - // #ifndef VUE3 - const Vue = require('vue'); - (Vue.default || Vue).mixin(lifecycle); - uni.report = function(type, options) { - stat.sendEvent(type, options); - }; - // #endif - } + // #ifdef VUE3 + uni.onCreateVueApp((app) => { + app.mixin(lifecycle) + uni.report = function(type, options) { + stat.sendEvent(type, options) + } + }) + + if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') { + uni.onAppHide(() => { + stat.appHide(get_page_vm()); + }) + uni.onAppShow(() => { + stat.appShow(get_page_vm()); + }) + } + // #endif + + // #ifndef VUE3 + const Vue = require('vue'); + (Vue.default || Vue).mixin(lifecycle); + uni.report = function(type, options) { + stat.sendEvent(type, options); + }; + // #endif + } } -main() +main()