Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
2a8712c6
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2a8712c6
编写于
4月 13, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp-weixin): add onSaveExitState (#3427)
上级
5c11434f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
1 deletion
+25
-1
packages/uni-app/src/apiLifecycle.ts
packages/uni-app/src/apiLifecycle.ts
+17
-1
packages/uni-shared/src/constants.ts
packages/uni-shared/src/constants.ts
+2
-0
packages/uni-shared/src/lifecycle.ts
packages/uni-shared/src/lifecycle.ts
+6
-0
未找到文件。
packages/uni-app/src/apiLifecycle.ts
浏览文件 @
2a8712c6
...
...
@@ -7,6 +7,7 @@ import {
ON_BACK_PRESS
,
ON_ERROR
,
ON_HIDE
,
ON_INIT
,
ON_LAUNCH
,
ON_LOAD
,
ON_NAVIGATION_BAR_BUTTON_TAP
,
...
...
@@ -20,6 +21,7 @@ import {
ON_REACH_BOTTOM
,
ON_READY
,
ON_RESIZE
,
ON_SAVE_EXIT_STATE
,
ON_SHARE_APP_MESSAGE
,
ON_SHARE_TIMELINE
,
ON_SHOW
,
...
...
@@ -50,6 +52,7 @@ type onPageShowHook = () => void
type
onLaunchHook
=
(
options
:
LaunchOption
)
=>
void
type
onLoadHook
=
(
query
:
Record
<
string
,
string
|
undefined
>
)
=>
void
type
onInitHook
=
onLoadHook
type
onErrorHook
=
(
error
:
string
)
=>
void
interface
ThemeChangeOption
{
theme
:
'
dark
'
|
'
light
'
...
...
@@ -130,6 +133,12 @@ type onShareAppMessageHook = (
options
:
ShareAppMessageOption
)
=>
CustomShareAppMessage
|
void
interface
SaveExitState
{
data
:
any
expireTimeStamp
:
number
}
type
onSaveExitStateHook
=
()
=>
SaveExitState
interface
NavigationBarButtonTapOption
{
index
:
number
}
...
...
@@ -162,7 +171,10 @@ const createHook =
<
T
extends
Function
=
()
=>
any
>
(
lifecycle
:
typeof
UniLifecycleHooks
[
number
]
)
=>
(
hook
:
T
,
target
:
ComponentInternalInstance
|
null
=
getCurrentInstance
())
=>
(
hook
:
T
,
target
:
ComponentInternalInstance
|
null
=
getCurrentInstance
()
):
void
=>
// post-create lifecycle registrations are noops during SSR
!
isInSSRComponentSetup
&&
injectHook
(
lifecycle
as
any
,
hook
,
target
)
...
...
@@ -179,6 +191,7 @@ export const onPageNotFound =
/*#__PURE__*/
createHook
<
onPageNotFoundHook
>
(
ON_PAGE_NOT_FOUND
)
export
const
onUnhandledRejection
=
/*#__PURE__*/
createHook
<
onUnhandledRejectionHook
>
(
ON_UNHANDLE_REJECTION
)
export
const
onInit
=
/*#__PURE__*/
createHook
<
onInitHook
>
(
ON_INIT
)
// 小程序如果想在 setup 的 props 传递页面参数,需要定义 props,故同时暴露 onLoad 吧
export
const
onLoad
=
/*#__PURE__*/
createHook
<
onLoadHook
>
(
ON_LOAD
)
export
const
onReady
=
/*#__PURE__*/
createHook
(
ON_READY
)
...
...
@@ -194,6 +207,9 @@ export const onTabItemTap =
export
const
onReachBottom
=
/*#__PURE__*/
createHook
(
ON_REACH_BOTTOM
)
export
const
onPullDownRefresh
=
/*#__PURE__*/
createHook
(
ON_PULL_DOWN_REFRESH
)
export
const
onSaveExitState
=
/*#__PURE__*/
createHook
<
onSaveExitStateHook
>
(
ON_SAVE_EXIT_STATE
)
export
const
onShareTimeline
=
/*#__PURE__*/
createHook
<
onShareTimelineHook
>
(
ON_SHARE_TIMELINE
)
export
const
onAddToFavorites
=
...
...
packages/uni-shared/src/constants.ts
浏览文件 @
2a8712c6
...
...
@@ -52,6 +52,8 @@ export const ON_READY = 'onReady'
export
const
ON_UNLOAD
=
'
onUnload
'
// 百度特有
export
const
ON_INIT
=
'
onInit
'
// 微信特有
export
const
ON_SAVE_EXIT_STATE
=
'
onSaveExitState
'
export
const
ON_RESIZE
=
'
onResize
'
export
const
ON_BACK_PRESS
=
'
onBackPress
'
...
...
packages/uni-shared/src/lifecycle.ts
浏览文件 @
2a8712c6
...
...
@@ -3,6 +3,7 @@ import {
ON_BACK_PRESS
,
ON_ERROR
,
ON_HIDE
,
ON_INIT
,
ON_LAUNCH
,
ON_LOAD
,
ON_NAVIGATION_BAR_BUTTON_TAP
,
...
...
@@ -16,6 +17,7 @@ import {
ON_REACH_BOTTOM
,
ON_READY
,
ON_RESIZE
,
ON_SAVE_EXIT_STATE
,
ON_SHARE_APP_MESSAGE
,
ON_SHARE_TIMELINE
,
ON_SHOW
,
...
...
@@ -26,6 +28,7 @@ import {
}
from
'
./constants
'
const
PAGE_HOOKS
=
[
ON_INIT
,
ON_LOAD
,
ON_SHOW
,
ON_HIDE
,
...
...
@@ -38,6 +41,7 @@ const PAGE_HOOKS = [
ON_SHARE_TIMELINE
,
ON_SHARE_APP_MESSAGE
,
ON_ADD_TO_FAVORITES
,
ON_SAVE_EXIT_STATE
,
ON_NAVIGATION_BAR_BUTTON_TAP
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED
,
...
...
@@ -63,6 +67,7 @@ export const UniLifecycleHooks = [
ON_THEME_CHANGE
,
ON_PAGE_NOT_FOUND
,
ON_UNHANDLE_REJECTION
,
ON_INIT
,
ON_LOAD
,
ON_READY
,
ON_UNLOAD
,
...
...
@@ -75,6 +80,7 @@ export const UniLifecycleHooks = [
ON_SHARE_TIMELINE
,
ON_ADD_TO_FAVORITES
,
ON_SHARE_APP_MESSAGE
,
ON_SAVE_EXIT_STATE
,
ON_NAVIGATION_BAR_BUTTON_TAP
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录