import { useState, useEffect } from 'react'; import SubCard from 'ui-component/cards/SubCard'; // import { gridSpacing } from 'store/constant'; import { API } from 'utils/api'; import { showError, showSuccess } from 'utils/common'; import { Typography, Accordion, AccordionSummary, AccordionDetails, Box, Stack } from '@mui/material'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import Label from 'ui-component/Label'; const SupportModels = () => { const [modelList, setModelList] = useState([]); const fetchModels = async () => { try { let res = await API.get(`/api/user/models`); if (res === undefined) { return; } // 对 res.data.data 里面的 owned_by 进行分组 let modelGroup = {}; res.data.data.forEach((model) => { if (modelGroup[model.owned_by] === undefined) { modelGroup[model.owned_by] = []; } modelGroup[model.owned_by].push(model.id); }); setModelList(modelGroup); } catch (error) { showError(error.message); } }; useEffect(() => { fetchModels(); }, []); return ( }> 当前可用模型 {Object.entries(modelList).map(([title, models]) => ( {models.map((model) => ( ))} ))} ); }; export default SupportModels;