Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
e5380be0
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6066
Star
93
Fork
166
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e5380be0
编写于
4月 20, 2024
作者:
H
hdx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(pageStyle): 新增示例及自动化测试
上级
9ef50c49
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
153 addition
and
71 deletion
+153
-71
pages.json
pages.json
+2
-1
pages/API/get-current-pages/get-current-pages.test.js
pages/API/get-current-pages/get-current-pages.test.js
+52
-26
pages/API/get-current-pages/get-current-pages.uvue
pages/API/get-current-pages/get-current-pages.uvue
+99
-44
未找到文件。
pages.json
浏览文件 @
e5380be0
...
@@ -361,7 +361,8 @@
...
@@ -361,7 +361,8 @@
{
{
"path"
:
"pages/API/get-current-pages/get-current-pages"
,
"path"
:
"pages/API/get-current-pages/get-current-pages"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"getCurrentPages"
"navigationBarTitleText"
:
"getCurrentPages"
,
"enablePullDownRefresh"
:
true
}
}
},
},
{
{
...
...
pages/API/get-current-pages/get-current-pages.test.js
浏览文件 @
e5380be0
const
HOME_PAGE_PATH
=
'
/pages/tabBar/component
'
const
HOME_PAGE_PATH
=
'
/pages/tabBar/component
'
const
PAGE_PATH
=
'
/pages/API/get-current-pages/get-current-pages
'
const
PAGE_PATH
=
'
/pages/API/get-current-pages/get-current-pages
'
describe
(
'
getCurrentPages
'
,
()
=>
{
describe
(
'
getCurrentPages
'
,
()
=>
{
let
page
let
page
it
(
'
getCurrentPages
'
,
async
()
=>
{
it
(
'
getCurrentPages
'
,
async
()
=>
{
// web 端等待应用首页加载完成
// web 端等待应用首页加载完成
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
web
'
))
{
const
waitTime
=
process
.
env
.
uniTestPlatformInfo
.
includes
(
'
safari
'
)
const
waitTime
=
process
.
env
.
uniTestPlatformInfo
.
includes
(
'
safari
'
)
?
?
5000
5000
:
:
1000
1000
await
new
Promise
((
resolve
)
=>
{
await
new
Promise
((
resolve
)
=>
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
resolve
()
resolve
()
},
waitTime
)
},
waitTime
)
})
})
}
}
page
=
await
program
.
switchTab
(
HOME_PAGE_PATH
)
page
=
await
program
.
switchTab
(
HOME_PAGE_PATH
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
1000
)
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
page
=
await
program
.
navigateTo
(
PAGE_PATH
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
1000
)
await
page
.
callMethod
(
'
_getCurrentPages
'
)
await
page
.
callMethod
(
'
_getCurrentPages
'
)
await
page
.
waitFor
(
200
)
await
page
.
waitFor
(
200
)
const
data
=
await
page
.
data
()
const
data
=
await
page
.
data
()
expect
(
data
.
checked
).
toBe
(
true
)
expect
(
data
.
checked
).
toBe
(
true
)
})
})
it
(
'
getPageStyle
'
,
async
()
=>
{
await
changeData
(
page
)
const
btn
=
await
page
.
$
(
'
.btn-get-page-style
'
)
await
btn
.
tap
()
await
page
.
waitFor
(
100
)
const
{
currentPageStyle
}
=
await
page
.
data
()
expect
(
currentPageStyle
[
'
enablePullDownRefresh
'
]).
toBe
(
true
)
})
it
(
'
setPageStyle
'
,
async
()
=>
{
await
changeData
(
page
)
const
btn
=
await
page
.
$
(
'
.btn-set-page-style-0
'
)
await
btn
.
tap
()
await
page
.
waitFor
(
100
)
const
{
currentPageStyle
}
=
await
page
.
data
()
expect
(
currentPageStyle
[
'
enablePullDownRefresh
'
]).
toBe
(
false
)
})
})
})
pages/API/get-current-pages/get-current-pages.uvue
浏览文件 @
e5380be0
<template>
<template>
<page-head title="getCurrentPages"></page-head>
<page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap">
<view class="uni-padding-wrap">
<button @click="_getCurrentPages">getCurrentPages</button>
<button @click="_getCurrentPages">getCurrentPages</button>
<view v-if="pages.length" style="padding: 15px 0px">
<view v-if="pages.length" style="padding: 15px 0px">
<text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text>
<text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text>
<template v-for="(page, index) in pages" :key="page.route">
<template v-for="(page, index) in pages" :key="page.route">
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
</template>
</template>
</view>
</view>
</view>
<button class="btn btn-get-page-style" type="primary" @click="getPageStyle">getPageStyle</button>
</template>
<button class="btn btn-set-page-style-1" type="default" @click="setPageStyle(true)">setPageStyle(true)</button>
<button class="btn btn-set-page-style-0" type="default" @click="setPageStyle(false)">setPageStyle(false)</button>
<script>
<textarea class="textarea" :value="pageStyleText" :maxlength="-1" :auto-height="true"></textarea>
class Page {
<text class="tips">
constructor(public route : string) {
当前版本仅支持设置属性 enablePullDownRefresh
}
</text>
}
</view>
</template>
export default {
data() {
<script>
return {
class Page {
checked: false,
constructor(public route : string) {
pages: [] as Page[],
}
}
}
},
methods: {
export default {
_getCurrentPages: function () {
data() {
this.pages.length = 0
return {
const pages = getCurrentPages()
checked: false,
this.pages.push(new Page(pages[0].route))
pages: [] as Page[],
if (this.pages[0].route.includes('/tabBar/')) {
currentPageStyle: {} as UTSJSONObject
this.checked = true
}
}
},
for (let i = 1; i < pages.length; i++) {
computed: {
this.pages.push(new Page(pages[i].route))
pageStyleText() : string {
if (pages[i].route.includes('/tabBar/')) {
return JSON.stringify(this.currentPageStyle)
this.checked = false
}
}
},
}
onPullDownRefresh() {
},
setTimeout(() => {
},
uni.stopPullDownRefresh()
}
}, 3000)
</script>
},
methods: {
_getCurrentPages: function () {
this.pages.length = 0
const pages = getCurrentPages()
this.pages.push(new Page(pages[0].route))
if (this.pages[0].route.includes('/tabBar/')) {
this.checked = true
}
for (let i = 1; i < pages.length; i++) {
this.pages.push(new Page(pages[i].route))
if (pages[i].route.includes('/tabBar/')) {
this.checked = false
}
}
},
getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle();
},
setPageStyle(epr : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle({
enablePullDownRefresh: epr
});
},
// getCurrentPage(): Page {
// const pages = getCurrentPages();
// const currentPage = pages[pages.length - 1];
// return currentPage;
// }
},
}
</script>
<style>
.btn {
margin-top: 10px;
}
.textarea {
margin-top: 5px;
padding: 5px;
background-color: #fff;
}
.tips {
font-size: 12px;
margin-top: 10px;
opacity: .8;
}
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录