Commit 21d4f751 authored by 陈帅's avatar 陈帅

fix: fix CopyBlock style warning

parent d75bbb29
import { Icon, Popover, Typography } from 'antd'; import { Icon, Popover, Typography } from 'antd';
import { FormattedMessage } from 'umi-plugin-react/locale'; import { FormattedMessage } from 'umi-plugin-react/locale';
import React from 'react'; import React, { useRef } from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import { isAntDesignPro } from '@/utils/utils'; import { isAntDesignPro } from '@/utils/utils';
import styles from './index.less'; import styles from './index.less';
...@@ -41,8 +41,13 @@ const BlockCodeView: React.SFC<{ ...@@ -41,8 +41,13 @@ const BlockCodeView: React.SFC<{
text: blockUrl, text: blockUrl,
onCopy: () => onBlockCopy(url), onCopy: () => onBlockCopy(url),
}} }}
style={{
display: 'flex',
}}
> >
<code className={styles['copy-block-code']}>{blockUrl}</code> <pre>
<code className={styles['copy-block-code']}>{blockUrl}</code>
</pre>
</Typography.Paragraph> </Typography.Paragraph>
</div> </div>
); );
...@@ -58,14 +63,16 @@ export default connect(({ routing }: { routing: RoutingType }) => ({ ...@@ -58,14 +63,16 @@ export default connect(({ routing }: { routing: RoutingType }) => ({
location: routing.location, location: routing.location,
}))(({ location }: RoutingType) => { }))(({ location }: RoutingType) => {
const url = location.pathname; const url = location.pathname;
const divDom = useRef<HTMLDivElement>(null);
return ( return (
<Popover <Popover
title={<FormattedMessage id="app.preview.down.block" defaultMessage="下载此页面到本地项目" />} title={<FormattedMessage id="app.preview.down.block" defaultMessage="下载此页面到本地项目" />}
placement="topLeft" placement="topLeft"
content={<BlockCodeView url={url} />} content={<BlockCodeView url={url} />}
trigger="click" trigger="click"
getPopupContainer={dom => (divDom.current ? divDom.current : dom)}
> >
<div className={styles['copy-block']}> <div className={styles['copy-block']} ref={divDom}>
<Icon type="download" /> <Icon type="download" />
</div> </div>
</Popover> </Popover>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment