index.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import FlieBox from '@/components/FileBoxAD'
  2. import HocError from '@/Hoc/HocError'
  3. import { Tabs } from 'antd'
  4. import React, { useEffect, useRef } from 'react'
  5. import { useModel } from 'umi'
  6. import style from './index.less'
  7. import SyncModal from '@/components/FileBox/components/syncModal'
  8. const { TabPane } = Tabs;
  9. function Cloud() {
  10. const { state, set, getList, init, typeEnum } = useModel('useLaunchAdq.useBdMedia')
  11. let refSync: { current: { show: (id: string, appIds: string[]) => void } } | any = useRef()//syncModal获取实例方法
  12. const { fileType, belongUser, parentId } = state
  13. /**加载组件或数据更新执行请求列表 */
  14. useEffect(() => {
  15. if (belongUser === '1' || belongUser === '0') {
  16. getList()
  17. }
  18. }, [fileType, belongUser, parentId])
  19. return <div className={style.colud}>
  20. <Tabs
  21. type="card"
  22. onChange={(activeKey: any) => {
  23. init({ fileType: activeKey })//切换类型时先初始化数据,并设置类型
  24. }}
  25. className={style.card}
  26. activeKey={fileType}
  27. >
  28. {
  29. ['image', 'video'].map((key: any) => {
  30. return <TabPane tab={typeEnum[key]} key={key} style={{ backgroundColor: '#fff', padding: '0 15px' }} >
  31. <Tabs onChange={(activeKey: any) => { set({ belongUser: activeKey }) }} activeKey={belongUser}>
  32. <TabPane tab={'个人本地'} key={1} />
  33. <TabPane tab={'公共本地'} key={0} />
  34. </Tabs>
  35. <FlieBox showSync={refSync?.current?.show} />
  36. </TabPane>
  37. })
  38. }
  39. </Tabs>
  40. {/**同步弹窗 */}
  41. <SyncModal ref={refSync} />
  42. </div>
  43. }
  44. export default HocError(Cloud)