@@ -175,6 +175,9 @@ const {
175175 search,
176176} = useTable ((page ) => listFile ({ ... queryForm , ... page }), { immediate: false , paginationOption })
177177const filePreviewRef = ref ()
178+
179+ const pathNameMap = ref <Map <string , string >>(new Map ())
180+
178181// 点击文件
179182const handleClickFile = (item : FileItem ) => {
180183 if (ImageTypes .includes (item .extension )) {
@@ -221,7 +224,9 @@ const handleClickFile = (item: FileItem) => {
221224// 双击文件
222225const handleDblclickFile = (item : FileItem ) => {
223226 if (item .type === 0 ) {
224- queryForm .parentPath = ` ${item .parentPath === ' /' ? ' ' : item .parentPath }/${item .name } `
227+ const path = ` ${item .parentPath === ' /' ? ' ' : item .parentPath }/${item .name } `
228+ pathNameMap .value .set (path , item .originalName )
229+ queryForm .parentPath = path
225230 search ()
226231 }
227232}
@@ -344,10 +349,32 @@ const handleCreateDir = async () => {
344349// 解析路径生成面包屑列表
345350const breadcrumbList = computed (() => {
346351 const path = queryForm .parentPath || ' /'
347- const parts = path .split (' /' ).filter ((p ) => p !== ' ' ) // 分割路径并过滤空字符串
352+ if (path === ' /' ) {
353+ return []
354+ }
355+ const parts = path .split (' /' ).filter ((p ) => p !== ' ' )
356+
348357 return parts .map ((part , index ) => {
349- const fullPath = parts .slice (0 , index + 1 ).join (' /' )
350- return { name: part || ' 根目录' , path: ` /${fullPath } ` }
358+ const fullPath = ` /${parts .slice (0 , index + 1 ).join (' /' )} `
359+ let displayName = pathNameMap .value .get (fullPath )
360+
361+ if (! displayName ) {
362+ const foundItem = fileList .value .find ((item ) => {
363+ const itemPath = ` ${item .parentPath === ' /' ? ' ' : item .parentPath }/${item .name } `
364+ return itemPath === fullPath && item .type === 0
365+ })
366+
367+ if (foundItem ) {
368+ displayName = foundItem .originalName
369+ pathNameMap .value .set (fullPath , displayName )
370+ }
371+ }
372+
373+ if (! displayName ) {
374+ displayName = part
375+ }
376+
377+ return { name: displayName , path: fullPath }
351378 })
352379})
353380
0 commit comments