mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-12-09 00:59:55 +08:00
fix(system/file): rename folder issue (#78)
This commit is contained in:
@@ -175,6 +175,9 @@ const {
|
||||
search,
|
||||
} = useTable((page) => listFile({ ...queryForm, ...page }), { immediate: false, paginationOption })
|
||||
const filePreviewRef = ref()
|
||||
|
||||
const pathNameMap = ref<Map<string, string>>(new Map())
|
||||
|
||||
// 点击文件
|
||||
const handleClickFile = (item: FileItem) => {
|
||||
if (ImageTypes.includes(item.extension)) {
|
||||
@@ -221,7 +224,9 @@ const handleClickFile = (item: FileItem) => {
|
||||
// 双击文件
|
||||
const handleDblclickFile = (item: FileItem) => {
|
||||
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()
|
||||
}
|
||||
}
|
||||
@@ -344,10 +349,32 @@ const handleCreateDir = async () => {
|
||||
// 解析路径生成面包屑列表
|
||||
const breadcrumbList = computed(() => {
|
||||
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) => {
|
||||
const fullPath = parts.slice(0, index + 1).join('/')
|
||||
return { name: part || '根目录', path: `/${fullPath}` }
|
||||
const fullPath = `/${parts.slice(0, index + 1).join('/')}`
|
||||
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 }
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user