From bd74eb65a7b3d0deecb8ea7b4efec99b47aefb81 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 2 Sep 2018 00:26:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=BE=E7=BD=AE=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E7=9A=84=E5=B1=95=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SettingDrawer/index.js | 63 +++++++++++++++++---------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/src/components/SettingDrawer/index.js b/src/components/SettingDrawer/index.js index 72f72976..91ce4120 100644 --- a/src/components/SettingDrawer/index.js +++ b/src/components/SettingDrawer/index.js @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { Select, message, Drawer, List, Switch, Divider, Icon, Button, Alert } from 'antd'; +import { Select, message, Drawer, List, Switch, Divider, Icon, Button, Alert, Tooltip } from 'antd'; import { formatMessage } from 'umi/locale'; import { CopyToClipboard } from 'react-copy-to-clipboard'; import { connect } from 'dva'; @@ -8,6 +8,8 @@ import styles from './index.less'; import ThemeColor from './ThemeColor'; import BlockChecbox from './BlockChecbox'; +const { Option } = Select; + const Body = ({ children, title, style }) => (
this.changeSetting('contentWidth', value)} style={{ width: 80 }} > - - {formatMessage({ id: 'app.setting.content-width.fixed' })} - - + {layout === 'sidemenu' ? null : ( + + )} + - , - ], + + + ), }, { title: formatMessage({ id: 'app.setting.fixedheader' }), - action: [ + action: ( this.changeSetting('fixedHeader', checked)} - />, - ], + /> + ), }, { title: formatMessage({ id: 'app.setting.hideheader' }), - hide: !fixedHeader, - action: [ + disabled: !fixedHeader, + disabledReason: '固定 Header 时有效', + action: ( this.changeSetting('autoHideHeader', checked)} - />, - ], + /> + ), }, { title: formatMessage({ id: 'app.setting.fixedsidebar' }), - hide: layout === 'topmenu', - action: [ + disabled: layout === 'topmenu', + disabledReason: '侧边菜单布局时有效', + action: ( this.changeSetting('fixSiderbar', checked)} - />, - ], + /> + ), }, - ].filter(item => !item.hide); + ]; }; changeSetting = (key, value) => { @@ -107,6 +113,19 @@ class SettingDrawer extends PureComponent { this.setState({ collapse: !collapse }); }; + renderLayoutSettingItem = item => { + const action = React.cloneElement(item.action, { + disabled: item.disabled, + }); + return ( + + + {item.title} + + + ); + }; + render() { const { setting } = this.props; const { navTheme, primaryColor, layout, colorWeak } = setting; @@ -183,7 +202,7 @@ class SettingDrawer extends PureComponent { {item.title}} + renderItem={this.renderLayoutSettingItem} /> -- GitLab