fix(workspace): 修复面包屑路径逻辑,确保当前路径正常化;优化预览文件下载和调整功能

This commit is contained in:
Wenjie Zhang 2026-05-04 08:24:25 +08:00
parent a450be57e3
commit 016dfb457a
2 changed files with 9 additions and 6 deletions

View File

@ -7,8 +7,8 @@
<button
type="button"
class="breadcrumb-action"
:class="{ current: item.path === currentPath }"
:disabled="item.path === currentPath"
:class="{ current: item.path === normalizedCurrentPath }"
:disabled="item.path === normalizedCurrentPath"
:title="item.path"
@click="$emit('select-path', item.path)"
>
@ -169,8 +169,9 @@ const emit = defineEmits([
const selectedPathSet = computed(() => new Set(props.selectedPaths))
const deletingPathSet = computed(() => new Set(props.deletingPaths))
const entryPaths = computed(() => props.entries.map((entry) => entry.path))
const normalizedCurrentPath = computed(() => (props.currentPath || '/').replace(/\/+$/, '') || '/')
const breadcrumbItems = computed(() => {
const normalizedPath = props.currentPath || '/'
const normalizedPath = normalizedCurrentPath.value
if (normalizedPath === '/') {
return [{ name: '工作区', path: '/' }]
}

View File

@ -233,8 +233,8 @@ const normalizePreviewFile = async (entry, response) => {
}
if (previewType === 'image' || previewType === 'pdf') {
const response = await downloadWorkspaceFile(entry.path)
const blob = await response.blob()
const downloadResponse = await downloadWorkspaceFile(entry.path)
const blob = await downloadResponse.blob()
revokePreviewObjectUrl()
previewObjectUrl.value = URL.createObjectURL(blob)
file.previewUrl = previewObjectUrl.value
@ -554,10 +554,11 @@ const stopPreviewResize = () => {
document.body.style.userSelect = ''
window.removeEventListener('pointermove', resizePreview)
window.removeEventListener('pointerup', stopPreviewResize)
window.removeEventListener('pointercancel', stopPreviewResize)
}
const resizePreview = (event) => {
if (!workspaceMainRef.value || resizePointerId === null) return
if (!workspaceMainRef.value || resizePointerId === null || event.pointerId !== resizePointerId) return
const rect = workspaceMainRef.value.getBoundingClientRect()
const relativeX = event.clientX - rect.left
const nextPreviewPercent = Math.round(((rect.width - relativeX) / rect.width) * 100)
@ -571,6 +572,7 @@ const startPreviewResize = (event) => {
document.body.style.userSelect = 'none'
window.addEventListener('pointermove', resizePreview)
window.addEventListener('pointerup', stopPreviewResize)
window.addEventListener('pointercancel', stopPreviewResize)
}
let workspaceResizeObserver = null