import React from 'react'; // import { message } from 'antd'; import { AssetTypeEnum, AssetInfo } from '@easytwin/core'; // import { PlusOutlined } from '@easyv/react-icons'; import { MenuItem, PreviewImage } from '@/components'; import { AssetTypeInfos } from '@/constants'; import { useAsset, useAssetCategory } from '../../module'; // const AssetTypeGroupInfo: { key: string; label: string }[] = [ // // { // // key: '', // // label: '全部', // // }, // ...Object.entries(AssetTypeInfo) // .filter((i) => !i[1].planned) // .map((i) => ({ // key: i[0], // label: i[1].label, // })), // ]; export interface AssetSelectProp { onSelect?: (asset: AssetInfo) => void; onMouseLeave?: () => void; } const AssetSelect: React.FC = function ({ onSelect, onMouseLeave }) { const { assetList, getAssetList } = useAsset(); const { assetCategoryList } = useAssetCategory(); const [currentIndex, setCurrentIndex] = React.useState(0); const selectAssteGroupKey = assetCategoryList[currentIndex]?.id; React.useEffect(() => { getAssetList({ id: selectAssteGroupKey, }); }, [getAssetList, selectAssteGroupKey]); return (
{/* left menu */}
{assetCategoryList.map(({ id, name }, index) => ( setCurrentIndex(index)} /> ))}
{/* right content */}
{/*
message.info('coding...')} >
*/} {assetList?.map((item) => (
onSelect?.(item)}> {item?.thumb && ( )}
{item.name}
))}
); }; export default AssetSelect;