fix(system/file): rename folder issue (#78)

This commit is contained in:
ppxb
2025-11-17 10:27:25 +08:00
committed by GitHub
parent 1a0429dfb6
commit 26e3738b74

View File

@@ -175,6 +175,9 @@ const {
search, search,
} = useTable((page) => listFile({ ...queryForm, ...page }), { immediate: false, paginationOption }) } = useTable((page) => listFile({ ...queryForm, ...page }), { immediate: false, paginationOption })
const filePreviewRef = ref() const filePreviewRef = ref()
const pathNameMap = ref<Map<string, string>>(new Map())
// 点击文件 // 点击文件
const handleClickFile = (item: FileItem) => { const handleClickFile = (item: FileItem) => {
if (ImageTypes.includes(item.extension)) { if (ImageTypes.includes(item.extension)) {
@@ -221,7 +224,9 @@ const handleClickFile = (item: FileItem) => {
// 双击文件 // 双击文件
const handleDblclickFile = (item: FileItem) => { const handleDblclickFile = (item: FileItem) => {
if (item.type === 0) { if (item.type === 0) {
queryForm.parentPath = `${item.parentPath === '/' ? '' : item.parentPath}/${item.name}` const path = `${item.parentPath === '/' ? '' : item.parentPath}/${item.name}`
pathNameMap.value.set(path, item.originalName)
queryForm.parentPath = path
search() search()
} }
} }
@@ -344,10 +349,32 @@ const handleCreateDir = async () => {
// 解析路径生成面包屑列表 // 解析路径生成面包屑列表
const breadcrumbList = computed(() => { const breadcrumbList = computed(() => {
const path = queryForm.parentPath || '/' const path = queryForm.parentPath || '/'
const parts = path.split('/').filter((p) => p !== '') // 分割路径并过滤空字符串 if (path === '/') {
return []
}
const parts = path.split('/').filter((p) => p !== '')
return parts.map((part, index) => { return parts.map((part, index) => {
const fullPath = parts.slice(0, index + 1).join('/') const fullPath = `/${parts.slice(0, index + 1).join('/')}`
return { name: part || '根目录', path: `/${fullPath}` } let displayName = pathNameMap.value.get(fullPath)
if (!displayName) {
const foundItem = fileList.value.find((item) => {
const itemPath = `${item.parentPath === '/' ? '' : item.parentPath}/${item.name}`
return itemPath === fullPath && item.type === 0
})
if (foundItem) {
displayName = foundItem.originalName
pathNameMap.value.set(fullPath, displayName)
}
}
if (!displayName) {
displayName = part
}
return { name: displayName, path: fullPath }
}) })
}) })