优化 预览稿件时图片加载慢导致无法显示

This commit is contained in:
YuanFeng 2024-09-08 17:48:48 +08:00
parent c1a7bee638
commit f30c3f233a
2 changed files with 23 additions and 22 deletions

View File

@ -59,7 +59,7 @@ import {
mergeDeepObject, objectHasKey,
} from "@/components/DraftDesign/utils/FuncUtil";
import {register, getTeleport} from '@antv/x6-vue-shape'
import {register} from '@antv/x6-vue-shape'
import './icons/style.css'
@ -169,8 +169,6 @@ const regNode = () => {
})
}
}
const TeleportContainer = defineComponent(getTeleport());
// @ts-nocheck
const emit = defineEmits(["save"])
const {t} = useI18n() //
@ -699,25 +697,28 @@ const toPngUrl = (callback: (url: string) => void, options?: {
bottom: number
}
}) => {
let widthScale = options && options.widthScale ? options.widthScale : 5
let heightScale = options && options.heightScale ? options.heightScale : 5
graph.toPNG((dataUri) => {
that.previewUrl = dataUri;
callback(that.previewUrl)
}, {
backgroundColor: that.pageConfig.background.areaColor,
width: that.pageConfig.width * (widthScale),
height: that.pageConfig.height * (heightScale),
padding: {
top: 0,
left: 0,
right: 0,
bottom: 0
},
quality: 1,
...options
})
setTimeout(()=>{
//
let widthScale = options && options.widthScale ? options.widthScale : 5
let heightScale = options && options.heightScale ? options.heightScale : 5
graph.toPNG((dataUri) => {
that.previewUrl = dataUri;
callback(that.previewUrl)
}, {
backgroundColor: that.pageConfig.background.areaColor,
width: that.pageConfig.width * (widthScale),
height: that.pageConfig.height * (heightScale),
padding: {
top: 0,
left: 0,
right: 0,
bottom: 0
},
quality: 1,
...options
})
},500)
}
const setPropList = (propDataInfo) => {
const keys = Object.keys(propDataInfo)

View File

@ -38,7 +38,7 @@ export function calcDpiFromSize( screenSize=16,opt = 'd'){
}
const tmpImage = {}
export function convertImageToBase64(url) {
return new Promise(async (resolve, reject)=>{
return new Promise(async (resolve)=>{
FileApi.getDomain().then(async (domain) => {
url = replaceDomain(domain, url)
if(tmpImage[url]){