docs: add techui promotion (#27465)

* feat: add techui promotion

* feat: change button to menu

* feat: change TechUI menu position
pull/27473/head
大猫 4 years ago committed by GitHub
parent 9052af449b
commit 5c0799d5ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,4 +4,4 @@ title: 组件总览
type: 组件总览 type: 组件总览
--- ---
`antd` 为 Web 应用提供了丰富的基础 UI 组件,我们还将持续探索企业级应用的最佳 UI 实践。除了官方组件,我们也提供了[社区精选组件](/docs/react/recommendation)作为必要的补充。 `antd` 为 Web 应用提供了丰富的基础 UI 组件,我们还将持续探索企业级应用的最佳 UI 实践。除了官方组件,我们也提供了[社区精选组件](/docs/react/recommendation)作为必要的补充,另外如果您是内网用户,欢迎尝试使用 [TechUI](https://techui.alipay.com)

@ -17,6 +17,7 @@ export interface NavigationProps extends SharedProps {
responsive: null | 'narrow' | 'crowded'; responsive: null | 'narrow' | 'crowded';
location: { pathname: string; query: any }; location: { pathname: string; query: any };
directionText: string; directionText: string;
showTechUIButton: boolean;
onLangChange: () => void; onLangChange: () => void;
onDirectionChange: () => void; onDirectionChange: () => void;
} }
@ -29,6 +30,7 @@ export default ({
responsive, responsive,
location, location,
directionText, directionText,
showTechUIButton,
onLangChange, onLangChange,
onDirectionChange, onDirectionChange,
}: NavigationProps) => { }: NavigationProps) => {
@ -100,6 +102,13 @@ export default ({
<FormattedMessage id="app.header.menu.resource" /> <FormattedMessage id="app.header.menu.resource" />
</Link> </Link>
</Menu.Item> </Menu.Item>
{showTechUIButton && (
<Menu.Item key="tech-ui">
<a href="https://techui.alipay.com" target="__blank" rel="noopener noreferrer">
TechUI
</a>
</Menu.Item>
)}
{isZhCN && !isGitee && ( {isZhCN && !isGitee && (
<Menu.Item key="mirror"> <Menu.Item key="mirror">
<a href="https://ant-design.gitee.io"></a> <a href="https://ant-design.gitee.io"></a>

@ -12,6 +12,7 @@ import More from './More';
import Navigation from './Navigation'; import Navigation from './Navigation';
import Github from './Github'; import Github from './Github';
import SiteContext from '../SiteContext'; import SiteContext from '../SiteContext';
import { ping } from '../../utils';
import './index.less'; import './index.less';
@ -61,15 +62,19 @@ interface HeaderState {
menuVisible: boolean; menuVisible: boolean;
windowWidth: number; windowWidth: number;
searching: boolean; searching: boolean;
showTechUIButton: boolean;
} }
class Header extends React.Component<HeaderProps, HeaderState> { class Header extends React.Component<HeaderProps, HeaderState> {
static contextType = SiteContext; static contextType = SiteContext;
pingTimer: NodeJS.Timeout;
state = { state = {
menuVisible: false, menuVisible: false,
windowWidth: 1400, windowWidth: 1400,
searching: false, searching: false,
showTechUIButton: false,
}; };
componentDidMount() { componentDidMount() {
@ -79,10 +84,19 @@ class Header extends React.Component<HeaderProps, HeaderState> {
window.addEventListener('resize', this.onWindowResize); window.addEventListener('resize', this.onWindowResize);
this.onWindowResize(); this.onWindowResize();
this.pingTimer = ping(status => {
if (status !== 'timeout' && status !== 'error') {
this.setState({
showTechUIButton: true,
});
}
});
} }
componentWillUnmount() { componentWillUnmount() {
window.removeEventListener('resize', this.onWindowResize); window.removeEventListener('resize', this.onWindowResize);
clearTimeout(this.pingTimer);
} }
onWindowResize = () => { onWindowResize = () => {
@ -179,7 +193,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
return ( return (
<SiteContext.Consumer> <SiteContext.Consumer>
{({ isMobile }) => { {({ isMobile }) => {
const { menuVisible, windowWidth, searching } = this.state; const { menuVisible, windowWidth, searching, showTechUIButton } = this.state;
const { direction } = this.context; const { direction } = this.context;
const { const {
location, location,
@ -232,6 +246,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
location={location} location={location}
responsive={responsive} responsive={responsive}
isMobile={isMobile} isMobile={isMobile}
showTechUIButton={showTechUIButton}
pathname={pathname} pathname={pathname}
directionText={this.getNextDirectionText()} directionText={this.getNextDirectionText()}
onLangChange={this.onLangChange} onLangChange={this.onLangChange}

Loading…
Cancel
Save