fix. [PWT-122] 액션 버튼 다운로드 버튼 모바일 다운로드 시 파일 확장자 오류 수정

This commit is contained in:
clkim
2025-11-28 14:38:57 +09:00
parent 25f38273cd
commit e5f0bf7992
2 changed files with 18 additions and 6 deletions

View File

@@ -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>

View File

@@ -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