diff --git a/package.json b/package.json
index cb2856771e46369c57ec08e6e0bbd094661b1de3..2e44151aea73d11914021a800e05185c98e7a9cb 100755
--- a/package.json
+++ b/package.json
@@ -78,7 +78,7 @@
"pro-download": "^1.0.1",
"redbox-react": "^1.5.0",
"regenerator-runtime": "^0.11.1",
- "roadhog": "2.3.0",
+ "roadhog": "^2.4.2",
"roadhog-api-doc": "^1.0.3",
"stylelint": "^9.2.1",
"stylelint-config-prettier": "^3.0.4",
diff --git a/src/components/SettingDarwer/BlockChecbox.js b/src/components/SettingDarwer/BlockChecbox.js
new file mode 100644
index 0000000000000000000000000000000000000000..2f05ec66394939a8d670188d44c8b3e565a99dec
--- /dev/null
+++ b/src/components/SettingDarwer/BlockChecbox.js
@@ -0,0 +1,33 @@
+import { Icon } from 'antd';
+import React from 'react';
+import style from './index.less';
+
+const BlockChecbox = ({ value, onChange, list }) => {
+ return (
+
+ {list.map(item => {
+ return (
+
{
+ onChange(item.key);
+ }}
+ >
+
+
+
+
+
+ );
+ })}
+
+ );
+};
+
+export default BlockChecbox;
diff --git a/src/components/SettingDarwer/ThemeColor.js b/src/components/SettingDarwer/ThemeColor.js
new file mode 100644
index 0000000000000000000000000000000000000000..63bf4782f6b077303f6e54fdcc6cfee80fd47102
--- /dev/null
+++ b/src/components/SettingDarwer/ThemeColor.js
@@ -0,0 +1,52 @@
+import { Icon } from 'antd';
+import React from 'react';
+import styles from './ThemeColor.less';
+
+const Tag = ({ color, check, ...rest }) => {
+ return (
+
+ {check ? : ''}
+
+ );
+};
+
+const ThemeColor = ({ colors, value, onChange }) => {
+ let colorList = colors;
+ if (!colors) {
+ colorList = [
+ '#F5222D',
+ '#FA541C',
+ '#FAAD14',
+ '#13C2C2',
+ '#52C41A',
+ '#1890FF',
+ '#2F54EB',
+ '#722ED1',
+ ];
+ }
+ return (
+
+
主题色
+
+ {colorList.map(color => {
+ return (
+ onChange && onChange(color)}
+ />
+ );
+ })}
+
+
+ );
+};
+
+export default ThemeColor;
diff --git a/src/components/SettingDarwer/ThemeColor.less b/src/components/SettingDarwer/ThemeColor.less
new file mode 100644
index 0000000000000000000000000000000000000000..4983eb9c67d207cfa4f9470a5a82068eb9c20c71
--- /dev/null
+++ b/src/components/SettingDarwer/ThemeColor.less
@@ -0,0 +1,21 @@
+.themeColor {
+ overflow: hidden;
+ margin-top: 24px;
+ .title {
+ font-size: 14px;
+ color: rgba(0, 0, 0, 0.65);
+ line-height: 22px;
+ margin-bottom: 12px;
+ }
+ .colorBlock {
+ width: 20px;
+ height: 20px;
+ border-radius: 2px;
+ float: left;
+ cursor: pointer;
+ margin-right: 8px;
+ text-align: center;
+ color: #fff;
+ font-weight: bold;
+ }
+}
diff --git a/src/components/SettingDarwer/index.js b/src/components/SettingDarwer/index.js
new file mode 100644
index 0000000000000000000000000000000000000000..e4a534e3f0336088563ff155da3d9ac803cd7176
--- /dev/null
+++ b/src/components/SettingDarwer/index.js
@@ -0,0 +1,187 @@
+import React, { PureComponent } from 'react';
+import { Select, message, List, Switch, Divider } from 'antd';
+import DrawerMenu from 'rc-drawer-menu';
+import { connect } from 'dva';
+import styles from './index.less';
+import ThemeColor from './ThemeColor';
+import BlockChecbox from './BlockChecbox';
+
+const Body = ({ children, title, style }) => (
+
+
{title}
+ {children}
+
+);
+
+@connect(({ setting }) => ({ setting }))
+class SettingDarwer extends PureComponent {
+ componentDidMount() {
+ const { themeColor } = this.props.setting;
+ if (themeColor !== '#1890FF') {
+ this.colorChange(themeColor);
+ }
+ }
+ getLayOutSetting = () => {
+ const { grid, fixedHeader, autoHideHeader, fixSiderbar } = this.props.setting;
+ return [
+ {
+ title: '栅格模式',
+ action: [
+ ,
+ ],
+ },
+ {
+ title: 'Fixed Header',
+ action: [
+ this.changeSetting('fixedHeader', checked)}
+ />,
+ ],
+ },
+ {
+ title: '下滑时隐藏 Header',
+ action: [
+ this.changeSetting('autoHideHeader', checked)}
+ />,
+ ],
+ },
+ {
+ title: 'Fix Siderbar',
+ action: [
+ this.changeSetting('fixSiderbar', checked)}
+ />,
+ ],
+ },
+ ];
+ };
+ changeSetting = (key, value) => {
+ const nextState = { ...this.props.setting };
+ nextState[key] = value;
+ if (key === 'layout') {
+ if (value === 'topmenu') {
+ nextState.grid = 'Wide';
+ } else {
+ nextState.grid = 'Fluid';
+ }
+ }
+ this.setState(nextState, () => {
+ this.props.dispatch({
+ type: 'setting/changeSetting',
+ payload: this.state,
+ });
+ });
+ };
+ togglerContent = () => {
+ this.changeSetting('collapse', !this.props.setting.collapse);
+ };
+ colorChange = color => {
+ this.changeSetting('themeColor', color);
+ const hideMessage = message.loading('正在编译主题!', 0);
+ setTimeout(() => {
+ window.less
+ .modifyVars({
+ '@primary-color': color,
+ })
+ .then(() => {
+ hideMessage();
+ })
+ .catch(() => {
+ message.error(`Failed to update theme`);
+ });
+ }, 200);
+ };
+ render() {
+ const { collapse, silderTheme, themeColor, layout } = this.props.setting;
+ return (
+
+
+
+
+
+
+
+
this.changeSetting('silderTheme', value)}
+ />
+
+
+
+
+
+
+
+ this.changeSetting('layout', value)}
+ />
+
+
+ {item.title}}
+ />
+
+
+
+ );
+ }
+}
+
+export default SettingDarwer;
diff --git a/src/components/Sidebar/index.less b/src/components/SettingDarwer/index.less
similarity index 59%
rename from src/components/Sidebar/index.less
rename to src/components/SettingDarwer/index.less
index 3ce62d07a4067da6770b23411997b9671933b5ce..5b196af21329bf58098601c4a1c0c226eb987cdc 100644
--- a/src/components/Sidebar/index.less
+++ b/src/components/SettingDarwer/index.less
@@ -1,4 +1,6 @@
-.sidebar {
+@import '~antd/lib/style/themes/default.less';
+
+.settingDarwer {
.mini_bar {
width: 50px;
height: 45px;
@@ -26,51 +28,50 @@
}
.content {
- width: 336px;
+ width: 273px;
height: 100%;
+ padding: 24px;
background: #fff;
- :global {
- .ant-switch-checked {
- background-color: #87d068;
- }
- .ant-list-item {
- padding-top: 7px;
- padding-bottom: 7px;
- }
- }
}
-.layoutSetting {
- margin: 5px;
+.blockChecbox {
display: flex;
.item {
+ margin-right: 16px;
+ position: relative;
+ // box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
+ border-radius: 4px;
cursor: pointer;
- width: 70px;
- height: 44px;
- text-align: center;
- margin: 8px;
+ img {
+ width: 48px;
+ }
+ }
+ .selectIcon {
+ position: absolute;
+ top: 0;
+ right: 0;
+ width: 100%;
+ padding-top: 15px;
+ padding-left: 24px;
+ height: 100%;
+ color: @primary-color;
+ font-size: 14px;
+ font-weight: bold;
}
}
.color_block {
width: 38px;
height: 22px;
margin: 4px;
+ border-radius: 4px;
cursor: pointer;
margin-right: 12px;
display: inline-block;
vertical-align: middle;
- background: #002140;
- border-radius: 2px;
-}
-.color_block_title {
- display: inline-block;
- font-size: 14px;
- color: rgba(0, 0, 0, 0.65);
- line-height: 22px;
}
-.bodyTitle {
+.title {
font-size: 14px;
color: rgba(0, 0, 0, 0.85);
line-height: 22px;
- margin-bottom: 10px;
+ margin-bottom: 12px;
}
diff --git a/src/components/Sidebar/LayoutSetting.js b/src/components/Sidebar/LayoutSetting.js
deleted file mode 100644
index b98b960190b5da0243ce2dfadeb2690f3d16c24a..0000000000000000000000000000000000000000
--- a/src/components/Sidebar/LayoutSetting.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import { Tooltip } from 'antd';
-import React from 'react';
-import NavSate from './navState';
-import style from './index.less';
-
-const LayoutSetting = ({ value, onChange }) => {
- return (
-
- {['sidemenu', 'topmenu'].map(layout => (
-
onChange && onChange(layout)} key={layout}>
-
-
- ))}
-
-
-
-
-
-
- );
-};
-
-export default LayoutSetting;
diff --git a/src/components/Sidebar/ThemeColor.js b/src/components/Sidebar/ThemeColor.js
deleted file mode 100644
index cd961fcfce70b4e7c07b3884e1561dd62446fb12..0000000000000000000000000000000000000000
--- a/src/components/Sidebar/ThemeColor.js
+++ /dev/null
@@ -1,52 +0,0 @@
-import React from 'react';
-import styles from './ThemeColor.less';
-
-const Tag = ({ color, ...rest }) => {
- return (
-
- );
-};
-
-const ThemeColor = ({ colors, value, onChange }) => {
- let colorList = colors;
- if (!colors) {
- colorList = [
- '#F5222D',
- '#FA541C',
- '#FA8C16',
- '#FAAD14',
- '#FADB14',
- '#A0D911',
- '#52C41A',
- '#13C2C2',
- '#1890FF',
- '#2F54EB',
- '#722ED1',
- '#EB2F96',
- ];
- }
- return (
-
-
主题颜色
- {colorList.map(color => {
- const classname =
- value === color ? `${styles.colorBlock} ${styles.active}` : styles.colorBlock;
- return (
- onChange && onChange(color)}
- />
- );
- })}
-
- );
-};
-
-export default ThemeColor;
diff --git a/src/components/Sidebar/ThemeColor.less b/src/components/Sidebar/ThemeColor.less
deleted file mode 100644
index e9e802f65f9bb1a55dca63f45ff7285fa0248a75..0000000000000000000000000000000000000000
--- a/src/components/Sidebar/ThemeColor.less
+++ /dev/null
@@ -1,27 +0,0 @@
-.themeColor {
- overflow: hidden;
- margin-top: 15px;
- margin-left: -5px;
- margin-right: -5px;
- .title {
- font-size: 14px;
- color: rgba(0, 0, 0, 0.65);
- line-height: 22px;
- margin-bottom: 5px;
- }
- .colorBlock {
- width: 16px;
- height: 16px;
- border-radius: 2px;
- float: left;
- cursor: pointer;
- margin: 5px;
- &.active {
- width: 18px;
- height: 18px;
- margin: 4px;
- border: 2px solid hsl(90, 100%, 50%);
- box-shadow: 0 0 4px 0 hsl(90, 100%, 50%);
- }
- }
-}
diff --git a/src/components/Sidebar/index.js b/src/components/Sidebar/index.js
deleted file mode 100644
index b6436c8e1ac62c567ccd9443aedb2ee04f7418d3..0000000000000000000000000000000000000000
--- a/src/components/Sidebar/index.js
+++ /dev/null
@@ -1,206 +0,0 @@
-import React, { PureComponent, Fragment } from 'react';
-import { Select, message, List, Switch, Divider, Radio } from 'antd';
-import DrawerMenu from 'rc-drawer-menu';
-import { connect } from 'dva';
-import styles from './index.less';
-import ThemeColor from './ThemeColor';
-import LayoutSeting from './LayoutSetting';
-
-const RadioGroup = Radio.Group;
-
-const ColorBlock = ({ color, title }) => (
-
-
- {title}
-
-);
-
-const Body = ({ children, title, style }) => (
-
-
{title}
- {children}
-
-);
-@connect(({ setting }) => ({ setting }))
-class Sidebar extends PureComponent {
- componentDidMount() {
- const { themeColor } = this.props.setting;
- if (themeColor !== '#1890FF') {
- this.colorChange(themeColor);
- }
- }
- getLayOutSetting = () => {
- const { grid, fixedHeader, autoHideHeader, fixSiderbar, layout } = this.props.setting;
- return [
- {
- title: '栅格模式',
- isShow: true,
- action: [
- ,
- ],
- },
- {
- title: 'Fixed Header',
- isShow: true,
- action: [
- this.changeSetting('fixedHeader', checked)}
- />,
- ],
- },
- {
- title: '↳ 下滑时隐藏 Header',
- isShow: true,
- action: [
- this.changeSetting('autoHideHeader', checked)}
- />,
- ],
- },
- {
- title: 'Fix Siderbar',
- isShow: layout === 'sidemenu',
- action: [],
- },
- ].filter(item => item.isShow);
- };
- fixSiderbar = checked => {
- this.changeSetting('fixSiderbar', checked);
- };
- changeSetting = (key, value) => {
- const nextState = { ...this.props.setting };
- nextState[key] = value;
- if (key === 'layout') {
- if (value === 'topmenu') {
- nextState.grid = 'Wide';
- } else {
- nextState.grid = 'Fluid';
- }
- }
- this.setState(nextState, () => {
- this.props.dispatch({
- type: 'setting/changeSetting',
- payload: this.state,
- });
- });
- };
- togglerContent = () => {
- this.changeSetting('collapse', !this.props.setting.collapse);
- };
- colorChange = color => {
- this.changeSetting('themeColor', color);
- const hideMessage = message.loading('正在编译主题!', 0);
- window.less
- .modifyVars({
- '@primary-color': color,
- })
- .then(() => {
- hideMessage();
- })
- .catch(() => {
- message.error(`Failed to update theme`);
- });
- };
- render() {
- const radioStyle = {
- display: 'block',
- };
- const { collapse, silderTheme, themeColor, layout, colorWeak } = this.props.setting;
- return (
-
-
-
-
-
-
-
-
this.changeSetting('silderTheme', target.value)}
- value={silderTheme}
- >
-
-
-
-
-
-
-
-
-
-
-
-
this.changeSetting('layout', value)}
- />
- {item.title}}
- />
-
-
-
- this.changeSetting('colorWeak', value)}
- style={{ width: 120 }}
- >
- 打开
- 关闭
- ,
- ],
- },
- ]}
- renderItem={item => {item.title}}
- />
-
-
-
-
- );
- }
-}
-
-export default Sidebar;
diff --git a/src/components/Sidebar/navState.js b/src/components/Sidebar/navState.js
deleted file mode 100644
index 59090fa2470c500c1f4cc00a449aa63ec88c6659..0000000000000000000000000000000000000000
--- a/src/components/Sidebar/navState.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import React from 'react';
-
-const UrlMap = {
- sidemenu: {
- active: 'https://gw.alipayobjects.com/zos/rmsportal/WEqgEeCsLvecmwJwbhif.svg',
- default: 'https://gw.alipayobjects.com/zos/rmsportal/bjdhEDZlJzyMlyGbFQQd.svg',
- disable: 'https://gw.alipayobjects.com/zos/rmsportal/VeCtUculrOjKzkzSzrye.svg',
- },
- topside: {
- active: 'https://gw.alipayobjects.com/zos/rmsportal/RbntcRzDHttDvYfKxsPc.svg',
- default: 'https://gw.alipayobjects.com/zos/rmsportal/gqjBdnSHfVYIFvpGbLZV.svg',
- disable: 'https://gw.alipayobjects.com/zos/rmsportal/VlSlQQkUGdbcOZdbUgMp.svg',
- },
- topmenu: {
- active: 'https://gw.alipayobjects.com/zos/rmsportal/nWoQtAGvMihfwxKZEzAi.svg',
- default: 'https://gw.alipayobjects.com/zos/rmsportal/tbfuZcaGaYQGyeaiTaDg.svg',
- disable: 'https://gw.alipayobjects.com/zos/rmsportal/VYNKTivFAQOBBbZkkWNb.svg',
- },
-};
-
-const navState = ({ alt, type, state }) => {
- const url = UrlMap[type][state];
- return ;
-};
-
-export default navState;
diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js
index d4853390c28fe97adb35ef14df2ab9297d1e9e34..9292de7eec2f3610e39efeedebacc87fed70aba5 100644
--- a/src/layouts/BasicLayout.js
+++ b/src/layouts/BasicLayout.js
@@ -10,7 +10,7 @@ import SiderMenu from '../components/SiderMenu';
import NotFound from '../routes/Exception/404';
import { getRoutes } from '../utils/utils';
import Authorized from '../utils/Authorized';
-import Sidebar from '../components/Sidebar';
+import SettingDarwer from '../components/SettingDarwer';
import logo from '../assets/logo.svg';
import Footer from './Footer';
import Header from './Header';
@@ -176,7 +176,7 @@ class BasicLayout extends React.PureComponent {
{layout}
-
+
)}
diff --git a/webpack.config.js b/webpack.config.js
index 13f3b9643a35e130eaf950dd7a3f2dfe28b70e3a..85f19db3650d8c0832e62c2a98545efd3cc44e6a 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -5,7 +5,7 @@ const path = require('path');
export default webpackConfig => {
const options = {
antDir: path.join(__dirname, './node_modules/antd'),
- stylesDir: path.join(__dirname, './src'),
+ stylesDir: path.join(__dirname, './src/'),
varFile: path.join(__dirname, './node_modules/antd/lib/style/themes/default.less'),
mainLessFile: path.join(__dirname, './src/index.less'),
themeVariables: ['@primary-color'],