jack 2 giorni fa
parent
commit
6c3df31d56
1 ha cambiato i file con 11 aggiunte e 7 eliminazioni
  1. 11 7
      src/hooks/useImport.ts

+ 11 - 7
src/hooks/useImport.ts

@@ -1694,11 +1694,15 @@ export default () => {
 
       // 收集当前幻灯片内所有上传任务
       const uploadTasks: Promise<void>[] = []
-
+      
       // 遍历每一张幻灯片
       for (const item of json.slides) {
-        // ----- 解析背景 -----
-        const { type, value } = item.fill
+        let type = "", value = "";
+        if (item.fill) {
+          // ----- 解析背景 -----
+          type = item.fill.type
+          value = item.fill.value
+        }
         let background: SlideBackground
         if (type === 'image') {
           // 背景图片也可能需要上传(但 PPTX 背景图通常是内嵌 base64)
@@ -1706,7 +1710,7 @@ export default () => {
           background = {
             type: 'image',
             image: {
-              src: value.picBase64,
+              src: value?.picBase64,
               size: 'cover',
             },
           }
@@ -1715,12 +1719,12 @@ export default () => {
           background = {
             type: 'gradient',
             gradient: {
-              type: value.path === 'line' ? 'linear' : 'radial',
-              colors: value.colors.map(item => ({
+              type: value?.path === 'line' ? 'linear' : 'radial',
+              colors: value?.colors.map(item => ({
                 ...item,
                 pos: parseInt(item.pos),
               })),
-              rotate: value.rot + 90,
+              rotate: value?.rot + 90,
             },
           }
         }