From d29aafefb552d5f726934bf1b7500366b23ba0f4 Mon Sep 17 00:00:00 2001 From: mehaotian <490272692@qq.com> Date: Thu, 31 Mar 2022 17:19:46 +0800 Subject: [PATCH] chore(uni-stat): update package.json --- packages/uni-stat/dist/uni-cloud-stat.cjs.js | 79 ++++++++------------ packages/uni-stat/dist/uni-cloud-stat.es.js | 75 ++++++++----------- packages/uni-stat/dist/uni-stat.cjs.js | 79 ++++++++------------ packages/uni-stat/dist/uni-stat.es.js | 75 ++++++++----------- packages/uni-stat/package.json | 4 +- packages/uni-stat/src/core/stat.js | 10 +-- packages/uni-stat/src/index.js | 70 ++++++++--------- 7 files changed, 161 insertions(+), 231 deletions(-) diff --git a/packages/uni-stat/dist/uni-cloud-stat.cjs.js b/packages/uni-stat/dist/uni-cloud-stat.cjs.js index 2847fb632..5daef9e39 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 e45529dd1..ce737bbed 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 c8b340aac..cdbd785a4 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 66e182447..5b8a43f6c 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 2f1f681ea..fdbf1caea 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 66f981978..58cd9e36c 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 ee5788754..bb822e4dc 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() -- GitLab