diff --git a/packages/uni-app-plus-nvue/dist/index.js b/packages/uni-app-plus-nvue/dist/index.js index 4baa7405cd891dc6bf12b198d7e5b7a492e3b869..97db0f43182d6704e7f8e5bfa3fc2ccbb4df4119 100644 --- a/packages/uni-app-plus-nvue/dist/index.js +++ b/packages/uni-app-plus-nvue/dist/index.js @@ -2647,8 +2647,12 @@ var serviceContext = (function () { header: { type: Object, validator (value, params) { - params.header = value || {}; - params.header['content-type'] = params.header['content-type'] || 'application/json'; + const header = params.header = value || {}; + if (params.method !== method.GET) { + if (!Object.keys(header).find(key => key.toLowerCase() === 'content-type')) { + header['Content-Type'] = 'application/json'; + } + } } }, dataType: { diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js index e421bd56694cf715c9f0c66e1c4fcfbca5777b70..79ee325f475e5aaf7734e2015448bb7330dc7843 100644 --- a/packages/uni-mp-toutiao/dist/index.js +++ b/packages/uni-mp-toutiao/dist/index.js @@ -1376,21 +1376,45 @@ function isPage () { function initRefs (vm) { const mpInstance = vm.$scope; - mpInstance.selectAllComponents('.vue-ref', (components) => { - components.forEach(component => { - const ref = component.dataset.ref; - vm.$refs[ref] = component.$vm || component; - }); - }); - mpInstance.selectAllComponents('.vue-ref-in-for', (forComponents) => { - forComponents.forEach(component => { - const ref = component.dataset.ref; - if (!vm.$refs[ref]) { - vm.$refs[ref] = []; + /* eslint-disable no-undef */ + const minorVersion = parseInt(tt.getSystemInfoSync().SDKVersion.split('.')[1]); + if (minorVersion > 16) { + Object.defineProperty(vm, '$refs', { + get () { + const $refs = {}; + const components = mpInstance.selectAllComponents('.vue-ref'); + components.forEach(component => { + const ref = component.dataset.ref; + $refs[ref] = component.$vm || component; + }); + const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for'); + forComponents.forEach(component => { + const ref = component.dataset.ref; + if (!$refs[ref]) { + $refs[ref] = []; + } + $refs[ref].push(component.$vm || component); + }); + return $refs } - vm.$refs[ref].push(component.$vm || component); }); - }); + } else { + mpInstance.selectAllComponents('.vue-ref', (components) => { + components.forEach(component => { + const ref = component.dataset.ref; + vm.$refs[ref] = component.$vm || component; + }); + }); + mpInstance.selectAllComponents('.vue-ref-in-for', (forComponents) => { + forComponents.forEach(component => { + const ref = component.dataset.ref; + if (!vm.$refs[ref]) { + vm.$refs[ref] = []; + } + vm.$refs[ref].push(component.$vm || component); + }); + }); + } } const instances = Object.create(null); diff --git a/packages/uni-stat/dist/index.js b/packages/uni-stat/dist/index.js index e97f0a6e45517294a03718b2830ba7520a3916d0..f943cba931c5ed914fa43e4b0a69c7b67e2e00a8 100644 --- a/packages/uni-stat/dist/index.js +++ b/packages/uni-stat/dist/index.js @@ -836,7 +836,15 @@ const lifecycle = { stat.ready(this); }, onLoad(options) { - stat.load(options, this); + stat.load(options, this); + // 重写分享,获取分享上报事件 + if (this.$scope && this.$scope.onShareAppMessage) { + let oldShareAppMessage = this.$scope.onShareAppMessage; + this.$scope.onShareAppMessage = function(options) { + stat.interceptShare(false); + return oldShareAppMessage.call(this, options) + }; + } }, onShow() { isHide = false; @@ -855,9 +863,6 @@ const lifecycle = { }, onError(e) { stat.error(e); - }, - onShareAppMessage() { - stat.interceptShare(false); } }; diff --git a/packages/uni-stat/src/index.js b/packages/uni-stat/src/index.js index ba2b4026cb3ba23bda3265d53c54c12cfd62b0d9..5b4a027ddfb23b1d3aa55f7b9074f5ec31e1c3fe 100644 --- a/packages/uni-stat/src/index.js +++ b/packages/uni-stat/src/index.js @@ -9,7 +9,15 @@ const lifecycle = { stat.ready(this); }, onLoad(options) { - stat.load(options, this); + stat.load(options, this); + // 重写分享,获取分享上报事件 + if (this.$scope && this.$scope.onShareAppMessage) { + let oldShareAppMessage = this.$scope.onShareAppMessage; + this.$scope.onShareAppMessage = function(options) { + stat.interceptShare(false); + return oldShareAppMessage.call(this, options) + } + } }, onShow() { isHide = false @@ -28,9 +36,6 @@ const lifecycle = { }, onError(e) { stat.error(e) - }, - onShareAppMessage() { - stat.interceptShare(false) } } diff --git a/packages/vue-cli-plugin-uni/commands/info.js b/packages/vue-cli-plugin-uni/commands/info.js index 4a0329bb0482deece1b81c985a5b7de29a223aa5..c2b5983c02f51fc43f3fd0fe46320264e765b91b 100644 --- a/packages/vue-cli-plugin-uni/commands/info.js +++ b/packages/vue-cli-plugin-uni/commands/info.js @@ -1,4 +1,5 @@ -console.log('uni-app v' + require('../package.json').version) +console.log('uni-app v' + require('@dcloudio/webpack-uni-pages-loader/package.json')['uni-app']['compilerVersion']) +console.log('uni-app cli v' + require('../package.json').version) console.log(require('chalk').bold('\nEnvironment Info:')) require('envinfo').run({ System: ['OS', 'CPU'], diff --git a/packages/vue-cli-plugin-uni/lib/check-update.js b/packages/vue-cli-plugin-uni/lib/check-update.js index 317dae0ce1efac9f637f38f79d75f6b94ca492eb..d0170a2da68ed3a2b5f7ebec1ac6e1bd0b6884ff 100644 --- a/packages/vue-cli-plugin-uni/lib/check-update.js +++ b/packages/vue-cli-plugin-uni/lib/check-update.js @@ -23,12 +23,12 @@ module.exports = async function checkUpdate () { if (update) { if (pkg.version.split('.')[0] !== update.latest.split('.')[0]) { - console.log(`发现 uni-app 新版本 ${update.latest}`) + console.log(`发现 uni-app cli 新版本 ${update.latest}`) console.log(`1.修改 package.json 中 @dcloudio 相关包版本为 ^${update.latest}`) console.log('2.删除 package-lock.json 或 yarn.lock') console.log('3.执行 npm install 或 yarn') } else { - console.log(`发现 uni-app 新版本 ${update.latest}. 请执行 npm update 升级`) + console.log(`发现 uni-app cli 新版本 ${update.latest}. 请执行 npm update 升级`) } } } diff --git a/src/core/helpers/protocol/network/request.js b/src/core/helpers/protocol/network/request.js index 6709d0e15baa9c93860e707514bd6722a05a4187..0d2c7021699e8da4a69427b51a301c8666af0b39 100644 --- a/src/core/helpers/protocol/network/request.js +++ b/src/core/helpers/protocol/network/request.js @@ -77,8 +77,12 @@ export const request = { header: { type: Object, validator (value, params) { - params.header = value || {} - params.header['content-type'] = params.header['content-type'] || 'application/json' + const header = params.header = value || {} + if (params.method !== method.GET) { + if (!Object.keys(header).find(key => key.toLowerCase() === 'content-type')) { + header['Content-Type'] = 'application/json' + } + } } }, dataType: { @@ -94,4 +98,4 @@ export const request = { params.responseType = Object.values(responseType).indexOf(value) < 0 ? responseType.TEXT : value } } -} +} diff --git a/src/platforms/h5/components/page/pageHead.vue b/src/platforms/h5/components/page/pageHead.vue index d1ec0cf2b415eefd352d8e8022ed50e55d159dfb..f8be0f9e5d44dfb50e03dd1c8430d4ca409c7f0c 100644 --- a/src/platforms/h5/components/page/pageHead.vue +++ b/src/platforms/h5/components/page/pageHead.vue @@ -36,7 +36,7 @@ v-if="!searchInput" class="uni-page-head-bd">
{ - components.forEach(component => { - const ref = component.dataset.ref - vm.$refs[ref] = component.$vm || component - }) - }) - mpInstance.selectAllComponents('.vue-ref-in-for', (forComponents) => { - forComponents.forEach(component => { - const ref = component.dataset.ref - if (!vm.$refs[ref]) { - vm.$refs[ref] = [] + /* eslint-disable no-undef */ + const minorVersion = parseInt(tt.getSystemInfoSync().SDKVersion.split('.')[1]) + if (minorVersion > 16) { + Object.defineProperty(vm, '$refs', { + get () { + const $refs = {} + const components = mpInstance.selectAllComponents('.vue-ref') + components.forEach(component => { + const ref = component.dataset.ref + $refs[ref] = component.$vm || component + }) + const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') + forComponents.forEach(component => { + const ref = component.dataset.ref + if (!$refs[ref]) { + $refs[ref] = [] + } + $refs[ref].push(component.$vm || component) + }) + return $refs } - vm.$refs[ref].push(component.$vm || component) }) - }) + } else { + mpInstance.selectAllComponents('.vue-ref', (components) => { + components.forEach(component => { + const ref = component.dataset.ref + vm.$refs[ref] = component.$vm || component + }) + }) + mpInstance.selectAllComponents('.vue-ref-in-for', (forComponents) => { + forComponents.forEach(component => { + const ref = component.dataset.ref + if (!vm.$refs[ref]) { + vm.$refs[ref] = [] + } + vm.$refs[ref].push(component.$vm || component) + }) + }) + } } const instances = Object.create(null) @@ -77,4 +101,4 @@ export function handleLink ({ vm._isMounted = true vm.__call_hook('mounted') vm.__call_hook('onReady') -} +}