Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
cde391e2
U
uni-app
项目概览
Velpro187
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
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,发现更多精彩内容 >>
提交
cde391e2
编写于
4月 27, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: useCurrentPageId, getPageIdByVm
上级
60b10804
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
49 addition
and
26 deletion
+49
-26
packages/uni-api/src/service/ui/createIntersectionObserver.ts
...ages/uni-api/src/service/ui/createIntersectionObserver.ts
+3
-3
packages/uni-components/src/components/label/index.tsx
packages/uni-components/src/components/label/index.tsx
+3
-5
packages/uni-components/src/helpers/useListeners.ts
packages/uni-components/src/helpers/useListeners.ts
+3
-4
packages/uni-components/src/helpers/useSubscribe.ts
packages/uni-components/src/helpers/useSubscribe.ts
+2
-2
packages/uni-core/src/helpers/index.ts
packages/uni-core/src/helpers/index.ts
+1
-0
packages/uni-core/src/helpers/page.ts
packages/uni-core/src/helpers/page.ts
+15
-0
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+20
-11
packages/uni-h5/src/service/api/context/operateVideoPlayer.ts
...ages/uni-h5/src/service/api/context/operateVideoPlayer.ts
+2
-1
未找到文件。
packages/uni-api/src/service/ui/createIntersectionObserver.ts
浏览文件 @
cde391e2
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
extend
,
isFunction
}
from
'
@vue/shared
'
import
{
getCurrentPageVm
}
from
'
@dcloudio/uni-core
'
import
{
getCurrentPageVm
,
getPageIdByVm
}
from
'
@dcloudio/uni-core
'
import
{
addIntersectionObserver
,
removeIntersectionObserver
,
...
...
@@ -48,7 +48,7 @@ class ServiceIntersectionObserver {
component
:
ComponentPublicInstance
,
options
?:
UniApp
.
CreateIntersectionObserverOptions
)
{
this
.
_pageId
=
component
.
$page
&&
component
.
$page
.
id
this
.
_pageId
=
getPageIdByVm
(
component
)
!
this
.
_component
=
component
this
.
_options
=
extend
({},
defaultOptions
,
options
)
}
...
...
@@ -96,7 +96,7 @@ class ServiceIntersectionObserver {
export
const
createIntersectionObserver
=
defineSyncApi
<
typeof
uni
.
createIntersectionObserver
>
(
'
createIntersectionObserver
'
,
(
context
?,
options
?)
=>
{
if
(
context
&&
!
context
.
$page
)
{
if
(
context
&&
!
getPageIdByVm
(
context
)
)
{
options
=
context
context
=
null
}
...
...
packages/uni-components/src/components/label/index.tsx
浏览文件 @
cde391e2
import
{
defineComponent
,
provide
,
getCurrentInstance
,
computed
}
from
'
vue
'
import
{
PolySymbol
}
from
'
@dcloudio/uni-core
'
import
{
defineComponent
,
provide
,
computed
}
from
'
vue
'
import
{
PolySymbol
,
useCurrentPageId
}
from
'
@dcloudio/uni-core
'
import
{
withWebEvent
}
from
'
@dcloudio/uni-components
'
export
const
uniLabelKey
=
PolySymbol
(
__DEV__
?
'
uniLabel
'
:
'
ul
'
)
...
...
@@ -14,9 +14,7 @@ export default /*#__PURE__*/ defineComponent({
name
:
'
Label
'
,
props
,
setup
(
props
,
{
emit
,
slots
})
{
const
instance
=
getCurrentInstance
()
!
const
pageId
=
instance
.
root
.
proxy
!
.
$page
.
id
const
pageId
=
useCurrentPageId
()
const
handlers
=
useProvideLabel
()
const
pointer
=
computed
(
...
...
packages/uni-components/src/helpers/useListeners.ts
浏览文件 @
cde391e2
import
{
isPlainObject
}
from
'
@vue/shared
'
import
{
watch
,
onUnmounted
,
getCurrentInstance
}
from
'
vue
'
import
{
useCurrentPageId
}
from
'
@dcloudio/uni-core
'
export
function
useListeners
(
props
:
{
id
:
string
},
...
...
@@ -25,8 +26,7 @@ function _addListeners(
listeners
:
Record
<
string
,
Function
>
,
watch
?:
boolean
)
{
const
instance
=
getCurrentInstance
()
!
const
pageId
=
instance
.
root
.
proxy
!
.
$page
.
id
const
pageId
=
useCurrentPageId
()
if
(
watch
&&
!
id
)
{
// id被置空
...
...
@@ -59,8 +59,7 @@ function _removeListeners(
listeners
:
Record
<
string
,
Function
>
,
watch
?:
boolean
)
{
const
instance
=
getCurrentInstance
()
!
const
pageId
=
instance
.
root
.
proxy
!
.
$page
.
id
const
pageId
=
useCurrentPageId
()
if
(
watch
&&
!
id
)
{
// id之前不存在
...
...
packages/uni-components/src/helpers/useSubscribe.ts
浏览文件 @
cde391e2
...
...
@@ -5,6 +5,7 @@ import {
getCurrentInstance
,
ComponentPublicInstance
,
}
from
'
vue
'
import
{
useCurrentPageId
}
from
'
@dcloudio/uni-core
'
function
normalizeEvent
(
pageId
:
number
,
...
...
@@ -45,8 +46,7 @@ export function useSubscribe(
)
{
const
instance
=
getCurrentInstance
()
!
const
vm
=
instance
.
proxy
!
// 不能直接使用instance.proxy.$root,此时可能获取到的是exposed
const
pageId
=
name
?
0
:
instance
.
root
.
proxy
!
.
$page
.
id
const
pageId
=
name
?
0
:
useCurrentPageId
()
onMounted
(()
=>
{
addSubscribe
(
name
||
normalizeEvent
(
pageId
,
vm
)
!
,
callback
)
if
(
!
name
)
{
...
...
packages/uni-core/src/helpers/index.ts
浏览文件 @
cde391e2
export
*
from
'
./dom
'
export
*
from
'
./util
'
export
*
from
'
./icon
'
export
*
from
'
./page
'
export
*
from
'
./scroll
'
export
*
from
'
./getRealRoute
'
packages/uni-core/src/helpers/page.ts
0 → 100644
浏览文件 @
cde391e2
import
{
ComponentPublicInstance
,
getCurrentInstance
}
from
'
vue
'
export
function
useCurrentPageId
()
{
return
getCurrentInstance
()
!
.
root
.
proxy
!
.
$page
.
id
}
export
function
getPageIdByVm
(
vm
:
ComponentPublicInstance
)
{
if
(
!
vm
.
$
)
{
return
}
const
rootProxy
=
vm
.
$
.
root
.
proxy
if
(
rootProxy
&&
rootProxy
.
$page
)
{
return
rootProxy
.
$page
.
id
}
}
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
cde391e2
import
{
isFunction
,
extend
,
hyphenate
,
isPlainObject
,
isString
,
isArray
,
hasOwn
as
hasOwn$1
,
isObject
as
isObject$1
,
capitalize
,
toRawType
,
makeMap
as
makeMap$1
,
isPromise
,
invokeArrayFns
as
invokeArrayFns$1
}
from
"
@vue/shared
"
;
import
{
injectHook
,
withModifiers
,
createVNode
,
inject
,
provide
,
reactive
,
computed
,
nextTick
,
getCurrentInstance
,
onBeforeMount
,
onMounted
,
onBeforeActivate
,
onBeforeDeactivate
,
openBlock
,
createBlock
,
mergeProps
,
toDisplayString
,
ref
,
defineComponent
,
resolveComponent
,
toHandlers
,
renderSlot
,
watch
,
onUnmounted
,
onBeforeUnmount
,
onActivated
,
withDirectives
,
vShow
,
createTextVNode
,
createCommentVNode
,
renderList
,
onDeactivated
,
createApp
,
watchEffect
,
Transition
,
withCtx
,
KeepAlive
,
resolveDynamicComponent
,
Fragment
}
from
"
vue
"
;
import
{
injectHook
,
withModifiers
,
createVNode
,
getCurrentInstance
,
inject
,
provide
,
reactive
,
computed
,
nextTick
,
onBeforeMount
,
onMounted
,
onBeforeActivate
,
onBeforeDeactivate
,
openBlock
,
createBlock
,
mergeProps
,
toDisplayString
,
ref
,
defineComponent
,
resolveComponent
,
toHandlers
,
renderSlot
,
watch
,
onUnmounted
,
onBeforeUnmount
,
onActivated
,
withDirectives
,
vShow
,
createTextVNode
,
createCommentVNode
,
renderList
,
onDeactivated
,
createApp
,
watchEffect
,
Transition
,
withCtx
,
KeepAlive
,
resolveDynamicComponent
,
Fragment
}
from
"
vue
"
;
import
{
once
,
passive
,
normalizeTarget
,
isBuiltInComponent
,
invokeArrayFns
,
NAVBAR_HEIGHT
,
parseQuery
,
PRIMARY_COLOR
,
removeLeadingSlash
,
getLen
,
ON_REACH_BOTTOM_DISTANCE
,
decodedQuery
,
debounce
,
updateElementStyle
,
addFont
,
scrollTo
}
from
"
@dcloudio/uni-shared
"
;
import
{
useRoute
,
createRouter
,
createWebHistory
,
createWebHashHistory
,
useRouter
,
isNavigationFailure
,
RouterView
}
from
"
vue-router
"
;
function
applyOptions
(
options
,
instance2
,
publicThis
)
{
...
...
@@ -768,6 +768,18 @@ function createSvgIconVNode(path, color = "#000", size = 27) {
},
null
,
8
,
[
"
d
"
,
"
fill
"
])
],
8
,
[
"
width
"
,
"
height
"
]);
}
function
useCurrentPageId
()
{
return
getCurrentInstance
().
root
.
proxy
.
$page
.
id
;
}
function
getPageIdByVm
(
vm
)
{
if
(
!
vm
.
$
)
{
return
;
}
const
rootProxy
=
vm
.
$
.
root
.
proxy
;
if
(
rootProxy
&&
rootProxy
.
$page
)
{
return
rootProxy
.
$page
.
id
;
}
}
function
disableScrollListener
(
evt
)
{
evt
.
preventDefault
();
}
...
...
@@ -1889,7 +1901,7 @@ function getBaseSystemInfo() {
};
}
function
operateVideoPlayer
(
videoId
,
vm
,
type
,
data
)
{
const
pageId
=
vm
.
$root
.
$page
.
id
;
const
pageId
=
getPageIdByVm
(
vm
)
;
UniServiceJSBridge
.
publishHandler
(
"
video.
"
+
videoId
,
{
videoId
,
type
,
...
...
@@ -2094,7 +2106,7 @@ function normalizeRootMargin(margins = {}) {
}
class
ServiceIntersectionObserver
{
constructor
(
component
,
options
)
{
this
.
_pageId
=
component
.
$page
&&
component
.
$page
.
id
;
this
.
_pageId
=
getPageIdByVm
(
component
)
;
this
.
_component
=
component
;
this
.
_options
=
extend
({},
defaultOptions
,
options
);
}
...
...
@@ -2126,7 +2138,7 @@ class ServiceIntersectionObserver {
}
}
const
createIntersectionObserver
=
defineSyncApi
(
"
createIntersectionObserver
"
,
(
context
,
options
)
=>
{
if
(
context
&&
!
context
.
$page
)
{
if
(
context
&&
!
getPageIdByVm
(
context
)
)
{
options
=
context
;
context
=
null
;
}
...
...
@@ -5034,8 +5046,7 @@ function useListeners(props2, listeners2) {
});
}
function
_addListeners
(
id2
,
listeners2
,
watch2
)
{
const
instance2
=
getCurrentInstance
();
const
pageId
=
instance2
.
root
.
proxy
.
$page
.
id
;
const
pageId
=
useCurrentPageId
();
if
(
watch2
&&
!
id2
)
{
return
;
}
...
...
@@ -5057,8 +5068,7 @@ function _addListeners(id2, listeners2, watch2) {
});
}
function
_removeListeners
(
id2
,
listeners2
,
watch2
)
{
const
instance2
=
getCurrentInstance
();
const
pageId
=
instance2
.
root
.
proxy
.
$page
.
id
;
const
pageId
=
useCurrentPageId
();
if
(
watch2
&&
!
id2
)
{
return
;
}
...
...
@@ -5171,8 +5181,7 @@ var index$b = /* @__PURE__ */ defineComponent({
emit
:
emit2
,
slots
})
{
const
instance2
=
getCurrentInstance
();
const
pageId
=
instance2
.
root
.
proxy
.
$page
.
id
;
const
pageId
=
useCurrentPageId
();
const
handlers
=
useProvideLabel
();
const
pointer
=
computed
(()
=>
props2
.
for
||
slots
.
default
&&
slots
.
default
.
length
);
const
_onClick
=
withWebEvent
((
$event
)
=>
{
...
...
@@ -10321,7 +10330,7 @@ function removeSubscribe(name) {
function
useSubscribe
(
callback
,
name
)
{
const
instance2
=
getCurrentInstance
();
const
vm
=
instance2
.
proxy
;
const
pageId
=
name
?
0
:
instance2
.
root
.
proxy
.
$page
.
id
;
const
pageId
=
name
?
0
:
useCurrentPageId
()
;
onMounted
(()
=>
{
addSubscribe
(
name
||
normalizeEvent
(
pageId
,
vm
),
callback
);
if
(
!
name
)
{
...
...
packages/uni-h5/src/service/api/context/operateVideoPlayer.ts
浏览文件 @
cde391e2
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
getPageIdByVm
}
from
'
@dcloudio/uni-core
'
export
function
operateVideoPlayer
(
videoId
:
string
,
...
...
@@ -6,7 +7,7 @@ export function operateVideoPlayer(
type
:
string
,
data
?:
unknown
)
{
const
pageId
=
vm
.
$root
!
.
$page
.
id
const
pageId
=
getPageIdByVm
(
vm
)
!
UniServiceJSBridge
.
publishHandler
(
'
video.
'
+
videoId
,
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录