From c7f61638d9895b3335417669ba1c5ebd304fe59e Mon Sep 17 00:00:00 2001
From: du <13220750630.163.com>
Date: 星期四, 27 三月 2025 10:10:07 +0800
Subject: [PATCH] 文本

---
 easegen-front/src/views/chooseTemplate/index.vue |  107 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 66 insertions(+), 41 deletions(-)

diff --git a/easegen-front/src/views/chooseTemplate/index.vue b/easegen-front/src/views/chooseTemplate/index.vue
index 9ce2830..cb60bfa 100644
--- a/easegen-front/src/views/chooseTemplate/index.vue
+++ b/easegen-front/src/views/chooseTemplate/index.vue
@@ -1111,6 +1111,12 @@
         PPTArr.value = res
         PPTArr.value[0].isActive = true
         selectPPT.value = PPTArr.value[0]
+        const htmlContent = PPTArr.value[0].pptRemark;
+        // 鍒涘缓涓�涓复鏃剁殑 DOM 鍏冪礌
+        const tempDiv = document.createElement('div');
+        tempDiv.innerHTML = htmlContent;
+        // 鑾峰彇绾枃鏈唴瀹�
+        selectPPT.value.pptRemark = tempDiv.textContent;
         console.log('selectPPT.value', selectPPT.value)
         showLeftList.value = true
         clearInterval(schedulePPTTimer.value)
@@ -1244,6 +1250,13 @@
       child.isActive = false
     }
   })
+  console.log(item)
+  const htmlContent = item.pptRemark;
+  // 鍒涘缓涓�涓复鏃剁殑 DOM 鍏冪礌
+  const tempDiv = document.createElement('div');
+  tempDiv.innerHTML = htmlContent;
+  // 鑾峰彇绾枃鏈唴瀹�
+  item.pptRemark = tempDiv.textContent;
   selectPPT.value = item
 }
 const selectHost = ref() // 閫夋嫨鐨勬暟瀛椾汉
@@ -1687,49 +1700,61 @@
     editorRef.value.insertNode(node);
     editorRef.value.move(1);
 }
+// 瀹氫箟 createAudio 寮傛鍑芥暟
 const createAudio = async () => {
-  // if (!selectTextarea.value || selectTextarea.value.length == 0) {
-  //   message.warning('璇峰垝閫夎嚦灏戜竴涓眽瀛�')
-  //   return false
-  // }
-  if (!editorRef.value.getText()) {
-    message.warning('璇疯緭鍏ラ渶瑕佽瘯鍚枃鏈殑鍐呭鈥�')
-        return false
-    }
-    // 鑾峰彇缂栬緫鍣� HTML 鍐呭
-    const html = editorRef.value.getText();
-  const params = {
-    text: html,
-    humanId: humanId
-  }
-  showAudioPlay1.value = true
-  pptTemplateApi
-    .createAudio(params)
-    .then((res) => {
-      if (res && !res.error) {
-        console.log(res)
-        showAudioPlay1.value = false
-        showAudioPlay.value = true
-        // 濡傛灉杩斿洖缁撴灉鏈夋晥涓旀病鏈夐敊璇紝鍒濆鍖朅udio
-        currentAudio.value = new Audio(res)
-        // 娣诲姞鎾斁缁撴潫浜嬩欢鐩戝惉
-        currentAudio.value.addEventListener('ended', () => {
-          showAudioPlay.value = false
-          currentAudio.value = null
-        })
+  // 鑾峰彇缂栬緫鍣ㄦ枃鏈唴瀹�
+  const text = editorRef.value.getText();
 
-        currentAudio.value.play()
-      } else {
-        // 濡傛灉杩斿洖缁撴灉涓虹┖鎴栨湁閿欒锛屽叧闂脊鍑烘
-        showAudioPlay1.value = false
-      }
-    })
-    .catch((error) => {
-      // 鎹曡幏璇锋眰閿欒锛屽叧闂脊鍑烘
-      console.error('API 璇锋眰澶辫触锛�', error)
-      showAudioPlay1.value = false
-    })
-}
+  // 妫�鏌ユ枃鏈槸鍚︿负绌�
+  if (!text) {
+    message.warning('璇疯緭鍏ラ渶瑕佽瘯鍚枃鏈殑鍐呭鈥�');
+    return false;
+  }
+
+  // 鎴彇鏂囨湰闀垮害涓嶈秴杩� 100
+  const truncatedText = text.length > 100 ? text.substring(0, 100) : text;
+
+  // 鏋勫缓璇锋眰鍙傛暟
+  const params = {
+    text: truncatedText,
+    humanId: humanId
+  };
+
+  try {
+    // 鏄剧ず闊抽鎾斁鍔犺浇鐘舵��
+    showAudioPlay1.value = true;
+
+    // 璋冪敤 API 鍒涘缓闊抽
+    const res = await pptTemplateApi.createAudio(params);
+
+    // 妫�鏌ュ搷搴旀槸鍚︽湁鏁堜笖鏃犻敊璇�
+    if (res && !res.error) {
+      console.log(res);
+      // 闅愯棌鍔犺浇鐘舵�侊紝鏄剧ず闊抽鎾斁鐘舵��
+      showAudioPlay1.value = false;
+      showAudioPlay.value = true;
+
+      // 鍒濆鍖� Audio 瀵硅薄
+      currentAudio.value = new Audio(res);
+
+      // 娣诲姞鎾斁缁撴潫浜嬩欢鐩戝惉鍣�
+      currentAudio.value.addEventListener('ended', () => {
+        showAudioPlay.value = false;
+        currentAudio.value = null;
+      });
+
+      // 鎾斁闊抽
+      currentAudio.value.play();
+    } else {
+      // 鍝嶅簲鏃犳晥鎴栨湁閿欒锛岄殣钘忓姞杞界姸鎬�
+      showAudioPlay1.value = false;
+    }
+  } catch (error) {
+    // 鎹曡幏璇锋眰閿欒锛岄殣钘忓姞杞界姸鎬佸苟鎵撳嵃閿欒淇℃伅
+    console.error('API 璇锋眰澶辫触锛�', error);
+    showAudioPlay1.value = false;
+  }
+};
 //鍙栨秷璇曞惉
 const pauseAudio = () => {
   currentAudio.value.pause()

--
Gitblit v1.9.3