提交 96699f6a 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -31,6 +31,8 @@ const DEPS = {
['/platforms/h5/components/system-routes/open-location/index.vue', 'OpenLocation']
],
'previewImage': [
['/core/view/components/swiper/index.vue', 'Swiper'],
['/core/view/components/swiper-item/index.vue', 'SwiperItem'],
['/platforms/h5/components/system-routes/preview-image/index.vue', 'PreviewImage']
],
'showToast': TOAST_DEPS,
......@@ -138,4 +140,4 @@ module.exports = {
JSON.stringify(manifestJson, null, 4)
)
}
}
}
......@@ -23,11 +23,12 @@
|acceleration|Boolean|false|当开启时,会根据滑动速度,连续滑动多屏|支付宝小程序|
|disable-programmatic-animation|Boolean|false|是否禁用代码变动触发 swiper 切换时使用动画。|支付宝小程序|
|display-multiple-items|Number|1|同时显示的滑块数量|支付宝小程序不支持|
|skip-hidden-item-layout|Boolean|false|是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息|5+App、微信小程序|
|disable-touch|Boolean|false|是否禁止用户 touch 操作|支付宝小程序|
|touchable|Boolean|true|是否监听用户的触摸事件|头条小程序|
|skip-hidden-item-layout|Boolean|false|是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息|5+App、微信小程序|
|disable-touch|Boolean|false|是否禁止用户 touch 操作|App 2.5.5+、H5 2.5.5+、支付宝小程序|
|disable-touch|Boolean|false|是否禁止用户 touch 操作|App 2.5.5+、H5 2.5.5+、支付宝小程序、头条小程序(只在初始化时有效,不能动态变更)|
|touchable|Boolean|true|是否监听用户的触摸事件,只在初始化时有效,不能动态变更|头条小程序(uni-app 2.5.5+ 推荐统一使用 disable-touch)|
|easing-function|String|default|指定 swiper 切换缓动动画类型,有效值:default、linear、easeInCubic、easeOutCubic、easeInOutCubic|微信小程序|
|@change|EventHandle||current 改变时会触发 change 事件,event.detail = {current: current, source: source}||
|@change|EventHandle||current 改变时会触发 change 事件,event.detail = {current: current, source: source}||
|@transition|EventHandle||swiper-item 的位置发生改变时会触发 transition 事件,event.detail = {dx: dx, dy: dy}|5+App、H5、微信小程序、支付宝小程序、头条小程序、QQ小程序|
|@animationfinish|EventHandle||动画结束时会触发 animationfinish 事件,event.detail = {current: current, source: source}|头条小程序不支持|
......@@ -48,7 +49,7 @@ change 事件返回 detail 中包含一个 source 字段,表示导致变更的
- 注意:其中只可放置 ``<swiper-item>`` 组件,否则会导致未定义的行为。
- 如果遇到current、current-item-id属性设置不生效的问题参考:[组件属性设置不生效解决办法](/use?id=%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98)
- banner图的切换效果和指示器的样式,有多种风格可自定义,可在[uni-app插件市场](https://ext.dcloud.net.cn/search?q=%E8%BD%AE%E6%92%AD)搜索
- swiper在App的vue中、百度支付宝头条QQ小程序中,不支持内嵌video、map等原生组件。在微信基础库2.4.4起和App nvue2.1.5起支持内嵌原生组件。竖向的swiper内嵌视频可实现抖音、映客等视频垂直拖动切换效果。
- swiper在App的vue中、百度支付宝头条QQ小程序中,不支持内嵌video、map等原生组件。在微信基础库2.4.4起和App nvue2.1.5起支持内嵌原生组件。竖向的swiper内嵌视频可实现抖音、映客等视频垂直拖动切换效果。
- 同时监听 change transition,开始滑动时触发transition, 放开手后,在ios平台触发顺序为 transition... change,Android/微信小程序/支付宝为 transition... change transition...
#### swiper-item
......
......@@ -1178,6 +1178,37 @@ export default {
- 各个`script`标签会分别被打包至对应支持平台,不需要额外写条件编译
- 自`HBuilderX 2.2.5`开始,不推荐使用各个小程序自有的引入方式,推荐使用`script`标签引入
## renderjs
uni-app 2.5.5+ 在 [WXS](?id=wxs) 的基础上扩展了 renderjs,以 vue 组件的写法运行在 view 层。仅支持 App([V3](https://ask.dcloud.net.cn/article/36599) 且不含 nvue)、H5。
### 使用方式
设置 script 节点的 lang 为 renderjs
```html
<script module="test" lang="renderjs">
export default {
mounted() {
// ...
},
methods: {
// ...
}
}
</script>
```
### 示例
* [echarts 示例](https://ext.dcloud.net.cn/plugin?id=1207)
### 注意事项
* 可以使用 dom、bom API 不可直接访问 service 层数据
* view 层和 service 层通讯方式与 [WXS](?id=wxs) 一致
* 观测更新的数据在 view 层可以直接访问到
* 不要直接引用大型类库,推荐通过动态创建 script 方式引用
* view 层的页面引用资源的路径相对于根目录计算,例如:./static/test.js
## 致谢
......
......@@ -7,7 +7,7 @@ module.exports = {
collectCoverageFrom: ['packages/*/src/**/*.js'],
moduleFileExtensions: ['js', 'json'],
moduleNameMapper: {
'^@dcloudio/(.*?)$': '<rootDir>/packages/$1/src'
'^@dcloudio/(.*?)$': '<rootDir>/packages/$1'
},
rootDir: __dirname,
testMatch: ['<rootDir>/packages/**/__tests__/**/*spec.(t|j)s']
......
......@@ -6,7 +6,7 @@ const {
getTagName
} = require('../../h5')
const tags = require('../../../../uni-cli-shared/lib/tags')
const tags = require('@dcloudio/uni-cli-shared/lib/tags')
// 仅限 view 层
module.exports = function parseTag (el) {
......
......@@ -6,15 +6,15 @@ const {
const {
removeExt
} = require('../../uni-cli-shared/lib/util')
} = require('@dcloudio/uni-cli-shared/lib/util')
const {
getAutoComponents
} = require('../../uni-cli-shared/lib/pages')
} = require('@dcloudio/uni-cli-shared/lib/pages')
const {
updateUsingAutoImportComponents
} = require('../../uni-cli-shared/lib/cache')
} = require('@dcloudio/uni-cli-shared/lib/cache')
function formatSource (source) {
if (source.indexOf('@/') === 0) { // 根目录
......
......@@ -8,7 +8,7 @@ const {
compileToFunctions,
ssrCompile,
ssrCompileToFunctions
} = require('../../vue-cli-plugin-uni/packages/vue-template-compiler')
} = require('@dcloudio/vue-cli-plugin-uni/packages/vue-template-compiler')
const platforms = require('./platforms')
const traverseScript = require('./script/traverse')
......@@ -19,6 +19,7 @@ const generateTemplate = require('./template/generate')
const compilerModule = require('./module')
const compilerAlipayModule = require('./module-alipay')
const compilerToutiaoModule = require('./module-toutiao')
const generateCodeFrame = require('./codeframe')
......@@ -75,6 +76,8 @@ module.exports = {
if (options.mp.platform === 'mp-alipay') {
options.modules.push(compilerAlipayModule)
} else if (options.mp.platform === 'mp-toutiao') {
options.modules.push(compilerToutiaoModule)
}
const res = compileTemplate(source, Object.assign(options, {
......@@ -254,4 +257,4 @@ at ${resourcePath}.vue:1`)
ssrCompile,
ssrCompileToFunctions,
generateCodeFrame
}
}
module.exports = {
postTransformNode (el) {
if (el.tag === 'swiper') {
const attrsMap = el.attrsMap
let touchable
if (attrsMap[':disable-touch']) {
touchable = `!(${attrsMap[':disable-touch']})`
} else if ('disable-touch' in attrsMap) {
touchable = 'false'
}
if (touchable) {
const attr = el.attrs.find(attr => attr.name === ':touchable')
if (attr) {
attr.value = touchable
} else {
el.attrs.push({
name: ':touchable',
value: touchable
})
}
}
}
}
}
const fs = require('fs')
const path = require('path')
const updateComponents = require('./component')
const tmpDir = path.resolve(__dirname, '../../.tmp')
......@@ -72,6 +73,12 @@ function updateAppComponents(paths) {
return updateExportDefaultObject(paths, 'app-components.js', false)
}
function updateCoreComponents(paths){
const tags = process.UNI_TAGS || new Set()
Object.keys(paths).forEach(tag => tags.add(tag.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()))
updateComponents(tags)
}
function updateAppMixins(paths) {
return updateExportDefaultObject(paths, 'app-mixins.js', false, true)
}
......@@ -93,6 +100,11 @@ const isAppComponents = filepath => {
filepath.indexOf('/platforms/' + process.env.UNI_PLATFORM + '/components/app/') === 0
}
const isCoreComponents = filepath => {
return path.extname(filepath) === '.vue' &&
filepath.indexOf('/core/view/components/') === 0
}
const isAppMixins = filepath => {
return path.extname(filepath) === '.js' &&
filepath.indexOf('/platforms/' + process.env.UNI_PLATFORM + '/components/app/') === 0
......@@ -113,6 +125,7 @@ function parseDeps(apis, manifest) {
const apiProtocolPaths = Object.create(null)
const invokeApiPaths = Object.create(null)
const appComponentsPaths = Object.create(null)
const coreComponentsPaths = Object.create(null)
const appMixinsPaths = Object.create(null)
const systemRoutesPaths = Object.create(null)
const apiSubscribePaths = Object.create(null)
......@@ -126,6 +139,9 @@ function parseDeps(apis, manifest) {
}, {
test: isAppComponents,
paths: appComponentsPaths
}, {
test: isCoreComponents,
paths: coreComponentsPaths
}, {
test: isAppMixins,
paths: appMixinsPaths
......@@ -159,7 +175,7 @@ function parseDeps(apis, manifest) {
})
if (strategy) {
strategy.paths[exports] = filepath
} else {
} else {
console.log('dep',name,dep)
console.warn(`${filepath} 未识别`)
}
......@@ -175,6 +191,7 @@ function parseDeps(apis, manifest) {
apiProtocolPaths,
invokeApiPaths,
appComponentsPaths,
coreComponentsPaths,
appMixinsPaths,
systemRoutesPaths,
apiSubscribePaths
......@@ -203,6 +220,7 @@ module.exports = function updateApis(apis = new Set(), userApis = new Set()) {
invokeApiPaths,
apiSubscribePaths,
appComponentsPaths,
coreComponentsPaths,
appMixinsPaths,
systemRoutesPaths
} = parseDeps(apis, manifest)
......@@ -214,6 +232,7 @@ module.exports = function updateApis(apis = new Set(), userApis = new Set()) {
updateInvokeApi(invokeApiPaths)
updateAppComponents(appComponentsPaths)
updateCoreComponents(coreComponentsPaths)
updateAppMixins(appMixinsPaths)
updateSystemRoutes(systemRoutesPaths)
}
}
......@@ -37,12 +37,14 @@ module.exports = function updateComponents(tags) {
tagName = capitalize(camelize(tagName))
return `${tagName}.name = 'VUni${tagName}'
${tagName}.mixins = ${tagName}.mixins ? [].concat(baseMixin, ${tagName}.mixins) : [baseMixin]
${tagName}.mixins.push(animation)
Vue.component(${tagName}.name,${tagName})`
}).join('\n')
const content = `
import Vue from 'vue'
import baseMixin from 'uni-mixins/base'
import animation from 'uni-mixins/animation'
${importsStr}
${componentsStr}
`
......
......@@ -91,6 +91,9 @@ module.exports = function generateJson (compilation) {
const jsonFileMap = getChangedJsonFileMap()
for (let name of jsonFileMap.keys()) {
const jsonObj = JSON.parse(jsonFileMap.get(name))
if (process.env.UNI_PLATFORM === 'app-plus') { // App平台默认增加usingComponents,激活__wxAppCode__
jsonObj.usingComponents = {}
}
// customUsingComponents
if (jsonObj.customUsingComponents && Object.keys(jsonObj.customUsingComponents).length) {
jsonObj.usingComponents = Object.assign(jsonObj.customUsingComponents, jsonObj.usingComponents)
......
import {
invokeMethod,
getCurrentPageVm
} from '../../platform'
} from '../../platform'
import {
callback
} from 'uni-shared'
function operateMapPlayer (mapId, pageVm, type, data) {
invokeMethod('operateMapPlayer', mapId, pageVm, type, data)
}
UniServiceJSBridge.subscribe('onMapMethodCallback', ({
callbackId,
data
}) => {
callback.invoke(callbackId, data)
})
const methods = ['getCenterLocation', 'translateMarker', 'getScale', 'getRegion']
export class MapContext {
constructor (id, pageVm) {
this.id = id
this.pageVm = pageVm
}
getCenterLocation (args) {
operateMapPlayer(this.id, this.pageVm, 'getCenterLocation', args)
}
moveToLocation () {
operateMapPlayer(this.id, this.pageVm, 'moveToLocation')
}
translateMarker (args) {
operateMapPlayer(this.id, this.pageVm, 'translateMarker', args)
}
includePoints (args) {
operateMapPlayer(this.id, this.pageVm, 'includePoints', args)
}
}
getRegion (args) {
operateMapPlayer(this.id, this.pageVm, 'getRegion', args)
}
getScale (args) {
operateMapPlayer(this.id, this.pageVm, 'getScale', args)
}
}
methods.forEach(function (method) {
MapContext.prototype[method] = callback.warp(function (options, callbackId) {
operateMapPlayer(this.id, this.pageVm, method, {
options,
callbackId
})
})
})
export function createMapContext (id, context) {
if (context) {
......
......@@ -61,6 +61,10 @@ export default {
displayMultipleItems: {
type: [Number, String],
default: 1
},
disableTouch: {
type: [Boolean, String],
default: false
}
},
data () {
......@@ -538,6 +542,9 @@ export default {
}
},
_handleContentTrack (e) {
if (this.disableTouch) {
return
}
if (!this._invalid) {
if (e.detail.state === 'start') {
this.userTracking = true
......
......@@ -31,7 +31,7 @@ export function createRequestTaskById (requestTaskId, {
hasContentType = true
headers['Content-Type'] = header[name]
// TODO 需要重构
if (method === 'POST' && header[name].indexOf('application/x-www-form-urlencoded') === 0) {
if (method !== 'GET' && header[name].indexOf('application/x-www-form-urlencoded') === 0 && typeof data !== 'string' && !(data instanceof ArrayBuffer)) {
let bodyArray = []
for (let key in data) {
if (data.hasOwnProperty(key)) {
......
......@@ -146,7 +146,9 @@ export default {
const list = this.controls.map((control) => {
let position = { position: 'absolute' };
['top', 'left', 'width', 'height'].forEach(key => {
position[key] = control.position[key] + 'px'
if (control.position[key]) {
position[key] = control.position[key] + 'px'
}
})
return {
id: control.id,
......@@ -160,6 +162,25 @@ export default {
watch: {
hidden (val) {
this.map && this.map[val ? 'hide' : 'show']()
},
latitude (val) {
this.map && this.map.setStyles({
center: new plus.maps.Point(this.longitude, this.latitude)
})
},
longitude (val) {
this.map && this.map.setStyles({
center: new plus.maps.Point(this.longitude, this.latitude)
})
},
markers (val) {
this.map && this._addMarkers(val)
},
polyline (val) {
this.map && this._addMapLines(val)
},
circles (val) {
this.map && this._addMapCircles(val)
}
},
mounted () {
......@@ -175,17 +196,6 @@ export default {
if (this.hidden) {
map.hide()
}
this.$watch('attrs', () => {
if (this.map) {
this.map.setStyles(this.attrs)
// TODO 临时处理更新 longitude, latitude 无效问题
this.map.setStyles({
center: new plus.maps.Point(this.longitude, this.latitude)
})
}
}, {
deep: true
})
this.$watch('position', () => {
this.map && this.map.setStyles(this.position)
}, {
......@@ -214,13 +224,40 @@ export default {
}
this.map && this[type](data)
},
getRegion () {
moveToLocation (data) {
this.map.setCenter(new plus.maps.Point(this.longitude, this.latitude))
},
getCenterLocation ({ callbackId }) {
const center = this.map.getCenter()
this._publishHandler(callbackId, {
longitude: center.longitude,
latitude: center.latitude,
errMsg: 'getCenterLocation:ok'
})
},
getScale () {
getRegion ({ callbackId }) {
const rect = this.map.getBounds()
this._publishHandler(callbackId, {
southwest: rect.southwest,
northeast: rect.northeast || rect.northease, // 5plus API 名字写错了
errMsg: 'getRegion:ok'
})
},
getScale ({ callbackId }) {
this._publishHandler(callbackId, {
scale: this.map.getZoom(),
errMsg: 'getScale:ok'
})
},
controlclick (e) {
this.$trigger('controltap', {}, { id: e.id })
},
_publishHandler (callbackId, data) {
UniViewJSBridge.publishHandler('onMapMethodCallback', {
callbackId,
data
}, this.$page.id)
},
_addMarker (nativeMap, marker) {
const {
id,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册