index.tsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { useState } from 'react'
  2. import { useIntl } from 'umi'
  3. import './index.less'
  4. interface StaffItem {
  5. avatar: string
  6. id: string
  7. username: string
  8. workStatus: string
  9. wsKey: string
  10. department: string
  11. }
  12. type UserListProps = {
  13. onlineList: StaffItem[]
  14. }
  15. const UesrList: React.FC<UserListProps> = ({ onlineList }) => {
  16. const [visible, setVisible] = useState(false)
  17. const intl = useIntl()
  18. return (
  19. <>
  20. <span className="absolute top-70 left-[-0.75rem]" onClick={() => setVisible(!visible)}>
  21. <div className="side-bg">
  22. <span className={['side-bg-current', visible ? 'show-side-bg' : ''].join(' ')} />
  23. </div>
  24. </span>
  25. <div
  26. className={[
  27. 'book-list border border-solid border-hex-1d1d1d border-opacity-7 bg-hex-f7f9fa flex flex-col bg-hex-f9f7fa text-hex-666',
  28. visible ? 'show-short' : ''
  29. ].join(' ')}>
  30. <div className="flex-1 h-full custom-scroll">
  31. <div className="w-full">
  32. <ul className="list-none m-0">
  33. {onlineList.map(item => {
  34. return (
  35. <li
  36. key={item.id}
  37. className="table px-2 py-2 text-hex-505050 hover-white hvr-rectangle-out w-full">
  38. <div className="table-cell align-middle status status-success status-sm ">
  39. <span
  40. className="w-8 h-8 rounded-1/2 block"
  41. style={{
  42. backgroundImage: `url(http://cld.smartcost.com.cn${item.avatar}_2.jpg)`,
  43. backgroundSize: 'cover'
  44. }}
  45. />
  46. </div>
  47. <div className="table-cell w-full align-middle pl-2 pr-2">
  48. <div className="max-w-160px overflow-hidden whitespace-nowrap overflow-ellipsis text-sm relative">
  49. <span>{item.username}</span>
  50. {/* <small className="block italic text-hex-1dc9b7 text-xs">Online</small> */}
  51. <small className="block text-xs">
  52. {/* <span className="mr-1">正在</span> */}
  53. <span className="italic">
  54. {intl.formatMessage({
  55. id: item.workStatus,
  56. defaultMessage: ''
  57. })}
  58. </span>
  59. <span className="ml-1">工作中</span>
  60. </small>
  61. <span className="text-xs text-gray-500 absolute right-0 top-1/2 postion">
  62. {item.department}
  63. </span>
  64. </div>
  65. </div>
  66. </li>
  67. )
  68. })}
  69. </ul>
  70. </div>
  71. </div>
  72. </div>
  73. </>
  74. )
  75. }
  76. export default UesrList