|
|
@@ -231,13 +231,18 @@ const AppDrawer: React.FC<AppDrawerProps> = (props) => {
|
|
|
setListLoading(true);
|
|
|
try {
|
|
|
const res = await api.get(`/deepseek/api/project/app`);
|
|
|
+ // 确保 res.data 是数组,如果不是则设为空数组
|
|
|
+ const data = Array.isArray(res.data) ? res.data : [];
|
|
|
+
|
|
|
if (type === 'all') {
|
|
|
- setList(res.data);
|
|
|
+ setList(data);
|
|
|
} else {
|
|
|
- setList(res.data.filter((item: any) => item.isCollect));
|
|
|
+ setList(data.filter((item: any) => item.isCollect));
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error(error);
|
|
|
+ // 出错时设置为空数组,避免渲染错误
|
|
|
+ setList([]);
|
|
|
} finally {
|
|
|
setListLoading(false);
|
|
|
}
|
|
|
@@ -284,7 +289,7 @@ const AppDrawer: React.FC<AppDrawerProps> = (props) => {
|
|
|
onClose={onClose}
|
|
|
>
|
|
|
{
|
|
|
- list.length > 0 ?
|
|
|
+ Array.isArray(list) && list.length > 0 ?
|
|
|
list.map((item, index) => {
|
|
|
return <div
|
|
|
style={{
|