Skip to content

Commit

Permalink
perf: 用download.json 替换模型json下载
Browse files Browse the repository at this point in the history
  • Loading branch information
zws-code committed Jan 16, 2025
1 parent e44f48c commit 9febee7
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/components/SimpleProcessDesignerV2/src/SimpleProcessModel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { SimpleFlowNode, NodeType, NODE_DEFAULT_TEXT } from './consts'
import { useWatchNode } from './node'
import { ZoomOut, ZoomIn, ScaleToOriginal } from '@element-plus/icons-vue'
import { isString } from '@/utils/is'
import download from "@/utils/download";
defineOptions({
name: 'SimpleProcessModel'
Expand Down Expand Up @@ -174,18 +175,7 @@ defineExpose({
/** 导出 JSON */
// TODO @zws:增加一个 download 里面搞个 json 更好
const exportJson = () => {
const blob = new Blob([JSON.stringify(processNodeTree.value)])
const tempLink = document.createElement('a') // 创建a标签
const href = window.URL.createObjectURL(blob) // 创建下载的链接
// filename
const fileName = `model.json`
tempLink.href = href
tempLink.target = '_blank'
tempLink.download = fileName
document.body.appendChild(tempLink)
tempLink.click() // 点击下载
document.body.removeChild(tempLink) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉 blob 对象
download.json(new Blob([JSON.stringify(processNodeTree.value)]), 'model.json')
}
/** 导入 JSON */
Expand Down

0 comments on commit 9febee7

Please sign in to comment.