提交 259fb90e 编写于 作者: Q qiang

Merge branch 'alpha'

......@@ -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|否||接口调用结束的回调函数(调用成功、失败都会执行)| |
......@@ -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数据,不含图片),过多数据应分页获取,以提升应用体验。
......@@ -12,5 +12,5 @@
"message": "chore(release): publish %s"
}
},
"version": "2.0.0-23220190921001"
"version": "2.0.0-23320190923002"
}
......@@ -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
}
......@@ -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();
......@@ -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
......@@ -4416,9 +4415,12 @@ 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
}));
......@@ -4426,6 +4428,16 @@ var serviceContext = (function () {
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;
......@@ -4446,7 +4458,7 @@ var serviceContext = (function () {
}
function startBluetoothDevicesDiscovery (data, callbackId) {
onBluetoothDeviceFound = onBluetoothDeviceFound || bluetoothOn('onBluetoothDeviceFound');
onBluetoothDeviceFound = onBluetoothDeviceFound || bluetoothOn('onBluetoothDeviceFound', checkDevices);
bluetoothExec('startBluetoothDevicesDiscovery', callbackId, data);
}
......@@ -4455,7 +4467,7 @@ var serviceContext = (function () {
}
function getBluetoothDevices (data, callbackId) {
bluetoothExec('getBluetoothDevices', callbackId, {});
bluetoothExec('getBluetoothDevices', callbackId, {}, checkDevices);
}
function getConnectedBluetoothDevices (data, callbackId) {
......@@ -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);
}
......@@ -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 () {
......
{
"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": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"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": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"name": "@dcloudio/uni-cli-shared",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-cli-shared",
"main": "lib/index.js",
"repository": {
......@@ -20,5 +20,5 @@
"hash-sum": "^1.0.2",
"strip-json-comments": "^2.0.1"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"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": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"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": {
......@@ -18,5 +18,5 @@
"intersection-observer": "^0.7.0",
"safe-area-insets": "^1.4.1"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"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": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"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": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"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": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
......@@ -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',
......@@ -439,8 +434,6 @@ const todos = [
'setBackgroundColor',
'setBackgroundTextStyle',
'chooseInvoiceTitle',
'navigateToMiniProgram',
'navigateBackMiniProgram',
'addTemplate',
'deleteTemplate',
'getTemplateLibraryById',
......@@ -450,13 +443,12 @@ const todos = [
'setEnableDebug',
'onWindowResize',
'offWindowResize',
'compressImage',
'createOffscreenCanvas',
'vibrate'
];
// 存在兼容性的 API 列表
// 头条小程序支持canIUses
// 头条小程序自1.35.0+支持canIUses
const canIUses = [
// 'createIntersectionObserver',
// 'getSavedFileList',
......@@ -472,6 +464,13 @@ const canIUses = [
// 'onSocketClose',
// 'getExtConfig',
// 'getExtConfigSync',
// 'navigateToMiniProgram',
// 'navigateBackMiniProgram',
// 'compressImage',
// 'chooseLocation',
// 'openDocument',
// 'onUserCaptureScreen',
// 'getBackgroundAudioManager',
];
// 需要做转换的 API 列表
......
{
"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": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"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": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"name": "@dcloudio/uni-stat",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "",
"main": "dist/index.js",
"repository": {
......@@ -34,5 +34,5 @@
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-uglify": "^6.0.2"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"name": "@dcloudio/uni-template-compiler",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-template-compiler",
"main": "lib/index.js",
"repository": {
......@@ -22,5 +22,5 @@
"@babel/types": "^7.3.3",
"vue-template-compiler": "^2.6.10"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"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": {
......@@ -18,5 +18,5 @@
"css": "~2.2.1",
"escodegen": "^1.8.1"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"name": "@dcloudio/vue-cli-plugin-uni-optimize",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app optimize plugin for vue-cli 3",
"main": "index.js",
"repository": {
......@@ -13,5 +13,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"name": "@dcloudio/vue-cli-plugin-uni",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app plugin for vue-cli 3",
"main": "index.js",
"repository": {
......@@ -17,7 +17,7 @@
"author": "fxy060608",
"license": "Apache-2.0",
"dependencies": {
"@dcloudio/uni-stat": "^2.0.0-23220190921001",
"@dcloudio/uni-stat": "^2.0.0-23320190923002",
"copy-webpack-plugin": "^4.6.0",
"cross-env": "^5.2.0",
"envinfo": "^6.0.1",
......@@ -34,5 +34,5 @@
"wrap-loader": "^0.2.0",
"xregexp": "4.0.0"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
{
"name": "@dcloudio/webpack-uni-mp-loader",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "webpack-uni-mp-loader",
"main": "index.js",
"repository": {
......@@ -16,5 +16,5 @@
},
"author": "fxy060608",
"license": "Apache-2.0",
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
......@@ -394,6 +394,10 @@ module.exports = function (pagesJson, userManifestJson) {
}
}
if (!process.env.UNI_USING_COMPONENTS) {
manifestJson.plus.launchwebview.kernel = 'UIWebview'
}
manifest.content = manifestJson
// 分包合并
......
{
"name": "@dcloudio/webpack-uni-pages-loader",
"version": "2.0.0-23220190921001",
"version": "2.0.0-23320190923002",
"description": "uni-app pages.json loader",
"main": "lib/index.js",
"repository": {
......@@ -21,7 +21,7 @@
"strip-json-comments": "^2.0.1"
},
"uni-app": {
"compilerVersion": "2.3.2"
"compilerVersion": "2.3.3"
},
"gitHead": "a9dfc1e2b7a5608e010228c06a040b8f267aace2"
"gitHead": "10184426b19cb76e01c93fb25c982c72887557e8"
}
......@@ -39,7 +39,7 @@ function updateCssVar (vm) {
}
}
export default function initSubscribe (subscribe) {
export default function initSubscribe (subscribe) {
Object.keys(subscribeApis).forEach(name => {
subscribe(name, subscribeApis[name])
})
......@@ -88,10 +88,10 @@ export default function initSubscribe (subscribe) {
onReachBottomDistance,
enableTransparentTitleNView
})
setTimeout(function () { // 避免监听太早,直接触发了 scroll
requestAnimationFrame(function () { // 避免监听太早,直接触发了 scroll
document.addEventListener('scroll', scrollListener)
}, 10)
})
}
})
}
}
}
......@@ -91,6 +91,10 @@ export function createScrollListener (pageId, {
}
function trigger () {
const pages = getCurrentPages()
if (!pages.length || pages[pages.length - 1].$page.id !== pageId) {
return
}
// publish
const scrollTop = window.pageYOffset
if (enablePageScroll) { // 向 Service 发送 onPageScroll 事件
......@@ -121,4 +125,4 @@ export function createScrollListener (pageId, {
}
ticking = true
}
}
}
......@@ -17,7 +17,8 @@ export function createRequestTaskById (requestTaskId, {
data,
header,
method = 'GET',
responseType
responseType,
sslVerify = true
} = {}) {
const stream = requireNativePlugin('stream')
const headers = {}
......@@ -57,7 +58,9 @@ export function createRequestTaskById (requestTaskId, {
headers,
type: responseType === 'arraybuffer' ? 'base64' : 'text',
// weex 官方文档未说明实际支持 timeout,单位:ms
timeout: timeout || 6e5
timeout: timeout || 6e5,
// 配置和weex模块内相反
sslVerify: !sslVerify
}
if (method !== 'GET') {
options.body = data
......
......@@ -2,21 +2,16 @@ import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
// 不支持的 API 列表
const todos = [
'getBackgroundAudioManager',
'createCameraContext',
'createLivePlayerContext',
'getSavedFileInfo',
'openDocument',
'chooseLocation',
'createMapContext',
'canIUse',
'onMemoryWarning',
'onGyroscopeChange',
'startGyroscope',
'stopGyroscope',
'setScreenBrightness',
'getScreenBrightness',
'onUserCaptureScreen',
'addPhoneContact',
'openBluetoothAdapter',
'startBluetoothDevicesDiscovery',
......@@ -55,8 +50,6 @@ const todos = [
'setBackgroundColor',
'setBackgroundTextStyle',
'chooseInvoiceTitle',
'navigateToMiniProgram',
'navigateBackMiniProgram',
'addTemplate',
'deleteTemplate',
'getTemplateLibraryById',
......@@ -66,13 +59,12 @@ const todos = [
'setEnableDebug',
'onWindowResize',
'offWindowResize',
'compressImage',
'createOffscreenCanvas',
'vibrate'
]
// 存在兼容性的 API 列表
// 头条小程序支持canIUses
// 头条小程序自1.35.0+支持canIUses
const canIUses = [
// 'createIntersectionObserver',
// 'getSavedFileList',
......@@ -88,6 +80,13 @@ const canIUses = [
// 'onSocketClose',
// 'getExtConfig',
// 'getExtConfigSync',
// 'navigateToMiniProgram',
// 'navigateBackMiniProgram',
// 'compressImage',
// 'chooseLocation',
// 'openDocument',
// 'onUserCaptureScreen',
// 'getBackgroundAudioManager',
]
// 需要做转换的 API 列表
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册