From 0796eebe3520fafb0ac5d36ee584af81506d7e9c Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期六, 20 九月 2025 14:05:52 +0800
Subject: [PATCH] 2025.9.20 数据产品(待完成)

---
 src/utils/doc.js |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/utils/doc.js b/src/utils/doc.js
index 25115f2..a757cfc 100644
--- a/src/utils/doc.js
+++ b/src/utils/doc.js
@@ -81,10 +81,20 @@
       let width = image.width;
       let height = image.height;
 
-      if (width > height && horizontalHeight && height > horizontalHeight && scale) {
+      if (
+        width > height &&
+        horizontalHeight &&
+        height > horizontalHeight &&
+        scale
+      ) {
         height = horizontalHeight;
         width = horizontalHeight * scale;
-      } else if (width <= height && verticalWidth && width > verticalWidth && scale) {
+      } else if (
+        width <= height &&
+        verticalWidth &&
+        width > verticalWidth &&
+        scale
+      ) {
         width = verticalWidth;
         height = verticalWidth * scale;
       }
@@ -144,12 +154,15 @@
         throw error;
       }
       const zip = new Pizzip(content);
-      const imageOptions = getImageOptions(imageSize);
       let doc = new docxtemplater()
         .setOptions({ paragraphLoop: true })
-        .loadZip(zip)
-        .attachModule(new ImageModule(imageOptions))
-        .compile();
+        .loadZip(zip);
+
+      if (imageSize) {
+        const imageOptions = getImageOptions(imageSize);
+        doc.attachModule(new ImageModule(imageOptions));
+      }
+      doc.compile();
       doc.resolveData(data).then(() => {
         try {
           doc.render();

--
Gitblit v1.9.3