UrlClipboard.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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, { memo } from 'react'
  21. import { Form, Input, Row, Col, Button } from 'antd'
  22. import { TCopyType } from '../types'
  23. import styles from '../SharePanel.less'
  24. const FormItem = Form.Item
  25. interface IUrlClipboardProps {
  26. shareUrl: string
  27. password?: string
  28. onCopy: (copytype: TCopyType) => () => void
  29. }
  30. const UrlClipboard: React.FC<IUrlClipboardProps> = ({
  31. shareUrl,
  32. password,
  33. onCopy
  34. }) => {
  35. const itemStyle = { labelCol: { span: 6 }, wrapperCol: { span: 17 } }
  36. return (
  37. shareUrl && (
  38. <>
  39. <Row gutter={8}>
  40. <Col span={24}>
  41. <FormItem label="分享链接" {...itemStyle}>
  42. <Input
  43. readOnly
  44. value={shareUrl}
  45. addonAfter={
  46. <span className={styles.copy} onClick={onCopy('link')}>
  47. 复制链接
  48. </span>
  49. }
  50. />
  51. </FormItem>
  52. </Col>
  53. </Row>
  54. {password && (
  55. <>
  56. <Row gutter={8}>
  57. <Col span={24}>
  58. <FormItem label="口令" {...itemStyle}>
  59. <Input
  60. readOnly
  61. value={password}
  62. addonAfter={
  63. <span className={styles.copy} onClick={onCopy('all')}>
  64. 复制链接及口令
  65. </span>
  66. }
  67. />
  68. </FormItem>
  69. </Col>
  70. </Row>
  71. </>
  72. )}
  73. </>
  74. )
  75. )
  76. }
  77. export default memo(UrlClipboard)