Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
0200ea64
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
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,发现更多精彩内容 >>
提交
0200ea64
编写于
11月 24, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: reLaunch
上级
6c898e6b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
74 addition
and
68 deletion
+74
-68
packages/uni-app-plus/src/service/api/route/_reLaunch.ts
packages/uni-app-plus/src/service/api/route/_reLaunch.ts
+57
-0
packages/uni-app-plus/src/service/api/route/reLaunch.ts
packages/uni-app-plus/src/service/api/route/reLaunch.ts
+1
-53
packages/uni-app-plus/src/service/framework/app/initGlobalEvent.ts
...uni-app-plus/src/service/framework/app/initGlobalEvent.ts
+14
-1
packages/uni-app-plus/src/service/framework/app/utils.ts
packages/uni-app-plus/src/service/framework/app/utils.ts
+2
-14
未找到文件。
packages/uni-app-plus/src/service/api/route/_reLaunch.ts
0 → 100644
浏览文件 @
0200ea64
import
{
API_TYPE_RE_LAUNCH
,
DefineAsyncApiFn
,
ReLaunchOptions
,
}
from
'
@dcloudio/uni-api
'
import
{
parseUrl
}
from
'
@dcloudio/uni-shared
'
import
tabBar
from
'
../../framework/app/tabBar
'
import
{
registerPage
}
from
'
../../framework/page/register
'
import
{
getAllPages
}
from
'
../../framework/page/getCurrentPages
'
import
{
setStatusBarStyle
}
from
'
../../statusBar
'
import
{
closePage
,
navigate
,
RouteOptions
}
from
'
./utils
'
import
{
showWebview
}
from
'
./webview
'
interface
ReLaunchOptions
extends
RouteOptions
{}
export
const
$reLaunch
:
DefineAsyncApiFn
<
API_TYPE_RE_LAUNCH
>
=
(
{
url
},
{
resolve
,
reject
}
)
=>
{
const
{
path
,
query
}
=
parseUrl
(
url
)
navigate
(
path
,
()
=>
{
_reLaunch
({
url
,
path
,
query
,
})
.
then
(
resolve
)
.
catch
(
reject
)
})
}
function
_reLaunch
({
url
,
path
,
query
}:
ReLaunchOptions
):
Promise
<
undefined
>
{
return
new
Promise
((
resolve
)
=>
{
// 获取目前所有页面
const
pages
=
getAllPages
().
slice
(
0
)
const
routeOptions
=
__uniRoutes
.
find
((
route
)
=>
route
.
path
===
path
)
!
if
(
routeOptions
.
meta
.
isTabBar
)
{
tabBar
.
switchTab
(
path
.
slice
(
1
))
}
showWebview
(
registerPage
({
url
,
path
,
query
,
openType
:
'
reLaunch
'
,
}),
'
none
'
,
0
,
()
=>
{
pages
.
forEach
((
page
)
=>
closePage
(
page
,
'
none
'
))
resolve
(
undefined
)
}
)
setStatusBarStyle
()
})
}
packages/uni-app-plus/src/service/api/route/reLaunch.ts
浏览文件 @
0200ea64
...
...
@@ -2,33 +2,10 @@ import {
API_RE_LAUNCH
,
API_TYPE_RE_LAUNCH
,
defineAsyncApi
,
DefineAsyncApiFn
,
ReLaunchOptions
,
ReLaunchProtocol
,
}
from
'
@dcloudio/uni-api
'
import
{
parseUrl
}
from
'
@dcloudio/uni-shared
'
import
tabBar
from
'
../../framework/app/tabBar
'
import
{
registerPage
}
from
'
../../framework/page
'
import
{
getAllPages
}
from
'
../../framework/page/getCurrentPages
'
import
{
setStatusBarStyle
}
from
'
../../statusBar
'
import
{
closePage
,
navigate
,
RouteOptions
}
from
'
./utils
'
import
{
showWebview
}
from
'
./webview
'
export
const
$reLaunch
:
DefineAsyncApiFn
<
API_TYPE_RE_LAUNCH
>
=
(
{
url
},
{
resolve
,
reject
}
)
=>
{
const
{
path
,
query
}
=
parseUrl
(
url
)
navigate
(
path
,
()
=>
{
_reLaunch
({
url
,
path
,
query
,
})
.
then
(
resolve
)
.
catch
(
reject
)
})
}
import
{
$reLaunch
}
from
'
./_reLaunch
'
export
const
reLaunch
=
defineAsyncApi
<
API_TYPE_RE_LAUNCH
>
(
API_RE_LAUNCH
,
...
...
@@ -36,32 +13,3 @@ export const reLaunch = defineAsyncApi<API_TYPE_RE_LAUNCH>(
ReLaunchProtocol
,
ReLaunchOptions
)
interface
ReLaunchOptions
extends
RouteOptions
{}
function
_reLaunch
({
url
,
path
,
query
}:
ReLaunchOptions
):
Promise
<
undefined
>
{
return
new
Promise
((
resolve
)
=>
{
// 获取目前所有页面
const
pages
=
getAllPages
().
slice
(
0
)
const
routeOptions
=
__uniRoutes
.
find
((
route
)
=>
route
.
path
===
path
)
!
if
(
routeOptions
.
meta
.
isTabBar
)
{
tabBar
.
switchTab
(
path
.
slice
(
1
))
}
showWebview
(
registerPage
({
url
,
path
,
query
,
openType
:
'
reLaunch
'
,
}),
'
none
'
,
0
,
()
=>
{
pages
.
forEach
((
page
)
=>
closePage
(
page
,
'
none
'
))
resolve
(
undefined
)
}
)
setStatusBarStyle
()
})
}
packages/uni-app-plus/src/service/framework/app/initGlobalEvent.ts
浏览文件 @
0200ea64
...
...
@@ -4,14 +4,16 @@ import {
ON_APP_ENTER_FOREGROUND
,
ON_THEME_CHANGE
,
ON_KEYBOARD_HEIGHT_CHANGE
,
addLeadingSlash
,
}
from
'
@dcloudio/uni-shared
'
import
{
$reLaunch
}
from
'
../../api/route/_reLaunch
'
import
{
EVENT_BACKBUTTON
,
backbuttonListener
,
parseRedirectInfo
,
initEnterOptions
,
getEnterOptions
,
initEnterReLaunch
,
RedirectInfo
,
}
from
'
./utils
'
export
function
initGlobalEvent
()
{
...
...
@@ -89,3 +91,14 @@ export function onPlusMessage<T>(
)
{
UniServiceJSBridge
.
subscribe
(
'
plusMessage.
'
+
type
,
callback
,
once
)
}
function
initEnterReLaunch
(
info
:
RedirectInfo
)
{
__uniConfig
.
realEntryPagePath
=
__uniConfig
.
realEntryPagePath
||
__uniConfig
.
entryPagePath
__uniConfig
.
entryPagePath
=
info
.
path
__uniConfig
.
entryPageQuery
=
info
.
query
$reLaunch
(
{
url
:
addLeadingSlash
(
info
.
path
)
+
info
.
query
},
{
resolve
()
{},
reject
()
{}
}
)
}
packages/uni-app-plus/src/service/framework/app/utils.ts
浏览文件 @
0200ea64
import
{
extend
}
from
'
@vue/shared
'
import
{
addLeadingSlash
,
parseQuery
}
from
'
@dcloudio/uni-shared
'
import
{
parseQuery
}
from
'
@dcloudio/uni-shared
'
import
{
createLaunchOptions
,
LaunchOptions
}
from
'
@dcloudio/uni-core
'
import
{
$reLaunch
}
from
'
../../api/route/reLaunch
'
export
const
EVENT_BACKBUTTON
=
'
backbutton
'
...
...
@@ -35,17 +34,6 @@ export function initEnterOptions({
})
}
export
function
initEnterReLaunch
(
info
:
RedirectInfo
)
{
__uniConfig
.
realEntryPagePath
=
__uniConfig
.
realEntryPagePath
||
__uniConfig
.
entryPagePath
__uniConfig
.
entryPagePath
=
info
.
path
__uniConfig
.
entryPageQuery
=
info
.
query
$reLaunch
(
{
url
:
addLeadingSlash
(
info
.
path
)
+
info
.
query
},
{
resolve
()
{},
reject
()
{}
}
)
}
export
function
initLaunchOptions
({
path
,
query
,
...
...
@@ -60,7 +48,7 @@ export function initLaunchOptions({
return
launchOptions
}
interface
RedirectInfo
extends
Omit
<
LaunchOptions
,
'
query
'
|
'
scene
'
>
{
export
interface
RedirectInfo
extends
Omit
<
LaunchOptions
,
'
query
'
|
'
scene
'
>
{
query
:
string
userAction
:
boolean
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录