From 869d515f9d1810f19ee3c1f01f19640537164a08 Mon Sep 17 00:00:00 2001 From: liuxiaohang <283700113@qq.com> Date: Fri, 13 Nov 2020 16:52:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(app-plus):=20=20=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=B0=83=E7=94=A8setNavigationBarColor?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A2=9C=E8=89=B2=E8=BF=87=E6=97=A9=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E8=A2=AB=E8=A6=86=E7=9B=96=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app-plus/service/api/ui/navigation-bar.js | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/platforms/app-plus/service/api/ui/navigation-bar.js b/src/platforms/app-plus/service/api/ui/navigation-bar.js index 631723ee4a..8c5c9e1bc7 100644 --- a/src/platforms/app-plus/service/api/ui/navigation-bar.js +++ b/src/platforms/app-plus/service/api/ui/navigation-bar.js @@ -40,6 +40,15 @@ export function hideNavigationBarLoading () { } } +function setPageMeta (statusBarStyle) { + const pages = getCurrentPages() + if (!pages.length) { + return + } + // 框架内部页面跳转会从这里获取style配置 + pages[pages.length - 1].$page.meta.statusBarStyle = statusBarStyle +} + export function setNavigationBarColor ({ frontColor, backgroundColor @@ -53,12 +62,17 @@ export function setNavigationBarColor ({ if (backgroundColor) { styles.backgroundColor = backgroundColor } - plus.navigator.setStatusBarStyle(frontColor === '#000000' ? 'dark' : 'light') + const statusBarStyle = frontColor === '#000000' ? 'dark' : 'light' + plus.navigator.setStatusBarStyle(statusBarStyle) + + // 用户调用api时同时改变当前页配置,这样在系统调用设置时,可以避免覆盖用户设置 + setPageMeta(statusBarStyle) + const style = webview.getStyle() - if (style && style.titleNView) { - if (style.titleNView.autoBackButton) { - styles.backButton = styles.backButton || {} - styles.backButton.color = frontColor + if (style && style.titleNView) { + if (style.titleNView.autoBackButton) { + styles.backButton = styles.backButton || {} + styles.backButton.color = frontColor } webview.setStyle({ titleNView: styles @@ -71,4 +85,4 @@ export function setNavigationBarColor ({ return { errMsg: 'setNavigationBarColor:fail' } -} +} -- GitLab