|
@@ -215,11 +215,12 @@ export default {
|
|
|
? JSON.parse(this.curPaperTemp.content)
|
|
|
: { pages: [], pageConfig: {} };
|
|
|
this.paperTempJson = paperTempJson;
|
|
|
- console.log("paperTempJson", paperTempJson);
|
|
|
+ // console.log("paperTempJson", paperTempJson);
|
|
|
this.pages = paperTempJson.pages;
|
|
|
this.updaterFieldInfo();
|
|
|
} catch (error) {
|
|
|
this.emitFrameResult(false, "数据错误");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
this.$nextTick(async () => {
|
|
@@ -231,6 +232,7 @@ export default {
|
|
|
this.buildElementsFromStruct();
|
|
|
} catch (error) {
|
|
|
this.emitFrameResult(false, "构建元素错误");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
const loadRes = await this.waitAllImgLoaded().catch(() => {});
|
|
@@ -245,14 +247,16 @@ export default {
|
|
|
this.buildPrePages();
|
|
|
} catch (error) {
|
|
|
this.emitFrameResult(false, "预构建页面错误");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
+ this.$nextTick(async () => {
|
|
|
try {
|
|
|
- this.updateGroupHeightInfo();
|
|
|
+ await this.updateGroupHeightInfo();
|
|
|
this.buildPagesByAutoPage();
|
|
|
} catch (error) {
|
|
|
this.emitFrameResult(false, "构建pdf错误");
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
this.$nextTick(async () => {
|
|
@@ -444,8 +448,8 @@ export default {
|
|
|
this.buildGroupsFromStruct();
|
|
|
this.buildPrePages();
|
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
- this.updateGroupHeightInfo();
|
|
|
+ this.$nextTick(async () => {
|
|
|
+ await this.updateGroupHeightInfo();
|
|
|
this.buildPagesByAutoPage();
|
|
|
if (this.prepareDownloadPdf) {
|
|
|
this.$nextTick(async () => {
|
|
@@ -462,25 +466,24 @@ export default {
|
|
|
},
|
|
|
// img ------ start >
|
|
|
loadImg(url) {
|
|
|
+ const fullurl = url.startsWith("http")
|
|
|
+ ? url
|
|
|
+ : `${window.location.origin}${url}`;
|
|
|
+
|
|
|
return new Promise((resolve, reject) => {
|
|
|
const img = new Image();
|
|
|
- img.onload = function () {
|
|
|
- resolve(true);
|
|
|
- };
|
|
|
- img.onerror = function () {
|
|
|
- reject();
|
|
|
- };
|
|
|
- img.src = url;
|
|
|
+ img.onload = () => resolve(true);
|
|
|
+ img.onerror = () => reject(new Error(`Failed to load image: ${url}`));
|
|
|
+ img.src = fullurl;
|
|
|
});
|
|
|
},
|
|
|
getRichJsonImgUrls(richJson) {
|
|
|
let urls = [];
|
|
|
- if (!richJson) return urls;
|
|
|
+ if (!richJson || !richJson.sections) return urls;
|
|
|
richJson.sections.forEach((section) => {
|
|
|
section.blocks.forEach((elem) => {
|
|
|
- if (elem.type === "image" && elem.value.startsWith("http")) {
|
|
|
- urls.push(elem.value);
|
|
|
- }
|
|
|
+ if (elem.type !== "image" || elem.value.includes("base64")) return;
|
|
|
+ urls.push(elem.value);
|
|
|
});
|
|
|
});
|
|
|
return urls;
|
|
@@ -491,11 +494,11 @@ export default {
|
|
|
imgUrls.push(...this.getRichJsonImgUrls(item.content));
|
|
|
});
|
|
|
|
|
|
- // console.log(imgUrls);
|
|
|
-
|
|
|
if (!imgUrls.length) return Promise.resolve(true);
|
|
|
- const imgLoads = imgUrls.map((item) => this.loadImg(item));
|
|
|
+ const imgLoads = imgUrls.map((url) => this.loadImg(url));
|
|
|
+ // const st = Date.now();
|
|
|
const imgLoadResult = await Promise.all(imgLoads).catch(() => {});
|
|
|
+ // console.log("load img:", Date.now() - st);
|
|
|
if (imgLoadResult && imgLoadResult.length) {
|
|
|
return Promise.resolve(true);
|
|
|
} else {
|
|
@@ -727,7 +730,7 @@ export default {
|
|
|
position: absolute;
|
|
|
left: -9999px;
|
|
|
z-index: 999;
|
|
|
- visibility: hidden;
|
|
|
+ /* visibility: hidden; */
|
|
|
}
|
|
|
.paper-template-build .page-column-element .element-item {
|
|
|
background-color: inherit;
|