Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
033a758c
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
033a758c
编写于
4月 22, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: onReachBottom
上级
2bc43dfa
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
18 deletion
+42
-18
packages/shims-vue-runtime.d.ts
packages/shims-vue-runtime.d.ts
+1
-0
packages/uni-core/src/service/plugin/subscribe.ts
packages/uni-core/src/service/plugin/subscribe.ts
+5
-1
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+18
-7
packages/uni-h5/src/framework/setup/page.ts
packages/uni-h5/src/framework/setup/page.ts
+18
-10
未找到文件。
packages/shims-vue-runtime.d.ts
浏览文件 @
033a758c
...
@@ -3,6 +3,7 @@ import { ComponentCustomProperties, ComponentInternalInstance } from 'vue'
...
@@ -3,6 +3,7 @@ import { ComponentCustomProperties, ComponentInternalInstance } from 'vue'
declare
module
'
@vue/runtime-core
'
{
declare
module
'
@vue/runtime-core
'
{
interface
ComponentCustomProperties
{
interface
ComponentCustomProperties
{
$page
:
Page
.
PageInstance
[
'
$page
'
]
$page
:
Page
.
PageInstance
[
'
$page
'
]
__isTabBar
:
boolean
}
}
type
LifecycleHook
=
Function
[]
|
null
type
LifecycleHook
=
Function
[]
|
null
...
...
packages/uni-core/src/service/plugin/subscribe.ts
浏览文件 @
033a758c
import
{
getPageVmById
,
invokeHook
}
from
'
./page
'
import
{
getPageVmById
,
invokeHook
}
from
'
./page
'
const
SUBSCRIBE_LIFECYCLE_HOOKS
=
[
'
onPageScroll
'
,
'
onReachBottom
'
]
export
function
initSubscribe
()
{
export
function
initSubscribe
()
{
UniServiceJSBridge
.
subscribe
(
'
onPageScroll
'
,
createPageEvent
(
'
onPageScroll
'
))
SUBSCRIBE_LIFECYCLE_HOOKS
.
forEach
((
name
)
=>
UniServiceJSBridge
.
subscribe
(
name
,
createPageEvent
(
name
))
)
}
}
function
createPageEvent
(
name
:
string
)
{
function
createPageEvent
(
name
:
string
)
{
...
...
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
033a758c
...
@@ -1013,8 +1013,9 @@ function onAppEnterBackground() {
...
@@ -1013,8 +1013,9 @@ function onAppEnterBackground() {
invokeHook
(
getApp
(),
"
onHide
"
);
invokeHook
(
getApp
(),
"
onHide
"
);
invokeHook
(
getCurrentPage
(),
"
onHide
"
);
invokeHook
(
getCurrentPage
(),
"
onHide
"
);
}
}
const
SUBSCRIBE_LIFECYCLE_HOOKS
=
[
"
onPageScroll
"
,
"
onReachBottom
"
];
function
initSubscribe
()
{
function
initSubscribe
()
{
UniServiceJSBridge
.
subscribe
(
"
onPageScroll
"
,
createPageEvent
(
"
onPageScroll
"
));
SUBSCRIBE_LIFECYCLE_HOOKS
.
forEach
((
name
)
=>
UniServiceJSBridge
.
subscribe
(
name
,
createPageEvent
(
name
)
));
}
}
function
createPageEvent
(
name
)
{
function
createPageEvent
(
name
)
{
return
(
args
,
pageId
)
=>
{
return
(
args
,
pageId
)
=>
{
...
@@ -3500,7 +3501,7 @@ function getCurrentPages$1() {
...
@@ -3500,7 +3501,7 @@ function getCurrentPages$1() {
const
curPages
=
[];
const
curPages
=
[];
const
pages
=
currentPagesMap
.
values
();
const
pages
=
currentPagesMap
.
values
();
for
(
const
page
of
pages
)
{
for
(
const
page
of
pages
)
{
if
(
page
.
$page
.
meta
.
isTabBar
)
{
if
(
page
.
__
isTabBar
)
{
if
(
page
.
$
.
__isActive
)
{
if
(
page
.
$
.
__isActive
)
{
curPages
.
push
(
page
);
curPages
.
push
(
page
);
}
}
...
@@ -3559,6 +3560,7 @@ function initPage(vm) {
...
@@ -3559,6 +3560,7 @@ function initPage(vm) {
const
page
=
initPublicPage
(
route
);
const
page
=
initPublicPage
(
route
);
vm
.
$vm
=
vm
;
vm
.
$vm
=
vm
;
vm
.
$page
=
page
;
vm
.
$page
=
page
;
vm
.
__isTabBar
=
page
.
meta
.
isTabBar
;
currentPagesMap
.
set
(
normalizeRouteKey
(
page
.
path
,
page
.
id
),
vm
);
currentPagesMap
.
set
(
normalizeRouteKey
(
page
.
path
,
page
.
id
),
vm
);
}
}
function
normalizeRouteKey
(
path
,
id2
)
{
function
normalizeRouteKey
(
path
,
id2
)
{
...
@@ -3592,6 +3594,18 @@ const routeCache = {
...
@@ -3592,6 +3594,18 @@ const routeCache = {
pageCacheMap
.
forEach
(
fn
);
pageCacheMap
.
forEach
(
fn
);
}
}
};
};
function
isTabBarVNode
(
vnode
)
{
if
(
!
hasOwn$1
(
vnode
,
"
__isTabBar
"
))
{
const
{
component
}
=
vnode
;
if
(
component
&&
component
.
refs
.
page
)
{
const
vm
=
component
.
refs
.
page
;
if
(
vm
.
$page
)
{
vnode
.
__isTabBar
=
vm
.
__isTabBar
;
}
}
}
return
vnode
.
__isTabBar
;
}
function
pruneRouteCache
(
key
)
{
function
pruneRouteCache
(
key
)
{
const
pageId
=
parseInt
(
key
.
split
(
SEP
)[
1
]);
const
pageId
=
parseInt
(
key
.
split
(
SEP
)[
1
]);
if
(
!
pageId
)
{
if
(
!
pageId
)
{
...
@@ -3600,11 +3614,8 @@ function pruneRouteCache(key) {
...
@@ -3600,11 +3614,8 @@ function pruneRouteCache(key) {
routeCache
.
forEach
((
vnode
,
key2
)
=>
{
routeCache
.
forEach
((
vnode
,
key2
)
=>
{
const
cPageId
=
parseInt
(
key2
.
split
(
SEP
)[
1
]);
const
cPageId
=
parseInt
(
key2
.
split
(
SEP
)[
1
]);
if
(
cPageId
&&
cPageId
>
pageId
)
{
if
(
cPageId
&&
cPageId
>
pageId
)
{
if
(
__UNI_FEATURE_TABBAR__
)
{
if
(
__UNI_FEATURE_TABBAR__
&&
isTabBarVNode
(
vnode
))
{
const
{
component
}
=
vnode
;
return
;
if
(
component
&&
component
.
refs
.
page
&&
component
.
refs
.
page
.
$page
.
meta
.
isTabBar
)
{
return
;
}
}
}
routeCache
.
delete
(
key2
);
routeCache
.
delete
(
key2
);
routeCache
.
pruneCacheEntry
(
vnode
);
routeCache
.
pruneCacheEntry
(
vnode
);
...
...
packages/uni-h5/src/framework/setup/page.ts
浏览文件 @
033a758c
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
ComponentPublicInstance
,
ComponentPublicInstance
,
ComponentInternalInstance
,
ComponentInternalInstance
,
}
from
'
vue
'
}
from
'
vue
'
import
{
hasOwn
}
from
'
@vue/shared
'
import
{
useRoute
,
RouteLocationNormalizedLoaded
}
from
'
vue-router
'
import
{
useRoute
,
RouteLocationNormalizedLoaded
}
from
'
vue-router
'
import
{
import
{
invokeHook
,
invokeHook
,
...
@@ -38,7 +39,7 @@ export function getCurrentPages() {
...
@@ -38,7 +39,7 @@ export function getCurrentPages() {
const
curPages
:
Page
.
PageInstance
[]
=
[]
const
curPages
:
Page
.
PageInstance
[]
=
[]
const
pages
=
currentPagesMap
.
values
()
const
pages
=
currentPagesMap
.
values
()
for
(
const
page
of
pages
)
{
for
(
const
page
of
pages
)
{
if
(
page
.
$page
.
meta
.
isTabBar
)
{
if
(
(
page
as
ComponentPublicInstance
).
__
isTabBar
)
{
if
((
page
as
ComponentPublicInstance
).
$
.
__isActive
)
{
if
((
page
as
ComponentPublicInstance
).
$
.
__isActive
)
{
curPages
.
push
(
page
)
curPages
.
push
(
page
)
}
}
...
@@ -103,6 +104,7 @@ export function initPage(vm: ComponentPublicInstance) {
...
@@ -103,6 +104,7 @@ export function initPage(vm: ComponentPublicInstance) {
const
page
=
initPublicPage
(
route
)
const
page
=
initPublicPage
(
route
)
;(
vm
as
any
).
$vm
=
vm
;(
vm
as
any
).
$vm
=
vm
;(
vm
as
any
).
$page
=
page
;(
vm
as
any
).
$page
=
page
vm
.
__isTabBar
=
page
.
meta
.
isTabBar
!
currentPagesMap
.
set
(
currentPagesMap
.
set
(
normalizeRouteKey
(
page
.
path
,
page
.
id
),
normalizeRouteKey
(
page
.
path
,
page
.
id
),
(
vm
as
unknown
)
as
Page
.
PageInstance
(
vm
as
unknown
)
as
Page
.
PageInstance
...
@@ -159,6 +161,19 @@ const routeCache: KeepAliveCache = {
...
@@ -159,6 +161,19 @@ const routeCache: KeepAliveCache = {
},
},
}
}
function
isTabBarVNode
(
vnode
:
VNode
):
boolean
{
if
(
!
hasOwn
(
vnode
,
'
__isTabBar
'
))
{
const
{
component
}
=
vnode
if
(
component
&&
component
.
refs
.
page
)
{
const
vm
=
component
.
refs
.
page
as
ComponentPublicInstance
if
(
vm
.
$page
)
{
;(
vnode
as
any
).
__isTabBar
=
vm
.
__isTabBar
}
}
}
return
(
vnode
as
any
).
__isTabBar
}
function
pruneRouteCache
(
key
:
string
)
{
function
pruneRouteCache
(
key
:
string
)
{
const
pageId
=
parseInt
(
key
.
split
(
SEP
)[
1
])
const
pageId
=
parseInt
(
key
.
split
(
SEP
)[
1
])
if
(
!
pageId
)
{
if
(
!
pageId
)
{
...
@@ -167,16 +182,9 @@ function pruneRouteCache(key: string) {
...
@@ -167,16 +182,9 @@ function pruneRouteCache(key: string) {
routeCache
.
forEach
((
vnode
,
key
)
=>
{
routeCache
.
forEach
((
vnode
,
key
)
=>
{
const
cPageId
=
parseInt
((
key
as
string
).
split
(
SEP
)[
1
])
const
cPageId
=
parseInt
((
key
as
string
).
split
(
SEP
)[
1
])
if
(
cPageId
&&
cPageId
>
pageId
)
{
if
(
cPageId
&&
cPageId
>
pageId
)
{
if
(
__UNI_FEATURE_TABBAR__
)
{
if
(
__UNI_FEATURE_TABBAR__
&&
isTabBarVNode
(
vnode
)
)
{
// tabBar keep alive
// tabBar keep alive
const
{
component
}
=
vnode
return
if
(
component
&&
component
.
refs
.
page
&&
(
component
.
refs
.
page
as
ComponentPublicInstance
).
$page
.
meta
.
isTabBar
)
{
return
}
}
}
routeCache
.
delete
(
key
)
routeCache
.
delete
(
key
)
routeCache
.
pruneCacheEntry
!
(
vnode
)
routeCache
.
pruneCacheEntry
!
(
vnode
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录