Commit e510ec82 authored by 崔佳豪's avatar 崔佳豪

feat: 顶部扩展图标菜单支持配置

parent 4ae968dc
Pipeline #52929 passed with stages
...@@ -171,20 +171,43 @@ const GlobalHeaderRight = props => { ...@@ -171,20 +171,43 @@ const GlobalHeaderRight = props => {
) )
} }
const renderTopMenu = () => {
if(!props.global || !props.global.topMenu) return null;
const topMenus = props.global.topMenu.split(',') || [];
return topMenus.map(name => {
switch (name) {
// 搜索,首页,常用,反馈,消息
case '搜索':
return ( return (
<div className={className} style={{marginLeft: 'inherit'}}>
{/* */}
<div className={styles.opteration}> <div className={styles.opteration}>
<Popover placement="bottomRight" content={renderHeaderSearch()} trigger="click" overlayClassName={styles.searchPopupWrapper}> <Popover
<Icon component={() => <img src={search} alt="icon" className={styles.active}/>}/> placement="bottomRight"
content={renderHeaderSearch()}
trigger="click"
overlayClassName={styles.searchPopupWrapper}
>
<Icon component={() => <img src={search} alt="icon" className={styles.active} />} />
</Popover> </Popover>
</div> </div>
);
case '反馈':
return (
<div className={styles.opteration}> <div className={styles.opteration}>
<Icon component={() => <img src={order} alt="icon"/>} onClick={handleFeedback}/> <Icon component={() => <img src={order} alt="icon" />} onClick={handleFeedback} />
</div> </div>
<NoticeIconView bell={ <Icon component={() => <img src={notice} alt="icon"/>}/>}/> );
<Avatar menu config={props.global} updateCurrentIndex={props.updateCurrentIndex} updateConfig={props.updateConfig} logout={props.logout}/> case '消息':
return <NoticeIconView bell={<Icon component={() => <img src={notice} alt="icon" />} />} />;
default:
return null;
}
})
}
return (
<div className={className} style={{ marginLeft: 'inherit' }}>
{renderTopMenu()}
<Avatar menu config={props.global} updateCurrentIndex={props.updateCurrentIndex} updateConfig={props.updateConfig} logout={props.logout} />
</div> </div>
); );
}; };
...@@ -211,17 +234,17 @@ const mapDispatchToProps = dispatch => ({ ...@@ -211,17 +234,17 @@ const mapDispatchToProps = dispatch => ({
dispatch(actionCreators.clearRecentProduct()); dispatch(actionCreators.clearRecentProduct());
}, },
updateCurrentIndex(index) { updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index)) dispatch(actionCreators.updateCurrentIndex(index));
}, },
updateConfig(config) { updateConfig(config) {
dispatch(actionCreators.getConfig(config)) dispatch(actionCreators.getConfig(config));
}, },
updateComplexConfig(config) { updateComplexConfig(config) {
dispatch(actionCreators.updateComplexConfig(config)) dispatch(actionCreators.updateComplexConfig(config));
}, },
logout() { logout() {
dispatch(actionCreators.logout()) dispatch(actionCreators.logout());
} },
}); });
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
...@@ -91,6 +91,7 @@ const appReducer = (state = initialState, action) => { ...@@ -91,6 +91,7 @@ const appReducer = (state = initialState, action) => {
// 临时补充messageVoice。后续需要加到AppConfig中。 // 临时补充messageVoice。后续需要加到AppConfig中。
action.data && action.data.hasOwnProperty('messageVoice') && (window.globalConfig.messageVoice = action.data.messageVoice) action.data && action.data.hasOwnProperty('messageVoice') && (window.globalConfig.messageVoice = action.data.messageVoice)
action.data && action.data.hasOwnProperty('topMenu') && (window.globalConfig.topMenu = action.data.topMenu)
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
createStoreage.set('globalConfig', window.globalConfig); createStoreage.set('globalConfig', window.globalConfig);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment