提交 ca64cfff 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'dev' of https://github.com/dcloudio/uni-app into dev

......@@ -17,6 +17,7 @@
|filePath|String|是|要上传文件资源的路径。||
|name|String|是|文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容||
|header|Object|否|HTTP 请求 Header, header 中不能设置 Referer。||
|timeout|Number|否|超时时间,单位 ms|H5(HBuilderX 2.9.8+)、APP(HBuilderX 2.9.8+)|
|formData|Object|否|HTTP 请求中其他额外的 form data||
|success|Function|否|接口调用成功的回调函数||
|fail|Function|否|接口调用失败的回调函数||
......@@ -27,7 +28,7 @@
- App支持多文件上传,微信小程序只支持单文件上传,传多个文件需要反复调用本API。所以跨端的写法就是循环调用本API。
- hello uni-app中的客服反馈,支持多图上传。[uni-app插件市场](https://ext.dcloud.net.cn/)中也有多个封装的组件。
- App平台选择和上传非图像、视频文件,参考[https://ask.dcloud.net.cn/article/35547](https://ask.dcloud.net.cn/article/35547)
- 网络请求的 ``超时时间`` 可以统一在 ``manifest.json`` 中配置 [networkTimeout](/collocation/manifest?id=networktimeout)
- 网络请求的 ``超时时间`` 可以统一在 ``manifest.json`` 中配置 [networkTimeout](/collocation/manifest?id=networktimeout)
- 支付宝小程序开发工具上传文件返回的http状态码为字符串形式,支付宝小程序真机返回的状态码为数字形式
**files参数说明**
......@@ -145,10 +146,11 @@ uni.chooseImage({
**OBJECT 参数说明**
|参数名|类型|必填|说明|
|:-|:-|:-|:-|
|参数名|类型|必填|说明|平台差异说明|
|:-|:-|:-|:-|:-|
|url|String|是|下载资源的 url|
|header|Object|否|HTTP 请求 Header, header 中不能设置 Referer。|
|timeout|Number|否|超时时间,单位 ms|H5(HBuilderX 2.9.8+)、APP(HBuilderX 2.9.8+)|
|success|Function|否|下载成功后以 tempFilePath 的形式传给页面,res = {tempFilePath: '文件的临时路径'}|
|fail|Function|否|接口调用失败的回调函数|
|complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)|
......
......@@ -11,7 +11,7 @@
|data|Object/String/ArrayBuffer|否||请求的参数|App(自定义组件编译模式)不支持ArrayBuffer类型|
|header|Object|否||设置请求的 header,header 中不能设置 Referer。|H5端会自动带上cookie不可手动覆盖|
|method|String|否|GET|有效值详见下方说明||
|timeout|Number|否|30000|超时时间,单位 ms|微信小程序(2.10.0)、支付宝小程序|
|timeout|Number|否|30000|超时时间,单位 ms|H5(HBuilderX 2.9.8+)、APP(HBuilderX 2.9.8+)、微信小程序(2.10.0)、支付宝小程序|
|dataType|String|否|json |如果设为 json,会尝试对返回的数据做一次 JSON.parse||
|responseType|String|否|text |设置响应的数据类型。合法值:text、arraybuffer|App和支付宝小程序不支持|
|sslVerify|Boolean|否|true|验证 ssl 证书|仅App安卓端支持(HBuilderX 2.3.3+)|
......
......@@ -16,7 +16,7 @@
|maxlength|Number|140|最大输入长度,设置为 -1 的时候不限制最大长度||
|cursor-spacing|Number|0|指定光标与键盘的距离,单位 px 。取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离|App、微信小程序、百度小程序、QQ小程序|
|focus|Boolean|false|获取焦点。|在 H5 平台能否聚焦以及软键盘是否跟随弹出,取决于当前浏览器本身的实现。|
|confirm-type|String|done|设置键盘右下角按钮的文字,仅在 type="text" 时生效。||
|confirm-type|String|done|设置键盘右下角按钮的文字,仅在 type="text" 时生效。|微信小程序基础库2.13.0、APP(HBuilder X2.9.8+)、H5(HBuilder X2.9.8+)|
|confirm-hold|Boolean|false|点击键盘右下角按钮时是否保持键盘不收起|App、微信小程序、支付宝小程序、百度小程序、QQ小程序|
|cursor|Number||指定focus时的光标位置||
|selection-start|Number|-1|光标起始位置,自动聚集时有效,需与selection-end搭配使用||
......@@ -68,6 +68,7 @@
- App平台的nvue页面,如果是uni-app编译模式,直接使用此属性设置即可生效。如果是weex编译模式,需通过weex的api设置,[weex相关文档参考](https://weex.apache.org/zh/docs/components/input.html#%E5%B1%9E%E6%80%A7)
- App平台的vue页面不支持控制键盘右下角为“发送”,涉及聊天的建议使用nvue。
- confirm-type属性仅在Chrome 77+、IOS 13.4+、Android 5-6.x WebView: Chromium 81+支持。
#### App平台iOS端软键盘上方横条去除方案
......
......@@ -17,6 +17,7 @@
|fixed|Boolean|false|如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true|微信小程序、百度小程序、字节跳动小程序、QQ小程序|
|cursor-spacing|Number|0|指定光标与键盘的距离,单位 px 。取 textarea 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离|App、微信小程序、百度小程序、字节跳动小程序、QQ小程序|
|cursor|Number||指定focus时的光标位置|微信小程序、App、H5、百度小程序、字节跳动小程序、QQ小程序|
|confirm-type|String|done|设置键盘右下角按钮的文字,仅在 type="text" 时生效。|微信小程序基础库2.13.0、APP(HBuilder X2.9.8+)、H5(HBuilder X2.9.8+)|
|show-confirm-bar|Boolean|true|是否显示键盘上方带有”完成“按钮那一栏|微信小程序、百度小程序、QQ小程序|
|selection-start|Number|-1|光标起始位置,自动聚焦时有效,需与selection-end搭配使用|微信小程序、App、H5、百度小程序、字节跳动小程序、QQ小程序|
|selection-end|Number|-1|光标结束位置,自动聚焦时有效,需与selection-start搭配使用|微信小程序、App、H5、百度小程序、字节跳动小程序、QQ小程序|
......@@ -28,7 +29,19 @@
|@linechange|EventHandle||输入框行数变化时调用,event.detail = {height: 0, heightRpx: 0, lineCount: 0}|字节跳动小程序不支持,nvue ios暂不支持|
|@input|EventHandle||当键盘输入时,触发 input 事件,event.detail = {value, cursor}, @input 处理函数的返回值并不会反映到 textarea 上||
|@confirm|EventHandle||点击完成时, 触发 confirm 事件,event.detail = {value: value}|微信小程序、百度小程序、QQ小程序|
|@keyboardheightchange|eventhandle||键盘高度发生变化的时候触发此事件,event.detail = {height: height, duration: duration}|微信小程序2.7.0|
|@keyboardheightchange|Eventhandle||键盘高度发生变化的时候触发此事件,event.detail = {height: height, duration: duration}|微信小程序2.7.0|
**confirm-type 有效值**
|值|说明|平台差异说明|
|:-|:-|-|
|send|右下角按钮为“发送”|微信、支付宝、百度小程序、App的nvue|
|search|右下角按钮为“搜索”||
|next|右下角按钮为“下一个”|微信、支付宝、百度小程序、App的nvue|
|go|右下角按钮为“前往”||
|done|右下角按钮为“完成”|微信、支付宝、百度小程序、App的nvue|
**示例** [查看示例](https://hellouniapp.dcloud.net.cn/pages/component/textarea/textarea)
......@@ -74,6 +87,7 @@ export default {
- 如果遇到 focus 属性设置不生效的问题参考:[组件属性设置不生效解决办法](/use?id=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)
- 软键盘的弹出和收起逻辑,详见[input的文档](/component/input?id=app%E5%B9%B3%E5%8F%B0ios%E7%AB%AF%E8%BD%AF%E9%94%AE%E7%9B%98%E4%B8%8A%E6%96%B9%E6%A8%AA%E6%9D%A1%E5%8E%BB%E9%99%A4%E6%96%B9%E6%A1%88)
- 如需禁止点击其他位置收起键盘的默认行为,可以监听`touch`事件并使用`prevent`修饰符(仅支持App-v3、H5,其他平台可以通过设置`focus`来使输入框重新获取焦点),例如在确认按钮上使用:```@touchend.prevent="onTap"```
- confirm-type属性仅在Chrome 77+、IOS 13.4+、Android 5-6.x WebView: Chromium 81+支持。
**富文本编辑的解决方案**
在输入框里图文混排内容,在web上该功能依赖document,而小程序和app的正常页面又没有document。
......
......@@ -106,7 +106,8 @@ if (pixelRatio !== 1) {
args[1] *= pixelRatio
args[2] *= pixelRatio
var font = this.font
// Safari 重新设置部分属性会导致其他值恢复默认,需获取原始值
var font = this.__font__ || this.font
this.font = font.replace(
/(\d+\.?\d*)(px|em|rem|pt)/g,
function (w, m, u) {
......@@ -130,7 +131,8 @@ if (pixelRatio !== 1) {
args[1] *= pixelRatio // x
args[2] *= pixelRatio // y
var font = this.font
// Safari 重新设置部分属性会导致其他值恢复默认,需获取原始值
var font = this.__font__ || this.font
this.font = font.replace(
/(\d+\.?\d*)(px|em|rem|pt)/g,
function (w, m, u) {
......
......@@ -103,5 +103,8 @@ export const request = {
},
withCredentials: {
type: Boolean
},
timeout: {
type: Number
}
}
......@@ -212,24 +212,21 @@ export default {
data.forEach(function (color_, method_) {
c2d[_[method_]] = _[method_] === 'shadowColor' ? resolveColor(color_) : color_
})
} else {
if (method1 === 'fontSize') {
c2d.font = c2d.font.replace(/\d+\.?\d*px/, data[0] + 'px')
} else {
if (method1 === 'lineDash') {
c2d.setLineDash(data[0])
c2d.lineDashOffset = data[1] || 0
} else {
if (method1 === 'textBaseline') {
if (data[0] === 'normal') {
data[0] = 'alphabetic'
}
c2d[method1] = data[0]
} else {
c2d[method1] = data[0]
}
}
} else if (method1 === 'fontSize') {
const font = c2d.__font__ || c2d.font
c2d.__font__ = c2d.font = font.replace(/\d+\.?\d*px/, data[0] + 'px')
} else if (method1 === 'lineDash') {
c2d.setLineDash(data[0])
c2d.lineDashOffset = data[1] || 0
} else if (method1 === 'textBaseline') {
if (data[0] === 'normal') {
data[0] = 'alphabetic'
}
c2d[method1] = data[0]
} else if (method1 === 'font') {
c2d.__font__ = c2d.font = data[0]
} else {
c2d[method1] = data[0]
}
} else if (method === 'fillPath' || method === 'strokePath') {
method = method.replace(/Path/, '')
......
......@@ -24,6 +24,7 @@
:type="inputType"
:maxlength="maxlength"
:step="step"
:enterkeyhint="confirmType"
class="uni-input-input"
autocomplete="off"
@focus="_onFocus"
......@@ -31,7 +32,7 @@
@input.stop="_onInput"
@compositionstart="_onComposition"
@compositionend="_onComposition"
@keyup.stop="_onKeyup"
@keyup.enter.stop="_onKeyup"
>
<input
v-if="disabled && fixColor"
......@@ -171,11 +172,9 @@ export default {
},
methods: {
_onKeyup ($event) {
if ($event.keyCode === 13) {
this.$trigger('confirm', $event, {
value: $event.target.value
})
}
this.$trigger('confirm', $event, {
value: $event.target.value
})
},
_onInput ($event) {
if (this.composing) {
......
......@@ -37,6 +37,7 @@
:maxlength="maxlengthNumber"
:class="{ 'uni-textarea-textarea-fix-margin': fixMargin }"
:style="{ 'overflow-y': autoHeight ? 'hidden' : 'auto' }"
:enterkeyhint="confirmType"
class="uni-textarea-textarea"
@compositionstart="_onCompositionstart"
@compositionend="_onCompositionend"
......@@ -44,6 +45,8 @@
@focus="_onFocus"
@blur="_onBlur"
@touchstart.passive="_onTouchstart"
@keyup.enter="_onKeyUpEnter"
@keydown.enter="_onKeyDownEnter"
/>
<textarea
v-if="disabled && fixColor"
......@@ -107,6 +110,10 @@ export default {
selectionEnd: {
type: [Number, String],
default: -1
},
confirmType: {
type: String,
default: ''
}
},
data () {
......@@ -141,6 +148,9 @@ export default {
},
valueCompute () {
return (this.composition ? this.valueComposition : this.valueSync).split('\n')
},
isDone () {
return ['done', 'go', 'next', 'search', 'send'].includes(this.confirmType)
}
},
watch: {
......@@ -208,6 +218,17 @@ export default {
})
},
methods: {
_onKeyDownEnter: function ($event) {
if (this.isDone) {
$event.preventDefault()
}
},
_onKeyUpEnter: function ($event) {
if (this.isDone) {
this._confirm($event)
this.$refs.textarea.blur()
}
},
_onFocus: function ($event) {
this.focusSync = true
this.$trigger('focus', $event, {
......
......@@ -19,10 +19,11 @@ const publishStateChange = (res) => {
const createDownloadTaskById = function (downloadTaskId, {
url,
header
header,
timeout = __uniConfig.networkTimeout.downloadFile ? __uniConfig.networkTimeout.downloadFile / 1000 : 120
} = {}) {
const downloader = plus.downloader.createDownload(url, {
time: __uniConfig.networkTimeout.downloadFile ? __uniConfig.networkTimeout.downloadFile / 1000 : 120,
timeout,
filename: TEMP_PATH + '/download/',
// 需要与其它平台上的表现保持一致,不走重试的逻辑。
retry: 0,
......@@ -91,4 +92,4 @@ export function operateDownloadTask ({
export function createDownloadTask (args) {
return createDownloadTaskById(++downloadTaskId, args)
}
}
......@@ -45,7 +45,8 @@ export function createRequestTaskById (requestTaskId, {
method = 'GET',
responseType,
sslVerify = true,
firstIpv4 = false
firstIpv4 = false,
timeout = __uniConfig.networkTimeout.request
} = {}) {
const stream = requireNativePlugin('stream')
const headers = {}
......@@ -77,7 +78,6 @@ export function createRequestTaskById (requestTaskId, {
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
}
const timeout = __uniConfig.networkTimeout.request
if (timeout) {
abortTimeout = setTimeout(() => {
aborted = true
......
......@@ -23,10 +23,11 @@ const createUploadTaskById = function (uploadTaskId, {
name,
files,
header,
formData
formData,
timeout = __uniConfig.networkTimeout.uploadFile ? __uniConfig.networkTimeout.uploadFile / 1000 : 120
} = {}) {
const uploader = plus.uploader.createUpload(url, {
timeout: __uniConfig.networkTimeout.uploadFile ? __uniConfig.networkTimeout.uploadFile / 1000 : 120,
timeout,
// 需要与其它平台上的表现保持一致,不走重试的逻辑。
retry: 0,
retryInterval: 0
......@@ -113,4 +114,4 @@ export function operateUploadTask ({
export function createUploadTask (args) {
return createUploadTaskById(++uploadTaskId, args)
}
}
......@@ -45,9 +45,9 @@ class DownloadTask {
*/
export function downloadFile ({
url,
header
header,
timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.downloadFile) || 60 * 1000
}, callbackId) {
var timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.downloadFile) || 60 * 1000
const {
invokeCallbackHandler: invoke
} = UniServiceJSBridge
......
......@@ -51,13 +51,13 @@ export function request ({
method,
dataType,
responseType,
withCredentials
withCredentials,
timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000
}, callbackId) {
const {
invokeCallbackHandler: invoke
} = UniServiceJSBridge
var body = null
var timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.request) || 60 * 1000
// 根据请求类型处理数据
var contentType
for (const key in header) {
......@@ -152,4 +152,4 @@ export function request ({
xhr.withCredentials = withCredentials
xhr.send(body)
return requestTask
}
}
......@@ -56,9 +56,9 @@ export function uploadFile ({
name,
files,
header,
formData
formData,
timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.uploadFile) || 60 * 1000
}, callbackId) {
var timeout = (__uniConfig.networkTimeout && __uniConfig.networkTimeout.uploadFile) || 60 * 1000
const {
invokeCallbackHandler: invoke
} = UniServiceJSBridge
......
......@@ -921,6 +921,7 @@ export default {
return element
}
}
throw new Error('translateMarker: fail cannot find marker with id ' + id)
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册