fix(workspace): 修复面包屑路径逻辑,确保当前路径正常化;优化预览文件下载和调整功能
This commit is contained in:
parent
a450be57e3
commit
016dfb457a
@ -7,8 +7,8 @@
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="breadcrumb-action"
|
class="breadcrumb-action"
|
||||||
:class="{ current: item.path === currentPath }"
|
:class="{ current: item.path === normalizedCurrentPath }"
|
||||||
:disabled="item.path === currentPath"
|
:disabled="item.path === normalizedCurrentPath"
|
||||||
:title="item.path"
|
:title="item.path"
|
||||||
@click="$emit('select-path', item.path)"
|
@click="$emit('select-path', item.path)"
|
||||||
>
|
>
|
||||||
@ -169,8 +169,9 @@ const emit = defineEmits([
|
|||||||
const selectedPathSet = computed(() => new Set(props.selectedPaths))
|
const selectedPathSet = computed(() => new Set(props.selectedPaths))
|
||||||
const deletingPathSet = computed(() => new Set(props.deletingPaths))
|
const deletingPathSet = computed(() => new Set(props.deletingPaths))
|
||||||
const entryPaths = computed(() => props.entries.map((entry) => entry.path))
|
const entryPaths = computed(() => props.entries.map((entry) => entry.path))
|
||||||
|
const normalizedCurrentPath = computed(() => (props.currentPath || '/').replace(/\/+$/, '') || '/')
|
||||||
const breadcrumbItems = computed(() => {
|
const breadcrumbItems = computed(() => {
|
||||||
const normalizedPath = props.currentPath || '/'
|
const normalizedPath = normalizedCurrentPath.value
|
||||||
if (normalizedPath === '/') {
|
if (normalizedPath === '/') {
|
||||||
return [{ name: '工作区', path: '/' }]
|
return [{ name: '工作区', path: '/' }]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -233,8 +233,8 @@ const normalizePreviewFile = async (entry, response) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (previewType === 'image' || previewType === 'pdf') {
|
if (previewType === 'image' || previewType === 'pdf') {
|
||||||
const response = await downloadWorkspaceFile(entry.path)
|
const downloadResponse = await downloadWorkspaceFile(entry.path)
|
||||||
const blob = await response.blob()
|
const blob = await downloadResponse.blob()
|
||||||
revokePreviewObjectUrl()
|
revokePreviewObjectUrl()
|
||||||
previewObjectUrl.value = URL.createObjectURL(blob)
|
previewObjectUrl.value = URL.createObjectURL(blob)
|
||||||
file.previewUrl = previewObjectUrl.value
|
file.previewUrl = previewObjectUrl.value
|
||||||
@ -554,10 +554,11 @@ const stopPreviewResize = () => {
|
|||||||
document.body.style.userSelect = ''
|
document.body.style.userSelect = ''
|
||||||
window.removeEventListener('pointermove', resizePreview)
|
window.removeEventListener('pointermove', resizePreview)
|
||||||
window.removeEventListener('pointerup', stopPreviewResize)
|
window.removeEventListener('pointerup', stopPreviewResize)
|
||||||
|
window.removeEventListener('pointercancel', stopPreviewResize)
|
||||||
}
|
}
|
||||||
|
|
||||||
const resizePreview = (event) => {
|
const resizePreview = (event) => {
|
||||||
if (!workspaceMainRef.value || resizePointerId === null) return
|
if (!workspaceMainRef.value || resizePointerId === null || event.pointerId !== resizePointerId) return
|
||||||
const rect = workspaceMainRef.value.getBoundingClientRect()
|
const rect = workspaceMainRef.value.getBoundingClientRect()
|
||||||
const relativeX = event.clientX - rect.left
|
const relativeX = event.clientX - rect.left
|
||||||
const nextPreviewPercent = Math.round(((rect.width - relativeX) / rect.width) * 100)
|
const nextPreviewPercent = Math.round(((rect.width - relativeX) / rect.width) * 100)
|
||||||
@ -571,6 +572,7 @@ const startPreviewResize = (event) => {
|
|||||||
document.body.style.userSelect = 'none'
|
document.body.style.userSelect = 'none'
|
||||||
window.addEventListener('pointermove', resizePreview)
|
window.addEventListener('pointermove', resizePreview)
|
||||||
window.addEventListener('pointerup', stopPreviewResize)
|
window.addEventListener('pointerup', stopPreviewResize)
|
||||||
|
window.addEventListener('pointercancel', stopPreviewResize)
|
||||||
}
|
}
|
||||||
|
|
||||||
let workspaceResizeObserver = null
|
let workspaceResizeObserver = null
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user