Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
01395aaf
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
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看板
提交
01395aaf
编写于
9月 18, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: set custom navigation bar color
上级
cf67cc05
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
202 addition
and
61 deletion
+202
-61
pages.json
pages.json
+42
-32
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
...igation-bar-color/set-custom-navigation-bar-color.test.js
+30
-0
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
...navigation-bar-color/set-custom-navigation-bar-color.uvue
+105
-0
pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
...set-navigation-bar-color/set-navigation-bar-color.test.js
+1
-2
pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
...PI/set-navigation-bar-color/set-navigation-bar-color.uvue
+24
-27
未找到文件。
pages.json
浏览文件 @
01395aaf
...
@@ -243,6 +243,13 @@
...
@@ -243,6 +243,13 @@
"navigationBarTitleText"
:
"设置导航条颜色"
"navigationBarTitleText"
:
"设置导航条颜色"
}
}
},
},
{
"path"
:
"pages/API/set-navigation-bar-color/set-custom-navigation-bar-color"
,
"style"
:
{
"navigationBarTitleText"
:
"设置自定义导航栏颜色"
,
"navigationStyle"
:
"custom"
}
},
{
{
"path"
:
"pages/API/navigator/new-page/new-page-1"
,
"path"
:
"pages/API/navigator/new-page/new-page-1"
,
"style"
:
{
"style"
:
{
...
@@ -335,48 +342,48 @@
...
@@ -335,48 +342,48 @@
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"background-image"
"navigationBarTitleText"
:
"background-image"
}
}
},
},
{
{
"path"
:
"pages/CSS/border/border-bottom"
,
"path"
:
"pages/CSS/border/border-bottom"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"border-bottom"
"navigationBarTitleText"
:
"border-bottom"
}
}
},
},
{
{
"path"
:
"pages/CSS/border/border-color"
,
"path"
:
"pages/CSS/border/border-color"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"border-color"
"navigationBarTitleText"
:
"border-color"
}
}
},
},
{
{
"path"
:
"pages/CSS/border/border-left"
,
"path"
:
"pages/CSS/border/border-left"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"border-left"
"navigationBarTitleText"
:
"border-left"
}
}
},
},
{
{
"path"
:
"pages/CSS/border/border-radius"
,
"path"
:
"pages/CSS/border/border-radius"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"border-radius"
"navigationBarTitleText"
:
"border-radius"
}
}
},
},
{
{
"path"
:
"pages/CSS/border/border-right"
,
"path"
:
"pages/CSS/border/border-right"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"border-right"
"navigationBarTitleText"
:
"border-right"
}
}
},
},
{
{
"path"
:
"pages/CSS/border/border-style"
,
"path"
:
"pages/CSS/border/border-style"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"border-style"
"navigationBarTitleText"
:
"border-style"
}
}
},
},
{
{
"path"
:
"pages/CSS/border/border-top"
,
"path"
:
"pages/CSS/border/border-top"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"border-top"
"navigationBarTitleText"
:
"border-top"
}
}
},
},
{
{
"path"
:
"pages/CSS/border/border-width"
,
"path"
:
"pages/CSS/border/border-width"
,
...
@@ -901,30 +908,33 @@
...
@@ -901,30 +908,33 @@
"style"
:
{
"style"
:
{
"navigationStyle"
:
"custom"
"navigationStyle"
:
"custom"
}
}
},
{
},
{
"path"
:
"pages/API/unicloud-file-api/unicloud-file-api"
,
"path"
:
"pages/API/unicloud-file-api/unicloud-file-api"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
""
"navigationBarTitleText"
:
""
}
}
},
},
{
{
"path"
:
"pages/API/unicloud-database/unicloud-database"
,
"path"
:
"pages/API/unicloud-database/unicloud-database"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
""
"navigationBarTitleText"
:
""
}
}
},
},
{
{
"path"
:
"pages/template/navbar-lite/navbar-lite"
,
"path"
:
"pages/template/navbar-lite/navbar-lite"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"自定义导航栏"
,
"navigationBarTitleText"
:
"自定义导航栏"
,
"navigationStyle"
:
"custom"
"navigationStyle"
:
"custom"
}
}
},
{
},
{
"path"
:
"pages/template/custom-tab-bar/custom-tab-bar"
,
"path"
:
"pages/template/custom-tab-bar/custom-tab-bar"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"自定义TabBar"
"navigationBarTitleText"
:
"自定义TabBar"
}
}
},
{
},
{
"path"
:
"pages/template/custom-tab-bar2/custom-tab-bar2"
,
"path"
:
"pages/template/custom-tab-bar2/custom-tab-bar2"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"自定义TabBar2"
"navigationBarTitleText"
:
"自定义TabBar2"
...
@@ -980,4 +990,4 @@
...
@@ -980,4 +990,4 @@
"query"
:
""
//启动参数,在页面的onLoad函数里面得到
"query"
:
""
//启动参数,在页面的onLoad函数里面得到
}]
}]
}
}
}
}
\ No newline at end of file
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
0 → 100644
浏览文件 @
01395aaf
const
CURRENT_PAGE_PATH
=
"
/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color
"
;
describe
(
"
setCustomNavigationBarColor
"
,
()
=>
{
let
page
;
let
originLifeCycleNum
;
beforeAll
(
async
()
=>
{
page
=
await
program
.
navigateTo
(
CURRENT_PAGE_PATH
);
await
page
.
waitFor
(
1000
);
originLifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
});
afterAll
(
async
()
=>
{
await
page
.
callMethod
(
"
setLifeCycleNum
"
,
originLifeCycleNum
);
const
lifeCycleNum
=
await
page
.
callMethod
(
"
getLifeCycleNum
"
);
expect
(
lifeCycleNum
).
toBe
(
originLifeCycleNum
);
});
it
(
"
setNavigationBarColor2
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarColor2
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
});
it
(
"
setNavigationBarColor1
"
,
async
()
=>
{
await
page
.
callMethod
(
"
setNavigationBarColor1
"
);
const
image
=
await
program
.
screenshot
();
expect
(
image
).
toMatchImageSnapshot
();
});
});
pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
0 → 100644
浏览文件 @
01395aaf
<template>
<view>
<view class="custom-navigation">
<text
class="back-icon"
@click="back"
:style="`color:${navigationBarTextColor}`"
>{{ backIcon }}</text
>
<text class="title" :style="`color:${navigationBarTextColor}`"
>自定义导航栏</text
>
</view>
<page-head title="setCustomNavigationBarColor"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarColor1" class="uni-btn">
设置自定义导航栏前景色白色
</button>
<button @tap="setNavigationBarColor2" class="uni-btn">
设置自定义导航栏前景色黑色
</button>
</view>
</view>
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data() {
return {
backIcon: '\ue582',
navigationBarTextColor: '#fff'
}
},
onShow(){
uni.loadFontFace({
family: 'UniFontFamily',
source: 'static/font/uni.ttf'
})
},
methods: {
back(){
uni.navigateBack()
},
setNavigationBarColor1() {
uni.setNavigationBarColor({
frontColor: '#ffffff',
backgroundColor: '#0000',
success() {
this.navigationBarTextColor = '#fff'
console.log('setNavigationBarColor success')
},
fail() {
console.log('setNavigationBarColor success')
},
complete() {
console.log('setNavigationBarColor success')
}
})
},
setNavigationBarColor2() {
uni.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: '#0000',
success() {
this.navigationBarTextColor = '#000'
console.log('setNavigationBarColor success')
},
fail() {
console.log('setNavigationBarColor success')
},
complete() {
console.log('setNavigationBarColor success')
}
})
},
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num: number) {
setLifeCycleNum(num)
},
},
}
</script>
<style>
.custom-navigation {
padding-top: 40px;
padding-bottom: 10px;
background-color: #007aff;
}
.custom-navigation > .title {
margin: 0 auto;
}
.custom-navigation > .back-icon {
position: absolute;
font-family: UniFontFamily;
font-size: 20px;
left: 10px;
}
</style>
pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
浏览文件 @
01395aaf
...
@@ -4,7 +4,6 @@ const CURRENT_PAGE_PATH =
...
@@ -4,7 +4,6 @@ const CURRENT_PAGE_PATH =
describe
(
'
setNavigationBarColor
'
,
()
=>
{
describe
(
'
setNavigationBarColor
'
,
()
=>
{
let
page
let
page
let
originLifeCycleNum
let
originLifeCycleNum
let
lifeCycleNum
beforeAll
(
async
()
=>
{
beforeAll
(
async
()
=>
{
page
=
await
program
.
navigateTo
(
CURRENT_PAGE_PATH
)
page
=
await
program
.
navigateTo
(
CURRENT_PAGE_PATH
)
await
page
.
waitFor
(
1000
)
await
page
.
waitFor
(
1000
)
...
@@ -13,7 +12,7 @@ describe('setNavigationBarColor', () => {
...
@@ -13,7 +12,7 @@ describe('setNavigationBarColor', () => {
afterAll
(
async
()
=>
{
afterAll
(
async
()
=>
{
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
originLifeCycleNum
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
originLifeCycleNum
)
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
const
lifeCycleNum
=
await
page
.
callMethod
(
'
getLifeCycleNum
'
)
expect
(
lifeCycleNum
).
toBe
(
originLifeCycleNum
)
expect
(
lifeCycleNum
).
toBe
(
originLifeCycleNum
)
})
})
...
...
pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
浏览文件 @
01395aaf
...
@@ -8,19 +8,17 @@
...
@@ -8,19 +8,17 @@
<button @tap="setNavigationBarColor2" class="uni-btn">
<button @tap="setNavigationBarColor2" class="uni-btn">
设置导航条背景红色,标题黑色
设置导航条背景红色,标题黑色
</button>
</button>
<button @tap="goCustomNavigation" class="uni-btn">
跳转自定义导航栏页面
</button>
</view>
</view>
</view>
</view>
</template>
</template>
<script lang="uts">
<script lang="uts">
import {
State,
state, setLifeCycleNum } from '@/store/index.uts'
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
export default {
data() {
return {
_state: state as State
}
},
methods: {
methods: {
setNavigationBarColor1() {
setNavigationBarColor1() {
uni.setNavigationBarColor({
uni.setNavigationBarColor({
...
@@ -28,36 +26,30 @@ export default {
...
@@ -28,36 +26,30 @@ export default {
backgroundColor: '#00ff00',
backgroundColor: '#00ff00',
success() {
success() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum + 1)
},
},
fail() {
fail() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum - 1)
},
},
complete() {
complete() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum + 1)
}
}
})
})
},
},
setNavigationBarColor2() {
setNavigationBarColor2() {
uni.setNavigationBarColor({
uni.setNavigationBarColor({
frontColor: '#000000',
frontColor: '#000000',
backgroundColor: '#ff0000',
backgroundColor: '#ff0000',
success() {
success() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor success')
setLifeCycleNum(state.lifeCycleNum + 1)
},
},
fail() {
fail() {
console.log('setNavigationBarColor success')
console.log('setNavigationBarColor success')
},
setLifeCycleNum(state.lifeCycleNum - 1)
complete() {
},
console.log('setNavigationBarColor success')
complete() {
}
console.log('setNavigationBarColor success')
})
setLifeCycleNum(state.lifeCycleNum + 1)
},
}
})
},
// 自动化测试
// 自动化测试
getLifeCycleNum(): number {
getLifeCycleNum(): number {
return state.lifeCycleNum
return state.lifeCycleNum
...
@@ -66,6 +58,11 @@ export default {
...
@@ -66,6 +58,11 @@ export default {
setLifeCycleNum(num: number) {
setLifeCycleNum(num: number) {
setLifeCycleNum(num)
setLifeCycleNum(num)
},
},
goCustomNavigation(){
uni.navigateTo({
url: '/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color'
})
}
},
},
}
}
</script>
</script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录