mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 18:08:07 +08:00
refactor(web): consolidate download helpers (#31664)
This commit is contained in:
@ -15,7 +15,7 @@ import {
|
||||
} from '@/app/components/base/portal-to-follow-elem'
|
||||
import { useDownloadPlugin } from '@/service/use-plugins'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { downloadFile } from '@/utils/format'
|
||||
import { downloadBlob } from '@/utils/download'
|
||||
import { getMarketplaceUrl } from '@/utils/var'
|
||||
|
||||
type Props = {
|
||||
@ -67,7 +67,7 @@ const OperationDropdown: FC<Props> = ({
|
||||
if (!needDownload || !blob)
|
||||
return
|
||||
const fileName = `${author}-${name}_${version}.zip`
|
||||
downloadFile({ data: blob, fileName })
|
||||
downloadBlob({ data: blob, fileName })
|
||||
setNeedDownload(false)
|
||||
queryClient.removeQueries({
|
||||
queryKey: ['plugins', 'downloadPlugin', downloadInfo],
|
||||
|
||||
@ -19,6 +19,7 @@ import {
|
||||
} from '@/app/components/base/portal-to-follow-elem'
|
||||
import { useStore } from '@/app/components/workflow/store'
|
||||
import { cn } from '@/utils/classnames'
|
||||
import { downloadUrl } from '@/utils/download'
|
||||
import { useNodesReadOnly } from '../hooks'
|
||||
import TipPopup from './tip-popup'
|
||||
|
||||
@ -146,26 +147,14 @@ const MoreActions: FC = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const fileName = `${filename}.${type}`
|
||||
|
||||
if (currentWorkflow) {
|
||||
setPreviewUrl(dataUrl)
|
||||
setPreviewTitle(`${filename}.${type}`)
|
||||
setPreviewTitle(fileName)
|
||||
}
|
||||
|
||||
const link = document.createElement('a')
|
||||
link.href = dataUrl
|
||||
link.download = `${filename}.${type}`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
else {
|
||||
// For current view, just download
|
||||
const link = document.createElement('a')
|
||||
link.href = dataUrl
|
||||
link.download = `${filename}.${type}`
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
downloadUrl({ url: dataUrl, fileName })
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Export image failed:', error)
|
||||
|
||||
Reference in New Issue
Block a user