From 7beaae553ac24855a7e94af934b6000530e9eb11 Mon Sep 17 00:00:00 2001 From: du <13220750630.163.com> Date: 星期四, 27 三月 2025 10:46:41 +0800 Subject: [PATCH] 文本 --- easegen-front/src/views/chooseTemplate/index.vue | 32 +++++++++++++------------------- 1 files changed, 13 insertions(+), 19 deletions(-) diff --git a/easegen-front/src/views/chooseTemplate/index.vue b/easegen-front/src/views/chooseTemplate/index.vue index cb60bfa..aeb1ab7 100644 --- a/easegen-front/src/views/chooseTemplate/index.vue +++ b/easegen-front/src/views/chooseTemplate/index.vue @@ -1111,12 +1111,6 @@ 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) @@ -1143,7 +1137,7 @@ if (!curr.pptRemark) return prev; // 鍘婚櫎鎵�鏈塖SML鏍囩,鍙繚鐣欐枃鏈唴瀹� - const plainText = curr.pptRemark.replace(/<[^>]+>/g, ''); + const plainText = curr.pptRemark; return prev + plainText.length; }, 0) //瑙嗛鏃堕暱鎹㈢畻 @@ -1250,13 +1244,6 @@ 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() // 閫夋嫨鐨勬暟瀛椾汉 @@ -1354,6 +1341,11 @@ 2: '2' } }) +const removeHtmlTags= (html) =>{ + const parser = new DOMParser(); + const doc = parser.parseFromString(html, 'text/html'); + return doc.body.textContent || ""; +} const saveSubmit = async (type) => { // 妫�鏌ュ満鏅槸鍚︿负绌� @@ -1430,7 +1422,9 @@ const innerPictureCom = item.innerPicture console.log('innerPictureCom:', JSON.stringify(innerPictureCom)) - + console.log(item.pptRemark) + item.pptRemark = removeHtmlTags(item.pptRemark) + console.log(plainText) const formatItem = { background: { backgroundType: item.backgroundType, @@ -1443,8 +1437,9 @@ originWidth: item.width, originHeight: item.height, color: '#ffffff', - pptRemark: editorHtml.elemToHtml(item.pptRemark) + pptRemark: item.pptRemark }, + components: [ { ...cloneDeep(digitalHumanComponents), // 娣辨嫹璐� @@ -1474,7 +1469,7 @@ speech_rate: voiceData.speechRate, volume: voiceData.volume, smartSpeed: '', - textJson: editorHtml.elemToHtml(item.pptRemark), + textJson: item.pptRemark, }, audioDriver: { fileName: item.fileList && item.fileList[0]?.name, @@ -1700,7 +1695,6 @@ editorRef.value.insertNode(node); editorRef.value.move(1); } -// 瀹氫箟 createAudio 寮傛鍑芥暟 const createAudio = async () => { // 鑾峰彇缂栬緫鍣ㄦ枃鏈唴瀹� const text = editorRef.value.getText(); @@ -1754,7 +1748,7 @@ console.error('API 璇锋眰澶辫触锛�', error); showAudioPlay1.value = false; } -}; +} //鍙栨秷璇曞惉 const pauseAudio = () => { currentAudio.value.pause() -- Gitblit v1.9.3