Browse Source

chore: update host judgement in modal

pull/38833/head
MadCcc 2 years ago
parent
commit
428803924f
  1. 24
      site/theme/template/Layout/Header/index.tsx

24
site/theme/template/Layout/Header/index.tsx

@ -42,7 +42,7 @@ const triggerDocSearchImport = () => {
return Promise.resolve();
}
return import('docsearch.js').then(ds => {
return import('docsearch.js').then((ds) => {
docsearch = ds.default;
});
};
@ -97,7 +97,7 @@ interface HeaderState {
showTechUIButton: boolean;
}
const Header: React.FC<HeaderProps & WrappedComponentProps<'intl'>> = props => {
const Header: React.FC<HeaderProps & WrappedComponentProps<'intl'>> = (props) => {
const { intl, router, location, themeConfig, changeDirection } = props;
const [headerState, setHeaderState] = useState<HeaderState>({
menuVisible: false,
@ -109,16 +109,16 @@ const Header: React.FC<HeaderProps & WrappedComponentProps<'intl'>> = props => {
const pingTimer = useRef<NodeJS.Timeout | null>(null);
const handleHideMenu = useCallback(() => {
setHeaderState(prev => ({ ...prev, menuVisible: false }));
setHeaderState((prev) => ({ ...prev, menuVisible: false }));
}, []);
const onWindowResize = useCallback(() => {
setHeaderState(prev => ({ ...prev, windowWidth: window.innerWidth }));
setHeaderState((prev) => ({ ...prev, windowWidth: window.innerWidth }));
}, []);
const onTriggerSearching = useCallback((searching: boolean) => {
setHeaderState(prev => ({ ...prev, searching }));
setHeaderState((prev) => ({ ...prev, searching }));
}, []);
const handleShowMenu = useCallback(() => {
setHeaderState(prev => ({ ...prev, menuVisible: true }));
setHeaderState((prev) => ({ ...prev, menuVisible: true }));
}, []);
const onDirectionChange = useCallback(() => {
changeDirection(direction !== 'rtl' ? 'rtl' : 'ltr');
@ -129,13 +129,13 @@ const Header: React.FC<HeaderProps & WrappedComponentProps<'intl'>> = props => {
initDocSearch({ isZhCN: intl.locale === 'zh-CN', router });
onWindowResize();
window.addEventListener('resize', onWindowResize);
pingTimer.current = ping(status => {
pingTimer.current = ping((status) => {
if (status !== 'timeout' && status !== 'error') {
setHeaderState(prev => ({ ...prev, showTechUIButton: true }));
setHeaderState((prev) => ({ ...prev, showTechUIButton: true }));
if (
process.env.NODE_ENV === 'production' &&
shouldOpenAntdMirrorModal() &&
window.location.host !== 'ant-design.antgroup.com' &&
window.location.host !== '4x-ant-design.antgroup.com' &&
window.location.host.indexOf('surge.sh') === -1
) {
Modal.confirm({
@ -211,7 +211,7 @@ const Header: React.FC<HeaderProps & WrappedComponentProps<'intl'>> = props => {
[antdVersion]: antdVersion,
...themeConfig?.docVersions,
};
const versionOptions = Object.keys(docVersions).map(version => (
const versionOptions = Object.keys(docVersions).map((version) => (
<Option value={docVersions[version]} key={version}>
{version}
</Option>
@ -264,7 +264,7 @@ const Header: React.FC<HeaderProps & WrappedComponentProps<'intl'>> = props => {
defaultValue={antdVersion}
onChange={handleVersionChange}
dropdownStyle={getDropdownStyle}
getPopupContainer={trigger => trigger.parentNode}
getPopupContainer={(trigger) => trigger.parentNode}
>
{versionOptions}
</Select>,
@ -309,7 +309,7 @@ const Header: React.FC<HeaderProps & WrappedComponentProps<'intl'>> = props => {
placement="right"
title={null}
closable={false}
onClose={() => setHeaderState(prev => ({ ...prev, menuVisible: false }))}
onClose={() => setHeaderState((prev) => ({ ...prev, menuVisible: false }))}
bodyStyle={{ margin: '0 -23px' }}
drawerStyle={{ overflowX: 'hidden' }}
width={260}

Loading…
Cancel
Save