fork from bc4552c5a8
This commit is contained in:
51
client/components/Notify/Notify.js
Normal file
51
client/components/Notify/Notify.js
Normal file
@@ -0,0 +1,51 @@
|
||||
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: process.env.version,
|
||||
version: process.env.version
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const versions = 'https://www.fastmock.site/mock/1529fa78fa4c4880ad153d115084a940/yapi/versions';
|
||||
axios.get(versions).then(req => {
|
||||
if (req.status === 200) {
|
||||
this.setState({ newVersion: req.data.data[0] });
|
||||
} else {
|
||||
message.error('无法获取新版本信息!');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const isShow = this.state.newVersion > this.state.version;
|
||||
return (
|
||||
<div>
|
||||
{isShow && (
|
||||
<Alert
|
||||
message={
|
||||
<div>
|
||||
当前版本是:{this.state.version} 可升级到: {this.state.newVersion}
|
||||
|
||||
<a
|
||||
target="view_window"
|
||||
href="https://github.com/YMFE/yapi/blob/master/CHANGELOG.md"
|
||||
>
|
||||
版本详情
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
banner
|
||||
closable
|
||||
type="info"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user