Skip to content

Commit 9febee7

Browse files
committed
perf: 用download.json 替换模型json下载
1 parent e44f48c commit 9febee7

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/components/SimpleProcessDesignerV2/src/SimpleProcessModel.vue

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { SimpleFlowNode, NodeType, NODE_DEFAULT_TEXT } from './consts'
5151
import { useWatchNode } from './node'
5252
import { ZoomOut, ZoomIn, ScaleToOriginal } from '@element-plus/icons-vue'
5353
import { isString } from '@/utils/is'
54+
import download from "@/utils/download";
5455
5556
defineOptions({
5657
name: 'SimpleProcessModel'
@@ -174,18 +175,7 @@ defineExpose({
174175
/** 导出 JSON */
175176
// TODO @zws:增加一个 download 里面搞个 json 更好
176177
const exportJson = () => {
177-
const blob = new Blob([JSON.stringify(processNodeTree.value)])
178-
const tempLink = document.createElement('a') // 创建a标签
179-
const href = window.URL.createObjectURL(blob) // 创建下载的链接
180-
// filename
181-
const fileName = `model.json`
182-
tempLink.href = href
183-
tempLink.target = '_blank'
184-
tempLink.download = fileName
185-
document.body.appendChild(tempLink)
186-
tempLink.click() // 点击下载
187-
document.body.removeChild(tempLink) // 下载完成移除元素
188-
window.URL.revokeObjectURL(href) // 释放掉 blob 对象
178+
download.json(new Blob([JSON.stringify(processNodeTree.value)]), 'model.json')
189179
}
190180
191181
/** 导入 JSON */

0 commit comments

Comments
 (0)