Skip to content

Commit

Permalink
Merge branch 'alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhetengbiji committed Sep 24, 2019
2 parents 941c2b8 + 4f56168 commit 259fb90
Show file tree
Hide file tree
Showing 27 changed files with 107 additions and 77 deletions.
4 changes: 3 additions & 1 deletion docs/api/request/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
|method|String||GET|有效值详见下方说明||
|dataType|String||json |如果设为 json,会尝试对返回的数据做一次 JSON.parse||
|responseType|String||text |设置响应的数据类型。合法值:text、arraybuffer|5+App和支付宝小程序不支持|
|sslVerify|Boolean||true|验证 ssl 证书|仅5+App安卓端支持(HBuilderX 2.3.4+)|
|success|Function|||收到开发者服务成功返回的回调函数||
|fail|Function|||接口调用失败的回调函数||
|complete|Function|||接口调用结束的回调函数(调用成功、失败都会执行)| |
Expand Down Expand Up @@ -122,5 +123,6 @@ requestTask.abort();
- debug 模式,安卓端暂时无法获取响应头,url中含有非法字符(如未编码为%20的空格)时会请求失败
- iOS App第一次安装启动后,会弹出是否允许联网的询问框,在用户点击同意前,调用联网API会失败。请注意判断这种情况。比如官方提供的新闻模板示例(HBuilderX新建项目可选择),会判断如果无法联网,则提供一个错误页,提示用户设置网络及下拉刷新重试。
- 良好体验的App,还会判断当前是否处于飞行模式([参考](https://ext.dcloud.net.cn/plugin?id=594))、是wifi还是3G([参考](https://uniapp.dcloud.io/api/system/network)
- 部分Android设备,真机运行或debug模式下的网络,低于release模式很多。
- 部分安卓设备,真机运行或debug模式下的网络,低于release模式很多。
- 使用一些比较小众的证书机构(如:CFCA OV OCA)签发的 ssl 证书在安卓设备请求会失败,因为这些机构的根证书不在系统内置根证书库,可以更换其他常见机构签发的证书(如:Let's Encrypt),或者配置 sslVerify 为 false 关闭 ssl 证书验证(不推荐)。
- 单次网络请求数据量建议控制在50K以下(仅指json数据,不含图片),过多数据应分页获取,以提升应用体验。
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"message": "chore(release): publish %s"
}
},
"version": "2.0.0-23220190921001"
"version": "2.0.0-23320190923002"
}
45 changes: 32 additions & 13 deletions packages/uni-app-plus-nvue/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ var serviceContext = (function () {
var base64Arraybuffer_1 = base64Arraybuffer.encode;
var base64Arraybuffer_2 = base64Arraybuffer.decode;

function pack (args) {
return args
}

function unpack (args) {
return args
}
Expand Down Expand Up @@ -4387,7 +4383,7 @@ var serviceContext = (function () {
/**
* 执行蓝牙相关方法
*/
function bluetoothExec (method, callbackId, data = {}) {
function bluetoothExec (method, callbackId, data = {}, beforeSuccess) {
var deviceId = data.deviceId;
if (deviceId) {
data.deviceId = deviceId.toUpperCase();
Expand All @@ -4399,7 +4395,10 @@ var serviceContext = (function () {

plus.bluetooth[method.replace('Changed', 'Change')](Object.assign(data, {
success (data) {
invoke(callbackId, Object.assign({}, pack(data), {
if (typeof beforeSuccess === 'function') {
beforeSuccess(data);
}
invoke(callbackId, Object.assign({}, data, {
errMsg: `${method}:ok`,
code: undefined,
message: undefined
Expand All @@ -4416,16 +4415,29 @@ var serviceContext = (function () {
/**
* 监听蓝牙相关事件
*/
function bluetoothOn (method) {
function bluetoothOn (method, beforeSuccess) {
plus.bluetooth[method.replace('Changed', 'Change')](function (data) {
publish(method, Object.assign({}, pack(data), {
if (typeof beforeSuccess === 'function') {
beforeSuccess(data);
}
publish(method, Object.assign({}, data, {
code: undefined,
message: undefined
}));
});
return true
}

function checkDevices (data) {
data.devices = data.devices.map(device => {
var advertisData = device.advertisData;
if (advertisData && typeof advertisData !== 'string') {
device.advertisData = arrayBufferToBase64(advertisData);
}
return device
});
}

var onBluetoothAdapterStateChange;
var onBluetoothDeviceFound;
var onBLEConnectionStateChange;
Expand All @@ -4446,7 +4458,7 @@ var serviceContext = (function () {
}

function startBluetoothDevicesDiscovery (data, callbackId) {
onBluetoothDeviceFound = onBluetoothDeviceFound || bluetoothOn('onBluetoothDeviceFound');
onBluetoothDeviceFound = onBluetoothDeviceFound || bluetoothOn('onBluetoothDeviceFound', checkDevices);
bluetoothExec('startBluetoothDevicesDiscovery', callbackId, data);
}

Expand All @@ -4455,7 +4467,7 @@ var serviceContext = (function () {
}

function getBluetoothDevices (data, callbackId) {
bluetoothExec('getBluetoothDevices', callbackId, {});
bluetoothExec('getBluetoothDevices', callbackId, {}, checkDevices);
}

function getConnectedBluetoothDevices (data, callbackId) {
Expand All @@ -4481,12 +4493,18 @@ var serviceContext = (function () {
}

function notifyBLECharacteristicValueChange (data, callbackId) {
onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange');
onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange',
data => {
data.value = arrayBufferToBase64(data.value);
});
bluetoothExec('notifyBLECharacteristicValueChange', callbackId, data);
}

function notifyBLECharacteristicValueChanged (data, callbackId) {
onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange');
onBLECharacteristicValueChange = onBLECharacteristicValueChange || bluetoothOn('onBLECharacteristicValueChange',
data => {
data.value = arrayBufferToBase64(data.value);
});
bluetoothExec('notifyBLECharacteristicValueChanged', callbackId, data);
}

Expand All @@ -4495,7 +4513,8 @@ var serviceContext = (function () {
}

function writeBLECharacteristicValue (data, callbackId) {
bluetoothExec('writeBLECharacteristicValue', callbackId, unpack(data));
data.value = base64ToArrayBuffer(data.value);
bluetoothExec('writeBLECharacteristicValue', callbackId, data);
}

function getScreenBrightness () {
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-plus-nvue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-app-plus-nvue",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app app-plus-nvue",
"main": "dist/index.js",
"repository": {
Expand All @@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/uni-app-plus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-app-plus",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app app-plus",
"main": "dist/index.js",
"repository": {
Expand All @@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/uni-cli-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-cli-shared",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-cli-shared",
"main": "lib/index.js",
"repository": {
Expand All @@ -20,5 +20,5 @@
"hash-sum": "^1.0.2",
"strip-json-comments": "^2.0.1"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/uni-h5-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-h5-ui",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app h5 ui",
"main": "dist/index.umd.min.js",
"repository": {
Expand All @@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
2 changes: 1 addition & 1 deletion packages/uni-h5/dist/index.umd.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/uni-h5/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-h5",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app h5",
"main": "dist/index.umd.min.js",
"repository": {
Expand All @@ -18,5 +18,5 @@
"intersection-observer": "^0.7.0",
"safe-area-insets": "^1.4.1"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/uni-mp-alipay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-mp-alipay",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app mp-alipay",
"main": "dist/index.js",
"repository": {
Expand All @@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/uni-mp-baidu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-mp-baidu",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app mp-baidu",
"main": "dist/index.js",
"repository": {
Expand All @@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/uni-mp-qq/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-mp-qq",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app mp-qq",
"main": "dist/index.js",
"repository": {
Expand All @@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
17 changes: 8 additions & 9 deletions packages/uni-mp-toutiao/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,21 +386,16 @@ var previewImage = {

// 不支持的 API 列表
const todos = [
'getBackgroundAudioManager',
'createCameraContext',
'createLivePlayerContext',
'getSavedFileInfo',
'openDocument',
'chooseLocation',
'createMapContext',
'canIUse',
'onMemoryWarning',
'onGyroscopeChange',
'startGyroscope',
'stopGyroscope',
'setScreenBrightness',
'getScreenBrightness',
'onUserCaptureScreen',
'addPhoneContact',
'openBluetoothAdapter',
'startBluetoothDevicesDiscovery',
Expand Down Expand Up @@ -439,8 +434,6 @@ const todos = [
'setBackgroundColor',
'setBackgroundTextStyle',
'chooseInvoiceTitle',
'navigateToMiniProgram',
'navigateBackMiniProgram',
'addTemplate',
'deleteTemplate',
'getTemplateLibraryById',
Expand All @@ -450,13 +443,12 @@ const todos = [
'setEnableDebug',
'onWindowResize',
'offWindowResize',
'compressImage',
'createOffscreenCanvas',
'vibrate'
];

// 存在兼容性的 API 列表
// 头条小程序不支持canIUses
// 头条小程序自1.35.0+支持canIUses
const canIUses = [
// 'createIntersectionObserver',
// 'getSavedFileList',
Expand All @@ -472,6 +464,13 @@ const canIUses = [
// 'onSocketClose',
// 'getExtConfig',
// 'getExtConfigSync',
// 'navigateToMiniProgram',
// 'navigateBackMiniProgram',
// 'compressImage',
// 'chooseLocation',
// 'openDocument',
// 'onUserCaptureScreen',
// 'getBackgroundAudioManager',
];

// 需要做转换的 API 列表
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-mp-toutiao/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-mp-toutiao",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app mp-toutiao",
"main": "dist/index.js",
"repository": {
Expand All @@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/uni-mp-weixin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-mp-weixin",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app mp-weixin",
"main": "dist/index.js",
"repository": {
Expand All @@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/uni-stat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-stat",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "",
"main": "dist/index.js",
"repository": {
Expand Down Expand Up @@ -34,5 +34,5 @@
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^6.0.2"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/uni-template-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-template-compiler",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-template-compiler",
"main": "lib/index.js",
"repository": {
Expand All @@ -22,5 +22,5 @@
"@babel/types": "^7.3.3",
"vue-template-compiler": "^2.6.10"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
4 changes: 2 additions & 2 deletions packages/vue-cli-plugin-hbuilderx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/vue-cli-plugin-hbuilderx",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "HBuilderX plugin for vue-cli 3",
"main": "index.js",
"repository": {
Expand All @@ -18,5 +18,5 @@
"css": "~2.2.1",
"escodegen": "^1.8.1"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
Loading

0 comments on commit 259fb90

Please sign in to comment.