diff --git a/src/layout/Container/mapRightMenu.vue b/src/layout/Container/mapRightMenu.vue index 4272057a..45a45cae 100644 --- a/src/layout/Container/mapRightMenu.vue +++ b/src/layout/Container/mapRightMenu.vue @@ -7,7 +7,7 @@ import { mapRightMenuEvent } from "@/gis/ol/olRightMenu"; import { getGif } from "@/utils/axios/symn"; import { useI18n } from "vue-i18n"; import { ElMessage } from "element-plus"; -import log from '@/pages/symn/log/index.vue'; +import log from "@/pages/symn/log/index.vue"; import { getrwssGifFileData, @@ -259,7 +259,7 @@ function handleIconClick(item: MapControlItem) { isShowGif.value = true; } ); - }else if(item.name=='calendar'){ + } else if (item.name == "calendar") { let falg: any = !item.isActive; switchIconActive(item.name, falg); EventBusTool.getEventBus().publish("sjfxCalendarEvent", { @@ -328,6 +328,23 @@ const generateGif = () => { ); }; +// 提取文件名工具 +const getFileNameFromDisposition = ( + disposition?: string, + defaultName = "download.gif" +) => { + if (!disposition) return defaultName; + const match = disposition.match(/filename=([^;]+)/); + if (match?.[1]) { + try { + return decodeURIComponent(match[1]); + } catch { + return match[1]; + } + } + return defaultName; +}; + // 下载任务所属GIF文件 const downGifFile = () => { let taskId = JSON.parse(sessionStorage.getItem("ssmnDataItem")).id; @@ -338,11 +355,16 @@ const downGifFile = () => { speciesId, genGifType: downTypeValue.value, }, - (res: Blob) => { - console.log(res, "2222222222222"); - // res 直接是Blob,没有headers,直接写死文件名 - const fileName = "JPX38_region.gif"; - const url = URL.createObjectURL(res); + (response) => { + console.log(response, "2222222222222"); + const blob = response.data; + const disposition = response.headers["content-disposition"]; + const fileName = getFileNameFromDisposition( + disposition, + "JPX38_global.gif" + ); + + const url = URL.createObjectURL(blob); const a = document.createElement("a"); a.href = url; a.download = fileName; @@ -405,7 +427,7 @@ onMounted(() => { svgList.value = [...baseList.value, ...yxcjTool.value]; } else if (res.key === "gifIcon") { svgList.value = [...baseList.value, ...symnTool.value]; - }else if(res.key=="sjfxList"){ + } else if (res.key == "sjfxList") { svgList.value = [...baseList.value, ...sjfxTool.value]; } // 按钮菜单触发状态 @@ -418,7 +440,7 @@ onMounted(() => { switchIconActive(res.key, res.falg); } - if(res.key == "calendar"){ + if (res.key == "calendar") { switchIconActive(res.key, res.falg); } }); @@ -495,45 +517,47 @@ onMounted(() => { style="min-height: 120px" @close="isShowGif = false" > - - - - - - - + + + + - - - - - - - - - - - - - - - - - 生成GIF - 查看日志 - + + + + + + + + + + + 生成GIF + + 查看日志 GIF -
-
+
+
{ @click="downGifFile" type="primary" class="custom-btn" - style="margin-left: 10px;" + style="margin-left: 10px" >下载
@@ -553,9 +577,9 @@ onMounted(() => { - - - + + +