Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
陈庄旺
uni-app
提交
1a9966d1
U
uni-app
项目概览
陈庄旺
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
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,发现更多精彩内容 >>
提交
1a9966d1
编写于
6月 11, 2019
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(h5): navigateBack delta>1
上级
a0f5d782
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
29 addition
and
5 deletion
+29
-5
src/core/service/api/route.js
src/core/service/api/route.js
+3
-0
src/core/service/plugins/app/router-guard.js
src/core/service/plugins/app/router-guard.js
+26
-5
未找到文件。
src/core/service/api/route.js
浏览文件 @
1a9966d1
...
...
@@ -34,6 +34,9 @@ function onAppRoute (type, {
}
}
if
(
canBack
)
{
if
(
delta
>
1
)
{
router
.
_$delta
=
delta
}
router
.
go
(
-
delta
)
}
break
...
...
src/core/service/plugins/app/router-guard.js
浏览文件 @
1a9966d1
...
...
@@ -8,11 +8,19 @@ function addKeepAliveInclude (componentName) {
}
}
function
removeKeepAliveInclude
(
componentName
)
{
const
index
=
this
.
keepAliveInclude
.
indexOf
(
componentName
)
let
deltaIds
=
[]
function
removeKeepAliveInclude
(
componentNameOrDelta
)
{
if
(
typeof
componentNameOrDelta
===
'
number
'
)
{
deltaIds
=
this
.
keepAliveInclude
.
splice
(
-
(
componentNameOrDelta
-
1
)).
map
(
name
=>
{
return
parseInt
(
name
.
split
(
'
-
'
).
pop
())
})
}
else
{
const
index
=
this
.
keepAliveInclude
.
indexOf
(
componentNameOrDelta
)
if
(
index
!==
-
1
)
{
this
.
keepAliveInclude
.
splice
(
index
,
1
)
}
}
}
let
positionStore
=
Object
.
create
(
null
)
...
...
@@ -117,6 +125,9 @@ function beforeEach (to, from, next, routes) {
// 后退或非 API 访问
if
(
fromId
&&
fromId
>
toId
)
{
// back
removeKeepAliveInclude
.
call
(
this
,
fromName
)
if
(
this
.
$router
.
_$delta
>
1
)
{
removeKeepAliveInclude
.
call
(
this
,
this
.
$router
.
_$delta
)
}
}
break
}
...
...
@@ -164,9 +175,19 @@ function afterEach (to, from) {
default
:
if
(
fromId
&&
fromId
>
toId
)
{
// history back
fromVm
&&
callPageHook
(
fromVm
,
'
onUnload
'
)
if
(
this
.
$router
.
_$delta
>
1
)
{
deltaIds
.
reverse
().
forEach
(
deltaId
=>
{
const
pageVm
=
currentPages
.
find
(
pageVm
=>
pageVm
.
$page
.
id
===
deltaId
)
pageVm
&&
callPageHook
(
pageVm
,
'
onUnload
'
)
})
}
}
break
}
delete
this
.
$router
.
_$delta
deltaIds
.
length
=
0
if
(
to
.
type
!==
'
reLaunch
'
)
{
// 因为 reLaunch 会重置 id,故不触发 onShow,switchTab 在 beforeRouteEnter 中触发
// 直接获取所有 pages,getCurrentPages 正常情况下仅返回页面栈内,传 true 则返回所有已存在(主要是 tabBar 页面)
const
toVm
=
getCurrentPages
(
true
).
find
(
pageVm
=>
pageVm
.
$page
.
id
===
toId
)
// 使用最新的 pages
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录