feat: 增加版本提醒

This commit is contained in:
gandchuan 2018-07-09 11:11:21 +08:00
parent 1d97e71de4
commit e3ab4b2a93
8 changed files with 61 additions and 4 deletions

View File

@ -25,6 +25,7 @@ module.exports = {
"no-console": ["off"],
"import/no-unresolved": ["off"],
"react/no-find-dom-node": ["off"]
// "react/no-unescaped-entities": 0
}
};

1
.npmrc Normal file
View File

@ -0,0 +1 @@
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/

BIN
.package.json.swp Normal file

Binary file not shown.

View File

@ -12,7 +12,7 @@ import Loading from './components/Loading/Loading';
import MyPopConfirm from './components/MyPopConfirm/MyPopConfirm';
import { checkLoginState } from './reducer/modules/user';
import { requireAuthentication } from './components/AuthenticatedComponent';
import Notify from './components/Notify/Notify'
const plugin = require('client/plugin.js');
@ -106,6 +106,7 @@ export default class App extends Component {
<Router getUserConfirmation={this.showConfirm}>
<div className="g-main">
<div className="router-main">
<Notify />
{alertContent()}
{this.props.loginState !== 1 ? <Header /> : null}
<div className="router-container">

View File

@ -87,7 +87,7 @@ Footer.defaultProps = {
title: 'Copyright © 2018 YMFE',
linkList: [
{
itemTitle: '版本: ' + version,
itemTitle: `版本: ${version} `,
itemLink: 'https://github.com/YMFE/yapi/blob/master/CHANGELOG.md'
}, {
itemTitle: '使用文档',

View File

@ -0,0 +1,52 @@
import React, { Component } from 'react';
import axios from 'axios';
import { Alert, message } from 'antd';
export default class Notify extends Component {
constructor(props) {
super(props);
this.state = {
newVersion: '',
version: process.env.version,
isOpen: process.env.isVersionInfo
};
}
componentDidMount() {
axios.get('http://yapi.demo.qunar.com/publicapi/versions').then(req => {
if (req.status === 200) {
this.setState({ newVersion: req.data[0].version });
} else {
message.error('无法获取新版本信息!');
}
});
}
render() {
// if (this.state.isOpen && this.state.newVersion === this.state.version) {
const isShow = this.state.isOpen && this.state.newVersion === this.state.version;
return (
<div>
{isShow && (
<Alert
message={
<div>
当前版本是{this.state.version} 可升级到: {this.state.newVersion}
&nbsp;
<a
target="view_window"
href="https://github.com/YMFE/yapi/blob/master/CHANGELOG.md"
>
版本详情
</a>
</div>
}
banner
closable
type="info"
/>
)}
</div>
);
}
}

View File

@ -117,7 +117,7 @@ export default (state = initialState, action) => {
studyTip: 0
};
}
case SET_IMAGE_URL: {
// console.log('state', state);
return {

View File

@ -10,6 +10,7 @@ var assetsPluginInstance = new AssetsPlugin({
})
var fs = require('fs');
var package = require('./package.json')
var yapi = require('./server/yapi')
var compressPlugin = new CompressionPlugin({
asset: "[path].gz[query]",
@ -139,7 +140,8 @@ module.exports = {
baseConfig.plugins.push(new this.webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(ENV_PARAMS),
'process.env.version' : JSON.stringify(package.version)
'process.env.version' : JSON.stringify(package.version),
'process.env.isVersionInfo' : yapi.WEBCONFIG.version
}))
//初始化配置