import React from 'react'; import { FormattedMessage, injectIntl } from 'react-intl'; import { Select, Modal } from 'antd'; import { version as antdVersion } from '../../../../package.json'; import * as utils from '../utils'; const Option = Select.Option; function isLocalStorageNameSupported() { const testKey = 'test'; const storage = window.localStorage; try { storage.setItem(testKey, '1'); storage.removeItem(testKey); return true; } catch (error) { return false; } } class Footer extends React.Component { componentDidMount() { // for some iOS // http://stackoverflow.com/a/14555361 if (!isLocalStorageNameSupported()) { return; } // 大版本发布后全局弹窗提示 // 1. 点击『知道了』之后不再提示 // 2. 超过截止日期后不再提示 if ( localStorage.getItem('antd@2.0.0-notification-sent') !== 'true' && Date.now() < new Date('2016/10/14').getTime() ) { this.infoNewVersion(); } } infoNewVersion() { const messages = this.props.intl.messages; Modal.info({ title: messages['app.publish.title'], content: (
Ant Design

{messages['app.publish.greeting']} antd@2.0.0 {messages['app.publish.intro']} {messages['app.publish.old-version-guide']} 1x.ant.design {messages['app.publish.old-version-tips']}

), okText: 'OK', onOk: () => localStorage.setItem('antd@2.0.0-notification-sent', 'true'), className: 'new-version-info-modal', width: 470, }); } handleVersionChange = (url) => { const currentUrl = window.location.href; const currentPathname = window.location.pathname; window.location.href = currentUrl.replace(window.location.origin, url) .replace(currentPathname, utils.getLocalizedPathname(currentPathname)); } render() { const { themeConfig } = this.props; const docVersions = { ...themeConfig.docVersions, [antdVersion]: antdVersion }; const options = Object.keys(docVersions) .map(version => ); return ( ); } } export default injectIntl(Footer);