import FlieBox from '@/components/FileBoxAD'
import HocError from '@/Hoc/HocError'
import { Tabs } from 'antd'
import React, { useEffect } from 'react'
import { useModel } from 'umi'
import style from './index.less'


const { TabPane } = Tabs;

function Cloud() {
    const { state, set, getList, init, typeEnum } = useModel('useLaunchAdq.useBdMedia')
    const { mediaType, belongUser, parentId } = state
    /**加载组件或数据更新执行请求列表 */
    useEffect(() => {
        if (belongUser === '1' || belongUser === '0') {
            getList()
        }
    }, [mediaType, belongUser, parentId])

    return <div className={style.colud}>
        <Tabs
            type="card"
            onChange={(activeKey: any) => {
                init({ mediaType: activeKey })//切换类型时先初始化数据,并设置类型
            }}
            className={style.card}
            activeKey={mediaType}
        >
            {
                ['IMG', 'VIDEO'].map((key: any) => {
                    return <TabPane tab={typeEnum[key]} key={key} style={{ backgroundColor: '#fff', padding: '0 15px' }} >
                        <Tabs onChange={(activeKey: any) => { set({ belongUser: activeKey }) }} activeKey={belongUser}>
                            <TabPane tab={'个人本地'} key={1} />
                            <TabPane tab={'公共本地'} key={0} />
                        </Tabs>
                        <FlieBox />
                    </TabPane>
                })
            }
        </Tabs>
    </div>

}

export default HocError(Cloud)