From 4a8a5d3e27c5a990331b9218970cd20d89f5dd6f Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Wed, 21 Aug 2019 14:30:41 +0800 Subject: [PATCH] fix(stat): improve UNI_USING_STAT logic --- packages/vue-cli-plugin-uni/lib/env.js | 32 +++++++++++++----------- packages/vue-cli-plugin-uni/package.json | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index 01af2beee..a24dfee16 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -65,21 +65,6 @@ process.UNI_STAT_CONFIG = { appid: manifestJsonObj.appid } -const uniStatistics = Object.assign( - manifestJsonObj.uniStatistics || {}, - platformOptions.uniStatistics || {} -) - -if (uniStatistics.enable !== false) { - if (process.UNI_STAT_CONFIG.appid) { - process.env.UNI_USING_STAT = true - } else { - console.log() - console.warn(`当前应用未配置Appid,无法使用uni统计,详情参考:https://ask.dcloud.net.cn/article/36303`) - console.log() - } -} - // fixed by hxy alpha 版默认启用新的框架 if (isInHBuilderXAlpha) { if (!platformOptions.hasOwnProperty('usingComponents')) { @@ -154,6 +139,23 @@ if (platformOptions.usingComponents === true) { } } +if (process.env.UNI_USING_COMPONENTS || process.env.UNI_PLATFORM === 'h5') { // 自定义组件模式或 h5 平台 + const uniStatistics = Object.assign( + manifestJsonObj.uniStatistics || {}, + platformOptions.uniStatistics || {} + ) + + if (uniStatistics.enable !== false) { + if (process.UNI_STAT_CONFIG.appid) { + process.env.UNI_USING_STAT = true + } else { + console.log() + console.warn(`当前应用未配置Appid,无法使用uni统计,详情参考:https://ask.dcloud.net.cn/article/36303`) + console.log() + } + } +} + if (process.env.UNI_USING_COMPONENTS) { // 是否启用分包优化 if (platformOptions.optimization) { if ( diff --git a/packages/vue-cli-plugin-uni/package.json b/packages/vue-cli-plugin-uni/package.json index aef6b5624..bce7a7673 100644 --- a/packages/vue-cli-plugin-uni/package.json +++ b/packages/vue-cli-plugin-uni/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/vue-cli-plugin-uni", - "version": "0.9.524", + "version": "0.9.525", "description": "uni-app plugin for vue-cli 3", "main": "index.js", "scripts": { -- GitLab