forked from sivagao/github-serendipity.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppMenu.js
More file actions
89 lines (77 loc) · 2.45 KB
/
Copy pathAppMenu.js
File metadata and controls
89 lines (77 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import React from 'react';
import { Menu, Icon, Spin, Tooltip, Popover } from 'antd';
const SubMenu = Menu.SubMenu;
import { Link } from 'react-router';
import _ from 'lodash'
import { store } from '../utils/store'
class AppMenu extends React.Component {
state = {}
render() {
console.log('rendering menu')
// default open all menus
const defaultKeys = ['Infinity,1000', 'topic_only', 'trending_first', 'Platforms', 'similar-repos']
const openKeys = _.union(defaultKeys, _.map(this.props.data, 'key'))
// const openKeys =
// openKeys && this.setState({ openKeys })
const cacheStore = store.get('repo:readdict') || {}
const wxGroupPopover = (i)=>{
return (
<div>
感兴趣 {_.capitalize(i.name)} 话题,加专业的群讨论吧~ <br/>
<img src={`${process.env.PUBLIC_URL}/qrcode_for_wx.jpg`} />
</div>
)
}
const getSubTitle = (i)=>{
return (
<span className="nav-text">
{ (i.key === 'topic_only') ? (
<Popover placement="rightBottom" trigger="hover" title="加群" content={wxGroupPopover(i)}>
{i.name}
<Icon type="info-circle-o" />
</Popover>
) : i.name }
</span>
)
}
const submenusElems = this.props.data.map((i)=>{
let menuItemsElems = i.list.map((ii)=>{
return (
<Menu.Item key={ii.key}>
{ii.description ? (
<Tooltip title={ii.description} placement="right">
<Link to={'/repo/'+ii.key}>
{cacheStore[ii.key] && <Icon type="check" />}
{ii.name}
<Icon type="info-circle-o" />
</Link>
</Tooltip>
) : (
<Link to={'/repo/'+ii.key}>
{cacheStore[ii.key] && <Icon type="check" style={{"color": "green"}} />}
{ii.name}
</Link>
)}
</Menu.Item>
)
})
return (
<SubMenu key={i.key}
title={getSubTitle(i)}>
{menuItemsElems}
</SubMenu>
)
})
// const now = new Date()
// const lastDay = new Date(now.setDate(now.getDate() -1)).toISOString().slice(0, 10)
return (
<Spin spinning={this.props.loading}>
<Menu inlineIndent="12" mode={this.props.mode}
defaultOpenKeys={openKeys}>
{submenusElems}
</Menu>
</Spin>
);
}
}
export default AppMenu;