2
0
Эх сурвалжийг харах

🐛 fix(word-preview): 修复图片模块导入路径错误并添加调试日志

- 修正ImageModule导入路径,从'docxtemplater-image-module-free'改为'docxtemplater-image-module-free/build/imagemodule.js'以解决模块加载问题
- 在图片获取函数中添加console.log调试语句,输出tagValue以便追踪图片处理过程中的数据
yourname 4 сар өмнө
parent
commit
c8740dfe59

+ 2 - 1
src/client/admin-shadcn/pages/WordPreview.tsx

@@ -2,7 +2,7 @@ import { useState, useRef } from 'react';
 import * as XLSX from 'xlsx';
 import PizZip from 'pizzip';
 import Docxtemplater from 'docxtemplater';
-import ImageModule from 'docxtemplater-image-module-free';
+import ImageModule from 'docxtemplater-image-module-free/build/imagemodule.js';
 import JSZip from 'jszip';
 import { Button } from '@/client/components/ui/button';
 import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/client/components/ui/card';
@@ -233,6 +233,7 @@ export default function WordPreview() {
       const imageOpts = {
         centered: false,
         getImage: (tagValue: string) => {
+          console.log('tagValue', tagValue);
           if (tagValue && typeof tagValue === 'string') {
             // 从imageMappings中获取对应的图片
             const folderIndex = (rowIndex + 1).toString();