Эх сурвалжийг харах

恢复 sidebar 代码中 点击我的应用的列表逻辑

Ryuiso 3 сар өмнө
parent
commit
99b80abeac

+ 8 - 7
app/components/sidebar.tsx

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