Skip to content

Commit 16fedd9

Browse files
committed
add weibo share component
remove original weibo share tool optimize share weibo
1 parent fb9a568 commit 16fedd9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

_theme/template/Header.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ import React from 'react';
22
import { Link } from 'react-router';
33
import { Icon } from 'antd';
44

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+
516
export default function Header(props) {
617
const route = props.route;
718
let path = '';
@@ -16,6 +27,11 @@ export default function Header(props) {
1627
<li><Link className={path.indexOf('articles') === -1 ? '' : 'current'} to="/articles/start"><Icon type="bulb"/><span>快速开始</span></Link></li>
1728
<li><Link className={path.indexOf('components') === -1 ? '' : 'current'} to="/components/about"><Icon type="appstore-o"/><span>组件文档</span></Link></li>
1829
<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>
1935
</ul>
2036
</div>
2137
</header>;

0 commit comments

Comments
 (0)