Commit 56ce1efa authored by jim's avatar jim Committed by 陈帅

add build message

parent c0bf7546
import { Tooltip } from 'antd';
import React from 'react'; import React from 'react';
import NavSate from './navState'; import NavSate from './navState';
...@@ -20,24 +21,22 @@ const LayoutSetting = ({ value, onChange }) => { ...@@ -20,24 +21,22 @@ const LayoutSetting = ({ value, onChange }) => {
margin: 8, margin: 8,
}} }}
> >
<NavSate <NavSate type={layout} state={value === layout ? 'active' : 'default'} alt={layout} />
type={layout}
state={value === layout ? 'active' : 'default'}
alt={layout}
/>
</div> </div>
))} ))}
<div <Tooltip title="等待后期实现!">
key="topside" <div
style={{ key="topside"
width: 70, style={{
height: 44, width: 70,
textAlign: 'center', height: 44,
margin: 8, textAlign: 'center',
}} margin: 8,
> }}
<NavSate type="topside" state="disable" alt="topside" /> >
</div> <NavSate type="topside" state="disable" alt="topside" />
</div>
</Tooltip>
</div> </div>
); );
}; };
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
width: 18px; width: 18px;
height: 18px; height: 18px;
margin: 4px; 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%); box-shadow: 0 0 4px 0 hsl(90, 100%, 50%);
} }
} }
......
...@@ -57,7 +57,9 @@ class Sidebar extends PureComponent { ...@@ -57,7 +57,9 @@ class Sidebar extends PureComponent {
const propsState = this.propsToState(props); const propsState = this.propsToState(props);
this.state = { ...this.defaultstate, ...propsState }; this.state = { ...this.defaultstate, ...propsState };
} }
componentDidMount() {
this.colorChange(this.state.themeColor);
}
getLayOutSetting = () => { getLayOutSetting = () => {
const { layout } = this.state; const { layout } = this.state;
return [ return [
...@@ -134,29 +136,37 @@ class Sidebar extends PureComponent { ...@@ -134,29 +136,37 @@ class Sidebar extends PureComponent {
this.changeSetting('collapse', !this.state.collapse); this.changeSetting('collapse', !this.state.collapse);
}; };
colorChange = color => { colorChange = color => {
window.less
.modifyVars({
'@primary-color': color,
})
.then(() => {})
.catch(() => {
message.error(`Failed to update theme`);
});
this.changeSetting('themeColor', color); 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() { render() {
const radioStyle = { const radioStyle = {
display: 'block', display: 'block',
}; };
return ( return (
<> <div className={styles.sidebar}>
<div className={styles.sidebar}> <div className={styles.mini_bar} onClick={this.togglerContent}>
<div className={styles.mini_bar} onClick={this.togglerContent}> <img
<img alt="logo"
alt="logo" src="https://gw.alipayobjects.com/zos/rmsportal/ApQgLmeZDNJMomKNvavq.svg"
src="https://gw.alipayobjects.com/zos/rmsportal/ApQgLmeZDNJMomKNvavq.svg" />
/>
</div>
</div> </div>
<DrawerMenu <DrawerMenu
parent={null} parent={null}
...@@ -223,7 +233,7 @@ class Sidebar extends PureComponent { ...@@ -223,7 +233,7 @@ class Sidebar extends PureComponent {
</Body> </Body>
</div> </div>
</DrawerMenu> </DrawerMenu>
</> </div>
); );
} }
} }
......
.sidebar { .sidebar {
position: fixed;
right: -336px;
top: 150px;
transition: 0.3s;
display: flex;
z-index: 9;
&.show {
right: 0;
}
.mini_bar { .mini_bar {
width: 50px; width: 50px;
height: 45px; height: 45px;
...@@ -25,6 +16,11 @@ ...@@ -25,6 +16,11 @@
height: 28px; height: 28px;
} }
} }
:global {
.drawer {
z-index: 999;
}
}
} }
.content { .content {
......
...@@ -2,28 +2,19 @@ import React from 'react'; ...@@ -2,28 +2,19 @@ import React from 'react';
const UrlMap = { const UrlMap = {
sidemenu: { sidemenu: {
active: active: 'https://gw.alipayobjects.com/zos/rmsportal/WEqgEeCsLvecmwJwbhif.svg',
'https://gw.alipayobjects.com/zos/rmsportal/WEqgEeCsLvecmwJwbhif.svg', default: 'https://gw.alipayobjects.com/zos/rmsportal/bjdhEDZlJzyMlyGbFQQd.svg',
default: disable: 'https://gw.alipayobjects.com/zos/rmsportal/VeCtUculrOjKzkzSzrye.svg',
'https://gw.alipayobjects.com/zos/rmsportal/bjdhEDZlJzyMlyGbFQQd.svg',
disable:
'https://gw.alipayobjects.com/zos/rmsportal/VeCtUculrOjKzkzSzrye.svg',
}, },
topside: { topside: {
active: active: 'https://gw.alipayobjects.com/zos/rmsportal/RbntcRzDHttDvYfKxsPc.svg',
'https://gw.alipayobjects.com/zos/rmsportal/RbntcRzDHttDvYfKxsPc.svg', default: 'https://gw.alipayobjects.com/zos/rmsportal/gqjBdnSHfVYIFvpGbLZV.svg',
default: disable: 'https://gw.alipayobjects.com/zos/rmsportal/VlSlQQkUGdbcOZdbUgMp.svg',
'https://gw.alipayobjects.com/zos/rmsportal/gqjBdnSHfVYIFvpGbLZV.svg',
disable:
'https://gw.alipayobjects.com/zos/rmsportal/VlSlQQkUGdbcOZdbUgMp.svg',
}, },
topmenu: { topmenu: {
active: active: 'https://gw.alipayobjects.com/zos/rmsportal/nWoQtAGvMihfwxKZEzAi.svg',
'https://gw.alipayobjects.com/zos/rmsportal/nWoQtAGvMihfwxKZEzAi.svg', default: 'https://gw.alipayobjects.com/zos/rmsportal/tbfuZcaGaYQGyeaiTaDg.svg',
default: disable: 'https://gw.alipayobjects.com/zos/rmsportal/VYNKTivFAQOBBbZkkWNb.svg',
'https://gw.alipayobjects.com/zos/rmsportal/tbfuZcaGaYQGyeaiTaDg.svg',
disable:
'https://gw.alipayobjects.com/zos/rmsportal/VYNKTivFAQOBBbZkkWNb.svg',
}, },
}; };
......
...@@ -45,19 +45,7 @@ class LoadingPage extends PureComponent { ...@@ -45,19 +45,7 @@ class LoadingPage extends PureComponent {
this.props.dispatch({ this.props.dispatch({
type: 'user/fetchCurrent', type: 'user/fetchCurrent',
}); });
const urlParams = new URL(window.location.href); this.initSetting();
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.hideLoading(); this.hideLoading();
} }
componentWillUnmount() { componentWillUnmount() {
...@@ -68,6 +56,27 @@ class LoadingPage extends PureComponent { ...@@ -68,6 +56,27 @@ class LoadingPage extends PureComponent {
loading: false, 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() { render() {
if (this.state.loading) { if (this.state.loading) {
return ( return (
......
...@@ -15,13 +15,16 @@ export default { ...@@ -15,13 +15,16 @@ export default {
reducers: { reducers: {
changeSetting(state, { payload }) { changeSetting(state, { payload }) {
const urlParams = new URL(window.location.href); const urlParams = new URL(window.location.href);
let urlParamsString = ''; Object.keys(payload).forEach(key => {
Object.keys(payload).forEach((key) => { if (key === 'collapse') {
if (payload[key] && state[key] !== undefined && key !== 'collapse') { return;
urlParamsString += `${key}:${payload[key]};`;
} }
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); window.history.replaceState(null, 'setting', urlParams.href);
return { return {
...state, ...state,
......
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