import React from 'react'; import { Icon, Typography, Popover } from 'antd'; import styles from './index.less'; import { connect } from 'dva'; import * as H from 'history'; import { FormattedMessage } from 'umi-plugin-react/locale'; import { isAntDesignPro } from '@/utils/utils'; const firstUpperCase = (pathString: string) => { return pathString .replace('.', '') .split(/\/|\-/) .map(s => s.toLowerCase().replace(/( |^)[a-z]/g, L => L.toUpperCase())) .filter(s => s) .join(''); }; // when click block copy, send block url to ga const onBlockCopy = (label: string) => { if (!isAntDesignPro()) { return; } const ga = window && (window as any).ga; if (ga) { ga('send', 'event', { eventCategory: 'block', eventAction: 'copy', eventLabel: label, }); } }; const BlockCodeView: React.SFC<{ url: string; }> = ({ url }) => { const blockUrl = `npx umi block add ${firstUpperCase(url)} --path=${url}`; return (
onBlockCopy(url), }} > {blockUrl}
); }; type RoutingType = { location: H.Location }; export default connect(({ routing }: { routing: RoutingType }) => ({ location: routing.location, }))(({ location }: RoutingType) => { const url = location.pathname; return ( } placement="topLeft" content={} trigger="click" >
); });