index.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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, {
  21. ChangeEvent,
  22. FormEvent,
  23. FC,
  24. useState,
  25. useEffect,
  26. useCallback
  27. } from 'react'
  28. import { Icon } from 'antd'
  29. import Background from 'share/components/Background'
  30. import styles from 'share/components/Background/index.less'
  31. interface ILoginPawwordProps {
  32. loading: boolean
  33. onCheck: (password: string) => void
  34. }
  35. const Password: FC<ILoginPawwordProps> = ({ loading, onCheck }) => {
  36. const [password, setPwd] = useState<string>()
  37. const onChangePassword = useCallback(
  38. (e: ChangeEvent<HTMLInputElement>) => {
  39. setPwd(e.target.value.trim())
  40. },
  41. [password]
  42. )
  43. const onSubmit = useCallback((e: FormEvent<HTMLFormElement>) => {
  44. e.preventDefault()
  45. onCheck(password)
  46. }, [password])
  47. return (
  48. <Background>
  49. <form className={styles.forms} onSubmit={onSubmit}>
  50. <div className={styles.inputs}>
  51. <Icon type="unlock" />
  52. <input
  53. placeholder="请输入口令"
  54. type="text"
  55. value={password}
  56. onChange={onChangePassword}
  57. />
  58. </div>
  59. <button type="submit" className={styles.submits} disabled={loading}>
  60. {loading ? <Icon type="loading" /> : ''}确 定
  61. </button>
  62. </form>
  63. </Background>
  64. )
  65. }
  66. export default Password