提交 8e5e8869 编写于 作者: Q qiang

chore: build

上级 cdf8cdc8
......@@ -674,34 +674,52 @@ var serviceContext = (function () {
return borderStyle
}
function normallizeStyles (pageStyle, themeConfig = {}, mode = 'light') {
function normalizeTitleColor (titleColor) {
return titleColor === 'black' ? '#000000' : '#ffffff'
}
function resolveStringStyleItem (modeStyle, styleItem, key) {
if (isString(styleItem) && styleItem.startsWith('@')) {
const _key = styleItem.replace('@', '');
let _styleItem = modeStyle[_key] || styleItem;
switch (key) {
case 'titleColor':
_styleItem = normalizeTitleColor(_styleItem);
break
case 'borderStyle':
_styleItem = normalizeTabBarStyles(_styleItem);
break
}
return _styleItem
}
return styleItem
}
function normalizeStyles (pageStyle, themeConfig = {}, mode = 'light') {
const modeStyle = themeConfig[mode];
const styles = {};
if (!modeStyle) {
return pageStyle
}
Object.keys(pageStyle).forEach((key) => {
if (typeof modeStyle === 'undefined') return pageStyle
Object.keys(pageStyle).forEach(key => {
const styleItem = pageStyle[key]; // Object Array String
styles[key] = (() => {
if (isPlainObject(styleItem)) {
return normallizeStyles(styleItem, themeConfig, mode)
} else if (Array.isArray(styleItem)) {
return styleItem.map((item) => isPlainObject(item)
? normallizeStyles(item, themeConfig, mode)
: item)
} else if (isStr(styleItem) && styleItem.startsWith('@')) {
const _key = styleItem.replace('@', '');
let _styleItem = modeStyle[_key] || styleItem;
switch (key) {
case 'borderStyle':
_styleItem = normalizeTabBarStyles(_styleItem);
break
}
return _styleItem
const parseStyleItem = () => {
if (isPlainObject(styleItem)) { return normalizeStyles(styleItem, themeConfig, mode) }
if (Array.isArray(styleItem)) {
return styleItem.map(item => {
if (typeof item === 'object') { return normalizeStyles(item, themeConfig, mode) }
return resolveStringStyleItem(modeStyle, item)
})
}
return styleItem
})();
return resolveStringStyleItem(modeStyle, styleItem, key)
};
styles[key] = parseStyleItem();
});
return styles
}
......@@ -6386,8 +6404,7 @@ var serviceContext = (function () {
autoBackButton: !routeOptions.meta.isQuit,
titleText:
titleImage === '' ? windowOptions.navigationBarTitleText || '' : '',
titleColor:
windowOptions.navigationBarTextStyle === 'white' ? '#ffffff' : '#000000',
titleColor: normalizeTitleColor(windowOptions.navigationBarTextStyle),
type: titleNViewTypeList[transparentTitle],
backgroundColor:
/^#[a-z0-9]{6}$/i.test(navigationBarBackgroundColor) ||
......@@ -7648,7 +7665,7 @@ var serviceContext = (function () {
theme = systemInfo.hostTheme;
}
parsedStyle = normallizeStyles(pageStyle, __uniConfig.themeConfig, theme);
parsedStyle = normalizeStyles(pageStyle, __uniConfig.themeConfig, theme);
return parsedStyle
}
return pageStyle
......@@ -7659,23 +7676,24 @@ var serviceContext = (function () {
const fn = () => {
const {
list = [], color, selectedColor,
backgroundColor, borderStyle
backgroundColor, borderStyle, midButton
} = parseTheme(options);
const tabbarStyle = {
color,
selectedColor,
backgroundColor,
borderStyle
};
tabBar && tabBar.setTabBarStyle(tabbarStyle);
tabBar && tabBar.setTabBarItems({
list: list.map((item) => ({
iconPath: item.iconPath,
selectedIconPath: item.selectedIconPath,
visible: item.visible
}))
});
if (tabBar) {
tabBar.setTabBarStyle({
color,
selectedColor,
backgroundColor,
borderStyle,
midButton
});
tabBar.setTabBarItems({
list: list.map((item) => ({
iconPath: item.iconPath,
selectedIconPath: item.selectedIconPath,
visible: item.visible
}))
});
}
// TODO 暂未实现
// tabBar && tabBar.setAnimationAlphaBGColor(parseTheme((__uniConfig.window || {}).backgroundColor, false))
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册