@@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from 'react';
33import ArticleIcon from '@mui/icons-material/Article' ;
44import FolderRounded from '@mui/icons-material/FolderRounded' ;
55import FolderOpenIcon from '@mui/icons-material/FolderOpen' ;
6- import { Box , CircularProgress } from '@mui/material' ;
6+ import { Box , CircularProgress , Skeleton } from '@mui/material' ;
77import {
88 TreeItemDragAndDropOverlay ,
99 TreeItemIcon ,
@@ -170,9 +170,11 @@ const RepoTree = ( {flag, directory }: {flag:string, directory: any[] }) => {
170170 }
171171
172172 return sortProjectsByType ( directory ) . map ( ( item ) => {
173-
173+
174174 const nodeName = item ?. name ?? '' ;
175- const currentPath = `${ parentBasePath } /${ nodeName } ` . replace ( '//' , '/' ) || '/' ;
175+ const currentPath = flag === 'contents' ?
176+ `${ parentBasePath } /${ nodeName } ` . replace ( '//' , '/' ) || '/'
177+ : `${ parentBasePath } ` . replace ( '//' , '/' ) || '/'
176178
177179 // eslint-disable-next-line no-console
178180 // console.log('生成节点路径:', nodeName, '=>', currentPath);
@@ -192,7 +194,7 @@ const RepoTree = ( {flag, directory }: {flag:string, directory: any[] }) => {
192194 ] : undefined ,
193195 } ;
194196 } ) ;
195- } , [ ] ) ;
197+ } , [ flag ] ) ;
196198
197199 useEffect ( ( ) => {
198200 if ( ! Array . isArray ( directory ) || directory . length === 0 ) {
@@ -205,7 +207,7 @@ const RepoTree = ( {flag, directory }: {flag:string, directory: any[] }) => {
205207
206208 setTreeData ( convertToTreeData ( rootPath , directory ) ) ;
207209 setIsInitialLoading ( false ) ;
208- } , [ directory , convertToTreeData , basePath ] ) ;
210+ } , [ directory , convertToTreeData , basePath ] ) ;
209211
210212 const sortProjectsByType = ( projects : any [ ] ) => {
211213 if ( ! Array . isArray ( projects ) || projects . length === 0 ) {
@@ -230,8 +232,9 @@ const RepoTree = ( {flag, directory }: {flag:string, directory: any[] }) => {
230232 // console.warn('updateTreeData: 接收到非数组或空的当前树数据', currentTree);
231233 return [ ] ;
232234 }
233-
235+
234236 return currentTree . map ( ( node ) => {
237+
235238 if ( node . id === nodeId ) {
236239 return {
237240 ...node ,
@@ -363,23 +366,25 @@ const RepoTree = ( {flag, directory }: {flag:string, directory: any[] }) => {
363366
364367 return (
365368 < >
366- { isInitialLoading ? (
369+ { isInitialLoading ? (
367370 < Box sx = { { display : 'flex' , justifyContent : 'center' , padding : '16px' } } >
368- < CircularProgress />
371+ < CircularProgress size = "1.2rem" color = "inherit" />
369372 </ Box >
370- ) : treeData . length === 0 ? (
371- < Box sx = { { color : 'text.secondary' , padding : '16px' } } >
372- no data
373+ )
374+ : treeData . length === 0 ? (
375+ < Box sx = { { display : 'flex' , paddingLeft :'16px' } } >
376+ < Skeleton width = "200px" height = "30px" />
373377 </ Box >
374- ) : (
378+ )
379+ : (
375380 < RichTreeView
376381 items = { treeData }
377382 defaultExpandedItems = { [ 'grid' , 'pickers' ] }
378383 expandedItems = { expandedNodes }
379384 selectedItems = { selectedNode }
380385 onExpandedItemsChange = { handleNodeToggle }
381386 onSelectedItemsChange = { handleNodeSelect }
382- sx = { { height : 'fit-content' , flexGrow : 1 , maxWidth : 400 , overflowY : 'auto' } }
387+ sx = { { height : 'fit-content' , flexGrow : 1 , Width : 400 , overflowY : 'auto' } }
383388 slots = { {
384389 item : ( itemProps ) => (
385390 < CustomTreeItem
0 commit comments