Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
96699f6a
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
96699f6a
编写于
1月 10, 2020
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
a6dc7f92
2203abe3
变更
15
显示空白变更内容
内联
并排
Showing
15 changed file
with
182 addition
and
47 deletion
+182
-47
build/manifest.js
build/manifest.js
+3
-1
docs/component/swiper.md
docs/component/swiper.md
+6
-5
docs/frame.md
docs/frame.md
+31
-0
jest.config.js
jest.config.js
+1
-1
packages/uni-template-compiler/lib/app/parser/tag-parser.js
packages/uni-template-compiler/lib/app/parser/tag-parser.js
+1
-1
packages/uni-template-compiler/lib/auto-components.js
packages/uni-template-compiler/lib/auto-components.js
+3
-3
packages/uni-template-compiler/lib/index.js
packages/uni-template-compiler/lib/index.js
+5
-2
packages/uni-template-compiler/lib/module-toutiao.js
packages/uni-template-compiler/lib/module-toutiao.js
+24
-0
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js
...ugin-uni-optimize/packages/webpack-optimize-plugin/api.js
+21
-2
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js
...ni-optimize/packages/webpack-optimize-plugin/component.js
+2
-0
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
+3
-0
src/core/service/api/context/create-map-context.js
src/core/service/api/context/create-map-context.js
+23
-17
src/core/view/components/swiper/index.vue
src/core/view/components/swiper/index.vue
+7
-0
src/platforms/app-plus/service/api/network/request.js
src/platforms/app-plus/service/api/network/request.js
+1
-1
src/platforms/app-plus/view/components/map/index.vue
src/platforms/app-plus/view/components/map/index.vue
+51
-14
未找到文件。
build/manifest.js
浏览文件 @
96699f6a
...
...
@@ -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
,
...
...
docs/component/swiper.md
浏览文件 @
96699f6a
...
...
@@ -24,8 +24,9 @@
|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|是否监听用户的触摸事件|头条小程序|
|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}||
|@transition|EventHandle||swiper-item 的位置发生改变时会触发 transition 事件,event.detail = {dx: dx, dy: dy}|5+App、H5、微信小程序、支付宝小程序、头条小程序、QQ小程序|
...
...
docs/frame.md
浏览文件 @
96699f6a
...
...
@@ -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
## 致谢
...
...
jest.config.js
浏览文件 @
96699f6a
...
...
@@ -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
'
]
...
...
packages/uni-template-compiler/lib/app/parser/tag-parser.js
浏览文件 @
96699f6a
...
...
@@ -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
)
{
...
...
packages/uni-template-compiler/lib/auto-components.js
浏览文件 @
96699f6a
...
...
@@ -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
)
{
// 根目录
...
...
packages/uni-template-compiler/lib/index.js
浏览文件 @
96699f6a
...
...
@@ -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
,
{
...
...
packages/uni-template-compiler/lib/module-toutiao.js
0 → 100644
浏览文件 @
96699f6a
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
})
}
}
}
}
}
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/api.js
浏览文件 @
96699f6a
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
...
...
@@ -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
)
}
packages/vue-cli-plugin-uni-optimize/packages/webpack-optimize-plugin/component.js
浏览文件 @
96699f6a
...
...
@@ -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
}
`
...
...
packages/webpack-uni-mp-loader/lib/plugin/generate-json.js
浏览文件 @
96699f6a
...
...
@@ -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
)
...
...
src/core/service/api/context/create-map-context.js
浏览文件 @
96699f6a
...
...
@@ -3,41 +3,47 @@ import {
getCurrentPageVm
}
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
)
{
return
new
MapContext
(
id
,
context
)
...
...
src/core/view/components/swiper/index.vue
浏览文件 @
96699f6a
...
...
@@ -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
...
...
src/platforms/app-plus/service/api/network/request.js
浏览文件 @
96699f6a
...
...
@@ -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
))
{
...
...
src/platforms/app-plus/view/components/map/index.vue
浏览文件 @
96699f6a
...
...
@@ -146,7 +146,9 @@ export default {
const
list
=
this
.
controls
.
map
((
control
)
=>
{
let
position
=
{
position
:
'
absolute
'
};
[
'
top
'
,
'
left
'
,
'
width
'
,
'
height
'
].
forEach
(
key
=>
{
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
'
})
},
getRegion
({
callbackId
})
{
const
rect
=
this
.
map
.
getBounds
()
this
.
_publishHandler
(
callbackId
,
{
southwest
:
rect
.
southwest
,
northeast
:
rect
.
northeast
||
rect
.
northease
,
// 5plus API 名字写错了
errMsg
:
'
getRegion:ok
'
})
},
getScale
()
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录