提交 c5587266 编写于 作者: D DCloud_LXH

fix(app): darkmode statusBarStyle question/157497

上级 3d598a08
......@@ -48,7 +48,7 @@ export function getAppBaseInfo () {
hostPackageName, hostName, osLanguage,
hostVersion, hostLanguage, hostTheme,
appId, appName, appVersion, appVersionCode,
appWgtVersion, osTheme
appWgtVersion
} = systemInfo
const appLanguage = uni
......@@ -74,7 +74,7 @@ export function getAppBaseInfo () {
hostFontSizeSetting: undefined,
language: osLanguage,
SDKVersion: '',
theme: hostTheme || osTheme,
theme: plus.navigator.getUIStyle(),
version: plus.runtime.innerVersion
}
}
......
......@@ -52,6 +52,8 @@ import {
parseRedirectInfo
} from './utils'
import { changePagesNavigatorStyle } from './theme'
let appCtx
const defaultApp = {
......@@ -131,6 +133,7 @@ function initGlobalListeners () {
publish('onUIStyleChange', {
style: event.uistyle
})
changePagesNavigatorStyle()
})
globalEvent.addEventListener('uniMPNativeEvent', function (event) {
......@@ -263,4 +266,4 @@ export function registerApp (appVm, Vue) {
__uniConfig.ready = true
process.env.NODE_ENV !== 'production' && perf('registerApp')
}
}
import { normallizeStyles } from 'uni-shared'
import { weexGetSystemInfoSync } from '../api/device/system'
import { setStatusBarStyle } from '../bridge'
import { getCurrentPages } from './page'
const ON_THEME_CHANGE = 'api.onThemeChange'
......@@ -11,13 +13,28 @@ function offThemeChange (callback = () => { }) {
UniServiceJSBridge.off(ON_THEME_CHANGE, callback)
}
function getNavigatorStyle () {
return plus.navigator.getUIStyle() === 'dark' ? 'light' : 'dark'
}
export function changePagesNavigatorStyle () {
const theme = getNavigatorStyle()
setStatusBarStyle(theme)
const pages = getCurrentPages(true)
pages.forEach((page) => {
page.$page.meta.statusBarStyle = theme
})
}
export function parseTheme (pageStyle) {
let parsedStyle = {}
if (__uniConfig.darkmode) {
let theme = 'light'
let theme = plus.navigator.getUIStyle()
const systemInfo = weexGetSystemInfoSync()
if (systemInfo) {
theme = systemInfo.hostTheme || systemInfo.osTheme
if (systemInfo && systemInfo.hostTheme) {
theme = systemInfo.hostTheme
}
parsedStyle = normallizeStyles(pageStyle, __uniConfig.themeConfig, theme)
}
......
......@@ -106,5 +106,6 @@ export function parseWebviewStyle (id, path, _routeOptions = {}) {
}
}
_routeOptions.meta = routeOptions.meta
return webviewStyle
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册