About.jsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**
  2. * @author oldj
  3. * @blog https://oldj.net
  4. */
  5. 'use strict'
  6. import React from 'react'
  7. import { Modal, Button } from 'antd'
  8. import Agent from '../Agent'
  9. import logo from '../../app/assets/[email protected]'
  10. import { version } from '../../app/version'
  11. import styles from './About.less'
  12. export default class About extends React.Component {
  13. constructor (props) {
  14. super(props)
  15. this.state = {
  16. visible: false
  17. }
  18. }
  19. hide () {
  20. this.setState({
  21. visible: false
  22. })
  23. }
  24. show () {
  25. const updateLink = () => {
  26. if (!this.el_content) {
  27. setTimeout(updateLink, 500)
  28. return
  29. }
  30. let links = this.el_content.querySelectorAll('a')
  31. links = Array.from(links)
  32. links.map(a => {
  33. a.onclick = () => {
  34. this.openUrl(a.href)
  35. return false
  36. }
  37. })
  38. }
  39. this.setState({
  40. visible: true
  41. }, updateLink)
  42. }
  43. openUrl (url) {
  44. Agent.pact('openUrl', url)
  45. }
  46. componentDidMount () {
  47. Agent.on('show-about', () => {
  48. this.show()
  49. })
  50. }
  51. render () {
  52. let {lang} = this.props
  53. let ver = `v${version.slice(0, 3).join('.')} (${version[3]})`
  54. return (
  55. <Modal
  56. visible={this.state.visible}
  57. width="360"
  58. onCancel={this.hide.bind(this)}
  59. wrapClassName="frame"
  60. closable={false}
  61. footer={[
  62. <Button key="back" size="large" onClick={this.hide.bind(this)}>{lang.close}</Button>
  63. ]}
  64. >
  65. <div>
  66. <div className={styles.logo}>
  67. <img src={logo} alt=""/>
  68. </div>
  69. <div className={styles.content} ref={c => this.el_content = c}>
  70. <h2>SwitchHosts!</h2>
  71. <div className={styles.version}>{ver}</div>
  72. <div>
  73. <a href="https://oldj.github.io/SwitchHosts/" target="_blank">{lang.homepage}</a>
  74. <a href="https://github.com/oldj/SwitchHosts" target="_blank">{lang.source_code}</a>
  75. </div>
  76. <p className={styles.br}/>
  77. <div>
  78. <h3>{lang.acknowledgement}:</h3>
  79. <div>
  80. <a href="https://github.com/oldj" target="_blank">oldj</a>
  81. <a href="https://github.com/allenm" target="_blank">Allen.M</a>
  82. <a href="https://github.com/charlestang" target="_blank">Charles Tang</a>
  83. <a href="https://github.com/stotem" target="_blank">WuJianjun</a>
  84. <a href="https://github.com/ElfSundae" target="_blank">Elf Sundae</a>
  85. <a href="https://github.com/codeyu" target="_blank">zhu yu</a>
  86. <a href="https://github.com/pangliang" target="_blank">胖梁</a>
  87. <a href="https://github.com/CaffreySun" target="_blank">CaffreySun</a>
  88. <a href="https://github.com/Xmader" target="_blank">Xmader</a>
  89. <a href="https://github.com/zhanggang807" target="_blank">Dean Zhang</a>
  90. <a href="https://github.com/CloverNet" target="_blank">CloverNet</a>
  91. <a href="https://github.com/ReAlign" target="_blank">ReAlign</a>
  92. </div>
  93. </div>
  94. </div>
  95. </div>
  96. </Modal>
  97. )
  98. }
  99. }