|
|
@ -4,6 +4,7 @@ import styles from './index.less'; |
|
|
import { connect } from 'dva'; |
|
|
import { connect } from 'dva'; |
|
|
import * as H from 'history'; |
|
|
import * as H from 'history'; |
|
|
import { FormattedMessage } from 'umi-plugin-react/locale'; |
|
|
import { FormattedMessage } from 'umi-plugin-react/locale'; |
|
|
|
|
|
import { isAntDesignPro } from '@/utils/utils'; |
|
|
|
|
|
|
|
|
const firstUpperCase = (pathString: string) => { |
|
|
const firstUpperCase = (pathString: string) => { |
|
|
return pathString |
|
|
return pathString |
|
|
@ -13,13 +14,34 @@ const firstUpperCase = (pathString: string) => { |
|
|
.filter(s => s) |
|
|
.filter(s => s) |
|
|
.join(''); |
|
|
.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<{ |
|
|
const BlockCodeView: React.SFC<{ |
|
|
url: string; |
|
|
url: string; |
|
|
}> = ({ url }) => { |
|
|
}> = ({ url }) => { |
|
|
const blockUrl = `npx umi block add ${firstUpperCase(url)} --path=${url}`; |
|
|
const blockUrl = `npx umi block add ${firstUpperCase(url)} --path=${url}`; |
|
|
return ( |
|
|
return ( |
|
|
<div className={styles['copy-block-view']}> |
|
|
<div className={styles['copy-block-view']}> |
|
|
<Typography.Paragraph copyable={{ text: blockUrl }}> |
|
|
<Typography.Paragraph |
|
|
|
|
|
copyable={{ |
|
|
|
|
|
text: blockUrl, |
|
|
|
|
|
onCopy: () => onBlockCopy(url), |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
<code className={styles['copy-block-code']}>{blockUrl}</code> |
|
|
<code className={styles['copy-block-code']}>{blockUrl}</code> |
|
|
</Typography.Paragraph> |
|
|
</Typography.Paragraph> |
|
|
</div> |
|
|
</div> |
|
|
|