Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
ed8e1549
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5992
Star
90
Fork
162
代码
文件
提交
分支
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看板
提交
ed8e1549
编写于
9月 24, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(dialogPage): 移除 eventBus
上级
ba2be59b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
26 addition
and
60 deletion
+26
-60
pages/API/dialog-page/dialog-1.uvue
pages/API/dialog-page/dialog-1.uvue
+0
-8
pages/API/dialog-page/dialog-page.test.js
pages/API/dialog-page/dialog-page.test.js
+6
-6
pages/API/dialog-page/dialog-page.uvue
pages/API/dialog-page/dialog-page.uvue
+20
-46
未找到文件。
pages/API/dialog-page/dialog-1.uvue
浏览文件 @
ed8e1549
...
...
@@ -55,14 +55,6 @@
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
dialogPage.emit('fn1', { from: 'dialog1' })
dialogPage.emit('fn2', null)
dialogPage.off('fn2', null)
dialogPage.emit('fn1', { from: 'dialog1' })
dialogPage.emit('fn2', null)
dialogPage.emit('fnOnce', null)
dialogPage.emit('fnOnce', null)
},
onHide() {
console.log('dialog 1 onHide')
...
...
pages/API/dialog-page/dialog-page.test.js
浏览文件 @
ed8e1549
...
...
@@ -37,7 +37,7 @@ describe('dialog page', () => {
// 不应触发父页面的生命周期,应该触发:
// 1. openDialogPage success & complete callback
// 2. dialog page 生命周期
expect
(
lifecycleNum
).
toBe
(
13
)
expect
(
lifecycleNum
).
toBe
(
7
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
0
)
});
...
...
@@ -69,7 +69,7 @@ describe('dialog page', () => {
await
page
.
callMethod
(
'
goNextPageOpenDialog1
'
)
await
page
.
waitFor
(
2000
)
if
(
isWeb
)
{
await
page
.
waitFor
(
2
000
)
await
page
.
waitFor
(
3
000
)
}
page
=
await
program
.
currentPage
()
expect
(
page
.
path
).
toBe
(
NEXT_PAGE_PATH
.
substring
(
1
))
...
...
@@ -235,7 +235,7 @@ describe('dialog page', () => {
});
expect
(
image2
).
toSaveImageSnapshot
();
lifecycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifecycleNum
).
toBe
(
1
6
)
expect
(
lifecycleNum
).
toBe
(
1
0
)
await
page
.
callMethod
(
'
closeSpecifiedDialog
'
,
0
)
const
image3
=
await
program
.
screenshot
({
...
...
@@ -247,7 +247,7 @@ describe('dialog page', () => {
});
expect
(
image3
).
toSaveImageSnapshot
();
lifecycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifecycleNum
).
toBe
(
13
)
expect
(
lifecycleNum
).
toBe
(
7
)
await
page
.
callMethod
(
'
closeSpecifiedDialog
'
,
1
)
const
image4
=
await
program
.
screenshot
({
...
...
@@ -259,7 +259,7 @@ describe('dialog page', () => {
});
expect
(
image4
).
toSaveImageSnapshot
();
lifecycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifecycleNum
).
toBe
(
11
)
expect
(
lifecycleNum
).
toBe
(
5
)
await
page
.
callMethod
(
'
closeSpecifiedDialog
'
,
0
)
const
image5
=
await
program
.
screenshot
({
...
...
@@ -271,7 +271,7 @@ describe('dialog page', () => {
});
expect
(
image5
).
toSaveImageSnapshot
();
lifecycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifecycleNum
).
toBe
(
8
)
expect
(
lifecycleNum
).
toBe
(
2
)
})
...
...
pages/API/dialog-page/dialog-page.uvue
浏览文件 @
ed8e1549
...
...
@@ -5,11 +5,10 @@
<button class="uni-common-mt" id="open-dialog1-wrong-path" @click="openDialog1WrongPath">open dialog page 1 with
wrong path</button>
<button class="uni-common-mt" id="go-next-page-open-dialog1" @click="goNextPageOpenDialog1">go next page & open
dialog1</button>
<!-- #ifdef APP-ANDROID -->
<button class="uni-common-mt" id="privacy_test" @click="privacy">隐私协议</button>
<!-- #endif -->
dialog1</button>
<!-- #ifdef APP-ANDROID -->
<button class="uni-common-mt" id="privacy_test" @click="privacy">隐私协议</button>
<!-- #endif -->
</view>
</template>
...
...
@@ -44,43 +43,23 @@
})
},
openDialog1() {
const dialogPage = uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1',
success(res) {
console.log('openDialogPage1 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialogPage1 fail', err)
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialogPage1 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
}) !
const fn1 = (options: any | null) => {
console.log('dialogPage1 be triggered fn1', options)
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1',
success(res) {
console.log('openDialogPage1 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialogPage1 fail', err)
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialogPage1 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
const fn11 = (options: any | null) => {
console.log('dialogPage1 be triggered fn11', options)
setLifeCycleNum(state.lifeCycleNum + 1)
}
const fn2 = (options: any | null) => {
console.log('dialogPage1 be triggered fn2', options)
setLifeCycleNum(state.lifeCycleNum + 1)
}
const fnOnce = (options: any | null) => {
console.log('dialogPage1 be triggered fnOnce', options)
setLifeCycleNum(state.lifeCycleNum + 1)
}
dialogPage.on('fn1', fn1)
dialogPage.on('fn1', fn11)
dialogPage.on('fn2', fn2)
dialogPage.once('fnOnce', fnOnce)
})
},
openDialog2() {
uni.openDialogPage({
...
...
@@ -194,12 +173,7 @@
},
getLifeCycleNum(): number {
return state.lifeCycleNum
},
privacy() {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-privacytest',
})
},
}
}
}
</script>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录