Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
touchx
uni-app
提交
783c6325
U
uni-app
项目概览
touchx
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
783c6325
编写于
10月 20, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: cover 组件支持嵌套
上级
52b9e8c2
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
177 addition
and
126 deletion
+177
-126
src/platforms/app-plus/view/components/ad/index.vue
src/platforms/app-plus/view/components/ad/index.vue
+45
-43
src/platforms/app-plus/view/components/cover-view/index.vue
src/platforms/app-plus/view/components/cover-view/index.vue
+13
-7
src/platforms/app-plus/view/components/map/index.vue
src/platforms/app-plus/view/components/map/index.vue
+29
-27
src/platforms/app-plus/view/components/video/index.vue
src/platforms/app-plus/view/components/video/index.vue
+25
-23
src/platforms/app-plus/view/components/web-view/index.vue
src/platforms/app-plus/view/components/web-view/index.vue
+10
-8
src/platforms/app-plus/view/mixins/cover.js
src/platforms/app-plus/view/mixins/cover.js
+10
-15
src/platforms/app-plus/view/mixins/native.js
src/platforms/app-plus/view/mixins/native.js
+45
-3
未找到文件。
src/platforms/app-plus/view/components/ad/index.vue
浏览文件 @
783c6325
...
...
@@ -73,53 +73,55 @@ export default {
}
},
mounted
()
{
this
.
_adId
=
'
AdView-
'
+
this
.
_newGUID
()
const
adStyle
=
Object
.
assign
({
id
:
this
.
_adId
},
this
.
position
)
const
adView
=
this
.
adView
=
plus
.
ad
.
createAdView
(
adStyle
)
adView
.
interceptTouchEvent
(
false
)
plus
.
webview
.
currentWebview
().
append
(
adView
)
if
(
this
.
hidden
)
{
adView
.
hide
()
}
this
.
$watch
(
'
attrs
'
,
()
=>
{
this
.
_request
()
},
{
deep
:
true
})
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
adView
&&
this
.
adView
.
setStyle
(
this
.
position
)
},
{
deep
:
true
})
// 模板渲染有效
adView
.
setDislikeListener
&&
adView
.
setDislikeListener
((
data
)
=>
{
this
.
adView
&&
this
.
adView
.
close
()
this
.
$refs
.
container
.
style
.
height
=
'
0px
'
this
.
_updateView
()
this
.
_onParentReady
(()
=>
{
this
.
_adId
=
'
AdView-
'
+
this
.
_newGUID
()
const
adStyle
=
Object
.
assign
({
id
:
this
.
_adId
},
this
.
position
)
const
adView
=
this
.
adView
=
plus
.
ad
.
createAdView
(
adStyle
)
adView
.
interceptTouchEvent
(
false
)
plus
.
webview
.
currentWebview
().
append
(
adView
)
if
(
this
.
hidden
)
{
adView
.
hide
()
}
this
.
$watch
(
'
attrs
'
,
()
=>
{
this
.
_request
()
},
{
deep
:
true
})
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
adView
&&
this
.
adView
.
setStyle
(
this
.
position
)
},
{
deep
:
true
})
// 模板渲染有效
adView
.
setDislikeListener
&&
adView
.
setDislikeListener
((
data
)
=>
{
this
.
adView
&&
this
.
adView
.
close
()
this
.
$refs
.
container
.
style
.
height
=
'
0px
'
this
.
$trigger
(
'
close
'
,
{},
data
)
})
adView
.
setRenderingListener
&&
adView
.
setRenderingListener
((
data
)
=>
{
if
(
data
.
result
===
0
)
{
this
.
$refs
.
container
.
style
.
height
=
data
.
height
+
'
px
'
this
.
_updateView
()
}
else
{
this
.
$trigger
(
'
error
'
,
{},
{
errCode
:
data
.
result
})
}
})
adView
.
setAdClickedListener
((
data
)
=>
{
this
.
$trigger
(
'
adclicked
'
,
{},
data
)
})
this
.
_callbackId
=
this
.
$page
.
id
+
this
.
_adId
UniViewJSBridge
.
subscribe
(
this
.
_callbackId
,
this
.
_handleAdData
.
bind
(
this
))
this
.
$trigger
(
'
close
'
,
{},
data
)
})
adView
.
setRenderingListener
&&
adView
.
setRenderingListener
((
data
)
=>
{
if
(
data
.
result
===
0
)
{
this
.
$refs
.
container
.
style
.
height
=
data
.
height
+
'
px
'
this
.
_updateView
()
}
else
{
this
.
$trigger
(
'
error
'
,
{},
{
errCode
:
data
.
result
})
}
})
adView
.
setAdClickedListener
((
data
)
=>
{
this
.
$trigger
(
'
adclicked
'
,
{},
data
)
})
this
.
_callbackId
=
this
.
$page
.
id
+
this
.
_adId
UniViewJSBridge
.
subscribe
(
this
.
_callbackId
,
this
.
_handleAdData
.
bind
(
this
))
this
.
_request
()
this
.
_request
()
})
},
beforeDestroy
()
{
this
.
adView
&&
this
.
adView
.
close
()
...
...
src/platforms/app-plus/view/components/cover-view/index.vue
浏览文件 @
783c6325
...
...
@@ -15,12 +15,17 @@ export default {
render
(
createElement
)
{
let
coverContent
=
''
const
$slots
=
this
.
$slots
.
default
||
[]
$slots
.
forEach
(
node
=>
{
if
(
!
node
.
tag
)
{
coverContent
+=
node
.
text
||
''
}
})
this
.
coverContent
=
coverContent
const
_slots
=
$slots
.
filter
(
node
=>
node
.
tag
)
if
(
!
_slots
.
length
)
{
$slots
.
forEach
(
node
=>
{
if
(
!
node
.
tag
)
{
coverContent
+=
node
.
text
||
''
}
})
this
.
coverContent
=
coverContent
}
else
{
coverContent
=
_slots
}
return
createElement
(
'
uni-cover-view
'
,
{
on
:
{
on
:
this
.
$listeners
...
...
@@ -28,7 +33,7 @@ export default {
},
[
createElement
(
'
div
'
,
{
ref
:
'
container
'
,
staticClass
:
'
uni-cover-view
'
},
[
coverContent
]
)])
},
[
].
concat
(
coverContent
)
)])
}
}
</
script
>
...
...
@@ -48,5 +53,6 @@ uni-cover-view[hidden] {
uni-cover-view
.uni-cover-view
{
width
:
100%
;
height
:
100%
;
visibility
:
hidden
;
}
</
style
>
src/platforms/app-plus/view/components/map/index.vue
浏览文件 @
783c6325
...
...
@@ -189,34 +189,36 @@ export default {
}
},
mounted
()
{
const
mapStyle
=
Object
.
assign
({},
this
.
attrs
,
this
.
position
)
if
(
this
.
latitude
&&
this
.
longitude
)
{
mapStyle
.
center
=
new
plus
.
maps
.
Point
(
this
.
longitude
,
this
.
latitude
)
}
const
map
=
this
.
map
=
plus
.
maps
.
create
(
this
.
$page
.
id
+
'
-map-
'
+
(
this
.
id
||
Date
.
now
()),
mapStyle
)
map
.
__markers__
=
[]
map
.
__markers_map__
=
{}
map
.
__lines__
=
[]
map
.
__circles__
=
[]
map
.
setZoom
(
parseInt
(
this
.
scale
))
plus
.
webview
.
currentWebview
().
append
(
map
)
if
(
this
.
hidden
)
{
map
.
hide
()
}
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
map
&&
this
.
map
.
setStyles
(
this
.
position
)
},
{
deep
:
true
this
.
_onParentReady
(()
=>
{
const
mapStyle
=
Object
.
assign
({},
this
.
attrs
,
this
.
position
)
if
(
this
.
latitude
&&
this
.
longitude
)
{
mapStyle
.
center
=
new
plus
.
maps
.
Point
(
this
.
longitude
,
this
.
latitude
)
}
const
map
=
this
.
map
=
plus
.
maps
.
create
(
this
.
$page
.
id
+
'
-map-
'
+
(
this
.
id
||
Date
.
now
()),
mapStyle
)
map
.
__markers__
=
[]
map
.
__markers_map__
=
{}
map
.
__lines__
=
[]
map
.
__circles__
=
[]
map
.
setZoom
(
parseInt
(
this
.
scale
))
plus
.
webview
.
currentWebview
().
append
(
map
)
if
(
this
.
hidden
)
{
map
.
hide
()
}
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
map
&&
this
.
map
.
setStyles
(
this
.
position
)
},
{
deep
:
true
})
map
.
onclick
=
(
e
)
=>
{
this
.
$trigger
(
'
click
'
,
{},
e
)
}
map
.
onstatuschanged
=
(
e
)
=>
{
this
.
$trigger
(
'
regionchange
'
,
{},
{})
}
this
.
_addMarkers
(
this
.
markers
)
this
.
_addMapLines
(
this
.
polyline
)
this
.
_addMapCircles
(
this
.
circles
)
})
map
.
onclick
=
(
e
)
=>
{
this
.
$trigger
(
'
click
'
,
{},
e
)
}
map
.
onstatuschanged
=
(
e
)
=>
{
this
.
$trigger
(
'
regionchange
'
,
{},
{})
}
this
.
_addMarkers
(
this
.
markers
)
this
.
_addMapLines
(
this
.
polyline
)
this
.
_addMapCircles
(
this
.
circles
)
},
beforeDestroy
()
{
this
.
map
&&
this
.
map
.
close
()
...
...
src/platforms/app-plus/view/components/video/index.vue
浏览文件 @
783c6325
...
...
@@ -197,30 +197,32 @@ export default {
}
},
mounted
()
{
const
video
=
this
.
video
=
plus
.
video
.
createVideoPlayer
(
'
video
'
+
Date
.
now
(),
Object
.
assign
({},
this
.
attrs
,
this
.
position
))
plus
.
webview
.
currentWebview
().
append
(
video
)
if
(
this
.
hidden
)
{
video
.
hide
()
}
this
.
$watch
(
'
attrs
'
,
()
=>
{
this
.
video
&&
this
.
video
.
setStyles
(
this
.
attrs
)
},
{
deep
:
true
})
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
video
&&
this
.
video
.
setStyles
(
this
.
position
)
},
{
deep
:
true
})
this
.
$watch
(
'
hidden
'
,
(
val
)
=>
{
const
video
=
this
.
video
if
(
video
)
{
video
[
val
?
'
hide
'
:
'
show
'
]()
// iOS 隐藏状态设置 setStyles 不生效
if
(
!
val
)
{
video
.
setStyles
(
this
.
position
)
}
this
.
_onParentReady
(()
=>
{
const
video
=
this
.
video
=
plus
.
video
.
createVideoPlayer
(
'
video
'
+
Date
.
now
(),
Object
.
assign
({},
this
.
attrs
,
this
.
position
))
plus
.
webview
.
currentWebview
().
append
(
video
)
if
(
this
.
hidden
)
{
video
.
hide
()
}
})
events
.
forEach
(
key
=>
{
video
.
addEventListener
(
key
,
(
e
)
=>
{
this
.
$trigger
(
key
,
{},
{
...
e
.
detail
})
this
.
$watch
(
'
attrs
'
,
()
=>
{
this
.
video
&&
this
.
video
.
setStyles
(
this
.
attrs
)
},
{
deep
:
true
})
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
video
&&
this
.
video
.
setStyles
(
this
.
position
)
},
{
deep
:
true
})
this
.
$watch
(
'
hidden
'
,
(
val
)
=>
{
const
video
=
this
.
video
if
(
video
)
{
video
[
val
?
'
hide
'
:
'
show
'
]()
// iOS 隐藏状态设置 setStyles 不生效
if
(
!
val
)
{
video
.
setStyles
(
this
.
position
)
}
}
})
events
.
forEach
(
key
=>
{
video
.
addEventListener
(
key
,
(
e
)
=>
{
this
.
$trigger
(
key
,
{},
{
...
e
.
detail
})
})
})
})
},
...
...
src/platforms/app-plus/view/components/web-view/index.vue
浏览文件 @
783c6325
...
...
@@ -93,15 +93,17 @@ export default {
}
},
mounted
()
{
this
.
htmlId
=
WEBVIEW_ID_PREFIX
+
this
.
$page
.
id
insertHTMLWebView
({
htmlId
:
this
.
htmlId
})
updateHTMLWebView
({
src
:
this
.
$getRealPath
(
this
.
src
),
webviewStyles
:
this
.
webviewStyles
this
.
_onParentReady
(()
=>
{
this
.
htmlId
=
WEBVIEW_ID_PREFIX
+
this
.
$page
.
id
insertHTMLWebView
({
htmlId
:
this
.
htmlId
})
updateHTMLWebView
({
src
:
this
.
$getRealPath
(
this
.
src
),
webviewStyles
:
this
.
webviewStyles
})
UniViewJSBridge
.
publishHandler
(
WEBVIEW_INSERTED
,
{},
this
.
$page
.
id
)
})
UniViewJSBridge
.
publishHandler
(
WEBVIEW_INSERTED
,
{},
this
.
$page
.
id
)
},
beforeDestroy
()
{
removeHTMLWebView
()
...
...
src/platforms/app-plus/view/mixins/cover.js
浏览文件 @
783c6325
...
...
@@ -8,7 +8,8 @@ export default {
name
:
'
Cover
'
,
data
()
{
return
{
style
:
{}
style
:
{},
parentPosition
:
{}
}
},
computed
:
{
...
...
@@ -17,12 +18,12 @@ export default {
for
(
const
key
in
this
.
position
)
{
let
val
=
this
.
position
[
key
]
const
valNumber
=
parseFloat
(
val
)
const
parentValNumber
=
parseFloat
(
this
.
_nativeParent
.
p
osition
[
key
])
const
parentValNumber
=
parseFloat
(
this
.
parentP
osition
[
key
])
if
(
key
===
'
top
'
||
key
===
'
left
'
)
{
val
=
Math
.
max
(
valNumber
,
parentValNumber
)
+
'
px
'
}
else
if
(
key
===
'
width
'
||
key
===
'
height
'
)
{
const
base
=
key
===
'
width
'
?
'
left
'
:
'
top
'
const
parentStart
=
parseFloat
(
this
.
_nativeParent
.
p
osition
[
base
])
const
parentStart
=
parseFloat
(
this
.
parentP
osition
[
base
])
const
viewStart
=
parseFloat
(
this
.
position
[
base
])
const
diff1
=
Math
.
max
(
parentStart
-
viewStart
,
0
)
const
diff2
=
Math
.
max
((
viewStart
+
valNumber
)
-
(
parentStart
+
parentValNumber
),
0
)
...
...
@@ -91,16 +92,10 @@ export default {
this
.
_nativeParent
=
$parent
},
mounted
()
{
this
.
_updateStyle
()
const
$nativeParent
=
this
.
_nativeParent
if
(
$nativeParent
.
isNative
)
{
if
(
$nativeParent
.
_isMounted
)
{
this
.
_onCanInsert
()
}
else
{
$nativeParent
.
onCanInsertCallbacks
.
push
(()
=>
{
this
.
_onCanInsert
()
})
}
this
.
_onParentReady
((
parentPosition
)
=>
{
this
.
parentPosition
=
this
.
_nativeParent
.
position
||
parentPosition
this
.
_updateStyle
()
this
.
_onCanInsert
()
this
.
$watch
(
'
hidden
'
,
(
val
)
=>
{
this
.
cover
&&
this
.
cover
[
val
?
'
hide
'
:
'
show
'
]()
})
...
...
@@ -115,7 +110,7 @@ export default {
}
},
{
deep
:
true
})
this
.
$on
(
'
uni-view-update
'
,
this
.
_requestStyleUpdate
)
}
}
)
},
beforeDestroy
()
{
if
(
this
.
_nativeParent
.
isNative
)
{
...
...
@@ -139,7 +134,7 @@ export default {
for
(
const
key
in
this
.
position
)
{
let
val
=
this
.
position
[
key
]
if
(
key
===
'
top
'
||
key
===
'
left
'
)
{
val
=
Math
.
min
((
parseFloat
(
val
)
-
parseFloat
(
this
.
_nativeParent
.
p
osition
[
key
])),
0
)
+
'
px
'
val
=
Math
.
min
((
parseFloat
(
val
)
-
parseFloat
(
this
.
parentP
osition
[
key
])),
0
)
+
'
px
'
}
position
[
key
]
=
val
}
...
...
src/platforms/app-plus/view/mixins/native.js
浏览文件 @
783c6325
...
...
@@ -26,15 +26,23 @@ export default {
hidden
:
false
}
},
provide
()
{
return
{
parentOnDraw
:
this
.
_onDraw
}
},
inject
:
{
parentOnDraw
:
{
default
:
null
}
},
created
()
{
this
.
isNative
=
true
this
.
onCanInsertCallbacks
=
[]
this
.
onDrawCallbacks
=
[]
},
mounted
()
{
this
.
_updatePosition
()
this
.
$nextTick
(()
=>
{
this
.
onCanInsertCallbacks
.
forEach
(
callback
=>
callback
())
})
this
.
onCanInsertCallbacks
.
forEach
(
callback
=>
callback
())
this
.
onCanInsertCallbacks
=
null
this
.
$on
(
'
uni-view-update
'
,
this
.
_requestPositionUpdate
)
},
methods
:
{
...
...
@@ -60,6 +68,40 @@ export default {
delete
this
.
_positionUpdateRequest
this
.
_updatePosition
()
})
},
_onParentReady
(
parentReadyCallback
)
{
const
callback
=
(
parentPosition
)
=>
{
parentReadyCallback
(
parentPosition
)
this
.
onDrawCallbacks
.
forEach
(
callback
=>
callback
(
this
.
position
))
this
.
onDrawCallbacks
=
null
}
this
.
_onSelfReady
(()
=>
{
if
(
this
.
parentOnDraw
)
{
this
.
parentOnDraw
(
callback
)
}
else
{
callback
({
top
:
'
0px
'
,
left
:
'
0px
'
,
width
:
Number
.
MAX_SAFE_INTEGER
+
'
px
'
,
height
:
Number
.
MAX_SAFE_INTEGER
+
'
px
'
,
position
:
'
static
'
})
}
})
},
_onSelfReady
(
callback
)
{
if
(
this
.
onCanInsertCallbacks
)
{
this
.
onCanInsertCallbacks
.
push
(
callback
)
}
else
{
callback
()
}
},
_onDraw
(
callback
)
{
if
(
this
.
onDrawCallbacks
)
{
this
.
onDrawCallbacks
.
push
(
callback
)
}
else
{
callback
(
this
.
position
)
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录