diff --git a/.eslintrc.js b/.eslintrc.js index b6538029..b9a3771b 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,6 +25,7 @@ module.exports = { "no-console": ["off"], "import/no-unresolved": ["off"], "react/no-find-dom-node": ["off"] + // "react/no-unescaped-entities": 0 } }; diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..a121360d --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ \ No newline at end of file diff --git a/.package.json.swp b/.package.json.swp new file mode 100644 index 00000000..0fe17186 Binary files /dev/null and b/.package.json.swp differ diff --git a/client/Application.js b/client/Application.js index bbb89885..c7b7c517 100755 --- a/client/Application.js +++ b/client/Application.js @@ -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 {
+ {alertContent()} {this.props.loginState !== 1 ?
: null}
diff --git a/client/components/Footer/Footer.js b/client/components/Footer/Footer.js index 17e40ea5..c52f467c 100755 --- a/client/components/Footer/Footer.js +++ b/client/components/Footer/Footer.js @@ -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: '使用文档', diff --git a/client/components/Notify/Notify.js b/client/components/Notify/Notify.js new file mode 100644 index 00000000..539f162d --- /dev/null +++ b/client/components/Notify/Notify.js @@ -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 ( +
+ {isShow && ( + + 当前版本是:{this.state.version} 可升级到: {this.state.newVersion} +   + + 版本详情 + +
+ } + banner + closable + type="info" + /> + )} +
+ ); + } +} diff --git a/client/reducer/modules/user.js b/client/reducer/modules/user.js index e17cd08d..951fb822 100755 --- a/client/reducer/modules/user.js +++ b/client/reducer/modules/user.js @@ -117,7 +117,7 @@ export default (state = initialState, action) => { studyTip: 0 }; } - + case SET_IMAGE_URL: { // console.log('state', state); return { diff --git a/ykit.config.js b/ykit.config.js index b502a7c2..38f6c4d9 100755 --- a/ykit.config.js +++ b/ykit.config.js @@ -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 })) //初始化配置