Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qianlong66
uni-app
提交
ebb9672c
U
uni-app
项目概览
qianlong66
/
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,发现更多精彩内容 >>
提交
ebb9672c
编写于
7月 15, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(app): add lifecycle
上级
c25a45fa
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
75 addition
and
7 deletion
+75
-7
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+13
-0
packages/uni-app-plus/src/service/api/route/navigateBack.ts
packages/uni-app-plus/src/service/api/route/navigateBack.ts
+2
-0
packages/uni-app-plus/src/service/api/route/navigateTo.ts
packages/uni-app-plus/src/service/api/route/navigateTo.ts
+3
-1
packages/uni-app-plus/src/service/framework/page/getCurrentPages.ts
...ni-app-plus/src/service/framework/page/getCurrentPages.ts
+5
-0
packages/uni-app-plus/src/service/framework/page/setup.ts
packages/uni-app-plus/src/service/framework/page/setup.ts
+16
-1
packages/uni-app-plus/src/service/framework/webview/init/event/index.ts
...pp-plus/src/service/framework/webview/init/event/index.ts
+5
-4
packages/uni-app-plus/src/service/framework/webview/init/event/popGesture.ts
...us/src/service/framework/webview/init/event/popGesture.ts
+30
-0
packages/uni-app-plus/src/service/statusBar.ts
packages/uni-app-plus/src/service/statusBar.ts
+1
-1
未找到文件。
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
ebb9672c
...
...
@@ -9355,6 +9355,15 @@ var serviceContext = (function (vue) {
pageVm.$page = __pageInstance;
pageVm.$vm = pageVm;
addCurrentPage(initScope(__pageId, pageVm));
invokeHook(pageVm, 'onLoad', __pageQuery);
invokeHook(pageVm, 'onShow');
vue.onMounted(() => {
invokeHook(pageVm, 'onReady');
// TODO preloadSubPackages
});
vue.onBeforeUnmount(() => {
invokeHook(pageVm, 'onUnload');
});
if (oldSetup) {
return oldSetup(__pageQuery, ctx);
}
...
...
@@ -9500,6 +9509,8 @@ var serviceContext = (function (vue) {
}, NavigateToProtocol, NavigateToOptions);
function _navigateTo({ url, path, query, aniType, aniDuration, }) {
// TODO eventChannel
// 当前页面触发 onHide
invokeHook('onHide');
return new Promise((resolve) => {
showWebview(registerPage({ url, path, query, openType: 'navigateTo' }), aniType, aniDuration, () => {
resolve(undefined);
...
...
@@ -9623,6 +9634,8 @@ var serviceContext = (function (vue) {
.slice(len - delta, len)
.forEach((page) => removePage(page));
setStatusBarStyle();
// 前一个页面触发 onShow
invokeHook('onShow');
};
const webview = plus.webview.getWebviewById(currentPage.$page.id + '');
if (!currentPage.__uniapp_webview) {
...
...
packages/uni-app-plus/src/service/api/route/navigateBack.ts
浏览文件 @
ebb9672c
...
...
@@ -104,6 +104,8 @@ function back(
.
slice
(
len
-
delta
,
len
)
.
forEach
((
page
)
=>
removePage
(
page
as
ComponentPublicInstance
))
setStatusBarStyle
()
// 前一个页面触发 onShow
invokeHook
(
'
onShow
'
)
}
const
webview
=
plus
.
webview
.
getWebviewById
(
currentPage
.
$page
.
id
+
''
)
...
...
packages/uni-app-plus/src/service/api/route/navigateTo.ts
浏览文件 @
ebb9672c
import
{
parseUrl
}
from
'
@dcloudio/uni-shared
'
import
{
getRouteMeta
}
from
'
@dcloudio/uni-core
'
import
{
getRouteMeta
,
invokeHook
}
from
'
@dcloudio/uni-core
'
import
{
API_NAVIGATE_TO
,
API_TYPE_NAVIGATE_TO
,
...
...
@@ -59,6 +59,8 @@ function _navigateTo({
aniDuration
,
}:
NavigateToOptions
):
Promise
<
undefined
>
{
// TODO eventChannel
// 当前页面触发 onHide
invokeHook
(
'
onHide
'
)
return
new
Promise
((
resolve
)
=>
{
showWebview
(
registerPage
({
url
,
path
,
query
,
openType
:
'
navigateTo
'
}),
...
...
packages/uni-app-plus/src/service/framework/page/getCurrentPages.ts
浏览文件 @
ebb9672c
import
{
getCurrentPage
}
from
'
@dcloudio/uni-core
'
import
{
formatLog
}
from
'
@dcloudio/uni-shared
'
import
{
ComponentPublicInstance
}
from
'
vue
'
...
...
@@ -21,6 +22,10 @@ export function getCurrentPages() {
return
curPages
}
export
function
removeCurrentPage
()
{
removePage
(
getCurrentPage
()
as
ComponentPublicInstance
)
}
export
function
removePage
(
curPage
:
ComponentPublicInstance
)
{
const
index
=
pages
.
findIndex
((
page
)
=>
page
===
curPage
)
if
(
index
===
-
1
)
{
...
...
packages/uni-app-plus/src/service/framework/page/setup.ts
浏览文件 @
ebb9672c
import
{
invokeHook
}
from
'
@dcloudio/uni-core
'
import
{
formatLog
}
from
'
@dcloudio/uni-shared
'
import
{
ComponentPublicInstance
,
getCurrentInstance
}
from
'
vue
'
import
{
ComponentPublicInstance
,
getCurrentInstance
,
onBeforeUnmount
,
onMounted
,
}
from
'
vue
'
import
{
VuePageComponent
}
from
'
./define
'
import
{
addCurrentPage
}
from
'
./getCurrentPages
'
...
...
@@ -18,6 +24,15 @@ export function setupPage(component: VuePageComponent) {
pageVm
.
$page
=
__pageInstance
as
Page
.
PageInstance
[
'
$page
'
]
pageVm
.
$vm
=
pageVm
addCurrentPage
(
initScope
(
__pageId
as
number
,
pageVm
))
invokeHook
(
pageVm
,
'
onLoad
'
,
__pageQuery
)
invokeHook
(
pageVm
,
'
onShow
'
)
onMounted
(()
=>
{
invokeHook
(
pageVm
,
'
onReady
'
)
// TODO preloadSubPackages
})
onBeforeUnmount
(()
=>
{
invokeHook
(
pageVm
,
'
onUnload
'
)
})
if
(
oldSetup
)
{
return
oldSetup
(
__pageQuery
as
any
,
ctx
)
}
...
...
packages/uni-app-plus/src/service/framework/webview/init/event/index.ts
浏览文件 @
ebb9672c
import
{
onWebviewClose
}
from
'
./close
'
import
{
onWebviewPopGesture
}
from
'
./popGesture
'
import
{
onWebviewResize
}
from
'
./resize
'
const
WEBVIEW_LISTENERS
=
{
...
...
@@ -21,8 +22,8 @@ export function initWebviewEvent(webview: PlusWebviewWebviewObject) {
onWebviewResize
(
webview
)
// TODO
//
if (plus.os.name === 'iOS') {
//
!(webview as any).nvue && onWebviewRecovery(webview, routeOptions)
//
onWebviewPopGesture(webview)
//
}
if
(
plus
.
os
.
name
===
'
iOS
'
)
{
//
!(webview as any).nvue && onWebviewRecovery(webview, routeOptions)
onWebviewPopGesture
(
webview
)
}
}
packages/uni-app-plus/src/service/framework/webview/init/event/popGesture.ts
0 → 100644
浏览文件 @
ebb9672c
import
{
invokeHook
}
from
'
@dcloudio/uni-core
'
import
{
lastStatusBarStyle
,
setStatusBarStyle
,
StatusBarStyle
,
}
from
'
../../../../statusBar
'
import
{
removeCurrentPage
}
from
'
../../../page/getCurrentPages
'
export
function
onWebviewPopGesture
(
webview
:
PlusWebviewWebviewObject
)
{
let
popStartStatusBarStyle
:
StatusBarStyle
webview
.
addEventListener
(
'
popGesture
'
,
(
e
)
=>
{
if
(
e
.
type
===
'
start
'
)
{
// 设置下一个页面的 statusBarStyle
const
pages
=
getCurrentPages
()
const
page
=
pages
[
pages
.
length
-
2
]
popStartStatusBarStyle
=
lastStatusBarStyle
const
statusBarStyle
=
page
&&
(
page
.
$page
.
statusBarStyle
as
StatusBarStyle
)
statusBarStyle
&&
setStatusBarStyle
(
statusBarStyle
)
}
else
if
(
e
.
type
===
'
end
'
&&
!
e
.
result
)
{
// 拖拽未完成,设置为当前状态栏前景色
setStatusBarStyle
(
popStartStatusBarStyle
)
}
else
if
(
e
.
type
===
'
end
'
&&
e
.
result
)
{
removeCurrentPage
()
setStatusBarStyle
()
// 触发前一个页面 onShow
invokeHook
(
'
onShow
'
)
}
})
}
packages/uni-app-plus/src/service/statusBar.ts
浏览文件 @
ebb9672c
import
{
formatLog
}
from
'
@dcloudio/uni-shared
'
type
SetStatusBarStyle
=
typeof
plus
.
navigator
.
setStatusBarStyle
type
StatusBarStyle
=
Parameters
<
SetStatusBarStyle
>
[
0
]
export
type
StatusBarStyle
=
Parameters
<
SetStatusBarStyle
>
[
0
]
export
let
lastStatusBarStyle
:
StatusBarStyle
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录