fix. [PWT-122] 액션 버튼 다운로드 버튼 모바일 다운로드 시 파일 확장자 오류 수정
This commit is contained in:
@@ -24,6 +24,7 @@ const componentTag = computed((): string => {
|
||||
switch (props.type) {
|
||||
case 'external':
|
||||
case 'link':
|
||||
case 'download':
|
||||
return 'a'
|
||||
case 'internal':
|
||||
return 'AtomsLocaleLink'
|
||||
@@ -45,6 +46,14 @@ const componentProps = computed(() => {
|
||||
}
|
||||
}
|
||||
|
||||
if (props.type === 'download') {
|
||||
return {
|
||||
href: props.href,
|
||||
target: '_self',
|
||||
download: props.href?.split('/').pop() ?? 'download',
|
||||
}
|
||||
}
|
||||
|
||||
return {}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -54,7 +54,7 @@ const isRunButtonVisible = (btnInfo: PageDataResourceGroupBtnInfo): boolean => {
|
||||
}
|
||||
}
|
||||
|
||||
const downloadZip = async (url: string, osType: number) => {
|
||||
const downloadFile = async (url: string = '', osType: number = 0) => {
|
||||
if (osType === 1 && breakpoints.value?.isMobile) {
|
||||
modalStore.handleOpenAlert({ contentText: tm('Alert_Download_PC') })
|
||||
return
|
||||
@@ -63,20 +63,23 @@ const downloadZip = async (url: string, osType: number) => {
|
||||
const fileUrl = getResourceHost(url)
|
||||
|
||||
try {
|
||||
const res = await $fetch(fileUrl, {
|
||||
const res = await $fetch<Blob>(fileUrl, {
|
||||
method: 'GET',
|
||||
responseType: 'blob',
|
||||
timeout: 10000,
|
||||
})
|
||||
|
||||
const blob = new Blob([res as BlobPart], { type: 'application/zip' })
|
||||
const blob = res
|
||||
const blobUrl = URL.createObjectURL(blob)
|
||||
const pathPart = fileUrl.split('/').pop()
|
||||
|
||||
const pathPart = fileUrl.split('/').pop() ?? 'download'
|
||||
const a = document.createElement('a')
|
||||
|
||||
a.href = blobUrl
|
||||
a.download = pathPart ?? 'download.zip'
|
||||
a.download = pathPart
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
a.remove()
|
||||
|
||||
// 메모리 정리
|
||||
URL.revokeObjectURL(blobUrl)
|
||||
@@ -108,7 +111,7 @@ const handleButtonClick = (button: PageDataResourceGroup) => {
|
||||
modalStore.handleOpenYoutube({ youtubeUrl: btnDetail.url ?? '' })
|
||||
return
|
||||
case 'DOWNLOAD':
|
||||
downloadZip(btnDetail?.file_path ?? '', btnDetail?.os_type ?? 0)
|
||||
downloadFile(btnDetail?.file_path, btnDetail?.os_type)
|
||||
return
|
||||
default:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user