diff --git a/packages/uni-stat/lib/uni.plugin.js b/packages/uni-stat/lib/uni.plugin.js index 7a9b9eba531a5ab080a5f6180d4767f36454e6d4..5ae74ceda17a75d6e41e5a9cc7d98bba9749ddf7 100644 --- a/packages/uni-stat/lib/uni.plugin.js +++ b/packages/uni-stat/lib/uni.plugin.js @@ -55,32 +55,34 @@ var index = () => [ // ssr 时不开启 if (!uniCliShared.isSsr(env.command, config)) { const statConfig = uniCliShared.getUniStatistics(inputDir, platform); - const uniCloudConfig = statConfig.uniCloud || {}; - statVersion = statConfig.version === '2' ? '2' : '1'; isEnable = statConfig.enable === true; - process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig); - process.env.UNI_STAT_DEBUG = statConfig.debug ? 'true' : 'false'; - if (process.env.NODE_ENV === 'production') { - const manifestJson = uniCliShared.parseManifestJsonOnce(inputDir); - if (!manifestJson.appid) { - uniStatLog(uniCliShared.M['stat.warn.appid']); - isEnable = false; - } - else { - if (!statConfig.version) { - uniStatLog(uniCliShared.M['stat.warn.version']); + if (isEnable) { + const uniCloudConfig = statConfig.uniCloud || {}; + statVersion = statConfig.version === '2' ? '2' : '1'; + process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig); + process.env.UNI_STAT_DEBUG = statConfig.debug ? 'true' : 'false'; + if (process.env.NODE_ENV === 'production') { + const manifestJson = uniCliShared.parseManifestJsonOnce(inputDir); + if (!manifestJson.appid) { + uniStatLog(uniCliShared.M['stat.warn.appid']); + isEnable = false; } - if (isEnable) { - uniStatLog(`已开启 uni统计${statVersion}.0 版本`); + else { + if (!statConfig.version) { + uniStatLog(uniCliShared.M['stat.warn.version']); + } + else { + uniStatLog(`已开启 uni统计${statVersion}.0 版本`); + } } } - } - else { - if (isEnable) { + else { if (!statConfig.version) { uniStatLog(uniCliShared.M['stat.warn.version']); } - uniStatLog(uniCliShared.M['stat.warn.tip'].replace('{version}', `${statVersion}.0`)); + else { + uniStatLog(uniCliShared.M['stat.warn.tip'].replace('{version}', `${statVersion}.0`)); + } } } debug__default["default"]('uni:stat')('isEnable', isEnable); diff --git a/packages/uni-stat/src/plugin/index.ts b/packages/uni-stat/src/plugin/index.ts index c63748e89e88738d2df92da0fd7a9f9a5c78085f..b430fdd30d804bfde1bd6cd6f78ca05f33a7e1ff 100644 --- a/packages/uni-stat/src/plugin/index.ts +++ b/packages/uni-stat/src/plugin/index.ts @@ -51,33 +51,34 @@ export default () => [ // ssr 时不开启 if (!isSsr(env.command, config)) { const statConfig = getUniStatistics(inputDir, platform) - const uniCloudConfig = statConfig.uniCloud || {} - statVersion = statConfig.version === '2' ? '2' : '1' isEnable = statConfig.enable === true - process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig) - process.env.UNI_STAT_DEBUG = statConfig.debug ? 'true' : 'false' - if (process.env.NODE_ENV === 'production') { - const manifestJson = parseManifestJsonOnce(inputDir) - if (!manifestJson.appid) { - uniStatLog(M['stat.warn.appid']) - isEnable = false - } else { - if (!statConfig.version) { - uniStatLog(M['stat.warn.version']) - } - if (isEnable) { - uniStatLog(`已开启 uni统计${statVersion}.0 版本`) + if (isEnable) { + const uniCloudConfig = statConfig.uniCloud || {} + + statVersion = statConfig.version === '2' ? '2' : '1' + process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig) + process.env.UNI_STAT_DEBUG = statConfig.debug ? 'true' : 'false' + if (process.env.NODE_ENV === 'production') { + const manifestJson = parseManifestJsonOnce(inputDir) + if (!manifestJson.appid) { + uniStatLog(M['stat.warn.appid']) + isEnable = false + } else { + if (!statConfig.version) { + uniStatLog(M['stat.warn.version']) + } else { + uniStatLog(`已开启 uni统计${statVersion}.0 版本`) + } } - } - } else { - if (isEnable) { + } else { if (!statConfig.version) { uniStatLog(M['stat.warn.version']) + } else { + uniStatLog( + M['stat.warn.tip'].replace('{version}', `${statVersion}.0`) + ) } - uniStatLog( - M['stat.warn.tip'].replace('{version}', `${statVersion}.0`) - ) } }