Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
73cf6ffd
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
73cf6ffd
编写于
3月 15, 2024
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(x): 修复 iOS 在 tab 页面执行 redirectTo 页面堆栈错误的问题
上级
ea9e5749
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
89 addition
and
73 deletion
+89
-73
packages/uni-app-plus/dist/uni.x.runtime.esm.js
packages/uni-app-plus/dist/uni.x.runtime.esm.js
+62
-51
packages/uni-app-plus/src/x/api/route/redirectTo.ts
packages/uni-app-plus/src/x/api/route/redirectTo.ts
+22
-11
packages/uni-app-plus/src/x/api/route/switchTab.ts
packages/uni-app-plus/src/x/api/route/switchTab.ts
+1
-2
packages/uni-app-plus/src/x/api/route/utils.ts
packages/uni-app-plus/src/x/api/route/utils.ts
+3
-1
packages/uni-app-plus/src/x/framework/app/tabBar.ts
packages/uni-app-plus/src/x/framework/app/tabBar.ts
+1
-8
未找到文件。
packages/uni-app-plus/dist/uni.x.runtime.esm.js
浏览文件 @
73cf6ffd
...
...
@@ -1936,49 +1936,6 @@ function back(delta, animationType, animationDuration) {
var
webview
=
getNativeApp
().
pageManager
.
findPageById
(
currentPage
.
$page
.
id
+
""
);
backPage
(
webview
);
}
var
redirectTo
=
/* @__PURE__ */
defineAsyncApi
(
API_REDIRECT_TO
,
(
_ref
,
_ref2
)
=>
{
var
{
url
}
=
_ref
;
var
{
resolve
,
reject
}
=
_ref2
;
var
{
path
,
query
}
=
parseUrl
(
url
);
_redirectTo
({
url
,
path
,
query
}).
then
(
resolve
).
catch
(
reject
);
},
RedirectToProtocol
,
RedirectToOptions
);
function
_redirectTo
(
_ref3
)
{
var
{
url
,
path
,
query
}
=
_ref3
;
var
lastPage
=
getCurrentPage
();
if
(
lastPage
)
{
removePage
(
lastPage
);
}
return
new
Promise
((
resolve
)
=>
{
showWebview
(
registerPage
({
url
,
path
,
query
,
openType
:
"
redirectTo
"
}),
"
none
"
,
0
,
()
=>
{
if
(
lastPage
)
{
closeWebview
(
lastPage
.
$nativePage
,
"
none
"
);
}
resolve
(
void
0
);
setStatusBarStyle
();
});
});
}
function
hasLeadingSlash
(
str
)
{
return
str
.
indexOf
(
"
/
"
)
==
0
;
}
...
...
@@ -2063,6 +2020,15 @@ function init() {
page
.
startRender
();
page
.
show
(
null
);
}
function
removeTabBarPage
(
page
)
{
var
pagePath
=
getRealPath
(
page
.
route
,
true
);
if
(
tabs
.
get
(
pagePath
)
===
page
)
{
tabs
.
delete
(
pagePath
);
if
(
getTabIndex
(
pagePath
)
===
selected0
)
{
selected0
=
-
1
;
}
}
}
function
getTabBar
()
{
return
tabBar0
;
}
...
...
@@ -2081,12 +2047,10 @@ function getTabIndex(path) {
}
return
selected
;
}
var
currentPageRoute
=
null
;
function
findPageRoute
(
path
)
{
return
__uniRoutes
.
find
((
route
)
=>
route
.
path
===
path
);
}
function
createTab
(
path
,
query
,
callback
)
{
currentPageRoute
=
findPageRoute
(
path
);
showWebview
(
registerPage
({
url
:
path
,
path
,
...
...
@@ -2094,7 +2058,6 @@ function createTab(path, query, callback) {
openType
:
"
switchTab
"
}),
"
none
"
,
0
,
callback
);
var
page
=
getCurrentPage
();
currentPageRoute
=
null
;
tabBar0
.
appendItem
(
page
.
$page
.
id
.
toString
());
return
page
;
}
...
...
@@ -2113,9 +2076,6 @@ function findTabPage(path) {
return
page
;
}
function
isTabPage
(
page
)
{
if
(
page
.
$route
===
currentPageRoute
)
{
return
true
;
}
var
has2
=
false
;
tabs
.
forEach
((
value
,
key
)
=>
{
if
(
value
===
page
)
{
...
...
@@ -2167,8 +2127,59 @@ function switchSelect(selected, path) {
selected0
=
selected
;
}
function
closePage
(
page
,
animationType
,
animationDuration
)
{
removePage
(
page
);
closeWebview
(
page
.
$nativePage
,
animationType
,
animationDuration
);
removePage
(
page
);
removeTabBarPage
(
page
);
}
var
redirectTo
=
/* @__PURE__ */
defineAsyncApi
(
API_REDIRECT_TO
,
(
_ref
,
_ref2
)
=>
{
var
{
url
}
=
_ref
;
var
{
resolve
,
reject
}
=
_ref2
;
var
{
path
,
query
}
=
parseUrl
(
url
);
_redirectTo
({
url
,
path
,
query
}).
then
(
resolve
).
catch
(
reject
);
},
RedirectToProtocol
,
RedirectToOptions
);
function
_redirectTo
(
_ref3
)
{
var
{
url
,
path
,
query
}
=
_ref3
;
var
lastPage
=
getCurrentPage
();
return
new
Promise
((
resolve
)
=>
{
showWebview
(
registerPage
({
url
,
path
,
query
,
openType
:
isTabPage
(
lastPage
)
||
getAllPages
().
length
===
1
?
"
reLaunch
"
:
"
redirectTo
"
}),
"
none
"
,
0
,
()
=>
{
if
(
lastPage
)
{
removePages
(
lastPage
);
}
resolve
(
void
0
);
setStatusBarStyle
();
});
});
}
function
removePages
(
currentPage
)
{
if
(
isTabPage
(
currentPage
))
{
var
pages2
=
getAllPages
().
slice
(
0
,
-
1
);
pages2
.
forEach
((
page
)
=>
{
closePage
(
page
,
"
none
"
);
});
}
else
{
closePage
(
currentPage
,
"
none
"
);
}
}
var
$switchTab
=
(
args
,
_ref
)
=>
{
var
{
...
...
@@ -2199,7 +2210,7 @@ function _switchTab(_ref2) {
if
(
selected
==
-
1
)
{
return
Promise
.
reject
(
"
tab
"
.
concat
(
path
,
"
not found
"
));
}
var
pages2
=
get
All
Pages
();
var
pages2
=
get
Current
Pages
();
switchSelect
(
selected
,
path
,
query
);
for
(
var
index2
=
pages2
.
length
-
1
;
index2
>=
0
;
index2
--
)
{
var
page
=
pages2
[
index2
];
...
...
packages/uni-app-plus/src/x/api/route/redirectTo.ts
浏览文件 @
73cf6ffd
...
...
@@ -7,12 +7,14 @@ import {
}
from
'
@dcloudio/uni-api
'
import
{
parseUrl
}
from
'
@dcloudio/uni-shared
'
import
{
getCurrentPage
}
from
'
@dcloudio/uni-core
'
import
{
removePage
}
from
'
../../../service/framework/page/getCurrentPages
'
import
{
getAllPages
}
from
'
../../../service/framework/page/getCurrentPages
'
import
{
registerPage
}
from
'
../../framework/page
'
import
{
RouteOptions
}
from
'
../../../service/api/route/utils
'
import
{
closeWebview
,
showWebview
}
from
'
./webview
'
import
{
showWebview
}
from
'
./webview
'
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
setStatusBarStyle
}
from
'
../../statusBar
'
import
{
isTabPage
}
from
'
../../framework/app/tabBar
'
import
{
closePage
}
from
'
./utils
'
export
const
redirectTo
=
defineAsyncApi
<
API_TYPE_REDIRECT_TO
>
(
API_REDIRECT_TO
,
...
...
@@ -37,10 +39,8 @@ function _redirectTo({
path
,
query
,
}:
RedirectToOptions
):
Promise
<
undefined
>
{
const
lastPage
=
getCurrentPage
()
if
(
lastPage
)
{
removePage
(
lastPage
)
}
const
lastPage
=
getCurrentPage
()
as
ComponentPublicInstance
// 与 uni-app x 安卓一致,后移除页面
return
new
Promise
((
resolve
)
=>
{
showWebview
(
...
...
@@ -48,16 +48,16 @@ function _redirectTo({
url
,
path
,
query
,
openType
:
'
redirectTo
'
,
openType
:
isTabPage
(
lastPage
)
||
getAllPages
().
length
===
1
?
'
reLaunch
'
:
'
redirectTo
'
,
}),
'
none
'
,
0
,
()
=>
{
if
(
lastPage
)
{
closeWebview
(
(
lastPage
as
ComponentPublicInstance
).
$nativePage
!
,
'
none
'
)
removePages
(
lastPage
)
}
resolve
(
undefined
)
setStatusBarStyle
()
...
...
@@ -65,3 +65,14 @@ function _redirectTo({
)
})
}
function
removePages
(
currentPage
:
ComponentPublicInstance
)
{
if
(
isTabPage
(
currentPage
))
{
const
pages
=
getAllPages
().
slice
(
0
,
-
1
)
pages
.
forEach
((
page
)
=>
{
closePage
(
page
,
'
none
'
)
})
}
else
{
closePage
(
currentPage
,
'
none
'
)
}
}
packages/uni-app-plus/src/x/api/route/switchTab.ts
浏览文件 @
73cf6ffd
...
...
@@ -14,7 +14,6 @@ import {
switchSelect
,
}
from
'
../../framework/app/tabBar
'
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
getAllPages
}
from
'
../../../service/framework/page/getCurrentPages
'
import
{
closePage
}
from
'
./utils
'
export
const
$switchTab
:
DefineAsyncApiFn
<
API_TYPE_SWITCH_TAB
>
=
(
...
...
@@ -46,7 +45,7 @@ function _switchTab({ url, path, query }: SwitchTabOptions) {
if
(
selected
==
-
1
)
{
return
Promise
.
reject
(
`tab
${
path
}
not found`
)
}
const
pages
=
get
All
Pages
()
const
pages
=
get
Current
Pages
()
switchSelect
(
selected
,
path
,
query
)
for
(
let
index
=
pages
.
length
-
1
;
index
>=
0
;
index
--
)
{
const
page
=
pages
[
index
]
as
ComponentPublicInstance
...
...
packages/uni-app-plus/src/x/api/route/utils.ts
浏览文件 @
73cf6ffd
import
{
ComponentPublicInstance
}
from
'
vue
'
import
{
removePage
}
from
'
../../../service/framework/page/getCurrentPages
'
import
{
closeWebview
}
from
'
./webview
'
import
{
removeTabBarPage
}
from
'
../../framework/app/tabBar
'
export
function
closePage
(
page
:
ComponentPublicInstance
,
animationType
:
string
,
animationDuration
?:
number
)
{
removePage
(
page
)
closeWebview
(
page
.
$nativePage
!
,
animationType
,
animationDuration
)
removePage
(
page
)
removeTabBarPage
(
page
)
}
packages/uni-app-plus/src/x/framework/app/tabBar.ts
浏览文件 @
73cf6ffd
...
...
@@ -127,7 +127,7 @@ export function clearTabBarStatus() {
}
export
function
removeTabBarPage
(
page
:
Page
)
{
const
pagePath
=
getRealPath
(
page
.
$route
?.
path
??
''
,
true
)
const
pagePath
=
getRealPath
(
page
.
route
,
true
)
if
(
tabs
.
get
(
pagePath
)
===
page
)
{
tabs
.
delete
(
pagePath
)
if
(
getTabIndex
(
pagePath
)
===
selected0
)
{
...
...
@@ -159,8 +159,6 @@ export function getTabIndex(path: string, list = getTabList()): number {
return
selected
}
let
currentPageRoute
:
unknown
=
null
function
findPageRoute
(
path
:
string
)
{
return
__uniRoutes
.
find
((
route
)
=>
route
.
path
===
path
)
!
}
...
...
@@ -170,7 +168,6 @@ function createTab(
query
:
Record
<
string
,
string
>
,
callback
?:
()
=>
void
):
Page
{
currentPageRoute
=
findPageRoute
(
path
)
showWebview
(
registerPage
({
url
:
path
,
path
,
query
,
openType
:
'
switchTab
'
}),
'
none
'
,
...
...
@@ -178,7 +175,6 @@ function createTab(
callback
)
const
page
=
getCurrentPage
()
as
Page
currentPageRoute
=
null
tabBar0
!
.
appendItem
(
page
!
.
$page
.
id
.
toString
())
return
page
}
...
...
@@ -209,9 +205,6 @@ function findTabPage(path: string): Page | null {
}
export
function
isTabPage
(
page
:
Page
):
boolean
{
if
(
page
.
$route
===
currentPageRoute
)
{
return
true
}
let
has
=
false
tabs
.
forEach
((
value
:
Page
,
key
:
string
)
=>
{
if
(
value
===
page
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录