diff --git a/packages/ui/src/layouts/shared/files-tab/components/FileContextMenu.vue b/packages/ui/src/layouts/shared/files-tab/components/FileContextMenu.vue index f0b49c09ac..cd8843d32a 100644 --- a/packages/ui/src/layouts/shared/files-tab/components/FileContextMenu.vue +++ b/packages/ui/src/layouts/shared/files-tab/components/FileContextMenu.vue @@ -85,6 +85,7 @@ import { commonMessages } from '#ui/utils/common-messages' import { injectFileManager } from '../providers/file-manager' import type { FileContextMenuOption, FileItem } from '../types' +import { joinDisplayPath } from '../utils' const { formatMessage } = useVIntl() const { addNotification } = injectNotificationManager() @@ -129,9 +130,7 @@ function handleCopyFilename() { function getFullPath() { if (!currentItem.value) return '' - const basePath = ctx.basePath?.value - const itemPath = currentItem.value.path - return basePath ? `${basePath}/${itemPath}`.replace(/\/+/g, '/') : itemPath + return joinDisplayPath(ctx.basePath?.value, currentItem.value.path) } function handleCopyPath() { diff --git a/packages/ui/src/layouts/shared/files-tab/components/FileTableRow.vue b/packages/ui/src/layouts/shared/files-tab/components/FileTableRow.vue index 8a696a9612..9384e3b2a0 100644 --- a/packages/ui/src/layouts/shared/files-tab/components/FileTableRow.vue +++ b/packages/ui/src/layouts/shared/files-tab/components/FileTableRow.vue @@ -133,6 +133,7 @@ import { } from '../composables/file-drag-state' import { injectFileManager } from '../providers/file-manager' import type { FileItem } from '../types' +import { joinDisplayPath } from '../utils' const { formatMessage } = useVIntl() const { addNotification } = injectNotificationManager() @@ -204,8 +205,7 @@ const fileExtension = computed(() => getFileExtension(props.name)) const isZip = computed(() => fileExtension.value === 'zip') function getFullPath() { - const basePath = ctx.basePath?.value - return basePath ? `${basePath}/${props.path}`.replace(/\/+/g, '/') : props.path + return joinDisplayPath(ctx.basePath?.value, props.path) } const menuOptions = computed(() => { diff --git a/packages/ui/src/layouts/shared/files-tab/utils.ts b/packages/ui/src/layouts/shared/files-tab/utils.ts new file mode 100644 index 0000000000..00beb570dd --- /dev/null +++ b/packages/ui/src/layouts/shared/files-tab/utils.ts @@ -0,0 +1,9 @@ +export function joinDisplayPath(basePath: string | undefined, itemPath: string) { + if (!basePath) return itemPath + + const separator = basePath.includes('\\') ? '\\' : '/' + const path = itemPath.replace(/^[\\/]+/, '').replace(/[\\/]+/g, separator) + const base = basePath.replace(/[\\/]+$/, '') + + return path ? `${base}${separator}${path}` : basePath +}