File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,17 @@ import React from 'react';
2
2
import { Link } from 'react-router' ;
3
3
import { Icon } from 'antd' ;
4
4
5
+ const shareIt = ( ) => {
6
+ const curPage = window . encodeURIComponent ( window . location . href ) ;
7
+ let text = `react-amap 是一个基于 React 封装的高德地图组件;帮助你轻松的接入地图到 React 项目中。除了必须引用的 Map 组件外,我们目前提供了最常用的 10 个地图组件,能满足大部分简单的业务场景;如果你有更复杂的需求,或者觉得默认提供的组件功能不够,你完全可以自定义一个地图组件,然后根据高德原生 API 做高德允许你做的一切事情。`
8
+ const article = document . querySelector ( 'article' ) ;
9
+ if ( article ) {
10
+ text = article . innerText . slice ( 0 , 140 ) ;
11
+ }
12
+ const url = `http://service.weibo.com/share/share.php?url=${ curPage } &appkey=3975764953&language=zh_cn&title=${ window . encodeURIComponent ( text ) } &source=thisissourcetest&sourceUrl=https%3A%2F%2Felemefe.github.io%2Freact-amap%2F&ralateUid=oslh&message=&uids=&pic=https%3A%2F%2Fcloud.githubusercontent.com%2Fassets%2F3898898%2F23833571%2Fe5c7ae68-0782-11e7-8590-cecf4f3c969f.png&searchPic=true&content=`
13
+ window . open ( url , '_blank' ) ;
14
+ }
15
+
5
16
export default function Header ( props ) {
6
17
const route = props . route ;
7
18
let path = '' ;
@@ -16,6 +27,11 @@ export default function Header(props) {
16
27
< li > < Link className = { path . indexOf ( 'articles' ) === - 1 ? '' : 'current' } to = "/articles/start" > < Icon type = "bulb" /> < span > 快速开始</ span > </ Link > </ li >
17
28
< li > < Link className = { path . indexOf ( 'components' ) === - 1 ? '' : 'current' } to = "/components/about" > < Icon type = "appstore-o" /> < span > 组件文档</ span > </ Link > </ li >
18
29
< li > < a href = "https://github.com/ElemeFE/react-amap" target = "_blank" > < Icon type = "github" /> < span > GitHub</ span > </ a > </ li >
30
+ < li >
31
+ < a target = "_blank" href = "javascript:;" onClick = { shareIt } >
32
+ < Icon type = "share-alt" />
33
+ </ a >
34
+ </ li >
19
35
</ ul >
20
36
</ div >
21
37
</ header > ;
You can’t perform that action at this time.
0 commit comments