Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
50291234
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,发现更多精彩内容 >>
提交
50291234
编写于
7月 16, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app): add reLaunch
上级
4d414c76
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
127 addition
and
12 deletion
+127
-12
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+45
-1
packages/uni-app-plus/src/service/api/index.ts
packages/uni-app-plus/src/service/api/index.ts
+1
-0
packages/uni-app-plus/src/service/api/route/navigateTo.ts
packages/uni-app-plus/src/service/api/route/navigateTo.ts
+2
-5
packages/uni-app-plus/src/service/api/route/reLaunch.ts
packages/uni-app-plus/src/service/api/route/reLaunch.ts
+68
-0
packages/uni-app-plus/src/service/api/route/redirectTo.ts
packages/uni-app-plus/src/service/api/route/redirectTo.ts
+2
-6
packages/uni-app-plus/src/service/api/route/utils.ts
packages/uni-app-plus/src/service/api/route/utils.ts
+5
-0
packages/uni-app-plus/src/service/framework/page/getCurrentPages.ts
...ni-app-plus/src/service/framework/page/getCurrentPages.ts
+4
-0
未找到文件。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
50291234
...
...
@@ -4405,6 +4405,7 @@ var serviceContext = (function (vue) {
};
const API_NAVIGATE_TO = 'navigateTo';
const API_REDIRECT_TO = 'redirectTo';
const API_RE_LAUNCH = 'reLaunch';
const API_SWITCH_TAB = 'switchTab';
const API_NAVIGATE_BACK = 'navigateBack';
const API_PRELOAD_PAGE = 'preloadPage';
...
...
@@ -4418,10 +4419,13 @@ var serviceContext = (function (vue) {
},
}, createAnimationProtocol(ANIMATION_OUT));
const RedirectToProtocol = BaseRouteProtocol;
const ReLaunchProtocol = BaseRouteProtocol;
const NavigateToOptions =
/*#__PURE__*/ createRouteOptions(API_NAVIGATE_TO);
const RedirectToOptions =
/*#__PURE__*/ createRouteOptions(API_REDIRECT_TO);
const ReLaunchOptions =
/*#__PURE__*/ createRouteOptions(API_RE_LAUNCH);
const NavigateBackOptions = {
formatArgs: {
delta(value, params) {
...
...
@@ -8993,6 +8997,9 @@ var serviceContext = (function (vue) {
function addCurrentPage(page) {
pages.push(page);
}
function getAllPages() {
return pages;
}
function getCurrentPages$1() {
const curPages = [];
pages.forEach((page) => {
...
...
@@ -9724,6 +9731,42 @@ var serviceContext = (function (vue) {
});
}
const reLaunch = defineAsyncApi(API_RE_LAUNCH, ({ url }, { resolve, reject }) => {
const { path, query } = parseUrl(url);
navigate(path, () => {
_reLaunch({
url,
path,
query,
})
.then(resolve)
.catch(reject);
});
}, ReLaunchProtocol, ReLaunchOptions);
function _reLaunch({ url, path, query }) {
return new Promise((resolve) => {
// 获取目前所有页面
const pages = getAllPages().slice(0);
const routeOptions = __uniRoutes.find((route) => route.path === path);
if (routeOptions.meta.isTabBar) {
tabBar$1.switchTab(path.slice(1));
}
showWebview(registerPage({
url,
path,
query,
openType: 'reLaunch',
}), 'none', 0, () => {
pages.forEach((page) => {
removePage(page);
closeWebview(page.$getAppWebview(), 'none');
});
resolve(undefined);
});
setStatusBarStyle();
});
}
var uni$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
upx2px: upx2px,
...
...
@@ -9853,7 +9896,8 @@ var serviceContext = (function (vue) {
createInteractiveAd: createInteractiveAd,
navigateBack: navigateBack,
navigateTo: navigateTo,
redirectTo: redirectTo
redirectTo: redirectTo,
reLaunch: reLaunch
});
let invokeViewMethodId = 0;
...
...
packages/uni-app-plus/src/service/api/index.ts
浏览文件 @
50291234
...
...
@@ -55,6 +55,7 @@ export * from './ad/interactiveAd'
export
*
from
'
./route/navigateBack
'
export
*
from
'
./route/navigateTo
'
export
*
from
'
./route/redirectTo
'
export
*
from
'
./route/reLaunch
'
export
{
upx2px
,
...
...
packages/uni-app-plus/src/service/api/route/navigateTo.ts
浏览文件 @
50291234
...
...
@@ -9,7 +9,7 @@ import {
}
from
'
@dcloudio/uni-api
'
import
{
ANI_DURATION
,
ANI_SHOW
}
from
'
../../constants
'
import
{
navigate
}
from
'
./utils
'
import
{
navigate
,
RouteOptions
}
from
'
./utils
'
import
{
showWebview
}
from
'
./webview
'
import
{
registerPage
}
from
'
../../framework/page
'
...
...
@@ -43,10 +43,7 @@ export const navigateTo = defineAsyncApi<API_TYPE_NAVIGATE_TO>(
NavigateToOptions
)
interface
NavigateToOptions
{
url
:
string
path
:
string
query
:
Record
<
string
,
any
>
interface
NavigateToOptions
extends
RouteOptions
{
aniType
:
string
aniDuration
:
number
}
...
...
packages/uni-app-plus/src/service/api/route/reLaunch.ts
0 → 100644
浏览文件 @
50291234
import
{
API_RE_LAUNCH
,
API_TYPE_RE_LAUNCH
,
defineAsyncApi
,
ReLaunchOptions
,
ReLaunchProtocol
,
}
from
'
@dcloudio/uni-api
'
import
{
parseUrl
}
from
'
@dcloudio/uni-shared
'
import
{
ComponentPublicInstance
}
from
'
vue
'
import
tabBar
from
'
../../framework/app/tabBar
'
import
{
registerPage
}
from
'
../../framework/page
'
import
{
getAllPages
,
removePage
}
from
'
../../framework/page/getCurrentPages
'
import
{
setStatusBarStyle
}
from
'
../../statusBar
'
import
{
navigate
,
RouteOptions
}
from
'
./utils
'
import
{
closeWebview
,
showWebview
}
from
'
./webview
'
export
const
reLaunch
=
defineAsyncApi
<
API_TYPE_RE_LAUNCH
>
(
API_RE_LAUNCH
,
({
url
},
{
resolve
,
reject
})
=>
{
const
{
path
,
query
}
=
parseUrl
(
url
)
navigate
(
path
,
()
=>
{
_reLaunch
({
url
,
path
,
query
,
})
.
then
(
resolve
)
.
catch
(
reject
)
})
},
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
)
=>
{
removePage
(
page
)
closeWebview
(
(
page
as
ComponentPublicInstance
).
$getAppWebview
!
(),
'
none
'
)
})
resolve
(
undefined
)
}
)
setStatusBarStyle
()
})
}
packages/uni-app-plus/src/service/api/route/redirectTo.ts
浏览文件 @
50291234
...
...
@@ -9,7 +9,7 @@ import { parseUrl } from '@dcloudio/uni-shared'
import
{
getCurrentPage
}
from
'
@dcloudio/uni-core
'
import
{
removePage
}
from
'
../../framework/page/getCurrentPages
'
import
{
registerPage
}
from
'
../../framework/page
'
import
{
navigate
}
from
'
./utils
'
import
{
navigate
,
RouteOptions
}
from
'
./utils
'
import
{
showWebview
}
from
'
./webview
'
import
{
setStatusBarStyle
}
from
'
../../statusBar
'
import
{
ComponentPublicInstance
}
from
'
vue
'
...
...
@@ -32,11 +32,7 @@ export const redirectTo = defineAsyncApi<API_TYPE_REDIRECT_TO>(
RedirectToOptions
)
interface
RedirectToOptions
{
url
:
string
path
:
string
query
:
Record
<
string
,
any
>
}
interface
RedirectToOptions
extends
RouteOptions
{}
function
_redirectTo
({
url
,
...
...
packages/uni-app-plus/src/service/api/route/utils.ts
浏览文件 @
50291234
...
...
@@ -6,6 +6,11 @@ import {
preloadWebview
,
}
from
'
../../framework/webview
'
export
interface
RouteOptions
{
url
:
string
path
:
string
query
:
Record
<
string
,
any
>
}
interface
PendingNavigator
{
path
:
string
nvue
?:
boolean
...
...
packages/uni-app-plus/src/service/framework/page/getCurrentPages.ts
浏览文件 @
50291234
...
...
@@ -8,6 +8,10 @@ export function addCurrentPage(page: ComponentPublicInstance) {
pages
.
push
(
page
)
}
export
function
getAllPages
()
{
return
pages
}
export
function
getCurrentPages
()
{
const
curPages
:
ComponentPublicInstance
[]
=
[]
pages
.
forEach
((
page
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录