Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
我本凡人 一念云泥
uni-app
提交
6e75e691
uni-app
项目概览
我本凡人 一念云泥
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6e75e691
编写于
12月 06, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 支持 nodesRef.context
上级
517afa30
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
71 addition
and
31 deletion
+71
-31
lib/apis.js
lib/apis.js
+1
-2
lib/modules.json
lib/modules.json
+1
-2
src/core/service/api/context/canvas.js
src/core/service/api/context/canvas.js
+1
-1
src/core/service/api/context/create-map-context.js
src/core/service/api/context/create-map-context.js
+2
-2
src/core/service/api/context/create-video-context.js
src/core/service/api/context/create-video-context.js
+6
-6
src/core/service/api/context/editor.js
src/core/service/api/context/editor.js
+1
-16
src/core/service/api/ui/create-selector-query.js
src/core/service/api/ui/create-selector-query.js
+38
-1
src/core/view/bridge/subscribe/api/request-component-info.js
src/core/view/bridge/subscribe/api/request-component-info.js
+6
-1
src/core/view/mixins/subscriber.js
src/core/view/mixins/subscriber.js
+15
-0
未找到文件。
lib/apis.js
浏览文件 @
6e75e691
...
...
@@ -59,8 +59,7 @@ const media = [
'
saveVideoToPhotosAlbum
'
,
'
createVideoContext
'
,
'
createCameraContext
'
,
'
createLivePlayerContext
'
,
'
createEditorContext
'
'
createLivePlayerContext
'
]
const
device
=
[
...
...
lib/modules.json
浏览文件 @
6e75e691
...
...
@@ -66,8 +66,7 @@
"uni.saveVideoToPhotosAlbum"
:
true
,
"uni.createVideoContext"
:
true
,
"uni.createCameraContext"
:
true
,
"uni.createLivePlayerContext"
:
true
,
"uni.createEditorContext"
:
true
"uni.createLivePlayerContext"
:
true
}
},
{
"name"
:
"device"
,
...
...
src/core/service/api/context/canvas.js
浏览文件 @
6e75e691
...
...
@@ -258,7 +258,7 @@ var methods3 = ['setFillStyle', 'setTextAlign', 'setStrokeStyle', 'setGlobalAlph
'
setTextBaseline
'
,
'
setLineDash
'
]
class
CanvasContext
{
export
class
CanvasContext
{
constructor
(
id
,
pageId
)
{
this
.
id
=
id
this
.
pageId
=
pageId
...
...
src/core/service/api/context/create-map-context.js
浏览文件 @
6e75e691
...
...
@@ -7,7 +7,7 @@ function operateMapPlayer (mapId, pageVm, type, data) {
invokeMethod
(
'
operateMapPlayer
'
,
mapId
,
pageVm
,
type
,
data
)
}
class
MapContext
{
export
class
MapContext
{
constructor
(
id
,
pageVm
)
{
this
.
id
=
id
this
.
pageVm
=
pageVm
...
...
@@ -43,4 +43,4 @@ export function createMapContext (id, context) {
return
new
MapContext
(
id
,
context
)
}
return
new
MapContext
(
id
,
getCurrentPageVm
(
'
createMapContext
'
))
}
}
src/core/service/api/context/create-video-context.js
浏览文件 @
6e75e691
...
...
@@ -9,7 +9,7 @@ function operateVideoPlayer (videoId, pageVm, type, data) {
invokeMethod
(
'
operateVideoPlayer
'
,
videoId
,
pageVm
,
type
,
data
)
}
class
VideoContext
{
export
class
VideoContext
{
constructor
(
id
,
pageVm
)
{
this
.
id
=
id
this
.
pageVm
=
pageVm
...
...
@@ -25,8 +25,8 @@ class VideoContext {
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
stop
'
)
}
seek
(
position
)
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
seek
'
,
{
position
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
seek
'
,
{
position
})
}
sendDanmu
(
args
)
{
...
...
@@ -36,8 +36,8 @@ class VideoContext {
if
(
!~
RATES
.
indexOf
(
rate
))
{
rate
=
1.0
}
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
playbackRate
'
,
{
rate
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
playbackRate
'
,
{
rate
})
}
requestFullScreen
(
args
=
{})
{
...
...
@@ -59,4 +59,4 @@ export function createVideoContext (id, context) {
return
new
VideoContext
(
id
,
context
)
}
return
new
VideoContext
(
id
,
getCurrentPageVm
(
'
createVideoContext
'
))
}
}
src/core/service/api/context/editor.js
浏览文件 @
6e75e691
import
{
getCurrentPageId
}
from
'
../../platform
'
import
{
callback
}
from
'
uni-shared
'
...
...
@@ -22,7 +19,7 @@ UniServiceJSBridge.subscribe('onEditorMethodCallback', ({
const
methods
=
[
'
insertDivider
'
,
'
insertImage
'
,
'
insertText
'
,
'
setContents
'
,
'
getContents
'
,
'
clear
'
,
'
removeFormat
'
,
'
undo
'
,
'
redo
'
]
class
EditorContext
{
export
class
EditorContext
{
constructor
(
id
,
pageId
)
{
this
.
id
=
id
this
.
pageId
=
pageId
...
...
@@ -45,15 +42,3 @@ methods.forEach(function (method) {
})
})
})
export
function
createEditorContext
(
id
,
context
)
{
if
(
context
)
{
return
new
EditorContext
(
id
,
context
.
$page
.
id
)
}
const
pageId
=
getCurrentPageId
()
if
(
pageId
)
{
return
new
EditorContext
(
id
,
pageId
)
}
else
{
UniServiceJSBridge
.
emit
(
'
onError
'
,
'
createEditorContext:fail
'
)
}
}
src/core/service/api/ui/create-selector-query.js
浏览文件 @
6e75e691
...
...
@@ -7,6 +7,26 @@ import {
getCurrentPageVm
}
from
'
../../platform
'
import
{
CanvasContext
}
from
'
../context/canvas
'
import
{
MapContext
}
from
'
../context/create-map-context
'
import
{
VideoContext
}
from
'
../context/create-video-context
'
import
{
EditorContext
}
from
'
../context/editor
'
const
ContextClasss
=
{
canvas
:
CanvasContext
,
map
:
MapContext
,
video
:
VideoContext
,
editor
:
EditorContext
}
function
convertContext
(
result
)
{
if
(
result
.
context
)
{
const
{
id
,
name
,
page
}
=
result
.
context
const
ContextClass
=
ContextClasss
[
name
]
result
.
context
=
ContextClass
&&
new
ContextClass
(
id
,
page
)
}
}
class
NodesRef
{
constructor
(
selectorQuery
,
component
,
selector
,
single
)
{
this
.
_selectorQuery
=
selectorQuery
...
...
@@ -53,6 +73,18 @@ class NodesRef {
)
return
this
.
_selectorQuery
}
context
(
callback
)
{
this
.
_selectorQuery
.
_push
(
this
.
_selector
,
this
.
_component
,
this
.
_single
,
{
context
:
true
},
callback
)
return
this
.
_selectorQuery
}
}
class
SelectorQuery
{
...
...
@@ -66,6 +98,11 @@ class SelectorQuery {
invokeMethod
(
'
requestComponentInfo
'
,
this
.
_page
,
this
.
_queue
,
res
=>
{
const
queueCbs
=
this
.
_queueCb
res
.
forEach
((
result
,
index
)
=>
{
if
(
Array
.
isArray
(
result
))
{
result
.
forEach
(
convertContext
)
}
else
{
convertContext
(
result
)
}
const
queueCb
=
queueCbs
[
index
]
if
(
isFn
(
queueCb
))
{
queueCb
.
call
(
this
,
result
)
...
...
@@ -109,4 +146,4 @@ export function createSelectorQuery (context) {
return
new
SelectorQuery
(
context
)
}
return
new
SelectorQuery
(
getCurrentPageVm
(
'
createSelectorQuery
'
))
}
}
src/core/view/bridge/subscribe/api/request-component-info.js
浏览文件 @
6e75e691
...
...
@@ -74,6 +74,11 @@ function getNodeInfo (el, fields) {
info
.
scrollTop
=
0
}
}
if
(
fields
.
context
)
{
if
(
el
.
__vue__
&&
el
.
__vue__
.
_getContextInfo
)
{
info
.
context
=
el
.
__vue__
.
_getContextInfo
()
}
}
return
info
}
...
...
@@ -134,4 +139,4 @@ export function requestComponentInfo ({
reqId
,
res
:
result
},
pageVm
.
$page
.
id
)
}
}
src/core/view/mixins/subscriber.js
浏览文件 @
6e75e691
...
...
@@ -19,6 +19,9 @@ export default {
},
beforeDestroy
()
{
// 销毁时移除
this
.
_toggleListeners
(
'
unsubscribe
'
,
this
.
id
)
if
(
this
.
_contextId
)
{
this
.
_toggleListeners
(
'
unsubscribe
'
,
this
.
_contextId
)
}
},
methods
:
{
_toggleListeners
(
type
,
id
,
watch
)
{
...
...
@@ -31,6 +34,18 @@ export default {
}
// 纠正VUniVideo等组件命名为Video
UniViewJSBridge
[
type
](
this
.
$page
.
id
+
'
-
'
+
this
.
$options
.
name
.
replace
(
/VUni
([
A-Z
])
/
,
'
$1
'
).
toLowerCase
()
+
'
-
'
+
id
,
this
.
_handleSubscribe
)
},
_getContextInfo
()
{
const
id
=
`context-
${
this
.
_uid
}
`
if
(
!
this
.
_contextId
)
{
this
.
_toggleListeners
(
'
subscribe
'
,
id
)
this
.
_contextId
=
id
}
return
{
name
:
this
.
$options
.
name
.
replace
(
/VUni
([
A-Z
])
/
,
'
$1
'
).
toLowerCase
(),
id
,
page
:
this
.
$page
.
id
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录