From 9171cea32737d35584de56fe3af2b0d0cf678b22 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Fri, 28 Jul 2023 17:03:46 +0800 Subject: [PATCH] feat(api): setNavigationBarColor --- pages.json | 34 +++++---- pages/API/navigator/new-page/new-page-2.uvue | 5 +- .../set-navigation-bar-color.test.js | 30 ++++++++ .../set-navigation-bar-color.uvue | 74 +++++++++++++++++++ pages/tabBar/API.uvue | 8 +- 5 files changed, 130 insertions(+), 21 deletions(-) create mode 100644 pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js create mode 100644 pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue diff --git a/pages.json b/pages.json index 9dc1f8da..5735e395 100644 --- a/pages.json +++ b/pages.json @@ -171,6 +171,13 @@ "navigationBarTitleText": "页面跳转" } }, + { + "path": "pages/API/set-navigation-bar-color/set-navigation-bar-color", + "style": { + "navigationBarTitleText": "设置导航条颜色" + } + }, + { "path": "pages/API/navigator/new-page/new-page-1", "style": { @@ -671,23 +678,20 @@ "navigationBarTitleText": "电量" } }, - { - "path" : "pages/CSS/border/complex-border/complex-border", - "style" : - { - "navigationBarTitleText": "border属性组合示例", - "enablePullDownRefresh": false - } + { + "path": "pages/CSS/border/complex-border/complex-border", + "style": { + "navigationBarTitleText": "border属性组合示例", + "enablePullDownRefresh": false } - ,{ - "path" : "pages/template/scroll-fold-nav2/scroll-fold-nav2", - "style" : - { + }, + { + "path": "pages/template/scroll-fold-nav2/scroll-fold-nav2", + "style": { "navigationStyle": "custom" - } - - } - ], + } + } + ], "globalStyle": { "pageOrientation": "portrait", "navigationBarTitleText": "Hello uniapp x", diff --git a/pages/API/navigator/new-page/new-page-2.uvue b/pages/API/navigator/new-page/new-page-2.uvue index 24e84e04..dca4fb6e 100644 --- a/pages/API/navigator/new-page/new-page-2.uvue +++ b/pages/API/navigator/new-page/new-page-2.uvue @@ -72,10 +72,7 @@ export default { }, pageScrollTo(){ uni.pageScrollTo({ - scrollTop: 1200, - complete(res){ - console.warn('pageScrollTo', res) - } + scrollTop: 1200 }) } }, diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js new file mode 100644 index 00000000..aeb3a668 --- /dev/null +++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js @@ -0,0 +1,30 @@ +const CURRENT_PAGE_PATH = + '/pages/API/set-navigation-bar-color/set-navigation-bar-color' + +describe('setNavigationBarColor', () => { + let page + let originLifeCycleNum + let lifeCycleNum + 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) + lifeCycleNum = await page.callMethod('getLifeCycleNum') + expect(lifeCycleNum).toBe(originLifeCycleNum) + }) + + it('setNavigationBarColor1', async () => { + await page.callMethod('setNavigationBarColor1') + const image = await program.screenshot() + expect(image).toMatchImageSnapshot() + }) + it('setNavigationBarColor2', async () => { + await page.callMethod('setNavigationBarColor2') + const image = await program.screenshot() + expect(image).toMatchImageSnapshot() + }) +}) diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue new file mode 100644 index 00000000..f80d957f --- /dev/null +++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue @@ -0,0 +1,74 @@ + + + + + diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue index 297d3b90..59960792 100644 --- a/pages/tabBar/API.uvue +++ b/pages/tabBar/API.uvue @@ -81,10 +81,14 @@ enable: false }, { - name: "设置导航条", + name: "设置导航条标题", url: "set-navigation-bar-title", enable: false - }, + }, + { + name: "设置导航条颜色", + url: "set-navigation-bar-color", + }, { name: "设置TabBar", url: "set-tabbar", -- GitLab