index.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import React from 'react'
  21. import { connect } from 'react-redux'
  22. import { createStructuredSelector } from 'reselect'
  23. import { Link, useLocation } from 'react-router-dom'
  24. import classnames from 'classnames'
  25. import DownloadList from '../DownloadList'
  26. import { loadDownloadList, downloadFile } from 'containers/App/actions'
  27. import {
  28. makeSelectLoginUser,
  29. makeSelectDownloadList,
  30. makeSelectDownloadListLoading
  31. } from 'containers/App/selectors'
  32. import { Dropdown, Menu, Icon } from 'antd'
  33. import { IDownloadRecord } from 'app/containers/App/types'
  34. const styles = require('./Navigator.less')
  35. const goGithub = () => window.open('https://github.com/edp963/davinci')
  36. const goDoc = () => window.open('https://edp963.github.io/davinci/')
  37. interface INavigatorProps {
  38. show: boolean
  39. loginUser: object
  40. downloadList: IDownloadRecord[]
  41. onLogout: () => void
  42. onLoadDownloadList: () => void
  43. onDownloadFile: (id) => void
  44. }
  45. export function Navigator(props: INavigatorProps) {
  46. const { show, downloadList, onLogout, onLoadDownloadList, onDownloadFile } =
  47. props
  48. const headerClass = classnames({
  49. [styles.header]: true,
  50. [styles.hide]: !show
  51. })
  52. const menu = (
  53. <Menu>
  54. {/*<Menu.Item key='0'>*/}
  55. {/* <Link to='/account'>*/}
  56. {/* 用户设置*/}
  57. {/* </Link>*/}
  58. {/*</Menu.Item>*/}
  59. <Menu.Divider />
  60. <Menu.Item key='3'>
  61. <a href='javascript:;' onClick={onLogout}>
  62. 退出登录
  63. </a>
  64. </Menu.Item>
  65. </Menu>
  66. )
  67. const location = useLocation()
  68. const { pathname } = location
  69. const menus = []
  70. return (
  71. <nav className={headerClass}>
  72. <div className={styles.logoPc}>
  73. <div className={styles.logo}>
  74. <Link to='/project/1/dataManager'>
  75. <img src={require('assets/images/logo_white.svg')} />
  76. </Link>
  77. </div>
  78. <ul className={styles.menus}>
  79. {[
  80. {
  81. link: '/project/1/dataManager',
  82. name: '数据管理'
  83. },
  84. {
  85. link: '/project/1/dataShareService',
  86. name: '数据开放服务'
  87. },
  88. {
  89. link: '/project/1/dataGovernance',
  90. name: '数据治理'
  91. }
  92. ].map((r) => (
  93. <li key={r.name} className={pathname.includes(r.link) ? styles.active : null}>
  94. <Link to={r.link}>{r.name}</Link>
  95. </li>
  96. ))}
  97. </ul>
  98. </div>
  99. <div className={styles.logoMobile}>
  100. <div className={styles.logo}>
  101. <Link to='/projects'>
  102. <img src={require('assets/images/logo_white.svg')} />
  103. </Link>
  104. </div>
  105. </div>
  106. <ul className={styles.tools}>
  107. <li>
  108. <Dropdown overlay={menu} trigger={['click']} placement='bottomCenter'>
  109. <Icon type='user' />
  110. </Dropdown>
  111. </li>
  112. </ul>
  113. </nav>
  114. )
  115. }
  116. const mapStateToProps = createStructuredSelector({
  117. loginUser: makeSelectLoginUser(),
  118. downloadList: makeSelectDownloadList()
  119. })
  120. function mapDispatchToProps(dispatch) {
  121. return {
  122. onLoadDownloadList: () => dispatch(loadDownloadList()),
  123. onDownloadFile: (id) => dispatch(downloadFile(id))
  124. }
  125. }
  126. export default connect(mapStateToProps, mapDispatchToProps)(Navigator)