Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/dcloudio/uni-app into v3
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/uni-h5/dist/index.umd.min.js
#	src/core/view/plugins/index.js
#	src/platforms/app-plus-nvue/service/api/index.js
#	src/platforms/app-plus-nvue/service/api/route/util.js
#	src/platforms/app-plus/service/api/route/navigate-to.js
#	src/platforms/app-plus/service/api/route/switch-tab.js
#	src/platforms/app-plus/service/constants.js
#	src/platforms/app-plus/service/framework/app.js
  • Loading branch information
fxy060608 committed Oct 11, 2019
2 parents fe45472 + e0c13bb commit dd3f979
Show file tree
Hide file tree
Showing 54 changed files with 622 additions and 600 deletions.
2 changes: 1 addition & 1 deletion docs/api/location/location.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ uni.getLocation({
- H5:在较新的手机浏览器上,H5 端获取定位信息,要求部署在 **https** 服务上,本地预览(localhost)仍然可以使用 http 协议。
- H5:无 GPS 模块的 PC 设备使用 Chrome 浏览器的时候,位置信息是连接谷歌服务器获取的,国内用户可能获取位置信息失败。
- H5:微信公众号可使用微信js sdk,[详见](https://ask.dcloud.net.cn/article/35380)
- App:Android由于谷歌服务被墙,想在国产手机上正常定位,需要向高德等三方服务商申请SDK资质,获取AppKey。云打包时需要在manifest的SDK配置中填写Appkey。在manifest可视化界面有详细申请指南。离线打包自行在原生工程中配置。
- App:Android由于谷歌服务被墙,想在国产手机上正常定位,需要向高德等三方服务商申请SDK资质,获取AppKey。云打包时需要在manifest的SDK配置中填写Appkey。在manifest可视化界面有详细申请指南。离线打包自行在原生工程中配置。注意包名和appkey信息必须匹配。
- App:``<map>`` 组件默认为国测局坐标gcj02,调用 ``uni.getLocation`` 返回结果传递给 ``<map>`` 组件时,需指定 type 为 gcj02。
- App:持续定位方案:iOS端可以申请持续定位权限,[参考](https://ask.dcloud.net.cn/article/12569)。Android如果进程被杀,代码无法执行。可以使用[unipush](https://ask.dcloud.net.cn/article/35622),通过服务器激活App,执行透传消息,让App启动然后采集位置。Android上,即使自己写原生插件做后台进程,也很容易被杀,unipush是更合适的方案
- 小程序:api默认不返回详细地址中文描述。需要中文地址有2种方式:1、使用高德地图小程序sdk,在app和微信上都可以获得中文地址,[参考](http://ask.dcloud.net.cn/article/35070)。2、只考虑app,使用``plus.geolocation``也可以获取中文地址
Expand Down
26 changes: 26 additions & 0 deletions docs/api/location/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ mapContext
|fail|Function||接口调用失败的回调函数|
|complete|Function||接口调用结束的回调函数(调用成功、失败都会执行)|

## mapSearch 模块(module)#### reverseGeocode(Object,callback)> 反向地理编码
##### Object属性|类型 |默认值|必填|说明:--|:--|:--|:--|:--|point|Object| |是|{latitude: 纬度, longitude: 经度}
##### callback 返回 Object 参数说明
属性|类型 |说明:--|:--|:--|type|String|"success" 表示成功, "fail" 表示失败code|Number| 成功返回 0,失败返回相应 code 码
message|String|失败描述
address|String|查询后地址 (成功时返回)

#### poiSearchNearBy(Object,callback);> 周边检索##### Object属性|类型 |默认值|必填|说明:--|:--|:--|:--|:--|point|Object| |是|检索的中心点坐标 {latitude: 纬度, longitude: 经度}
key|String| | 是|搜索关键字radius|Number|3000|否|检索的半径,单位为米index|Number|1|否|要获取检索结果的页号索引##### callback 返回 Object 参数说明
属性|类型 |说明:--|:--|:--|
type|String|"success" 表示成功, "fail" 表示失败code|Number| 成功返回 0,失败返回相应 code 码
message|String|失败描述
totalNumber|Number|返回的POI数目
currentNumber|Number|当前页POI数目
pageNumber|Number|页数
pageIndex|Number|当前页号索引
poiList|Array.&lt;poiObject&gt;|POI信息数组

##### poiObject
属性|类型 |说明:--|:--|:--|
location|Object|{latitude: 纬度, longitude: 经度}
name|String|名称
type|String|类型
distance|Number|距离(单位米)
address|String|地址


**Tips**

Expand Down
1 change: 1 addition & 0 deletions docs/api/plugins/share.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ uni.share({
```javascript
uni.share({
provider: 'weixin',
scene: "WXSceneSession",
type: 5,
imageUrl: 'https://img-cdn-qiniu.dcloud.net.cn/uniapp/app/share-logo@3.png',
title: '欢迎体验uniapp',
Expand Down
4 changes: 2 additions & 2 deletions docs/api/request/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +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+)|
|sslVerify|Boolean||true|验证 ssl 证书|仅5+App安卓端支持(HBuilderX 2.3.3+)|
|success|Function|||收到开发者服务成功返回的回调函数||
|fail|Function|||接口调用失败的回调函数||
|complete|Function|||接口调用结束的回调函数(调用成功、失败都会执行)|&nbsp;|
Expand Down Expand Up @@ -124,5 +124,5 @@ requestTask.abort();
- iOS App第一次安装启动后,会弹出是否允许联网的询问框,在用户点击同意前,调用联网API会失败。请注意判断这种情况。比如官方提供的新闻模板示例(HBuilderX新建项目可选择),会判断如果无法联网,则提供一个错误页,提示用户设置网络及下拉刷新重试。
- 良好体验的App,还会判断当前是否处于飞行模式([参考](https://ext.dcloud.net.cn/plugin?id=594))、是wifi还是3G([参考](https://uniapp.dcloud.io/api/system/network)
- 部分安卓设备,真机运行或debug模式下的网络,低于release模式很多。
- 安卓端请求某些 https 服务会失败,可以尝试配置 sslVerify 为 false 关闭 ssl 证书验证
- 使用一些比较小众的证书机构(如:CFCA OV OCA)签发的 ssl 证书在安卓设备请求会失败,因为这些机构的根证书不在系统内置根证书库,可以更换其他常见机构签发的证书(如:Let's Encrypt),或者配置 sslVerify 为 false 关闭 ssl 证书验证(不推荐)。
- 单次网络请求数据量建议控制在50K以下(仅指json数据,不含图片),过多数据应分页获取,以提升应用体验。
11 changes: 10 additions & 1 deletion docs/api/ui/tabbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,17 @@ uni.setTabBarBadge({
|fail|Function||接口调用失败的回调函数|
|complete|Function||接口调用结束的回调函数(调用成功、失败都会执行)|

### uni.onTabBarMidButtonTap(CALLBACK)
监听中间按钮的点击事件

**平台差异说明**

|App|H5|微信小程序|支付宝小程序|百度小程序|头条小程序|QQ小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|√(HBuilderX 2.3.4+)|x|x|x|x|x|x|


**Tip**
- tabbar是原生的,层级高于前端元素
- [uni-app插件市场](https://ext.dcloud.net.cn/search?q=%E5%BA%95%E9%83%A8%E5%9B%BE%E6%A0%87%E8%8F%9C%E5%8D%95)有封装的前端tabbar,但性能不如原生tabbar
- 如果想要一个中间带+号的tabbar,在HBuilderX中新建uni-app项目、选择 底部选项卡 模板
- HBuilderX 2.3.4 版本以下如果想要一个中间带+号的tabbar,在HBuilderX中新建uni-app项目、选择 底部选项卡 模板
29 changes: 27 additions & 2 deletions docs/collocation/pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"selectedColor": "#3cc51f",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"height": "56px",
"fontSize": "12px",
"iconWidth": "24px",
"list": [{
"pagePath": "pages/component/index",
"iconPath": "static/image/icon_component.png",
Expand All @@ -65,7 +68,15 @@
"iconPath": "static/image/icon_API.png",
"selectedIconPath": "static/image/icon_API_HL.png",
"text": "接口"
}]
}],
"midButton": {
"width": "80px",
"height": "56px",
"text": "文字",
"iconPath": "static/image/midButton_iconPath.png",
"iconWidth": "24px",
"backgroundImage": "static/image/midButton_backgroundImage.png"
}
}
}
```
Expand Down Expand Up @@ -663,6 +674,10 @@ h5 平台下拉刷新动画,只有 circle 类型。
|borderStyle|String||black|tabbar 上边框的颜色,仅支持 black/white||
|list|Array|||tab 的列表,详见 list 属性说明,最少2个、最多5个 tab||
|position|String||bottom|可选值 bottom、top|top 值仅微信小程序支持|
|fontSize|String||12px|文字默认大小|App(HBuilderX 2.3.4+)|
|iconWidth|String||24px|图标默认宽度(高度等比例缩放)|App(HBuilderX 2.3.4+)|
|height|String||56px|tabBar 默认高度|App(HBuilderX 2.3.4+)|
|midButton|Object|||中间按钮 仅在 list 项为偶数时有效|App(HBuilderX 2.3.4+)|

其中 list 接收一个数组,数组中的每个项都是一个对象,其属性值如下:

Expand All @@ -673,14 +688,24 @@ h5 平台下拉刷新动画,只有 circle 类型。
|iconPath|String||图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片,不支持字体图标|
|selectedIconPath|String||选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效|

**midButton 属性说明**

|属性|类型|必填|默认值|描述|
|:-|:-|:-|:-|:-|
|width|String||80px|中间按钮的宽度,tabBar 其它项为减去此宽度后平分,默认值为与其它项平分宽度|
|height|String||56px|中间按钮的高度,可以大于 tabBar 高度|
|text|String|||中间按钮的文字|
|iconPath|String|||中间按钮的图片路径|
|iconWidth|String||24px||图片宽度(高度等比例缩放)|
|backgroundImage|String|||中间按钮的背景图片路径|

#### **tabbar常见问题** @tips-tabbar
- tabbar 的 js api 见[接口-界面-tabbar](https://uniapp.dcloud.io/api/ui/tabbar),可实现动态显示隐藏(如弹出层无法覆盖tabbar)、内容修改(如国际化)、item加角标等功能。hello uni-app中也有示例。
- tabbar 的 item 点击事件见[页面生命周期的onTabItemTap](https://uniapp.dcloud.io/frame?id=%E9%A1%B5%E9%9D%A2%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F)
- 代码跳转到tabbar页面,api只能使用[uni.switchTab](https://uniapp.dcloud.io/api/router?id=switchtab),不能使用uni.navigateTo、uni.redirectTo;使用navigator组件跳转时必须设置[open-type="switchTab"](https://uniapp.dcloud.io/component/navigator)
- tabbar 在H5端是div模拟的,属于前端屏幕窗口的一部分,如果要使用bottom居底定位方式,应该使用css变量`--window-bottom`,比如悬浮在tabbar上方10px的按钮,样式如下`bottom: calc(var(--window-bottom) + 10px)`
- tabbar 的默认高度,在不同平台不一样。[详见](https://uniapp.dcloud.io/frame?id=%e5%9b%ba%e5%ae%9a%e5%80%bc)
- 中间带+号的tabbar模板例子,[参考](https://ext.dcloud.net.cn/plugin?id=98)。可跨端,但+号不凸起。
- 如需 tabbar 中间凸起,可自定义tabbar,插件市场有例子,如colorUI等。但注意前端tabbar的性能不如原生tabbar,如果是多页方式,底部tabbar会在切换时闪执行转场动画,如果是单页方式,承载复杂页面内容会有性能问题。[插件市场](https://ext.dcloud.net.cn/search?q=tabbar)搜索tabbar有不少类似例子。
- App端若使用nvue,自定义tabbar,没有性能体验问题。
- 纯nvue项目(manifest里renderer为native),目前使用pages.json里的tabbar反而影响性能,建议使用前端自己实现单页面的tabbar。后续会解决这个bug。
- Android App上弹出键盘顶起tabbar的问题。升级到HBuilderX 2.2后不再存在。
Expand Down
10 changes: 5 additions & 5 deletions docs/component/editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ editor组件目前只有App的vue页面和微信支持,其他端的富文本
| show-img-size | boolean | false || 点击图片时显示图片大小控件 |
| show-img-toolbar | boolean | false || 点击图片时显示工具栏控件 |
| show-img-resize | boolean | false || 点击图片时显示修改尺寸控件 |
| bindready | eventhandle | || 编辑器初始化完成时触发 |
| bindfocus | eventhandle | || 编辑器聚焦时触发,event.detail = {html, text, delta} |
| bindblur | eventhandle | || 编辑器失去焦点时触发,detail = {html, text, delta} |
| bindinput | eventhandle | || 编辑器内容改变时触发,detail = {html, text, delta} |
| bindstatuschange | eventhandle | || 通过 Context 方法改变编辑器内样式时触发,返回选区已设置的样式 |
| @ready | eventhandle | || 编辑器初始化完成时触发 |
| @focus | eventhandle | || 编辑器聚焦时触发,event.detail = {html, text, delta} |
| @blur | eventhandle | || 编辑器失去焦点时触发,detail = {html, text, delta} |
| @input | eventhandle | || 编辑器内容改变时触发,detail = {html, text, delta} |
| @statuschange | eventhandle | || 通过 Context 方法改变编辑器内样式时触发,返回选区已设置的样式 |

编辑器内支持部分 HTML 标签和内连样式,不支持**class****id**

Expand Down
2 changes: 1 addition & 1 deletion docs/component/map.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
|controls|Array||控件||
|include-points|Array||缩放视野以包含所有给定的坐标点|App-nvue 2.1.5+、微信小程序、H5、百度小程序、支付宝小程序|
|show-location|Boolean||显示带有方向的当前定位点|微信小程序、H5、百度小程序、支付宝小程序|
|@markertap|EventHandle||点击标记点时触发|App-nvue暂不支持, App平台需要指定 marker 对象属性 id|
|@markertap|EventHandle||点击标记点时触发|App-nvue 2.3.3+, App平台需要指定 marker 对象属性 id|
|@callouttap|EventHandle||点击标记点对应的气泡时触发||
|@controltap|EventHandle||点击控件时触发||
|@regionchange|EventHandle||视野发生变化时触发|微信小程序、H5、百度小程序、支付宝小程序|
Expand Down
1 change: 1 addition & 0 deletions docs/component/web-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export default {
// #ifdef APP-PLUS
wv = plus.webview.create("","custom-webview",{
plusrequire:"none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突
top:uni.getSystemInfoSync().statusBarHeight+44 //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
})
wv.loadURL("https://www.baidu.com")
Expand Down
4 changes: 3 additions & 1 deletion docs/frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,15 @@ const package = require('packageName')
|支付宝小程序|支持支付宝小程序组件|mycomponents|
|百度小程序|支持百度小程序组件|swancomponents|
|头条小程序|支持头条小程序组件|ttcomponents|
|QQ小程序|支持QQ小程序组件|wxcomponents|

此文档要求开发者对各端小程序的**自定义组件**有一定了解,没接触过小程序**自定义组件**的可以参考:

- [微信小程序自定义组件](https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/)
- [百度小程序自定义组件](https://smartprogram.baidu.com/docs/develop/framework/custom-component/)
- [支付宝小程序自定义组件](https://docs.alipay.com/mini/framework/custom-component-overview)
- [头条小程序自定义组件](https://developer.toutiao.com/docs/framework/custom_component_intro.html)
- [QQ小程序自定义组件](https://q.qq.com/wiki/develop/miniprogram/frame/diy_components/)

**目录结构**

Expand Down Expand Up @@ -785,7 +787,7 @@ const package = require('packageName')
"path": "index/index",
"style": {
"usingComponents": {
// #ifdef APP-PLUS || MP-WEIXIN
// #ifdef APP-PLUS || MP-WEIXIN || MP-QQ
"custom": "/wxcomponents/custom/index"
// #endif
// #ifdef MP-BAIDU
Expand Down
17 changes: 15 additions & 2 deletions docs/performance.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
#### 运行原理

``uni-app`` 在 App 端或小程序端运行时,从架构上分为逻辑层和视图层两个部分。逻辑层负责储存数据和执行业务逻辑,视图层负责页面渲染。
1. 逻辑层和视图层分离,且非H5端通信有折损

``uni-app`` 在非H5端运行时,从架构上分为逻辑层和视图层两个部分。逻辑层负责储存数据和执行业务逻辑,视图层负责页面渲染。

页面加载时,联网和逻辑运算在逻辑层(Android是v8,iOS是jscore),然后会传递数据给视图层渲染。这种通信有损耗。同样,在视图层操作时,比如拖动页面,要实时传递事件给逻辑层接收,也是有损耗的。

2. App端渲染引擎可切换

在App端,nvue页面的视图层是由原生引擎渲染的,vue页面的视图层是os的webview渲染的。
uni-app的webview渲染经过优化,性能也足够好。它比nvue弱的地方主要在于启动速度和可左右拖动的长列表。

3. app-vue和小程序的数据更新,分页面级和组件级

对于复杂页面,更新某个区域的数据时,需要把这个区域做成组件,这样更新数据时就只更新这个组件,否则会整个页面的数据更新,造成点击延迟卡顿。
这就是自定义组件编译模式的特点。

比如微博长列表页面,点击一个点赞图标,赞数要立即+1,此时这个点赞图标一定要做成组件。否则这个+1会引发页面级所有数据的更新。

app-nvue和h5不存在此问题。造成差异的原因是小程序目前只提供了组件差量更新的机制,不能自动计算所有页面差量。

#### 优化建议

Expand Down Expand Up @@ -52,7 +65,7 @@

**优化页面切换动画**

* 页面初始化时若存在大量图片渲染和大量数据通讯,很有可能造成页面切换卡顿、掉帧。建议延时100ms~300ms渲染图片,分批进行数据通讯,以减少一次性渲染的节点数量。
* 页面初始化时若存在大量图片或原生组件渲染和大量数据通讯,会发生新页面渲染和窗体进入动画抢资源,造成页面切换卡顿、掉帧。建议延时100ms~300ms渲染图片或复杂原生组件,分批进行数据通讯,以减少一次性渲染的节点数量。
* App端动画效果可以自定义。popin/popout的双窗体联动挤压动画效果对资源的消耗更大,如果动画期间页面里在执行耗时的js,可能会造成动画掉帧。此时可以使用消耗资源更小的动画效果,比如slide-in-right/slide-out-right。

**优化样式渲染速度**
Expand Down
8 changes: 8 additions & 0 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# uni-app 更新日志
======================================
#### 2.3.3.20190924
* App-Android平台 新增 uni.request 网络请求增加参数 sslVerify,配置是否验证 ssl 证书。但建议使用普遍受信的证书而不是忽略证书校验。[详情](https://uniapp.dcloud.io/api/request/request)
* App-iOS平台 调整 非自定义组件模式 逻辑层默认从 WKWebview 切回 UIWebview,避免 uni.request 无法跨域的问题。但仍建议开发者尽快升级自定义组件模式
* App-iOS平台 新增 非自定义组件模式 iOS13上页面无法滚动的问题,如不能很快升级为自定义组件模式,可临时使用本文的方案2来解决,[详情](https://ask.dcloud.net.cn/article/36410)
* App-iOS平台 修复 nvue swiper组件包含子组件少于3个时布局可能不正确的Bug
* App-iOS平台 修复 nvue video组件退出全屏动画会闪现底层组件的Bug
* H5端 修复 监听页面滚动(onPageScroll)后切换页面报错的Bug [详情](https://ask.dcloud.net.cn/question/78955)

#### 2.3.2.20190921
* App平台 修复 uni.writeBLECharacteristicValue 无法写入数据的 Bug [详情](https://ask.dcloud.net.cn/question/79204)
* App平台 修复 调用 uni.pageScrollTo 时页面内元素 fixed 定位失效的 Bug [详情](https://ask.dcloud.net.cn/question/73179)
Expand Down
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-23020190919001"
"version": "2.0.0-23320190923002"
}
5 changes: 3 additions & 2 deletions lib/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const device = [
]

const keyboard = [
'hideKeyboard',
'hideKeyboard',
'onKeyboardHeightChange'
]

Expand All @@ -138,6 +138,7 @@ const ui = [
'removeTabBarBadge',
'showTabBarRedDot',
'hideTabBarRedDot',
'onTabBarMidButtonTap',
'setBackgroundColor',
'setBackgroundTextStyle',
'createAnimation',
Expand Down Expand Up @@ -209,4 +210,4 @@ const apis = [
...third
]

module.exports = apis
module.exports = apis
Loading

0 comments on commit dd3f979

Please sign in to comment.