Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_68066342
uni-app
提交
5f0dd12d
U
uni-app
项目概览
m0_68066342
/
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,发现更多精彩内容 >>
提交
5f0dd12d
编写于
11月 01, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: app-v3 实现 cover-image cover-view
上级
6f851066
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
286 addition
and
70 deletion
+286
-70
src/platforms/app-plus/view/components/cover-image/index.vue
src/platforms/app-plus/view/components/cover-image/index.vue
+54
-0
src/platforms/app-plus/view/components/cover-view/index.vue
src/platforms/app-plus/view/components/cover-view/index.vue
+57
-0
src/platforms/app-plus/view/components/video/index.vue
src/platforms/app-plus/view/components/video/index.vue
+6
-8
src/platforms/app-plus/view/framework/plugins/data.js
src/platforms/app-plus/view/framework/plugins/data.js
+1
-1
src/platforms/app-plus/view/mixins/cover.js
src/platforms/app-plus/view/mixins/cover.js
+142
-0
src/platforms/app-plus/view/mixins/native.js
src/platforms/app-plus/view/mixins/native.js
+26
-61
未找到文件。
src/platforms/app-plus/view/components/cover-image/index.vue
0 → 100644
浏览文件 @
5f0dd12d
<
template
>
<uni-cover-image
:src=
"src"
v-on=
"$listeners"
>
<div
ref=
"container"
class=
"uni-cover-image"
/>
</uni-cover-image>
</
template
>
<
script
>
import
native
from
'
../../mixins/native
'
import
cover
from
'
../../mixins/cover
'
export
default
{
name
:
'
CoverImage
'
,
mixins
:
[
native
,
cover
],
props
:
{
src
:
{
type
:
String
,
default
:
''
}
},
data
()
{
return
{
coverType
:
'
image
'
}
},
computed
:
{
coverContent
()
{
return
this
.
$getRealPath
(
this
.
src
)
}
}
}
</
script
>
<
style
>
uni-cover-image
{
display
:
block
;
line-height
:
1.2
;
overflow
:
hidden
;
height
:
100%
;
width
:
100%
;
pointer-events
:
auto
;
}
uni-cover-image
[
hidden
]
{
display
:
none
;
}
uni-cover-image
.uni-cover-image
{
width
:
100%
;
height
:
100%
;
}
</
style
>
src/platforms/app-plus/view/components/cover-view/index.vue
0 → 100644
浏览文件 @
5f0dd12d
<
template
>
<uni-cover-view
v-on=
"$listeners"
>
<div
ref=
"container"
class=
"uni-cover-view"
/>
</uni-cover-view>
</
template
>
<
script
>
import
native
from
'
../../mixins/native
'
import
cover
from
'
../../mixins/cover
'
export
default
{
name
:
'
CoverView
'
,
mixins
:
[
native
,
cover
],
props
:
{},
data
()
{
return
{
coverType
:
'
text
'
,
coverContent
:
''
}
},
watch
:
{},
mounted
()
{
this
.
_updateContent
()
this
.
$watch
(
'
$slot
'
,
this
.
_updateContent
)
},
methods
:
{
_updateContent
(
val
)
{
const
$slots
=
this
.
$slots
.
default
||
[]
$slots
.
forEach
(
node
=>
{
if
(
!
node
.
tag
)
{
this
.
coverContent
+=
node
.
text
||
''
}
})
}
}
}
</
script
>
<
style
>
uni-cover-view
{
display
:
block
;
line-height
:
1.2
;
overflow
:
hidden
;
white-space
:
nowrap
;
pointer-events
:
auto
;
}
uni-cover-view
[
hidden
]
{
display
:
none
;
}
uni-cover-view
.uni-cover-view
{
width
:
100%
;
height
:
100%
;
}
</
style
>
src/platforms/app-plus/view/components/video/index.vue
浏览文件 @
5f0dd12d
...
...
@@ -156,13 +156,8 @@ export default {
return
obj
}
},
watch
:
{
hidden
(
val
)
{
this
.
video
&&
this
.
video
[
val
?
'
hide
'
:
'
show
'
]()
}
},
mounted
()
{
const
video
=
this
.
video
=
plus
.
video
.
createVideoPlayer
(
'
video
'
+
Date
.
now
(),
Object
.
assign
({},
this
.
attrs
,
this
.
style
))
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
()
...
...
@@ -170,9 +165,12 @@ export default {
this
.
$watch
(
'
attrs
'
,
()
=>
{
this
.
video
&&
this
.
video
.
setStyles
(
this
.
attrs
)
},
{
deep
:
true
})
this
.
$watch
(
'
style
'
,
()
=>
{
this
.
video
&&
this
.
video
.
setStyles
(
this
.
style
)
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
video
&&
this
.
video
.
setStyles
(
this
.
position
)
},
{
deep
:
true
})
this
.
$watch
(
'
hidden
'
,
(
val
)
=>
{
this
.
video
&&
this
.
video
[
val
?
'
hide
'
:
'
show
'
]()
})
events
.
forEach
(
key
=>
{
video
.
addEventListener
(
key
,
(
data
=
{})
=>
{
this
.
$trigger
(
key
,
{},
data
)
...
...
src/platforms/app-plus/view/framework/plugins/data.js
浏览文件 @
5f0dd12d
...
...
@@ -69,7 +69,7 @@ function broadcast (vm, componentName, eventName, ...params) {
})
}
const
NATIVE_COMPONENTS
=
[
'
Camera
'
,
'
LivePlayer
'
,
'
LivePusher
'
,
'
Map
'
,
'
Video
'
]
const
NATIVE_COMPONENTS
=
[
'
Camera
'
,
'
LivePlayer
'
,
'
LivePusher
'
,
'
Map
'
,
'
Video
'
,
'
CoverView
'
,
'
CoverImage
'
]
function
updateView
()
{
const
pages
=
getCurrentPages
()
...
...
src/platforms/app-plus/view/mixins/cover.js
0 → 100644
浏览文件 @
5f0dd12d
const
base
=
[
'
padding
'
,
'
borderRadius
'
,
'
borderColor
'
,
'
borderWidth
'
,
'
backgroundColor
'
]
const
text
=
[
'
color
'
,
'
textAlign
'
,
'
lineHeight
'
,
'
fontSize
'
,
'
fontWeight
'
,
'
textOverflow
'
]
const
image
=
[]
let
index
=
0
export
default
{
name
:
'
Cover
'
,
data
()
{
return
{
style
:
{}
}
},
computed
:
{
viewPosition
()
{
const
position
=
{}
for
(
const
key
in
this
.
position
)
{
let
val
=
this
.
position
[
key
]
let
valNumber
=
parseFloat
(
val
)
let
parentValNumber
=
parseFloat
(
this
.
$parent
.
position
[
key
])
if
(
key
===
'
top
'
||
key
===
'
left
'
)
{
val
=
Math
.
max
(
valNumber
,
parentValNumber
)
+
'
px
'
}
else
if
(
key
===
'
width
'
||
key
===
'
height
'
)
{
const
base
=
key
===
'
width
'
?
'
left
'
:
'
left
'
const
parentStart
=
parseFloat
(
this
.
$parent
.
position
[
base
])
const
viewStart
=
parseFloat
(
this
.
position
[
base
])
const
diff1
=
Math
.
max
(
parentStart
-
viewStart
,
0
)
const
diff2
=
Math
.
max
((
viewStart
+
valNumber
)
-
(
parentStart
+
parentValNumber
),
0
)
val
=
Math
.
max
(
valNumber
-
diff1
-
diff2
,
0
)
+
'
px
'
}
position
[
key
]
=
val
}
return
position
},
tags
()
{
const
position
=
this
.
_getTagPosition
()
const
style
=
this
.
style
return
[
{
tag
:
'
rect
'
,
position
,
rectStyles
:
{
color
:
style
.
backgroundColor
,
radius
:
style
.
borderRadius
,
borderColor
:
style
.
borderColor
,
borderWidth
:
style
.
borderWidth
}
},
this
.
coverType
===
'
image
'
?
{
tag
:
'
img
'
,
position
,
src
:
this
.
coverContent
}
:
{
tag
:
'
font
'
,
position
,
textStyles
:
{
align
:
style
.
textAlign
,
color
:
style
.
color
,
decoration
:
'
none
'
,
lineSpacing
:
(
parseFloat
(
style
.
lineHeight
)
-
parseFloat
(
style
.
fontSize
))
+
'
px
'
,
margin
:
style
.
padding
,
overflow
:
style
.
textOverflow
,
size
:
style
.
fontSize
,
weight
:
style
.
fontWeight
,
whiteSpace
:
style
.
whiteSpace
},
text
:
this
.
coverContent
}
]
}
},
mounted
()
{
this
.
_updateStyle
()
const
$parent
=
this
.
$parent
if
(
$parent
.
isNative
)
{
if
(
$parent
.
_isMounted
)
{
this
.
_onCanInsert
()
}
else
{
$parent
.
onCanInsertCallbacks
.
push
(()
=>
{
this
.
_onCanInsert
()
})
}
this
.
$watch
(
'
hidden
'
,
(
val
)
=>
{
this
.
cover
&&
this
.
cover
[
val
?
'
hide
'
:
'
show
'
]()
})
this
.
$watch
(
'
viewPosition
'
,
(
val
)
=>
{
this
.
cover
&&
this
.
cover
.
setStyle
(
val
)
},
{
deep
:
true
})
this
.
$watch
(
'
tags
'
,
()
=>
{
const
cover
=
this
.
cover
if
(
cover
)
{
cover
.
reset
()
cover
.
draw
(
this
.
tags
)
}
},
{
deep
:
true
})
this
.
$on
(
'
uni-view-update
'
,
this
.
_requestStyleUpdate
)
}
},
beforeDestroy
()
{
if
(
this
.
$parent
.
isNative
)
{
this
.
cover
&&
this
.
cover
.
close
()
delete
this
.
cover
}
},
methods
:
{
_onCanInsert
()
{
const
cover
=
this
.
cover
=
new
plus
.
nativeObj
.
View
(
`cover-
${
Date
.
now
()}
-
${
index
++
}
`
,
this
.
viewPosition
,
this
.
tags
)
plus
.
webview
.
currentWebview
().
append
(
cover
)
if
(
this
.
hidden
)
{
cover
.
hide
()
}
cover
.
addEventListener
(
'
click
'
,
()
=>
{
this
.
$trigger
(
'
click
'
,
{},
{})
})
},
_getTagPosition
()
{
const
position
=
{}
for
(
const
key
in
this
.
position
)
{
let
val
=
this
.
position
[
key
]
if
(
key
===
'
top
'
||
key
===
'
left
'
)
{
val
=
Math
.
min
((
parseFloat
(
val
)
-
parseFloat
(
this
.
$parent
.
position
[
key
])),
0
)
+
'
px
'
}
position
[
key
]
=
val
}
return
position
},
_updateStyle
()
{
const
style
=
getComputedStyle
(
this
.
$el
)
base
.
concat
(
text
,
image
).
forEach
(
key
=>
{
this
.
style
[
key
]
=
style
[
key
]
})
},
_requestStyleUpdate
()
{
if
(
this
.
_styleUpdateRequest
)
{
cancelAnimationFrame
(
this
.
_styleUpdateRequest
)
}
this
.
_styleUpdateRequest
=
requestAnimationFrame
(()
=>
{
delete
this
.
_styleUpdateRequest
this
.
_updateStyle
()
})
}
}
}
src/platforms/app-plus/view/mixins/native.js
浏览文件 @
5f0dd12d
import
{
listeners
}
from
'
uni-mixins
'
export
default
{
name
:
'
Native
'
,
mixins
:
[
listeners
],
data
()
{
return
{
style
:
{
position
:
{
top
:
'
0px
'
,
left
:
'
0px
'
,
width
:
'
0px
'
,
height
:
'
0px
'
,
position
:
'
static
'
},
hidden
:
false
,
tags
:
[]
hidden
:
false
}
},
created
()
{
this
.
isNative
=
true
this
.
onCanInsertCallbacks
=
[]
},
mounted
()
{
this
.
_update
Style
()
this
.
_update
Position
()
this
.
$nextTick
(()
=>
{
if
(
this
.
tags
.
length
)
{
const
view
=
this
.
view
=
plus
.
nativeObj
.
View
(
'
view
'
+
Date
.
now
(),
this
.
style
,
this
.
tags
)
plus
.
webview
.
currentWebview
().
append
(
view
)
if
(
this
.
hidden
)
{
view
.
hide
()
}
}
this
.
onCanInsertCallbacks
.
forEach
(
callback
=>
callback
())
})
},
beforeDestroy
()
{
this
.
view
&&
this
.
view
.
close
()
delete
this
.
view
},
listeners
:
{
'
@view-update
'
:
'
_requestUpdate
'
this
.
$on
(
'
uni-view-update
'
,
this
.
_requestPositionUpdate
)
},
methods
:
{
insertTextView
()
{
},
updateTextView
()
{
},
removeTextView
()
{
},
insertImageView
()
{
},
updateImageView
()
{
},
removeImageView
()
{
},
_updateStyle
()
{
const
rect
=
this
.
$refs
.
container
.
getBoundingClientRect
()
this
.
hidden
=
false
;
[
'
top
'
,
'
left
'
,
'
width
'
,
'
height
'
].
forEach
(
key
=>
{
let
val
=
rect
[
key
]
val
=
key
===
'
top
'
?
val
+
(
document
.
documentElement
.
scrollTop
||
document
.
body
.
scrollTop
||
0
)
:
val
if
(
!
val
&&
(
key
===
'
width
'
||
key
===
'
height
'
))
{
this
.
hidden
=
true
}
this
.
style
[
key
]
=
val
+
'
px
'
})
},
_requestUpdate
()
{
if
(
this
.
_animationFrame
)
{
cancelAnimationFrame
(
this
.
_animationFrame
)
}
if
(
this
.
_isMounted
)
{
this
.
_animationFrame
=
requestAnimationFrame
(()
=>
{
delete
this
.
_animationFrame
this
.
_updateStyle
()
_updatePosition
()
{
const
rect
=
(
this
.
$refs
.
container
||
this
.
$el
).
getBoundingClientRect
()
this
.
hidden
=
rect
.
width
===
0
||
rect
.
height
===
0
if
(
!
this
.
hidden
)
{
[
'
top
'
,
'
left
'
,
'
width
'
,
'
height
'
].
forEach
(
key
=>
{
let
val
=
rect
[
key
]
val
=
key
===
'
top
'
?
val
+
(
document
.
documentElement
.
scrollTop
||
document
.
body
.
scrollTop
||
0
)
:
val
this
.
position
[
key
]
=
val
+
'
px
'
})
}
},
_requestPositionUpdate
()
{
if
(
this
.
_positionUpdateRequest
)
{
cancelAnimationFrame
(
this
.
_positionUpdateRequest
)
}
this
.
_positionUpdateRequest
=
requestAnimationFrame
(()
=>
{
delete
this
.
_positionUpdateRequest
this
.
_updatePosition
()
})
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录