diff --git a/src/components/Sidebar/LayoutSetting.js b/src/components/Sidebar/LayoutSetting.js
index 7670480cf3b28fa1a11d794e264afda5a32a18da..f4947402b7f27c74515e455cf335e004ac7e73bd 100644
--- a/src/components/Sidebar/LayoutSetting.js
+++ b/src/components/Sidebar/LayoutSetting.js
@@ -1,3 +1,4 @@
+import { Tooltip } from 'antd';
import React from 'react';
import NavSate from './navState';
@@ -20,24 +21,22 @@ const LayoutSetting = ({ value, onChange }) => {
margin: 8,
}}
>
-
+
))}
-
-
-
+
+
+
+
+
);
};
diff --git a/src/components/Sidebar/ThemeColor.less b/src/components/Sidebar/ThemeColor.less
index 9170eca31f1d9eae0d5ecd20144ace5b17cc995f..9dd141b423f36d52f327421e5322c0afc4621acf 100644
--- a/src/components/Sidebar/ThemeColor.less
+++ b/src/components/Sidebar/ThemeColor.less
@@ -19,7 +19,7 @@
width: 18px;
height: 18px;
margin: 4px;
- border: 2px solid hsl(90, 100%, 50%);
+ 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
index a1999753824d7bdb1c50a30e419c56fedad99e8a..1a538168f4243d71677f7de72dd03a38a4106307 100644
--- a/src/components/Sidebar/index.js
+++ b/src/components/Sidebar/index.js
@@ -57,7 +57,9 @@ class Sidebar extends PureComponent {
const propsState = this.propsToState(props);
this.state = { ...this.defaultstate, ...propsState };
}
-
+ componentDidMount() {
+ this.colorChange(this.state.themeColor);
+ }
getLayOutSetting = () => {
const { layout } = this.state;
return [
@@ -134,29 +136,37 @@ class Sidebar extends PureComponent {
this.changeSetting('collapse', !this.state.collapse);
};
colorChange = color => {
- window.less
- .modifyVars({
- '@primary-color': color,
- })
- .then(() => {})
- .catch(() => {
- message.error(`Failed to update theme`);
- });
this.changeSetting('themeColor', color);
+ this.setState(
+ {
+ 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',
};
return (
- <>
-
-
-
-
+
+
+
- >
+
);
}
}
diff --git a/src/components/Sidebar/index.less b/src/components/Sidebar/index.less
index c44432ba92f3562f431c9b4956e93c037812a71b..a58f689611a67c082833da5f0ccbe70fe68f0b9a 100644
--- a/src/components/Sidebar/index.less
+++ b/src/components/Sidebar/index.less
@@ -1,13 +1,4 @@
.sidebar {
- position: fixed;
- right: -336px;
- top: 150px;
- transition: 0.3s;
- display: flex;
- z-index: 9;
- &.show {
- right: 0;
- }
.mini_bar {
width: 50px;
height: 45px;
@@ -25,6 +16,11 @@
height: 28px;
}
}
+ :global {
+ .drawer {
+ z-index: 999;
+ }
+ }
}
.content {
diff --git a/src/components/Sidebar/navState.js b/src/components/Sidebar/navState.js
index fbabb24112d5887a8bb29ee8cb0bcebe8a36d17a..59090fa2470c500c1f4cc00a449aa63ec88c6659 100644
--- a/src/components/Sidebar/navState.js
+++ b/src/components/Sidebar/navState.js
@@ -2,28 +2,19 @@ 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',
+ 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',
+ 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',
+ 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',
},
};
diff --git a/src/layouts/LoadingPage.js b/src/layouts/LoadingPage.js
index 5b3356a6b61a6b3e3a4220ae1aa57831948b8669..5a4167be825e5847db37f42d7685cfa80c284438 100644
--- a/src/layouts/LoadingPage.js
+++ b/src/layouts/LoadingPage.js
@@ -45,19 +45,7 @@ class LoadingPage extends PureComponent {
this.props.dispatch({
type: 'user/fetchCurrent',
});
- const urlParams = new URL(window.location.href);
- const settingString = urlParams.searchParams.get('setting');
- if (settingString) {
- const setting = {};
- settingString.split(';').forEach(keyValue => {
- const [key, value] = keyValue.split(':');
- setting[key] = value;
- });
- this.props.dispatch({
- type: 'setting/changeSetting',
- payload: setting,
- });
- }
+ this.initSetting();
this.hideLoading();
}
componentWillUnmount() {
@@ -68,6 +56,27 @@ class LoadingPage extends PureComponent {
loading: false,
});
}
+ initSetting() {
+ const setting = {
+ collapse: false,
+ silderTheme: 'dark',
+ themeColor: '#1890FF',
+ layout: 'sidemenu',
+ grid: 'Fluid',
+ fixedHeader: false,
+ autoHideHeader: false,
+ fixSiderbar: false,
+ colorWeak: 'close',
+ };
+ const urlParams = new URL(window.location.href);
+ Object.keys(setting).forEach(key => {
+ setting[key] = urlParams.searchParams.get(key);
+ });
+ this.props.dispatch({
+ type: 'setting/changeSetting',
+ payload: setting,
+ });
+ }
render() {
if (this.state.loading) {
return (
diff --git a/src/models/setting.js b/src/models/setting.js
index e2a554e6c725ab1ccbfb1565f9c4a738f506b416..a7b3a6fbd42127202aac000d76b750dfbd168b62 100644
--- a/src/models/setting.js
+++ b/src/models/setting.js
@@ -15,13 +15,16 @@ export default {
reducers: {
changeSetting(state, { payload }) {
const urlParams = new URL(window.location.href);
- let urlParamsString = '';
- Object.keys(payload).forEach((key) => {
- if (payload[key] && state[key] !== undefined && key !== 'collapse') {
- urlParamsString += `${key}:${payload[key]};`;
+ Object.keys(payload).forEach(key => {
+ if (key === 'collapse') {
+ return;
}
+ let value = payload[key];
+ if (value === true) {
+ value = 1;
+ }
+ urlParams.searchParams.set(key, value);
});
- urlParams.searchParams.set('setting', urlParamsString);
window.history.replaceState(null, 'setting', urlParams.href);
return {
...state,