index.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 } from 'react-router-dom'
  24. import classnames from 'classnames'
  25. import DownloadList from '../DownloadList'
  26. import {
  27. loadDownloadList,
  28. downloadFile
  29. } from 'containers/App/actions'
  30. import {
  31. makeSelectLoginUser,
  32. makeSelectDownloadList,
  33. makeSelectDownloadListLoading
  34. } from 'containers/App/selectors'
  35. import { Dropdown, Menu, Icon } from 'antd'
  36. import { IDownloadRecord } from 'app/containers/App/types'
  37. const styles = require('./Navigator.less')
  38. const goGithub = () => window.open('https://github.com/edp963/davinci')
  39. const goDoc = () => window.open('https://edp963.github.io/davinci/')
  40. interface INavigatorProps {
  41. show: boolean
  42. loginUser: object
  43. downloadList: IDownloadRecord[]
  44. onLogout: () => void
  45. onLoadDownloadList: () => void
  46. onDownloadFile: (id) => void
  47. }
  48. export function Navigator (props: INavigatorProps) {
  49. const {
  50. show,
  51. downloadList,
  52. onLogout,
  53. onLoadDownloadList,
  54. onDownloadFile
  55. } = props
  56. const headerClass = classnames({
  57. [styles.header]: true,
  58. [styles.hide]: !show
  59. })
  60. const menu = (
  61. <Menu>
  62. <Menu.Item key="0">
  63. <Link to="/account" >
  64. 用户设置
  65. </Link>
  66. </Menu.Item>
  67. <Menu.Divider />
  68. <Menu.Item key="3">
  69. <a href="javascript:;" onClick={onLogout}>
  70. 退出登录
  71. </a>
  72. </Menu.Item>
  73. </Menu>
  74. )
  75. return (
  76. <nav className={headerClass}>
  77. <div className={styles.logoPc}>
  78. <div className={styles.logo}>
  79. <Link to="/projects">
  80. <img src={require('assets/images/logo.svg')} />
  81. </Link>
  82. </div>
  83. </div>
  84. <div className={styles.logoMobile}>
  85. <div className={styles.logo}>
  86. <Link to="/projects">
  87. <img src={require('assets/images/logo_mobile.svg')} />
  88. </Link>
  89. </div>
  90. </div>
  91. <ul className={styles.tools}>
  92. <li>
  93. <DownloadList
  94. downloadList={downloadList}
  95. onLoadDownloadList={onLoadDownloadList}
  96. onDownloadFile={onDownloadFile}
  97. />
  98. </li>
  99. <li>
  100. <Icon type="file-text" onClick={goDoc} />
  101. </li>
  102. <li>
  103. <Icon type="github" onClick={goGithub}/>
  104. </li>
  105. <li>
  106. <Dropdown overlay={menu} trigger={['click']} placement="bottomCenter">
  107. <Icon type="user" />
  108. </Dropdown>
  109. </li>
  110. </ul>
  111. </nav>
  112. )
  113. }
  114. const mapStateToProps = createStructuredSelector({
  115. loginUser: makeSelectLoginUser(),
  116. downloadList: makeSelectDownloadList()
  117. })
  118. function mapDispatchToProps (dispatch) {
  119. return {
  120. onLoadDownloadList: () => dispatch(loadDownloadList()),
  121. onDownloadFile: (id) => dispatch(downloadFile(id))
  122. }
  123. }
  124. export default connect(mapStateToProps, mapDispatchToProps)(Navigator)