docs: render china mirror link before hydration (#44233)

* docs: render china mirror link before hydration

* docs: fix pre render error

* chore: hide first

* chore: show china mirror link always
This commit is contained in:
afc163
2023-08-16 18:19:11 +08:00
committed by GitHub
parent 83e3b5218a
commit a92a883b77
3 changed files with 29 additions and 14 deletions

View File

@@ -30,7 +30,8 @@ const locales = {
// ============================= Style =============================
const useStyle = createStyles(({ token }) => {
const { antCls, iconCls, fontFamily, headerHeight, menuItemBorder, colorPrimary } = token;
const { antCls, iconCls, fontFamily, headerHeight, menuItemBorder, colorPrimary, colorText } =
token;
return {
nav: css`
@@ -56,6 +57,17 @@ const useStyle = createStyles(({ token }) => {
left: 12px;
border-width: ${menuItemBorder}px;
}
a {
color: ${colorText};
}
a:before {
position: absolute;
inset: 0;
background-color: transparent;
content: "";
}
}
& ${antCls}-menu-submenu-title ${iconCls} {
@@ -97,7 +109,6 @@ const useStyle = createStyles(({ token }) => {
export interface NavigationProps extends SharedProps {
isMobile: boolean;
isClient: boolean;
responsive: null | 'narrow' | 'crowded';
directionText: string;
onLangChange: () => void;
@@ -106,7 +117,6 @@ export interface NavigationProps extends SharedProps {
export default ({
isZhCN,
isClient,
isMobile,
responsive,
directionText,
@@ -224,16 +234,21 @@ export default ({
),
key: 'docs/resources',
},
isZhCN &&
isClient &&
window.location.host !== 'ant-design.antgroup.com' &&
window.location.host !== 'ant-design.gitee.io'
isZhCN
? {
label: '国内镜像',
label: (
<a href="https://ant-design.antgroup.com" target="_blank" rel="noreferrer">
</a>
),
key: 'mirror',
children: [
{
label: <a href="https://ant-design.antgroup.com"></a>,
label: (
<a href="https://ant-design.antgroup.com" target="_blank" rel="noreferrer">
</a>
),
icon: (
<img
alt="logo"
@@ -245,7 +260,11 @@ export default ({
key: 'antgroup',
},
{
label: <a href="https://ant-design.gitee.io">Gitee </a>,
label: (
<a href="https://ant-design.gitee.io" target="_blank" rel="noreferrer">
Gitee
</a>
),
icon: (
<img
alt="gitee"

View File

@@ -127,7 +127,6 @@ interface HeaderState {
// ================================= Header =================================
const Header: React.FC = () => {
const [isClient, setIsClient] = React.useState(false);
const [, lang] = useLocale();
const { pkg } = useSiteData();
@@ -166,7 +165,6 @@ const Header: React.FC = () => {
}, [location]);
useEffect(() => {
setIsClient(typeof window !== 'undefined');
onWindowResize();
window.addEventListener('resize', onWindowResize);
pingTimer.current = ping((status) => {
@@ -273,7 +271,6 @@ const Header: React.FC = () => {
const sharedProps: SharedProps = {
isZhCN,
isRTL,
isClient,
};
const navigationNode = (

View File

@@ -1,5 +1,4 @@
export interface SharedProps {
isZhCN: boolean;
isRTL: boolean;
isClient: boolean;
}