mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
docs: add techui promotion (#27465)
* feat: add techui promotion * feat: change button to menu * feat: change TechUI menu position
This commit is contained in:
parent
9052af449b
commit
5c0799d5ac
@ -4,4 +4,4 @@ title: 组件总览
|
||||
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';
|
||||
location: { pathname: string; query: any };
|
||||
directionText: string;
|
||||
showTechUIButton: boolean;
|
||||
onLangChange: () => void;
|
||||
onDirectionChange: () => void;
|
||||
}
|
||||
@ -29,6 +30,7 @@ export default ({
|
||||
responsive,
|
||||
location,
|
||||
directionText,
|
||||
showTechUIButton,
|
||||
onLangChange,
|
||||
onDirectionChange,
|
||||
}: NavigationProps) => {
|
||||
@ -100,6 +102,13 @@ export default ({
|
||||
<FormattedMessage id="app.header.menu.resource" />
|
||||
</Link>
|
||||
</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 && (
|
||||
<Menu.Item key="mirror">
|
||||
<a href="https://ant-design.gitee.io">国内镜像</a>
|
||||
|
@ -12,6 +12,7 @@ import More from './More';
|
||||
import Navigation from './Navigation';
|
||||
import Github from './Github';
|
||||
import SiteContext from '../SiteContext';
|
||||
import { ping } from '../../utils';
|
||||
|
||||
import './index.less';
|
||||
|
||||
@ -61,15 +62,19 @@ interface HeaderState {
|
||||
menuVisible: boolean;
|
||||
windowWidth: number;
|
||||
searching: boolean;
|
||||
showTechUIButton: boolean;
|
||||
}
|
||||
|
||||
class Header extends React.Component<HeaderProps, HeaderState> {
|
||||
static contextType = SiteContext;
|
||||
|
||||
pingTimer: NodeJS.Timeout;
|
||||
|
||||
state = {
|
||||
menuVisible: false,
|
||||
windowWidth: 1400,
|
||||
searching: false,
|
||||
showTechUIButton: false,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@ -79,10 +84,19 @@ class Header extends React.Component<HeaderProps, HeaderState> {
|
||||
|
||||
window.addEventListener('resize', this.onWindowResize);
|
||||
this.onWindowResize();
|
||||
|
||||
this.pingTimer = ping(status => {
|
||||
if (status !== 'timeout' && status !== 'error') {
|
||||
this.setState({
|
||||
showTechUIButton: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
window.removeEventListener('resize', this.onWindowResize);
|
||||
clearTimeout(this.pingTimer);
|
||||
}
|
||||
|
||||
onWindowResize = () => {
|
||||
@ -179,7 +193,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
|
||||
return (
|
||||
<SiteContext.Consumer>
|
||||
{({ isMobile }) => {
|
||||
const { menuVisible, windowWidth, searching } = this.state;
|
||||
const { menuVisible, windowWidth, searching, showTechUIButton } = this.state;
|
||||
const { direction } = this.context;
|
||||
const {
|
||||
location,
|
||||
@ -232,6 +246,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
|
||||
location={location}
|
||||
responsive={responsive}
|
||||
isMobile={isMobile}
|
||||
showTechUIButton={showTechUIButton}
|
||||
pathname={pathname}
|
||||
directionText={this.getNextDirectionText()}
|
||||
onLangChange={this.onLangChange}
|
||||
|
Loading…
Reference in New Issue
Block a user