Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
558dff52
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6022
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
558dff52
编写于
7月 13, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: remove useless page & add annotation
上级
cb82131b
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
138 addition
and
221 deletion
+138
-221
App.vue
App.vue
+25
-14
pages/API/navigator/navigator.uvue
pages/API/navigator/navigator.uvue
+113
-111
pages/API/page-lifecycle/page-lifecycle.test.js
pages/API/page-lifecycle/page-lifecycle.test.js
+0
-55
pages/API/page-lifecycle/page-lifecycle.uvue
pages/API/page-lifecycle/page-lifecycle.uvue
+0
-41
未找到文件。
App.vue
浏览文件 @
558dff52
...
...
@@ -2,37 +2,48 @@
import
{
state
,
setLifeCycleNum
}
from
'
./store/index.uts
'
export
default
{
onLaunch
:
function
()
{
// 自动化测试
setLifeCycleNum
(
state
.
lifeCycleNum
+
1000
)
console
.
log
(
"
App Launch
"
);
console
.
log
(
'
App Launch
'
)
// const performance: Performance = uni.getPerformance()
// const observer1: PerformanceObserver = performance.createObserver((entryList: PerformanceObserverEntryList) => {
// console.log("observer1:entryList.getEntries()" + JSON.stringify(entryList.getEntries()))
// })
// observer1.observe({ entryTypes: ['render', 'navigation'] } as PerformanceObserverOptions)
const
performance
:
Performance
=
uni
.
getPerformance
()
const
observer1
:
PerformanceObserver
=
performance
.
createObserver
(
(
entryList
:
PerformanceObserverEntryList
)
=>
{
console
.
log
(
'
observer1:entryList.getEntries()
'
+
JSON
.
stringify
(
entryList
.
getEntries
())
)
}
)
observer1
.
observe
({
entryTypes
:
[
'
render
'
,
'
navigation
'
],
}
as
PerformanceObserverOptions
)
},
onShow
:
function
()
{
// 自动化测试
setLifeCycleNum
(
state
.
lifeCycleNum
+
100
)
console
.
log
(
"
App Show
"
);
console
.
log
(
'
App Show
'
)
},
onHide
:
function
()
{
// 自动化测试
setLifeCycleNum
(
state
.
lifeCycleNum
-
100
)
console
.
log
(
"
App Hide
"
);
console
.
log
(
'
App Hide
'
)
},
onLastPageBackPress
:
function
():
boolean
|
null
{
// 自动化测试
setLifeCycleNum
(
state
.
lifeCycleNum
-
1000
)
uni
.
showToast
({
title
:
"
再按一次退出应用
"
,
position
:
"
bottom
"
,
})
;
return
null
;
title
:
'
再按一次退出应用
'
,
position
:
'
bottom
'
,
})
return
null
},
}
;
}
</
script
>
<
style
>
/*每个页面公共css */
@import
"./common/uni.css"
;
@import
'./common/uni.css'
;
/* #ifdef H5 */
@media
screen
and
(
min-width
:
768px
)
{
...
...
pages/API/navigator/navigator.uvue
浏览文件 @
558dff52
...
...
@@ -43,8 +43,8 @@
</view>
</template>
<script lang="ts">
import { setLifeCycleNum, state } from '@/store/index.uts'
export default {
import { setLifeCycleNum, state } from '@/store/index.uts'
export default {
data() {
return {
onLoadTime: 0,
...
...
@@ -109,12 +109,14 @@
animationDuration: 200,
})
},
setLifeCycleNum(num : number) {
// 自动化测试
setLifeCycleNum(num: number) {
setLifeCycleNum(num)
},
getLifeCycleNum() : number {
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
},
},
}
}
</script>
pages/API/page-lifecycle/page-lifecycle.test.js
已删除
100644 → 0
浏览文件 @
cb82131b
const
PAGE_PATH
=
'
/pages/API/page-lifecycle/page-lifecycle
'
const
INTERMEDIATE_PAGE_PATH
=
'
/pages/API/navigator/navigator
'
describe
(
'
page-lifecycle
'
,
()
=>
{
let
page
let
lifeCycleNum
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
INTERMEDIATE_PAGE_PATH
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
1100
)
const
initLifecycleNum
=
0
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
initLifecycleNum
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
initLifecycleNum
)
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
1000
)
})
it
(
'
onLoad onShow onReady
'
,
async
()
=>
{
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
120
)
})
it
(
'
onHide
'
,
async
()
=>
{
page
=
await
program
.
navigateTo
(
INTERMEDIATE_PAGE_PATH
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
110
)
page
=
await
program
.
navigateBack
()
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
120
)
})
it
(
'
onUnload
'
,
async
()
=>
{
page
=
await
program
.
redirectTo
(
INTERMEDIATE_PAGE_PATH
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
20
)
})
it
(
'
onBackPress
'
,
async
()
=>
{
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
140
)
page
=
await
program
.
navigateBack
()
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
30
)
})
it
(
'
onLastPageBackPress
'
,
async
()
=>
{
page
=
await
program
.
navigateBack
()
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
-
970
)
const
resetLifecycleNum
=
1100
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
resetLifecycleNum
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
resetLifecycleNum
)
})
})
pages/API/page-lifecycle/page-lifecycle.uvue
已删除
100644 → 0
浏览文件 @
cb82131b
<template>
<view class="page">
<text>page lifecycle</text>
</view>
</template>
<script lang="ts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
onLoad() {
setLifeCycleNum(state.lifeCycleNum + 100)
console.log('Page onLoad')
},
onShow() {
setLifeCycleNum(state.lifeCycleNum + 10)
console.log('Page onShow')
},
onReady() {
setLifeCycleNum(state.lifeCycleNum + 10)
console.log('Page onReady')
},
onHide() {
setLifeCycleNum(state.lifeCycleNum - 10)
console.log('Page onHide')
},
onUnload() {
setLifeCycleNum(state.lifeCycleNum - 100)
console.log('Page onUnload')
},
onBackPress(options: Map<string, string>) : boolean | null {
setLifeCycleNum(state.lifeCycleNum - 10)
console.log('Page onBackPress',options)
return null
},
methods: {
getLifeCycleNum() : number {
return state.lifeCycleNum
}
},
}
</script>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录