fix: 修复版本提醒功能bug和默认在新版本开启了版本提醒功能

This commit is contained in:
suwenxiong 2019-02-04 08:09:52 +08:00
parent ccaa32a507
commit 6dab1df55e
2 changed files with 8 additions and 6 deletions

View File

@ -69,7 +69,8 @@ plugin.emitHook('app_route', AppRoute);
@connect(
state => {
return {
loginState: state.user.loginState
loginState: state.user.loginState,
curUserRole: state.user.role
};
},
{
@ -86,7 +87,8 @@ export default class App extends Component {
static propTypes = {
checkLoginState: PropTypes.func,
loginState: PropTypes.number
loginState: PropTypes.number,
curUserRole: PropTypes.string
};
componentDidMount() {
@ -110,7 +112,7 @@ export default class App extends Component {
<Router getUserConfirmation={this.showConfirm}>
<div className="g-main">
<div className="router-main">
{process.env.versionNotify && <Notify />}
{this.props.curUserRole === 'admin' && <Notify />}
{alertContent()}
{this.props.loginState !== 1 ? <Header /> : null}
<div className="router-container">

View File

@ -7,14 +7,14 @@ export default class Notify extends Component {
super(props);
this.state = {
newVersion: process.env.version,
version: process.env.version
version: 'v1.0'
};
}
componentDidMount() {
axios.get('http://yapi.demo.qunar.com/publicapi/versions').then(req => {
axios.get('https://www.easy-mock.com/mock/5c2851e3d84c733cb500c3b9/yapi/versions').then(req => {
if (req.status === 200) {
this.setState({ newVersion: req.data[0].version });
this.setState({ newVersion: req.data.data[0] });
} else {
message.error('无法获取新版本信息!');
}