import React, { Component } from 'react'; 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'; import omit from 'omit.js'; import styles from './index.less'; import ThemeColor from './ThemeColor'; import BlockCheckbox from './BlockCheckbox'; const { Option } = Select; const Body = ({ children, title, style }) => (

{title}

{children}
); @connect(({ setting }) => ({ setting })) class SettingDrawer extends Component { state = { collapse: false, }; getLayoutSetting = () => { const { setting: { contentWidth, fixedHeader, layout, autoHideHeader, fixSiderbar }, } = this.props; return [ { title: formatMessage({ id: 'app.setting.content-width' }), action: ( ), }, { title: formatMessage({ id: 'app.setting.fixedheader' }), action: ( this.changeSetting('fixedHeader', checked)} /> ), }, { title: formatMessage({ id: 'app.setting.hideheader' }), disabled: !fixedHeader, disabledReason: formatMessage({ id: 'app.setting.hideheader.hint' }), action: ( this.changeSetting('autoHideHeader', checked)} /> ), }, { title: formatMessage({ id: 'app.setting.fixedsidebar' }), disabled: layout === 'topmenu', disabledReason: formatMessage({ id: 'app.setting.fixedsidebar.hint' }), action: ( this.changeSetting('fixSiderbar', checked)} /> ), }, ]; }; changeSetting = (key, value) => { const { setting } = this.props; const nextState = { ...setting }; nextState[key] = value; if (key === 'layout') { nextState.contentWidth = value === 'topmenu' ? 'Fixed' : 'Fluid'; } else if (key === 'fixedHeader' && !value) { nextState.autoHideHeader = false; } this.setState(nextState, () => { const { dispatch } = this.props; dispatch({ type: 'setting/changeSetting', payload: this.state, }); }); }; togglerContent = () => { const { collapse } = this.state; 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; const { collapse } = this.state; return ( } style={{ zIndex: 999, }} >
this.changeSetting('navTheme', value)} /> this.changeSetting('primaryColor', color)} /> this.changeSetting('layout', value)} /> this.changeSetting('colorWeak', checked)} /> ), }, ]} /> message.success(formatMessage({ id: 'app.setting.copyinfo' }))} > {formatMessage({ id: 'app.setting.production.hint' })}{' '} src/defaultSettings.js
} />
); } } export default SettingDrawer;