From 86ba04339d2eca08ee831562f335ddf7971fd89a Mon Sep 17 00:00:00 2001 From: mehaotian <490272692@qq.com> Date: Tue, 12 Apr 2022 11:18:25 +0800 Subject: [PATCH] fix(stat): uni-stat tips --- packages/uni-cli-i18n/locales/en.json | 1 + packages/uni-cli-i18n/locales/zh_CN.json | 1 + packages/vue-cli-plugin-uni/lib/env.js | 24 +++++++++++++++++------- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/packages/uni-cli-i18n/locales/en.json b/packages/uni-cli-i18n/locales/en.json index a4814f2c6..2dfce1c30 100644 --- a/packages/uni-cli-i18n/locales/en.json +++ b/packages/uni-cli-i18n/locales/en.json @@ -54,6 +54,7 @@ "pluginUni.pluginNameNotExist": "Plug-in name does not exist", "pluginUni.pluginIllegal": "The plugin is illegal", "pluginUni.uniStatisticsNoAppid": "The current application is not configured with Appid, and uni statistics cannot be used. For details, see {{0}}", + "pluginUni.uniStatisticsNoVersion": "The uni statistics version is not configured. The default version is 1.0.uni statistics version 2.0 is recommended, private deployment data is more secure and code is open source and customizable. details:{{0}} ", "pluginUni.pleaseConfigScriptName": "Please specify the script name under package.json->uni-app->scripts", "pluginUni.mpBrowserKernelDifference": "There are differences in the implementation mechanism of the browser kernels and custom components of each mini-program, and there may be compatibility issues with styles and layouts, please refer to: {{0}}", "mpLoader.firstParameterNeedStaticString": "The first parameter of {{0}} must be a static string", diff --git a/packages/uni-cli-i18n/locales/zh_CN.json b/packages/uni-cli-i18n/locales/zh_CN.json index f8d22c4c1..392717a2e 100644 --- a/packages/uni-cli-i18n/locales/zh_CN.json +++ b/packages/uni-cli-i18n/locales/zh_CN.json @@ -54,6 +54,7 @@ "pluginUni.pluginNameNotExist": "插件名称不存在", "pluginUni.pluginIllegal": "插件不合法", "pluginUni.uniStatisticsNoAppid": "当前应用未配置Appid,无法使用uni统计,详情参考 {{0}}", + "pluginUni.uniStatisticsNoVersion": "当前应用未配置uni统计版本,默认使用1.0版本;建议使用uni统计2.0版本 ,私有部署数据更安全,代码开源可定制。详情 {{0}}", "pluginUni.pleaseConfigScriptName": "请指定 package.json->uni-app->scripts 下的 script 名称", "pluginUni.mpBrowserKernelDifference": "小程序各家浏览器内核及自定义组件实现机制存在差异,可能存在样式布局兼容问题,参考:{{0}}", "mpLoader.firstParameterNeedStaticString": "{{0}}的第一个参数必须为静态字符串", diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index 79843149b..bc1b48f3a 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -309,13 +309,23 @@ if ( ) if (uniStatistics.enable === true) { - process.env.UNI_USING_STAT = uniStatistics.version === '2' ? '2' : '1' - if (!process.UNI_STAT_CONFIG.appid && process.env.NODE_ENV === 'production') { - console.log() - console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', { - 0: 'https://ask.dcloud.net.cn/article/36303' - })) - console.log() + process.env.UNI_USING_STAT = uniStatistics.version === '2' ? '2' : '1' + if (process.env.NODE_ENV === 'production') { + if (!process.UNI_STAT_CONFIG.appid) { + console.log() + console.warn(uniI18n.__('pluginUni.uniStatisticsNoAppid', { + 0: 'https://ask.dcloud.net.cn/article/36303' + })) + console.log() + } else { + if(!uniStatistics.version) { + console.log() + console.warn(uniI18n.__('pluginUni.uniStatisticsNoVersion', { + 0: 'https://uniapp.dcloud.io/uni-stat' + })) + console.log() + } + } } } } -- GitLab