Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
55c2e4de
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
717
Star
38705
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
55c2e4de
编写于
10月 28, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'v3' of github.com:dcloudio/uni-app into v3
上级
62c39768
0c9d6da3
变更
51
展开全部
隐藏空白更改
内联
并排
Showing
51 changed file
with
3974 addition
and
3393 deletion
+3974
-3393
lerna.json
lerna.json
+1
-1
packages/uni-app-plus-nvue/package.json
packages/uni-app-plus-nvue/package.json
+1
-1
packages/uni-app-plus/dist/index.v3.js
packages/uni-app-plus/dist/index.v3.js
+493
-100
packages/uni-app-plus/dist/view.umd.js
packages/uni-app-plus/dist/view.umd.js
+2854
-2806
packages/uni-app-plus/package.json
packages/uni-app-plus/package.json
+1
-1
packages/uni-cli-shared/package.json
packages/uni-cli-shared/package.json
+1
-1
packages/uni-h5-ui/package.json
packages/uni-h5-ui/package.json
+1
-1
packages/uni-h5/dist/index.umd.min.js
packages/uni-h5/dist/index.umd.min.js
+1
-1
packages/uni-h5/manifest.json
packages/uni-h5/manifest.json
+16
-4
packages/uni-h5/package.json
packages/uni-h5/package.json
+1
-1
packages/uni-mp-alipay/package.json
packages/uni-mp-alipay/package.json
+1
-1
packages/uni-mp-baidu/dist/index.js
packages/uni-mp-baidu/dist/index.js
+17
-4
packages/uni-mp-baidu/package.json
packages/uni-mp-baidu/package.json
+1
-1
packages/uni-mp-qq/package.json
packages/uni-mp-qq/package.json
+1
-1
packages/uni-mp-toutiao/package.json
packages/uni-mp-toutiao/package.json
+1
-1
packages/uni-mp-weixin/package.json
packages/uni-mp-weixin/package.json
+1
-1
packages/uni-stat/package.json
packages/uni-stat/package.json
+1
-1
packages/uni-template-compiler/package.json
packages/uni-template-compiler/package.json
+1
-1
packages/vue-cli-plugin-hbuilderx/package.json
packages/vue-cli-plugin-hbuilderx/package.json
+1
-1
packages/vue-cli-plugin-uni-optimize/package.json
packages/vue-cli-plugin-uni-optimize/package.json
+1
-1
packages/vue-cli-plugin-uni/package.json
packages/vue-cli-plugin-uni/package.json
+2
-2
packages/webpack-uni-mp-loader/package.json
packages/webpack-uni-mp-loader/package.json
+1
-1
packages/webpack-uni-pages-loader/package.json
packages/webpack-uni-pages-loader/package.json
+2
-2
src/core/service/api/context/create-map-context.js
src/core/service/api/context/create-map-context.js
+46
-0
src/core/service/api/context/create-video-context.js
src/core/service/api/context/create-video-context.js
+62
-0
src/core/service/api/ui/create-intersection-observer.js
src/core/service/api/ui/create-intersection-observer.js
+64
-63
src/core/service/api/ui/create-selector-query.js
src/core/service/api/ui/create-selector-query.js
+12
-25
src/core/service/platform.js
src/core/service/platform.js
+10
-0
src/core/view/bridge/subscribe/api/request-component-info.js
src/core/view/bridge/subscribe/api/request-component-info.js
+9
-6
src/core/view/bridge/subscribe/api/request-component-observer.js
...e/view/bridge/subscribe/api/request-component-observer.js
+82
-73
src/core/view/bridge/subscribe/api/util.js
src/core/view/bridge/subscribe/api/util.js
+29
-0
src/platforms/app-plus-nvue/service/api/context/map.js
src/platforms/app-plus-nvue/service/api/context/map.js
+0
-47
src/platforms/app-plus-nvue/service/api/context/operate-map-player.js
...s/app-plus-nvue/service/api/context/operate-map-player.js
+30
-0
src/platforms/app-plus-nvue/service/api/context/operate-video-player.js
...app-plus-nvue/service/api/context/operate-video-player.js
+42
-0
src/platforms/app-plus-nvue/service/api/context/video.js
src/platforms/app-plus-nvue/service/api/context/video.js
+0
-63
src/platforms/app-plus-nvue/service/api/index.js
src/platforms/app-plus-nvue/service/api/index.js
+3
-3
src/platforms/app-plus-nvue/service/api/ui/request-component-info.js
...ms/app-plus-nvue/service/api/ui/request-component-info.js
+76
-0
src/platforms/app-plus-nvue/service/api/util.js
src/platforms/app-plus-nvue/service/api/util.js
+6
-2
src/platforms/app-plus/service/api/context/operate-map-player.js
...tforms/app-plus/service/api/context/operate-map-player.js
+12
-0
src/platforms/app-plus/service/api/context/operate-video-player.js
...orms/app-plus/service/api/context/operate-video-player.js
+12
-0
src/platforms/app-plus/service/api/index.js
src/platforms/app-plus/service/api/index.js
+5
-1
src/platforms/app-plus/service/api/ui/request-component-info.js
...atforms/app-plus/service/api/ui/request-component-info.js
+13
-0
src/platforms/app-plus/service/framework/plugins/index.js
src/platforms/app-plus/service/framework/plugins/index.js
+6
-0
src/platforms/app-plus/service/publish-handler.js
src/platforms/app-plus/service/publish-handler.js
+2
-2
src/platforms/app-plus/view/framework/plugins/data.js
src/platforms/app-plus/view/framework/plugins/data.js
+2
-1
src/platforms/h5/service/api/context/map.js
src/platforms/h5/service/api/context/map.js
+0
-91
src/platforms/h5/service/api/context/operate-map-player.js
src/platforms/h5/service/api/context/operate-map-player.js
+8
-0
src/platforms/h5/service/api/context/operate-video-player.js
src/platforms/h5/service/api/context/operate-video-player.js
+8
-0
src/platforms/h5/service/api/context/video.js
src/platforms/h5/service/api/context/video.js
+0
-72
src/platforms/h5/service/api/ui/request-component-info.js
src/platforms/h5/service/api/ui/request-component-info.js
+10
-0
src/platforms/mp-baidu/runtime/wrapper/component-parser.js
src/platforms/mp-baidu/runtime/wrapper/component-parser.js
+24
-9
未找到文件。
lerna.json
浏览文件 @
55c2e4de
...
...
@@ -12,5 +12,5 @@
"message"
:
"chore(release): publish %s"
}
},
"version"
:
"3.0.0-alpha-240201910180
06
"
"version"
:
"3.0.0-alpha-240201910180
12
"
}
packages/uni-app-plus-nvue/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-app-plus-nvue"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app app-plus-nvue"
,
"main"
:
"dist/index.js"
,
"repository"
:
{
...
...
packages/uni-app-plus/dist/index.v3.js
浏览文件 @
55c2e4de
此差异已折叠。
点击以展开。
packages/uni-app-plus/dist/view.umd.js
浏览文件 @
55c2e4de
此差异已折叠。
点击以展开。
packages/uni-app-plus/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-app-plus"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app app-plus"
,
"main"
:
"dist/index.js"
,
"repository"
:
{
...
...
packages/uni-cli-shared/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-cli-shared"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-cli-shared"
,
"main"
:
"lib/index.js"
,
"repository"
:
{
...
...
packages/uni-h5-ui/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-h5-ui"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app h5 ui"
,
"main"
:
"dist/index.umd.min.js"
,
"repository"
:
{
...
...
packages/uni-h5/dist/index.umd.min.js
浏览文件 @
55c2e4de
此差异已折叠。
点击以展开。
packages/uni-h5/manifest.json
浏览文件 @
55c2e4de
...
...
@@ -261,8 +261,12 @@
]
],
"createMapContext"
:
[
"/
platforms/h5/service/api/context/map
.js"
,
"/
core/service/api/context/create-map-context
.js"
,
[
[
"/platforms/h5/service/api/context/operate-map-player.js"
,
"operateMapPlayer"
],
[
"/core/helpers/protocol/context/context.js"
,
"createMapContext"
...
...
@@ -314,8 +318,12 @@
]
],
"createVideoContext"
:
[
"/
platforms/h5/service/api/context/video
.js"
,
"/
core/service/api/context/create-video-context
.js"
,
[
[
"/platforms/h5/service/api/context/operate-video-player.js"
,
"operateVideoPlayer"
],
[
"/core/helpers/protocol/context/context.js"
,
"createVideoContext"
...
...
@@ -661,8 +669,12 @@
[]
],
"createSelectorQuery"
:
[
"/
platforms/h5
/service/api/ui/create-selector-query.js"
,
"/
core
/service/api/ui/create-selector-query.js"
,
[
[
"/platforms/h5/service/api/ui/request-component-info.js"
,
"requestComponentInfo"
],
[
"/core/view/bridge/subscribe/api/request-component-info.js"
,
"requestComponentInfo"
...
...
@@ -670,7 +682,7 @@
]
],
"createIntersectionObserver"
:
[
"/
platforms/h5
/service/api/ui/create-intersection-observer.js"
,
"/
core
/service/api/ui/create-intersection-observer.js"
,
[
[
"/core/view/bridge/subscribe/api/request-component-observer.js"
,
...
...
packages/uni-h5/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-h5"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app h5"
,
"main"
:
"dist/index.umd.min.js"
,
"repository"
:
{
...
...
packages/uni-mp-alipay/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-mp-alipay"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app mp-alipay"
,
"main"
:
"dist/index.js"
,
"repository"
:
{
...
...
packages/uni-mp-baidu/dist/index.js
浏览文件 @
55c2e4de
...
...
@@ -1499,6 +1499,8 @@ function parseBaseComponent (vueComponentOptions, {
return
[
componentOptions
,
VueComponent
]
}
const
newLifecycle
=
swan
.
canIUse
(
'
lifecycle-2-0
'
);
function
parseComponent
(
vueOptions
)
{
const
componentOptions
=
parseBaseComponent
(
vueOptions
,
{
isPage
,
...
...
@@ -1513,16 +1515,27 @@ function parseComponent (vueOptions) {
// 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
this
.
pageinstance
.
$vm
=
this
.
$vm
;
if
(
hasOwn
(
this
.
pageinstance
,
'
_$args
'
))
{
if
(
hasOwn
(
this
.
pageinstance
,
'
_$args
'
))
{
this
.
$vm
.
$mp
.
query
=
this
.
pageinstance
.
_$args
;
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
this
.
pageinstance
.
_$args
);
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
this
.
pageinstance
.
_$args
);
delete
this
.
pageinstance
.
_$args
;
}
// TODO
目前版本
百度 Component 作为页面时,methods 中的 onShow 不触发
this
.
$vm
.
__call_hook
(
'
onShow
'
);
// TODO
3.105.17以下基础库内
百度 Component 作为页面时,methods 中的 onShow 不触发
!
newLifecycle
&&
this
.
$vm
.
__call_hook
(
'
onShow
'
);
}
};
if
(
newLifecycle
)
{
delete
componentOptions
.
lifetimes
.
ready
;
componentOptions
.
methods
.
onReady
=
function
()
{
if
(
this
.
$vm
)
{
this
.
$vm
.
_isMounted
=
true
;
this
.
$vm
.
__call_hook
(
'
mounted
'
);
this
.
$vm
.
__call_hook
(
'
onReady
'
);
}
};
}
componentOptions
.
messages
=
{
'
__l
'
:
componentOptions
.
methods
[
'
__l
'
]
};
...
...
packages/uni-mp-baidu/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-mp-baidu"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app mp-baidu"
,
"main"
:
"dist/index.js"
,
"repository"
:
{
...
...
packages/uni-mp-qq/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-mp-qq"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app mp-qq"
,
"main"
:
"dist/index.js"
,
"repository"
:
{
...
...
packages/uni-mp-toutiao/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-mp-toutiao"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app mp-toutiao"
,
"main"
:
"dist/index.js"
,
"repository"
:
{
...
...
packages/uni-mp-weixin/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-mp-weixin"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app mp-weixin"
,
"main"
:
"dist/index.js"
,
"repository"
:
{
...
...
packages/uni-stat/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-stat"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
""
,
"main"
:
"dist/index.js"
,
"repository"
:
{
...
...
packages/uni-template-compiler/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/uni-template-compiler"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-template-compiler"
,
"main"
:
"lib/index.js"
,
"repository"
:
{
...
...
packages/vue-cli-plugin-hbuilderx/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/vue-cli-plugin-hbuilderx"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"HBuilderX plugin for vue-cli 3"
,
"main"
:
"index.js"
,
"repository"
:
{
...
...
packages/vue-cli-plugin-uni-optimize/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/vue-cli-plugin-uni-optimize"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app optimize plugin for vue-cli 3"
,
"main"
:
"index.js"
,
"repository"
:
{
...
...
packages/vue-cli-plugin-uni/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/vue-cli-plugin-uni"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app plugin for vue-cli 3"
,
"main"
:
"index.js"
,
"repository"
:
{
...
...
@@ -17,7 +17,7 @@
"author"
:
"fxy060608"
,
"license"
:
"Apache-2.0"
,
"dependencies"
:
{
"@dcloudio/uni-stat"
:
"^3.0.0-alpha-240201910180
06
"
,
"@dcloudio/uni-stat"
:
"^3.0.0-alpha-240201910180
12
"
,
"copy-webpack-plugin"
:
"^4.6.0"
,
"cross-env"
:
"^5.2.0"
,
"envinfo"
:
"^6.0.1"
,
...
...
packages/webpack-uni-mp-loader/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/webpack-uni-mp-loader"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"webpack-uni-mp-loader"
,
"main"
:
"index.js"
,
"repository"
:
{
...
...
packages/webpack-uni-pages-loader/package.json
浏览文件 @
55c2e4de
{
"name"
:
"@dcloudio/webpack-uni-pages-loader"
,
"version"
:
"3.0.0-alpha-240201910180
06
"
,
"version"
:
"3.0.0-alpha-240201910180
12
"
,
"description"
:
"uni-app pages.json loader"
,
"main"
:
"lib/index.js"
,
"repository"
:
{
...
...
@@ -21,7 +21,7 @@
"strip-json-comments"
:
"^2.0.1"
},
"uni-app"
:
{
"compilerVersion"
:
"2.3.
3
"
"compilerVersion"
:
"2.3.
4
"
},
"gitHead"
:
"10184426b19cb76e01c93fb25c982c72887557e8"
}
src/core/service/api/context/create-map-context.js
0 → 100644
浏览文件 @
55c2e4de
import
{
invokeMethod
,
getCurrentPageVm
}
from
'
../../platform
'
function
operateMapPlayer
(
mapId
,
pageVm
,
type
,
data
)
{
invokeMethod
(
'
operateMapPlayer
'
,
mapId
,
pageVm
,
type
,
data
)
}
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
)
}
}
export
function
createMapContext
(
id
,
context
)
{
if
(
context
)
{
return
new
MapContext
(
id
,
context
)
}
return
new
MapContext
(
id
,
getCurrentPageVm
(
'
createMapContext
'
))
}
src/core/service/api/context/create-video-context.js
0 → 100644
浏览文件 @
55c2e4de
import
{
invokeMethod
,
getCurrentPageVm
}
from
'
../../platform
'
const
RATES
=
[
0.5
,
0.8
,
1.0
,
1.25
,
1.5
]
function
operateVideoPlayer
(
videoId
,
pageVm
,
type
,
data
)
{
invokeMethod
(
'
operateVideoPlayer
'
,
videoId
,
pageVm
,
type
,
data
)
}
class
VideoContext
{
constructor
(
id
,
pageVm
)
{
this
.
id
=
id
this
.
pageVm
=
pageVm
}
play
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
play
'
)
}
pause
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
pause
'
)
}
stop
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
stop
'
)
}
seek
(
position
)
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
seek
'
,
{
position
})
}
sendDanmu
(
args
)
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
sendDanmu
'
,
args
)
}
playbackRate
(
rate
)
{
if
(
!~
RATES
.
indexOf
(
rate
))
{
rate
=
1.0
}
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
playbackRate
'
,
{
rate
})
}
requestFullScreen
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
requestFullScreen
'
)
}
exitFullScreen
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
exitFullScreen
'
)
}
showStatusBar
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
showStatusBar
'
)
}
hideStatusBar
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageVm
,
'
hideStatusBar
'
)
}
}
export
function
createVideoContext
(
id
,
context
)
{
if
(
context
)
{
return
new
VideoContext
(
id
,
context
)
}
return
new
VideoContext
(
id
,
getCurrentPageVm
(
'
createVideoContext
'
))
}
src/
platforms/h5
/service/api/ui/create-intersection-observer.js
→
src/
core
/service/api/ui/create-intersection-observer.js
浏览文件 @
55c2e4de
import
Vue
from
'
vue
'
import
createCallbacks
from
'
uni-helpers/callbacks
'
const
createIntersectionObserverCallbacks
=
createCallbacks
(
'
requestComponentObserver
'
)
const
defaultOptions
=
{
thresholds
:
[
0
],
initialRatio
:
0
,
observeAll
:
false
}
class
MPIntersectionObserver
{
constructor
(
pageId
,
options
)
{
this
.
pageId
=
pageId
this
.
options
=
Object
.
assign
({},
defaultOptions
,
options
)
}
_makeRootMargin
(
margins
=
{})
{
this
.
options
.
rootMargin
=
[
'
top
'
,
'
right
'
,
'
bottom
'
,
'
left
'
].
map
(
name
=>
`
${
Number
(
margins
[
name
])
||
0
}
px`
).
join
(
'
'
)
}
relativeTo
(
selector
,
margins
)
{
this
.
options
.
relativeToSelector
=
selector
this
.
_makeRootMargin
(
margins
)
return
this
}
relativeToViewport
(
margins
)
{
this
.
options
.
relativeToSelector
=
null
this
.
_makeRootMargin
(
margins
)
return
this
}
observe
(
selector
,
callback
)
{
if
(
typeof
callback
!==
'
function
'
)
{
return
}
this
.
options
.
selector
=
selector
this
.
reqId
=
createIntersectionObserverCallbacks
.
push
(
callback
)
UniServiceJSBridge
.
publishHandler
(
'
requestComponentObserver
'
,
{
reqId
:
this
.
reqId
,
options
:
this
.
options
},
this
.
pageId
)
}
disconnect
()
{
UniServiceJSBridge
.
publishHandler
(
'
destroyComponentObserver
'
,
{
reqId
:
this
.
reqId
},
this
.
pageId
)
}
}
export
function
createIntersectionObserver
(
context
,
options
)
{
if
(
!
(
context
instanceof
Vue
))
{
options
=
context
context
=
null
}
if
(
context
)
{
return
new
MPIntersectionObserver
(
context
.
$page
.
id
,
options
)
}
const
app
=
getApp
()
if
(
app
.
$route
&&
app
.
$route
.
params
.
__id__
)
{
return
new
MPIntersectionObserver
(
app
.
$route
.
params
.
__id__
,
options
)
}
else
{
UniServiceJSBridge
.
emit
(
'
onError
'
,
'
createIntersectionObserver:fail
'
)
}
import
createCallbacks
from
'
uni-helpers/callbacks
'
import
{
getCurrentPageVm
}
from
'
../../platform
'
const
createIntersectionObserverCallbacks
=
createCallbacks
(
'
requestComponentObserver
'
)
const
defaultOptions
=
{
thresholds
:
[
0
],
initialRatio
:
0
,
observeAll
:
false
}
class
ServiceIntersectionObserver
{
constructor
(
component
,
options
)
{
this
.
pageId
=
component
.
$page
.
id
this
.
component
=
component
.
_$id
||
component
// app-plus 平台传输_$id
this
.
options
=
Object
.
assign
({},
defaultOptions
,
options
)
}
_makeRootMargin
(
margins
=
{})
{
this
.
options
.
rootMargin
=
[
'
top
'
,
'
right
'
,
'
bottom
'
,
'
left
'
].
map
(
name
=>
`
${
Number
(
margins
[
name
])
||
0
}
px`
).
join
(
'
'
)
}
relativeTo
(
selector
,
margins
)
{
this
.
options
.
relativeToSelector
=
selector
this
.
_makeRootMargin
(
margins
)
return
this
}
relativeToViewport
(
margins
)
{
this
.
options
.
relativeToSelector
=
null
this
.
_makeRootMargin
(
margins
)
return
this
}
observe
(
selector
,
callback
)
{
if
(
typeof
callback
!==
'
function
'
)
{
return
}
this
.
options
.
selector
=
selector
this
.
reqId
=
createIntersectionObserverCallbacks
.
push
(
callback
)
UniServiceJSBridge
.
publishHandler
(
'
requestComponentObserver
'
,
{
reqId
:
this
.
reqId
,
component
:
this
.
component
,
options
:
this
.
options
},
this
.
pageId
)
}
disconnect
()
{
UniServiceJSBridge
.
publishHandler
(
'
destroyComponentObserver
'
,
{
reqId
:
this
.
reqId
},
this
.
pageId
)
}
}
export
function
createIntersectionObserver
(
context
,
options
)
{
if
(
!
context
.
_isVue
)
{
options
=
context
context
=
null
}
if
(
context
)
{
return
new
ServiceIntersectionObserver
(
context
,
options
)
}
return
new
ServiceIntersectionObserver
(
getCurrentPageVm
(
'
createIntersectionObserver
'
),
options
)
}
src/
platforms/h5
/service/api/ui/create-selector-query.js
→
src/
core
/service/api/ui/create-selector-query.js
浏览文件 @
55c2e4de
...
...
@@ -2,9 +2,10 @@ import {
isFn
}
from
'
uni-shared
'
import
createCallbacks
from
'
uni-helpers/callbacks
'
const
requestComponentInfoCallbacks
=
createCallbacks
(
'
requestComponentInfo
'
)
import
{
invokeMethod
,
getCurrentPageVm
}
from
'
../../platform
'
class
NodesRef
{
constructor
(
selectorQuery
,
component
,
selector
,
single
)
{
...
...
@@ -54,24 +55,15 @@ class NodesRef {
}
}
function
requestComponentInfo
(
pageId
,
queue
,
callback
)
{
const
reqId
=
requestComponentInfoCallbacks
.
push
(
callback
)
UniServiceJSBridge
.
publishHandler
(
'
requestComponentInfo
'
,
{
reqId
,
reqs
:
queue
},
pageId
)
}
class
SelectorQuery
{
constructor
(
page
Id
)
{
this
.
pageId
=
pageId
constructor
(
page
)
{
this
.
_page
=
page
this
.
_queue
=
[]
this
.
_queueCb
=
[]
}
exec
(
callback
)
{
requestComponentInfo
(
this
.
pageId
,
this
.
_queue
,
res
=>
{
invokeMethod
(
'
requestComponentInfo
'
,
this
.
_page
,
this
.
_queue
,
res
=>
{
const
queueCbs
=
this
.
_queueCb
res
.
forEach
((
result
,
index
)
=>
{
const
queueCb
=
queueCbs
[
index
]
...
...
@@ -83,9 +75,9 @@ class SelectorQuery {
})
}
[
'
in
'
]
(
component
)
{
//
TODO 跨平台,非 h5 平台传递 component._$
id
this
.
_component
=
component
[
'
in
'
]
(
component
)
{
//
app-plus 平台传递
id
this
.
_component
=
component
.
_$id
||
component
return
this
}
...
...
@@ -114,12 +106,7 @@ class SelectorQuery {
export
function
createSelectorQuery
(
context
)
{
if
(
context
)
{
return
new
SelectorQuery
(
context
.
$page
.
id
)
}
const
app
=
getApp
()
if
(
app
.
$route
&&
app
.
$route
.
params
.
__id__
)
{
return
new
SelectorQuery
(
app
.
$route
.
params
.
__id__
)
}
else
{
UniServiceJSBridge
.
emit
(
'
onError
'
,
'
createSelectorQuery:fail
'
)
return
new
SelectorQuery
(
context
)
}
return
new
SelectorQuery
(
getCurrentPageVm
(
'
createSelectorQuery
'
))
}
src/core/service/platform.js
浏览文件 @
55c2e4de
...
...
@@ -13,4 +13,14 @@ export function invokeMethod (name, ...args) {
*/
export
function
onMethod
(
name
,
callback
)
{
return
UniServiceJSBridge
.
on
(
'
api.
'
+
name
,
callback
)
}
export
function
getCurrentPageVm
(
method
)
{
const
pages
=
getCurrentPages
()
const
len
=
pages
.
length
if
(
!
len
)
{
UniServiceJSBridge
.
emit
(
'
onError
'
,
`
${
method
}
:fail`
)
}
const
page
=
pages
[
len
-
1
]
return
page
.
$vm
}
src/core/view/bridge/subscribe/api/request-component-info.js
浏览文件 @
55c2e4de
...
...
@@ -4,6 +4,10 @@ import {
import
getWindowOffset
from
'
uni-platform/helpers/get-window-offset
'
import
{
findElm
}
from
'
./util
'
function
getRootInfo
(
fields
)
{
const
info
=
{}
if
(
fields
.
id
)
{
...
...
@@ -74,9 +78,7 @@ function getNodeInfo (el, fields) {
}
function
getNodesInfo
(
pageVm
,
component
,
selector
,
single
,
fields
)
{
/* eslint-disable no-mixed-operators */
// TODO 判断 component 是否是 _$id,如果是,从 pageVm 中递归查找该组件实例
const
$el
=
component
&&
component
.
$el
||
pageVm
.
$el
const
$el
=
findElm
(
component
,
pageVm
)
if
(
single
)
{
const
node
=
$el
&&
(
$el
.
matches
(
selector
)
?
$el
:
$el
.
querySelector
(
selector
))
if
(
node
)
{
...
...
@@ -106,13 +108,14 @@ export function requestComponentInfo ({
},
pageId
)
{
const
pages
=
getCurrentPages
()
// 跨平台时,View 层也应该实现该方法,举例 App 上,View 层的 getCurrentPages 返回长度为1的当前页面数组
const
page
Vm
=
pages
.
find
(
page
=>
page
.
$page
.
id
===
pageId
)
const
page
=
pages
.
find
(
page
=>
page
.
$page
.
id
===
pageId
)
if
(
!
pageVm
)
{
// TODO 是否需要 defer
if
(
!
page
)
{
throw
new
Error
(
`Not Found:Page[
${
pageId
}
]`
)
}
const
pageVm
=
page
.
$vm
const
result
=
[]
reqs
.
forEach
(
function
({
component
,
...
...
src/core/view/bridge/subscribe/api/request-component-observer.js
浏览文件 @
55c2e4de
import
'
intersection-observer
'
import
{
normalizeDataset
}
from
'
uni-helpers/index
'
function
getRect
(
rect
)
{
return
{
bottom
:
rect
.
bottom
,
height
:
rect
.
height
,
left
:
rect
.
left
,
right
:
rect
.
right
,
top
:
rect
.
top
,
width
:
rect
.
width
}
}
const
intersectionObservers
=
{}
export
function
requestComponentObserver
({
reqId
,
options
},
pageId
)
{
const
pages
=
getCurrentPages
()
const
pageVm
=
pages
.
find
(
page
=>
page
.
$page
.
id
===
pageId
)
if
(
!
pageVm
)
{
throw
new
Error
(
`Not Found:Page[
${
pageId
}
]`
)
import
'
intersection-observer
'
import
{
normalizeDataset
}
from
'
uni-helpers/index
'
import
{
findElm
}
from
'
./util
'
function
getRect
(
rect
)
{
return
{
bottom
:
rect
.
bottom
,
height
:
rect
.
height
,
left
:
rect
.
left
,
right
:
rect
.
right
,
top
:
rect
.
top
,
width
:
rect
.
width
}
}
const
intersectionObservers
=
{}
export
function
requestComponentObserver
({
reqId
,
component
,
options
},
pageId
)
{
const
pages
=
getCurrentPages
()
const
page
=
pages
.
find
(
page
=>
page
.
$page
.
id
===
pageId
)
if
(
!
page
)
{
throw
new
Error
(
`Not Found:Page[
${
pageId
}
]`
)
}
const
$el
=
pageVm
.
$el
const
root
=
options
.
relativeToSelector
?
$el
.
querySelector
(
options
.
relativeToSelector
)
:
null
let
intersectionObserver
=
intersectionObservers
[
reqId
]
=
new
IntersectionObserver
((
entries
,
observer
)
=>
{
entries
.
forEach
(
entrie
=>
{
UniViewJSBridge
.
publishHandler
(
'
onRequestComponentObserver
'
,
{
reqId
,
res
:
{
intersectionRatio
:
entrie
.
intersectionRatio
,
intersectionRect
:
getRect
(
entrie
.
intersectionRect
),
boundingClientRect
:
getRect
(
entrie
.
boundingClientRect
),
relativeRect
:
getRect
(
entrie
.
rootBounds
),
time
:
Date
.
now
(),
dataset
:
normalizeDataset
(
entrie
.
target
.
dataset
||
{}),
id
:
entrie
.
target
.
id
}
},
pageVm
.
$page
.
id
)
})
},
{
root
,
rootMargin
:
options
.
rootMargin
,
threshold
:
options
.
thresholds
})
if
(
options
.
observeAll
)
{
intersectionObserver
.
USE_MUTATION_OBSERVER
=
true
Array
.
prototype
.
map
.
call
(
$el
.
querySelectorAll
(
options
.
selector
),
el
=>
{
intersectionObserver
.
observe
(
el
)
})
}
else
{
intersectionObserver
.
USE_MUTATION_OBSERVER
=
false
intersectionObserver
.
observe
(
$el
.
querySelector
(
options
.
selector
))
}
}
export
function
destroyComponentObserver
({
reqId
})
{
const
intersectionObserver
=
intersectionObservers
[
reqId
]
if
(
intersectionObserver
)
{
intersectionObserver
.
disconnect
()
UniViewJSBridge
.
publishHandler
(
'
onRequestComponentObserver
'
,
{
reqId
,
reqEnd
:
true
})
}
const
pageVm
=
page
.
$vm
const
$el
=
findElm
(
component
,
pageVm
)
const
root
=
options
.
relativeToSelector
?
$el
.
querySelector
(
options
.
relativeToSelector
)
:
null
let
intersectionObserver
=
intersectionObservers
[
reqId
]
=
new
IntersectionObserver
((
entries
,
observer
)
=>
{
entries
.
forEach
(
entrie
=>
{
UniViewJSBridge
.
publishHandler
(
'
onRequestComponentObserver
'
,
{
reqId
,
res
:
{
intersectionRatio
:
entrie
.
intersectionRatio
,
intersectionRect
:
getRect
(
entrie
.
intersectionRect
),
boundingClientRect
:
getRect
(
entrie
.
boundingClientRect
),
relativeRect
:
getRect
(
entrie
.
rootBounds
),
time
:
Date
.
now
(),
dataset
:
normalizeDataset
(
entrie
.
target
.
dataset
||
{}),
id
:
entrie
.
target
.
id
}
},
pageVm
.
$page
.
id
)
})
},
{
root
,
rootMargin
:
options
.
rootMargin
,
threshold
:
options
.
thresholds
})
if
(
options
.
observeAll
)
{
intersectionObserver
.
USE_MUTATION_OBSERVER
=
true
Array
.
prototype
.
map
.
call
(
$el
.
querySelectorAll
(
options
.
selector
),
el
=>
{
intersectionObserver
.
observe
(
el
)
})
}
else
{
intersectionObserver
.
USE_MUTATION_OBSERVER
=
false
intersectionObserver
.
observe
(
$el
.
querySelector
(
options
.
selector
))
}
}
export
function
destroyComponentObserver
({
reqId
})
{
const
intersectionObserver
=
intersectionObservers
[
reqId
]
if
(
intersectionObserver
)
{
intersectionObserver
.
disconnect
()
UniViewJSBridge
.
publishHandler
(
'
onRequestComponentObserver
'
,
{
reqId
,
reqEnd
:
true
})
}
}
src/core/view/bridge/subscribe/api/util.js
0 → 100644
浏览文件 @
55c2e4de
function
findVmById
(
id
,
vm
)
{
if
(
id
===
vm
.
_$id
)
{
return
vm
}
const
childVms
=
vm
.
$children
const
len
=
childVms
.
length
for
(
let
i
=
0
;
i
<
len
;
i
++
)
{
const
childVm
=
findVmById
(
id
,
childVms
[
i
])
if
(
childVm
)
{
return
childVm
}
}
}
export
function
findElm
(
component
,
pageVm
)
{
if
(
!
component
)
{
return
pageVm
.
$el
}
if
(
__PLATFORM__
===
'
app-plus
'
)
{
if
(
typeof
component
===
'
string
'
)
{
const
componentVm
=
findVmById
(
component
,
pageVm
)
if
(
!
componentVm
)
{
throw
new
Error
(
`Not Found:Page[
${
pageVm
.
$page
.
id
}
][
${
component
}
]`
)
}
return
componentVm
.
$el
}
}
return
component
.
$el
}
src/platforms/app-plus-nvue/service/api/context/map.js
已删除
100644 → 0
浏览文件 @
62c39768
import
{
findElmById
,
invokeVmMethod
,
invokeVmMethodWithoutArgs
}
from
'
../util
'
class
MapContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
this
.
ctx
=
ctx
}
getCenterLocation
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getCenterLocation
'
,
cbs
)
}
moveToLocation
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
moveToLocation
'
)
}
translateMarker
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
translateMarker
'
,
args
,
[
'
animationEnd
'
])
}
includePoints
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
includePoints
'
,
args
)
}
getRegion
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getRegion
'
,
cbs
)
}
getScale
(
cbs
)
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
getScale
'
,
cbs
)
}
}
export
function
createMapContext
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createMapContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
const
elm
=
findElmById
(
id
,
vm
)
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
new
MapContext
(
id
,
elm
)
}
src/platforms/app-plus-nvue/service/api/context/operate-map-player.js
0 → 100644
浏览文件 @
55c2e4de
import
{
findElmById
,
invokeVmMethod
,
invokeVmMethodWithoutArgs
}
from
'
../util
'
const
METHODS
=
{
getCenterLocation
(
ctx
,
cbs
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
getCenterLocation
'
,
cbs
)
},
moveToLocation
(
ctx
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
moveToLocation
'
)
},
translateMarker
(
ctx
,
args
)
{
return
invokeVmMethod
(
ctx
,
'
translateMarker
'
,
args
,
[
'
animationEnd
'
])
},
includePoints
(
ctx
,
args
)
{
return
invokeVmMethod
(
ctx
,
'
includePoints
'
,
args
)
},
getRegion
(
ctx
,
cbs
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
getRegion
'
,
cbs
)
},
getScale
(
ctx
,
cbs
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
getScale
'
,
cbs
)
}
}
export
function
operateMapPlayer
(
mapId
,
pageVm
,
type
,
data
)
{
return
METHODS
[
type
](
findElmById
(
mapId
,
pageVm
),
data
)
}
src/platforms/app-plus-nvue/service/api/context/operate-video-player.js
0 → 100644
浏览文件 @
55c2e4de
import
{
findElmById
,
invokeVmMethod
,
invokeVmMethodWithoutArgs
}
from
'
../util
'
const
METHODS
=
{
play
(
ctx
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
play
'
)
},
pause
(
ctx
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
pause
'
)
},
seek
(
ctx
,
args
)
{
return
invokeVmMethod
(
ctx
,
'
seek
'
,
args
)
},
stop
(
ctx
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
stop
'
)
},
sendDanmu
(
ctx
,
args
)
{
return
invokeVmMethod
(
ctx
,
'
sendDanmu
'
,
args
)
},
playbackRate
(
ctx
,
args
)
{
return
invokeVmMethod
(
ctx
,
'
playbackRate
'
,
args
)
},
requestFullScreen
(
ctx
,
args
)
{
return
invokeVmMethod
(
ctx
,
'
requestFullScreen
'
,
args
)
},
exitFullScreen
(
ctx
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
exitFullScreen
'
)
},
showStatusBar
(
ctx
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
showStatusBar
'
)
},
hideStatusBar
(
ctx
)
{
return
invokeVmMethodWithoutArgs
(
ctx
,
'
hideStatusBar
'
)
}
}
export
function
operateVideoPlayer
(
videoId
,
pageVm
,
type
,
data
)
{
return
METHODS
[
type
](
findElmById
(
videoId
,
pageVm
),
data
)
}
src/platforms/app-plus-nvue/service/api/context/video.js
已删除
100644 → 0
浏览文件 @
62c39768
import
{
findElmById
,
invokeVmMethod
,
invokeVmMethodWithoutArgs
}
from
'
../util
'
class
VideoContext
{
constructor
(
id
,
ctx
)
{
this
.
id
=
id
this
.
ctx
=
ctx
}
play
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
play
'
)
}
pause
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
pause
'
)
}
seek
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
seek
'
,
args
)
}
stop
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
stop
'
)
}
sendDanmu
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
sendDanmu
'
,
args
)
}
playbackRate
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
playbackRate
'
,
args
)
}
requestFullScreen
(
args
)
{
return
invokeVmMethod
(
this
.
ctx
,
'
requestFullScreen
'
,
args
)
}
exitFullScreen
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
exitFullScreen
'
)
}
showStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
showStatusBar
'
)
}
hideStatusBar
()
{
return
invokeVmMethodWithoutArgs
(
this
.
ctx
,
'
hideStatusBar
'
)
}
}
export
function
createVideoContext
(
id
,
vm
)
{
if
(
!
vm
)
{
return
console
.
warn
(
'
uni.createVideoContext 必须传入第二个参数,即当前 vm 对象(this)
'
)
}
const
elm
=
findElmById
(
id
,
vm
)
if
(
!
elm
)
{
return
console
.
warn
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
new
VideoContext
(
id
,
elm
)
}
src/platforms/app-plus-nvue/service/api/index.js
浏览文件 @
55c2e4de
export
*
from
'
./context/live-pusher
'
export
*
from
'
./context/
map
'
export
*
from
'
./context/
video
'
export
*
from
'
./context/
operate-map-player
'
export
*
from
'
./context/
operate-video-player
'
export
*
from
'
./ui/
create-selector-query
'
export
*
from
'
./ui/
request-component-info
'
src/platforms/app-plus-nvue/service/api/ui/
create-selector-query
.js
→
src/platforms/app-plus-nvue/service/api/ui/
request-component-info
.js
浏览文件 @
55c2e4de
import
{
isFn
}
from
'
uni-shared
'
class
NodesRef
{
constructor
(
selectorQuery
,
component
,
selector
,
single
)
{
this
.
_selectorQuery
=
selectorQuery
this
.
_component
=
component
this
.
_selector
=
selector
this
.
_single
=
single
}
boundingClientRect
(
callback
)
{
this
.
_selectorQuery
.
_push
(
this
.
_selector
,
this
.
_component
,
this
.
_single
,
{
id
:
true
,
dataset
:
true
,
rect
:
true
,
size
:
true
},
callback
)
return
this
.
_selectorQuery
}
fields
(
fields
,
callback
)
{
this
.
_selectorQuery
.
_push
(
this
.
_selector
,
this
.
_component
,
this
.
_single
,
fields
,
callback
)
return
this
.
_selectorQuery
}
scrollOffset
(
callback
)
{
this
.
_selectorQuery
.
_push
(
this
.
_selector
,
this
.
_component
,
this
.
_single
,
{
id
:
true
,
dataset
:
true
,
scrollOffset
:
true
},
callback
)
return
this
.
_selectorQuery
}
}
function
processDataset
(
attr
)
{
const
dataset
=
{}
Object
.
keys
(
attr
||
{}).
forEach
(
key
=>
{
if
(
key
.
indexOf
(
'
data
'
)
===
0
)
{
let
str
=
key
.
replace
(
'
data
'
,
''
)
str
=
str
.
charAt
(
0
).
toLowerCase
()
+
str
.
slice
(
1
)
dataset
[
str
]
=
attr
[
key
]
}
})
return
dataset
}
function
findAttrs
(
ids
,
elm
,
result
)
{
let
nodes
=
elm
.
children
if
(
!
Array
.
isArray
(
nodes
))
{
return
false
}
for
(
let
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
let
node
=
nodes
[
i
]
if
(
node
.
attr
)
{
let
index
=
ids
.
indexOf
(
node
.
attr
.
id
)
if
(
index
>=
0
)
{
result
[
index
]
=
{
id
:
ids
[
index
],
ref
:
node
.
ref
,
dataset
:
processDataset
(
node
.
attr
)
}
if
(
ids
.
length
===
1
)
{
break
}
}
}
if
(
node
.
children
)
{
findAttrs
(
ids
,
node
,
result
)
}
}
}
function
getSelectors
(
queue
)
{
let
ids
=
[]
for
(
let
i
=
0
;
i
<
queue
.
length
;
i
++
)
{
const
selector
=
queue
[
i
].
selector
if
(
selector
.
indexOf
(
'
#
'
)
===
0
)
{
ids
.
push
(
selector
.
substring
(
1
))
}
}
return
ids
}
function
getComponentRectAll
(
dom
,
attrs
,
index
,
result
,
callback
)
{
const
attr
=
attrs
[
index
]
dom
.
getComponentRect
(
attr
.
ref
,
option
=>
{
option
.
size
.
id
=
attr
.
id
option
.
size
.
dataset
=
attr
.
dataset
result
.
push
(
option
.
size
)
index
+=
1
if
(
index
<
attrs
.
length
)
{
getComponentRectAll
(
dom
,
attrs
,
index
,
result
,
callback
)
}
else
{
callback
(
result
)
}
})
}
function
requestComponentInfo
(
dom
,
component
,
queue
,
callback
)
{
const
selectors
=
getSelectors
(
queue
)
let
outAttrs
=
new
Array
(
selectors
.
length
)
findAttrs
(
selectors
,
component
.
$el
,
outAttrs
)
getComponentRectAll
(
dom
,
outAttrs
,
0
,
[],
(
result
)
=>
{
callback
(
result
)
})
}
class
SelectorQuery
{
constructor
(
pageId
)
{
this
.
pageId
=
pageId
this
.
_queue
=
[]
this
.
_queueCb
=
[]
}
exec
(
callback
)
{
if
(
!
this
.
_component
)
{
return
}
this
.
_dom
=
this
.
_component
.
_$weex
.
requireModule
(
'
dom
'
)
requestComponentInfo
(
this
.
_dom
,
this
.
_component
,
this
.
_queue
,
res
=>
{
const
queueCbs
=
this
.
_queueCb
res
.
forEach
((
result
,
index
)
=>
{
const
queueCb
=
queueCbs
[
index
]
if
(
isFn
(
queueCb
))
{
queueCb
.
call
(
this
,
result
)
}
})
isFn
(
callback
)
&&
callback
.
call
(
this
,
res
)
})
}
[
'
in
'
]
(
component
)
{
if
(
!
component
)
{
return
console
.
warn
(
'
uni.createSelectorQuery 必须传入当前 vm 对象(this)
'
)
}
this
.
_component
=
component
return
this
}
select
(
selector
)
{
return
new
NodesRef
(
this
,
this
.
_component
,
selector
,
true
)
}
selectAll
(
selector
)
{
return
new
NodesRef
(
this
,
this
.
_component
,
selector
,
false
)
}
selectViewport
()
{
return
new
NodesRef
(
this
,
0
,
''
,
true
)
}
_push
(
selector
,
component
,
single
,
fields
,
callback
)
{
this
.
_queue
.
push
({
component
,
selector
,
single
,
fields
})
this
.
_queueCb
.
push
(
callback
)
}
}
export
function
createSelectorQuery
()
{
return
new
SelectorQuery
()
function
parseDataset
(
attr
)
{
const
dataset
=
{}
Object
.
keys
(
attr
||
{}).
forEach
(
key
=>
{
if
(
key
.
indexOf
(
'
data
'
)
===
0
)
{
let
str
=
key
.
replace
(
'
data
'
,
''
)
str
=
str
.
charAt
(
0
).
toLowerCase
()
+
str
.
slice
(
1
)
dataset
[
str
]
=
attr
[
key
]
}
})
return
dataset
}
function
findAttrs
(
ids
,
elm
,
result
)
{
let
nodes
=
elm
.
children
if
(
!
Array
.
isArray
(
nodes
))
{
return
false
}
for
(
let
i
=
0
;
i
<
nodes
.
length
;
i
++
)
{
let
node
=
nodes
[
i
]
if
(
node
.
attr
)
{
let
index
=
ids
.
indexOf
(
node
.
attr
.
id
)
if
(
index
>=
0
)
{
result
[
index
]
=
{
id
:
ids
[
index
],
ref
:
node
.
ref
,
dataset
:
parseDataset
(
node
.
attr
)
}
if
(
ids
.
length
===
1
)
{
break
}
}
}
if
(
node
.
children
)
{
findAttrs
(
ids
,
node
,
result
)
}
}
}
function
getSelectors
(
queue
)
{
let
ids
=
[]
for
(
let
i
=
0
;
i
<
queue
.
length
;
i
++
)
{
const
selector
=
queue
[
i
].
selector
if
(
selector
.
indexOf
(
'
#
'
)
===
0
)
{
ids
.
push
(
selector
.
substring
(
1
))
}
}
return
ids
}
function
getComponentRectAll
(
dom
,
attrs
,
index
,
result
,
callback
)
{
const
attr
=
attrs
[
index
]
dom
.
getComponentRect
(
attr
.
ref
,
option
=>
{
option
.
size
.
id
=
attr
.
id
option
.
size
.
dataset
=
attr
.
dataset
result
.
push
(
option
.
size
)
index
+=
1
if
(
index
<
attrs
.
length
)
{
getComponentRectAll
(
dom
,
attrs
,
index
,
result
,
callback
)
}
else
{
callback
(
result
)
}
})
}
export
function
requestComponentInfo
(
pageVm
,
queue
,
callback
)
{
// TODO 重构,逻辑不对,queue 里的每一项可能有单独的作用域查找(即 component)
const
dom
=
pageVm
.
_$weex
.
requireModule
(
'
dom
'
)
const
selectors
=
getSelectors
(
queue
)
let
outAttrs
=
new
Array
(
selectors
.
length
)
findAttrs
(
selectors
,
pageVm
.
$el
,
outAttrs
)
getComponentRectAll
(
dom
,
outAttrs
,
0
,
[],
(
result
)
=>
{
callback
(
result
)
})
}
src/platforms/app-plus-nvue/service/api/util.js
浏览文件 @
55c2e4de
...
...
@@ -46,7 +46,11 @@ export function invokeVmMethod (vm, method, args, extras) {
}
export
function
findElmById
(
id
,
vm
)
{
return
findRefByElm
(
id
,
vm
.
$el
)
const
elm
=
findRefByElm
(
id
,
vm
.
$el
)
if
(
!
elm
)
{
return
console
.
error
(
'
Can not find `
'
+
id
+
'
`
'
)
}
return
elm
}
function
findRefByElm
(
id
,
elm
)
{
...
...
@@ -108,4 +112,4 @@ function normalizeCallback (method, callbacks) {
isFn
(
complete
)
&&
complete
(
ret
)
}
}
}
}
src/platforms/app-plus/service/api/context/operate-map-player.js
0 → 100644
浏览文件 @
55c2e4de
import
{
operateMapPlayer
as
operateVueMapPlayer
}
from
'
uni-platforms/h5/service/api/context/operate-map-player
'
import
{
operateMapPlayer
as
operateNVueMapPlayer
}
from
'
uni-platforms/app-plus-nvue/service/api/context/operate-map-player
'
export
function
operateMapPlayer
(
mapId
,
pageVm
,
type
,
data
)
{
pageVm
.
$page
.
meta
.
isNVue
?
operateNVueMapPlayer
(
mapId
,
pageVm
,
type
,
data
)
:
operateVueMapPlayer
(
mapId
,
pageVm
,
type
,
data
)
}
src/platforms/app-plus/service/api/context/operate-video-player.js
0 → 100644
浏览文件 @
55c2e4de
import
{
operateVideoPlayer
as
operateVueVideoPlayer
}
from
'
uni-platforms/h5/service/api/context/operate-video-player
'
import
{
operateVideoPlayer
as
operateNVueVideoPlayer
}
from
'
uni-platforms/app-plus-nvue/service/api/context/operate-video-player
'
export
function
operateVideoPlayer
(
videoId
,
pageVm
,
type
,
data
)
{
pageVm
.
$page
.
meta
.
isNVue
?
operateNVueVideoPlayer
(
videoId
,
pageVm
,
type
,
data
)
:
operateVueVideoPlayer
(
videoId
,
pageVm
,
type
,
data
)
}
src/platforms/app-plus/service/api/index.js
浏览文件 @
55c2e4de
export
*
from
'
./context/audio
'
export
*
from
'
./context/background-audio
'
export
*
from
'
./context/background-audio
'
export
*
from
'
./context/operate-map-player
'
export
*
from
'
./context/operate-video-player
'
export
*
from
'
./device/accelerometer
'
export
*
from
'
./device/add-phone-contact
'
...
...
@@ -61,3 +63,5 @@ export {
from
'
./ui/pull-down-refresh
'
export
*
from
'
./ui/tab-bar
'
export
*
from
'
./ui/request-component-info
'
src/platforms/app-plus/service/api/ui/request-component-info.js
0 → 100644
浏览文件 @
55c2e4de
import
{
requestComponentInfo
as
requestVueComponentInfo
}
from
'
uni-platforms/h5/service/api/ui/request-component-info
'
import
{
requestComponentInfo
as
requestNVueComponentInfo
}
from
'
uni-platforms/app-plus-nvue/service/api/ui/request-component-info
'
export
function
requestComponentInfo
(
pageVm
,
queue
,
callback
)
{
pageVm
.
$page
.
meta
.
isNVue
?
requestNVueComponentInfo
(
pageVm
,
queue
,
callback
)
:
requestVueComponentInfo
(
pageVm
,
queue
,
callback
)
}
src/platforms/app-plus/service/framework/plugins/index.js
浏览文件 @
55c2e4de
...
...
@@ -19,6 +19,12 @@ export default {
initData
(
Vue
)
initLifecycle
(
Vue
)
Object
.
defineProperty
(
Vue
.
prototype
,
'
$page
'
,
{
get
()
{
return
this
.
$root
.
$scope
.
$page
}
})
const
oldMount
=
Vue
.
prototype
.
$mount
Vue
.
prototype
.
$mount
=
function
mount
(
el
,
hydrating
)
{
if
(
this
.
mpType
===
'
app
'
)
{
...
...
src/platforms/app-plus/service/publish-handler.js
浏览文件 @
55c2e4de
...
...
@@ -7,9 +7,9 @@ export function publishHandler (eventType, args, pageIds) {
pageIds
=
[
pageIds
]
}
const
evalJSCode
=
`typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("
${
eventType
}
",
${
args
}
)`
`typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("
${
eventType
}
",
${
args
}
,__PAGE_ID__
)`
pageIds
.
forEach
(
id
=>
{
const
webview
=
plus
.
webview
.
getWebviewById
(
String
(
id
))
webview
&&
webview
.
evalJS
(
evalJSCode
)
webview
&&
webview
.
evalJS
(
evalJSCode
.
replace
(
'
__PAGE_ID__
'
,
id
)
)
})
}
src/platforms/app-plus/view/framework/plugins/data.js
浏览文件 @
55c2e4de
...
...
@@ -50,7 +50,8 @@ const handleData = {
},
[
PAGE_CREATED
]:
function
onPageCreated
(
data
)
{
const
[
pageId
,
pagePath
]
=
data
new
PageVueComponent
({
const
page
=
getCurrentPages
()[
0
]
page
.
$vm
=
new
PageVueComponent
({
mpType
:
'
page
'
,
pageId
,
pagePath
...
...
src/platforms/h5/service/api/context/map.js
已删除
100644 → 0
浏览文件 @
62c39768
function
operateMapPlayer
(
mapId
,
pageId
,
type
,
data
)
{
UniServiceJSBridge
.
publishHandler
(
pageId
+
'
-map-
'
+
mapId
,
{
mapId
,
type
,
data
},
pageId
)
}
class
MapContext
{
constructor
(
id
,
pageId
)
{
this
.
id
=
id
this
.
pageId
=
pageId
}
getCenterLocation
({
success
,
fail
,
complete
})
{
operateMapPlayer
(
this
.
id
,
this
.
pageId
,
'
getCenterLocation
'
,
{
success
,
fail
,
complete
})
}
moveToLocation
()
{
operateMapPlayer
(
this
.
id
,
this
.
pageId
,
'
moveToLocation
'
)
}
translateMarker
({
markerId
,
destination
,
autoRotate
,
rotate
,
duration
,
animationEnd
,
fail
})
{
operateMapPlayer
(
this
.
id
,
this
.
pageId
,
'
translateMarker
'
,
{
markerId
,
destination
,
autoRotate
,
rotate
,
duration
,
animationEnd
,
fail
})
}
includePoints
({
points
,
padding
})
{
operateMapPlayer
(
this
.
id
,
this
.
pageId
,
'
includePoints
'
,
{
points
,
padding
})
}
getRegion
({
success
,
fail
,
complete
})
{
operateMapPlayer
(
this
.
id
,
this
.
pageId
,
'
getRegion
'
,
{
success
,
fail
,
complete
})
}
getScale
({
success
,
fail
,
complete
})
{
operateMapPlayer
(
this
.
id
,
this
.
pageId
,
'
getScale
'
,
{
success
,
fail
,
complete
})
}
}
export
function
createMapContext
(
id
,
context
)
{
if
(
context
)
{
return
new
MapContext
(
id
,
context
.
$page
.
id
)
}
const
app
=
getApp
()
if
(
app
.
$route
&&
app
.
$route
.
params
.
__id__
)
{
return
new
MapContext
(
id
,
app
.
$route
.
params
.
__id__
)
}
else
{
UniServiceJSBridge
.
emit
(
'
onError
'
,
'
createMapContext:fail
'
)
}
}
src/platforms/h5/service/api/context/operate-map-player.js
0 → 100644
浏览文件 @
55c2e4de
export
function
operateMapPlayer
(
mapId
,
pageVm
,
type
,
data
)
{
const
pageId
=
pageVm
.
$page
.
id
UniServiceJSBridge
.
publishHandler
(
pageId
+
'
-map-
'
+
mapId
,
{
mapId
,
type
,
data
},
pageId
)
}
src/platforms/h5/service/api/context/operate-video-player.js
0 → 100644
浏览文件 @
55c2e4de
export
function
operateVideoPlayer
(
videoId
,
pageVm
,
type
,
data
)
{
const
pageId
=
pageVm
.
$page
.
id
UniServiceJSBridge
.
publishHandler
(
pageId
+
'
-video-
'
+
videoId
,
{
videoId
,
type
,
data
},
pageId
)
}
src/platforms/h5/service/api/context/video.js
已删除
100644 → 0
浏览文件 @
62c39768
function
operateVideoPlayer
(
videoId
,
pageId
,
type
,
data
)
{
UniServiceJSBridge
.
publishHandler
(
pageId
+
'
-video-
'
+
videoId
,
{
videoId
,
type
,
data
},
pageId
)
}
const
RATES
=
[
0.5
,
0.8
,
1.0
,
1.25
,
1.5
]
class
VideoContext
{
constructor
(
id
,
pageId
)
{
this
.
id
=
id
this
.
pageId
=
pageId
}
play
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
play
'
)
}
pause
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
pause
'
)
}
stop
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
stop
'
)
}
seek
(
position
)
{
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
seek
'
,
{
position
})
}
sendDanmu
({
text
,
color
}
=
{})
{
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
sendDanmu
'
,
{
text
,
color
})
}
playbackRate
(
rate
)
{
if
(
!~
RATES
.
indexOf
(
rate
))
{
rate
=
1.0
}
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
playbackRate
'
,
{
rate
})
}
requestFullScreen
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
requestFullScreen
'
)
}
exitFullScreen
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
exitFullScreen
'
)
}
showStatusBar
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
showStatusBar
'
)
}
hideStatusBar
()
{
operateVideoPlayer
(
this
.
id
,
this
.
pageId
,
'
hideStatusBar
'
)
}
}
export
function
createVideoContext
(
id
,
context
)
{
if
(
context
)
{
return
new
VideoContext
(
id
,
context
.
$page
.
id
)
}
const
app
=
getApp
()
if
(
app
.
$route
&&
app
.
$route
.
params
.
__id__
)
{
return
new
VideoContext
(
id
,
app
.
$route
.
params
.
__id__
)
}
else
{
UniServiceJSBridge
.
emit
(
'
onError
'
,
'
createVideoContext:fail
'
)
}
}
src/platforms/h5/service/api/ui/request-component-info.js
0 → 100644
浏览文件 @
55c2e4de
import
createCallbacks
from
'
uni-helpers/callbacks
'
const
requestComponentInfoCallbacks
=
createCallbacks
(
'
requestComponentInfo
'
)
export
function
requestComponentInfo
(
pageVm
,
queue
,
callback
)
{
UniServiceJSBridge
.
publishHandler
(
'
requestComponentInfo
'
,
{
reqId
:
requestComponentInfoCallbacks
.
push
(
callback
),
reqs
:
queue
},
pageVm
.
$page
.
id
)
}
src/platforms/mp-baidu/runtime/wrapper/component-parser.js
浏览文件 @
55c2e4de
import
{
hasOwn
}
from
'
uni-shared
'
import
{
isPage
,
hasOwn
}
from
'
uni-shared
'
import
{
isPage
,
initRelation
}
from
'
./util
'
import
parseBaseComponent
from
'
../../../mp-weixin/runtime/wrapper/component-base-parser
'
const
newLifecycle
=
swan
.
canIUse
(
'
lifecycle-2-0
'
)
export
default
function
parseComponent
(
vueOptions
)
{
const
componentOptions
=
parseBaseComponent
(
vueOptions
,
{
isPage
,
...
...
@@ -23,13 +25,26 @@ export default function parseComponent (vueOptions) {
// 百度 当组件作为页面时 pageinstancce 不是原来组件的 instance
this
.
pageinstance
.
$vm
=
this
.
$vm
if
(
hasOwn
(
this
.
pageinstance
,
'
_$args
'
))
{
if
(
hasOwn
(
this
.
pageinstance
,
'
_$args
'
))
{
this
.
$vm
.
$mp
.
query
=
this
.
pageinstance
.
_$args
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
this
.
pageinstance
.
_$args
)
this
.
$vm
.
__call_hook
(
'
onLoad
'
,
this
.
pageinstance
.
_$args
)
delete
this
.
pageinstance
.
_$args
}
// TODO 目前版本 百度 Component 作为页面时,methods 中的 onShow 不触发
this
.
$vm
.
__call_hook
(
'
onShow
'
)
// TODO 3.105.17以下基础库内百度 Component 作为页面时,methods 中的 onShow 不触发
!
newLifecycle
&&
this
.
$vm
.
__call_hook
(
'
onShow
'
)
}
}
if
(
newLifecycle
)
{
delete
componentOptions
.
lifetimes
.
ready
componentOptions
.
methods
.
onReady
=
function
()
{
if
(
this
.
$vm
)
{
this
.
$vm
.
_isMounted
=
true
this
.
$vm
.
__call_hook
(
'
mounted
'
)
this
.
$vm
.
__call_hook
(
'
onReady
'
)
}
else
{
// this.is && console.warn(this.is + ' is not attached')
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录