Skip to content

Commit

Permalink
导航页面添加数据
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Feb 21, 2018
1 parent bf1e857 commit 2606348
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/pages/Navigation/Edit.less
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
margin: 0 50px;
.category {
display: flex;
font-size: 14px;
font-weight: 200;
color: rgba(255,255,255,.4);
border-bottom: 1px solid rgba(255,255,255,.05);
padding-bottom: 12px;
Expand Down Expand Up @@ -106,7 +108,7 @@
}
}
img {
border-radius: 2px;
border-radius: 3px;
display: block;
background-color: #ffffff2b;
width: 62px;
Expand Down
17 changes: 15 additions & 2 deletions src/pages/Navigation/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { Component } from 'react';
import styles from './index.less';
import addIcon from '../../assets/add-icon.png';
import website from '../../assets/website.svg';
import websiteIcon from '../../assets/website.svg';
import website from '../../source/website.json';
import Edit from './Edit';
// import Contextmenu from "../../component/Contextmenu";

Expand Down Expand Up @@ -32,6 +33,18 @@ export default class Navigation extends Component {
window.addEventListener('resize', this.handleResize, true);
document.addEventListener('keydown', this.handleClickOption, true);
document.addEventListener('keyup', this.handleClickOptionUp, true);
const { navContent } = this.state;
const { storage, dbs } = this.props;
if (navContent.length === 0) {
for (let i = 0; i < website.length; i += 1) {
if (website[i].children && website[i].children[0]) {
navContent.push(website[i].children[0]);
dbs.nav = navContent;
storage.set({ dbs });
this.setState({ navContent });
}
}
}
}
handleClickOption(e) {
const key = e.keyCode || e.which || e.charCode;
Expand Down Expand Up @@ -108,7 +121,7 @@ export default class Navigation extends Component {
{navContent.map((item, idx) => {
return (
<a key={idx} href={item.value} target="_top">
<img alt={item.label} onError={e => e.target.src = website} src={item.icon} />
<img alt={item.label} onError={e => e.target.src = websiteIcon} src={item.icon} />
<p>{item.label}</p>
{optionDown && <i onClick={this.onKeyDownOption.bind(this, item)} className={styles.keyDown} />}
</a>
Expand Down
8 changes: 8 additions & 0 deletions src/source/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@
"label": "StackOverflow",
"value": "stackoverflow",
"url": "https://stackoverflow.com/search?q={{kw}}"
}, {
"label": "React.parts",
"value": "react-parts",
"url": "https://react.parts/?search={{kw}}"
}, {
"label": "JS.coach",
"value": "JS.coach",
"url": "https://js.coach/?search={{kw}}"
},
{
"label": "Linux命令",
Expand Down
171 changes: 161 additions & 10 deletions src/source/website.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"label": "办公",
"value": "office",
"children": [
{
"label": "Teambition",
"value": "https://www.teambition.com/",
"icon": "https://jaywcjlove.github.io/logo/teambition.jpg"
},
{
"label": "Microsoft Office",
"value": "https://www.office.com/",
Expand All @@ -18,6 +23,11 @@
"value": "https://slack.com/",
"icon": "https://jaywcjlove.github.io/logo/slack.png"
},
{
"label": "Gitter",
"value": "https://gitter.im/",
"icon": "https://jaywcjlove.github.io/logo/gitter.png"
},
{
"label": "QQ邮箱",
"value": "https://mail.qq.com/",
Expand All @@ -39,6 +49,16 @@
"value": "https://v.qq.com/",
"icon": "https://jaywcjlove.github.io/logo/vqq.png"
},
{
"label": "熊猫直播",
"value": "https://www.panda.tv/",
"icon": "https://jaywcjlove.github.io/logo/panda.jpg"
},
{
"label": "YouTube",
"value": "https://www.youtube.com/",
"icon": "https://jaywcjlove.github.io/logo/youtube.jpg"
},
{
"label": "网易音乐",
"value": "http://music.163.com/",
Expand Down Expand Up @@ -156,6 +176,11 @@
"value": "https://www.zhihu.com/",
"icon": "https://jaywcjlove.github.io/logo/zhihu.png"
},
{
"label": "果壳网",
"value": "https://www.guokr.com/",
"icon": "https://jaywcjlove.github.io/logo/guokr.jpg"
},
{
"label": "威锋网",
"value": "http://www.feng.com/",
Expand All @@ -166,6 +191,11 @@
"value": "https://www.v2ex.com/",
"icon": "https://jaywcjlove.github.io/logo/v2ex.png"
},
{
"label": "科学公园",
"value": "http://www.ikexue.org/",
"icon": "https://jaywcjlove.github.io/logo/ikexue.jpg"
},
{
"label": "简书",
"value": "http://www.jianshu.com/",
Expand All @@ -178,24 +208,59 @@
"value": "media",
"children": [
{
"label": "一席",
"value": "http://yixi.tv/",
"icon": "https://jaywcjlove.github.io/logo/yixi.png"
"label": "36氪",
"value": "http://36kr.com/",
"icon": "https://jaywcjlove.github.io/logo/36kr.png"
},
{
"label": "Engadget",
"value": "https://cn.engadget.com/",
"icon": "https://jaywcjlove.github.io/logo/engadget.jpg"
},
{
"label": "cnBeta",
"value": "http://www.cnbeta.com/",
"icon": "https://jaywcjlove.github.io/logo/cnbeta.png"
},
{
"label": "爱范儿",
"value": "http://www.ifanr.com/",
"icon": "https://jaywcjlove.github.io/logo/ifanr.png"
},
{
"label": "虎嗅网",
"value": "https://www.huxiu.com/",
"icon": "https://jaywcjlove.github.io/logo/huxiu.png"
},
{
"label": "极客公园",
"value": "http://www.geekpark.net/",
"icon": "https://jaywcjlove.github.io/logo/geekpark.png"
},
{
"label": "一席",
"value": "http://yixi.tv/",
"icon": "https://jaywcjlove.github.io/logo/yixi.png"
},
{
"label": "雷锋网",
"value": "http://www.leiphone.com/",
"icon": "https://jaywcjlove.github.io/logo/leiphone.png"
},
{
"label": "36氪",
"value": "http://36kr.com/",
"icon": "https://jaywcjlove.github.io/logo/36kr.png"
"label": "PingWest品玩",
"value": "http://www.pingwest.com/",
"icon": "https://jaywcjlove.github.io/logo/pingwest.jpg"
},
{
"label": "TechCrunch",
"value": "http://techcrunch.cn/",
"icon": "https://jaywcjlove.github.io/logo/techcrunch.jpg"
},
{
"label": "VICE中国",
"value": "http://www.vice.cn/",
"icon": "https://jaywcjlove.github.io/logo/vice.png"
}
]
},
Expand All @@ -204,15 +269,30 @@
"value": "finance",
"children": [
{
"label": "自选股",
"value": "http://gu.qq.com/i/",
"icon": "https://jaywcjlove.github.io/logo/guqq.png"
"label": "和讯",
"value": "http://www.hexun.com/",
"icon": "https://jaywcjlove.github.io/logo/hexun.png"
},
{
"label": "东方财富网",
"value": "http://www.eastmoney.com/",
"icon": "https://jaywcjlove.github.io/logo/eastmoney.png"
},
{
"label": "雪球",
"value": "https://xueqiu.com/",
"icon": "https://jaywcjlove.github.io/logo/xueqiu.png"
},
{
"label": "自选股",
"value": "http://gu.qq.com/i/",
"icon": "https://jaywcjlove.github.io/logo/guqq.png"
},
{
"label": "FT中文网",
"value": "http://www.ftchinese.com/",
"icon": "https://jaywcjlove.github.io/logo/ftchinese.png"
},
{
"label": "富途证券",
"value": "https://www.futu5.com/",
Expand All @@ -224,20 +304,45 @@
"label": "商旅",
"value": "business-trip",
"children": [
{
"label": "蚂蜂窝",
"value": "http://www.mafengwo.cn/",
"icon": "https://jaywcjlove.github.io/logo/mafengwo.png"
},
{
"label": "携程",
"value": "http://www.ctrip.com/",
"icon": "https://jaywcjlove.github.io/logo/ctrip.png"
},
{
"label": "Airbnb",
"label": "缤客",
"value": "http://www.booking.com/",
"icon": "https://jaywcjlove.github.io/logo/booking.png"
},
{
"label": "Airbnb爱彼迎",
"value": "https://www.airbnbchina.cn/",
"icon": "https://jaywcjlove.github.io/logo/airbnbchina.png"
},
{
"label": "猫途鹰",
"value": "https://www.tripadvisor.cn/",
"icon": "https://jaywcjlove.github.io/logo/tripadvisor.png"
},
{
"label": "穷游网",
"value": "http://www.qyer.com/",
"icon": "https://jaywcjlove.github.io/logo/qyer.png"
},
{
"label": "天巡网",
"value": "https://www.tianxun.com/",
"icon": "https://jaywcjlove.github.io/logo/tianxun.jpg"
},
{
"label": "去哪儿网",
"value": "http://www.qunar.com/",
"icon": "https://jaywcjlove.github.io/logo/qunar.png"
}
]
},
Expand Down Expand Up @@ -316,6 +421,11 @@
"value": "https://developer.apple.com/",
"icon": "https://jaywcjlove.github.io/logo/developerApple.png"
},
{
"label": "Can I use",
"value": "https://caniuse.com/",
"icon": "https://jaywcjlove.github.io/logo/caniuse.png"
},
{
"label": "掘金",
"value": "https://juejin.im",
Expand All @@ -336,11 +446,52 @@
"value": "https://segmentfault.com/",
"icon": "https://jaywcjlove.github.io/logo/segmentfault.png"
},
{
"label": "博客园",
"value": "https://www.cnblogs.com/",
"icon": "https://jaywcjlove.github.io/logo/cnblogs.jpg"
},
{
"label": "开源中国",
"value": "http://www.oschina.net/",
"icon": "https://jaywcjlove.github.io/logo/oschina.png"
}
]
},
{
"label": "软件下载",
"value": "download",
"children": [
{
"label": "MacUpdate",
"value": "https://www.macupdate.com/",
"icon": "https://jaywcjlove.github.io/logo/macupdate.jpg"
},
{
"label": "Mac程序推荐",
"value": "http://jaywcjlove.github.io/awesome-mac/index.zh.html",
"icon": "https://jaywcjlove.github.io/logo/developerApple.png"
},
{
"label": "MacX 麦克叉",
"value": "https://www.macx.cn/",
"icon": "https://jaywcjlove.github.io/logo/macx.png"
},
{
"label": "绿色软件联盟",
"value": "http://www.xdowns.com/",
"icon": "https://jaywcjlove.github.io/logo/xdowns.jpg"
},
{
"label": "pc6下载站",
"value": "http://www.pc6.com/",
"icon": "https://jaywcjlove.github.io/logo/pc6.jpg"
},
{
"label": "下载吧",
"value": "http://www.xiazaiba.com/",
"icon": "https://jaywcjlove.github.io/logo/xiazaiba.jpg"
}
]
}
]

0 comments on commit 2606348

Please sign in to comment.