Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
6e75e691
U
uni-app
项目概览
DCloud
/
uni-app
4 个月 前同步成功
通知
730
Star
38707
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
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
...
...
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
...
...
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
)
...
...
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
}
...
...
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录