Commit ade30966 by zhuzhequan

pod us 排版png图片下载

parent 04823d8a
...@@ -32,6 +32,7 @@ declare module 'vue' { ...@@ -32,6 +32,7 @@ declare module 'vue' {
ElImage: typeof import('element-plus/es')['ElImage'] ElImage: typeof import('element-plus/es')['ElImage']
ElInput: typeof import('element-plus/es')['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElLink: typeof import('element-plus/es')['ElLink']
ElMenu: typeof import('element-plus/es')['ElMenu'] ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem'] ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption'] ElOption: typeof import('element-plus/es')['ElOption']
......
...@@ -2220,11 +2220,31 @@ const downloadTif = async (type: string) => { ...@@ -2220,11 +2220,31 @@ const downloadTif = async (type: string) => {
type, type,
) )
const url = type === 'tiff' ? `https://ps.jomalls.com/tiff/` + res.message : filePath + res.message const url = type === 'tiff' ? `https://ps.jomalls.com/tiff/` + res.message : filePath + res.message
window.open(url, '_blank')
if (type === 'tiff') { if (type === 'tiff') {
window.open(url, '_blank')
tifDownloadLoading.value = false tifDownloadLoading.value = false
} else { } else {
pngDownloadLoading.value = false fetch(url)
.then(response => {
// 确保响应是 OK
if (!response.ok) {
throw new Error('网络响应错误')
}
// 返回图片的二进制数据(Blob)
return response.blob()
})
.then(blob => {
const a = document.createElement('a')
a.href = window.URL.createObjectURL(blob)
a.target = '_blank'
a.download = (res.message as string).split('/')[ (res.message as string).split('/').length - 1]
a.click()
pngDownloadLoading.value = false
})
.catch(error => {
console.error('下载图片时出错:', error)
pngDownloadLoading.value = false
})
} }
} catch (e) { } catch (e) {
console.log(e) console.log(e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment