mirror of
https://github.com/langgenius/dify.git
synced 2026-05-01 07:58:02 +08:00
The backend route /apps/{app_id}/sandbox/files expects the actual app ID
as the URL parameter and derives sandbox_id from the logged-in user
internally. The frontend was incorrectly passing userProfile.id (user ID)
as the appId, resulting in wrong storage paths.
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
'use client'
|
|
|
|
import * as React from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import Loading from '@/app/components/base/loading'
|
|
import { useStore } from '@/app/components/workflow/store'
|
|
import { useSandboxFileDownloadUrl } from '@/service/use-sandbox-file'
|
|
import { getArtifactPath } from './constants'
|
|
import { getFileExtension } from './utils/file-utils'
|
|
import ReadOnlyFilePreview from './viewer/read-only-file-preview'
|
|
|
|
const ArtifactContentPanel = () => {
|
|
const { t } = useTranslation('workflow')
|
|
const activeTabId = useStore(s => s.activeTabId)
|
|
const appId = useStore(s => s.appId)
|
|
|
|
const path = activeTabId ? getArtifactPath(activeTabId) : undefined
|
|
const fileName = path?.split('/').pop() ?? ''
|
|
const extension = getFileExtension(fileName)
|
|
|
|
const { data: ticket, isLoading } = useSandboxFileDownloadUrl(appId, path)
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="flex h-full w-full items-center justify-center bg-components-panel-bg">
|
|
<Loading type="area" />
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (!ticket?.download_url) {
|
|
return (
|
|
<div className="flex h-full w-full items-center justify-center bg-components-panel-bg text-text-tertiary">
|
|
<span className="system-sm-regular">
|
|
{t('skillSidebar.loadError')}
|
|
</span>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div className="h-full w-full overflow-auto bg-components-panel-bg">
|
|
<ReadOnlyFilePreview
|
|
downloadUrl={ticket.download_url}
|
|
fileName={fileName}
|
|
extension={extension}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default React.memo(ArtifactContentPanel)
|