fix(front): enhance error handling in file download components by refining error message extraction

This commit is contained in:
keven1024
2025-07-07 15:55:08 +08:00
parent 1b12703b90
commit 3001ea3250
3 changed files with 6 additions and 6 deletions

View File

@@ -135,8 +135,8 @@ watch(
}
try {
await downloadFileByShareId(id)
} catch (error) {
toast.error((error as any)?.data?.message || error)
} catch (error: any) {
toast.error(error?.data?.message || error?.message || error)
}
}
"

View File

@@ -34,8 +34,8 @@ const handleDownload = async () => {
throw new Error('获取token失败')
}
downloadFile(token)
} catch (error) {
toast.error((error as any)?.data?.message || error)
} catch (error: any) {
toast.error(error?.data?.message || error?.message || error)
} finally {
queryClient.invalidateQueries({ queryKey: ['share', id] })
}

View File

@@ -64,8 +64,8 @@ const handlePreview = async () => {
}
}>(`/api/download?token=${token}`)
previewText.value = r?.data?.data
} catch (error) {
toast.error((error as any)?.data?.message || error)
} catch (error: any) {
toast.error(error?.data?.message || error?.message || error)
}
}
</script>