liyanbo 8 месяцев назад
Родитель
Сommit
5fc5ce639d
3 измененных файлов с 39 добавлено и 12 удалено
  1. 3 2
      .env
  2. 32 4
      src/components/PPT/PptView.vue
  3. 4 6
      src/views/AIQuestions.vue

+ 3 - 2
.env

@@ -2,8 +2,9 @@
 VITE_APP_TITLE=AI课程网
 
 # 请求路径
-# VITE_BASE_URL='http://59.110.91.129/admin-api'
-VITE_BASE_URL='http://192.168.110.8:8080/admin-api'
+VITE_BASE_URL='http://59.110.91.129:8088/admin-api'
+#VITE_BASE_URL='https://learn-ai.com.cn/admin-api'
+#VITE_BASE_URL='http://192.168.110.8:8080/admin-api'
 
 # 默认账户密码
 VITE_APP_DEFAULT_LOGIN_TENANT = 博雅智算

+ 32 - 4
src/components/PPT/PptView.vue

@@ -12,6 +12,7 @@
               @rendered="handlePptRendered"
               :animation="true"
               :animation-speed="1.0"
+              :key="pptKey"
           />
         </div>
         
@@ -41,7 +42,7 @@
 </template>
 
 <script setup>
-import { ref, onMounted, defineProps } from 'vue'
+import { ref, onMounted, onUnmounted, defineProps } from 'vue'
 import { ElMessage } from 'element-plus'
 // 导入图标
 import leftImg from '@/assets/icon/videoImage01.png'
@@ -86,7 +87,20 @@ const handlePageChange = (newPage) => {
 
 // 新增滚动控制变量
 const pptContainer = ref(null)
-const pageHeight = ref(620) // 单页高度
+const pageHeight = ref(0) // 单页高度,初始设为0
+const pptKey = ref(0) // 添加key用于重新渲染
+
+// 窗口大小变化处理函数
+const handleResize = () => {
+  if (pptContainer.value) {
+    // 更新页面高度
+    pageHeight.value = pptContainer.value.clientHeight || 620;
+    // 通过更新key强制重新渲染PPT
+    pptKey.value += 1;
+    // 重新定位到当前页
+    scrollToPage(currentPage.value);
+  }
+}
 
 const nextPage = () => {
   if (currentPage.value < totalPages.value) {
@@ -124,8 +138,18 @@ const scrollToPage = (pageNum) => {
 onMounted(() => {
   // 获取容器元素
   pptContainer.value = document.querySelector('.carousel-wrapper');
+  // 初始化页面高度
+  if (pptContainer.value) {
+    pageHeight.value = pptContainer.value.clientHeight || 620;
+  }
   // 初始滚动到第一页
   scrollToPage(1);
+  // 添加窗口大小监听
+  window.addEventListener('resize', handleResize);
+})
+// 组件卸载时移除监听
+onUnmounted(() => {
+  window.removeEventListener('resize', handleResize);
 })
 
 // PPT错误处理事件
@@ -169,7 +193,9 @@ const handlePptError = (error) => {
 
 .carousel-wrapper {
   width: 70%;
-  height: rpx(290);
+  //height: rpx(290);
+
+  height: 100%;
   overflow: hidden;
   border-radius: rpx(12);
   position: relative;
@@ -287,7 +313,9 @@ const handlePptError = (error) => {
 
 // 确保每张幻灯片占满容器高度
 ::v-deep .slide-item {
-  height: rpx(620) !important;
+  //height: rpx(620) !important;
+
+  height: 100% !important;
   width: 100% !important;
   box-sizing: border-box;
 }

+ 4 - 6
src/views/AIQuestions.vue

@@ -237,15 +237,14 @@ const getConversation = async (id) => {
 // =========== 【语音录入】相关 ===========
 // 初始化语音识别
 const initSpeechRecognition = () => {
-  const SpeechRecognition =
-    window.SpeechRecognition || window.webkitSpeechRecognition;
+  const SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
   if (!SpeechRecognition) {
     alert("当前浏览器不支持语音输入功能");
     return null;
   }
 
   const instance = new SpeechRecognition();
-  instance.lang = "zh-CN";
+  instance.lang = 'zh-CN';
   instance.interimResults = false;
 
   instance.onresult = (event) => {
@@ -262,7 +261,7 @@ const initSpeechRecognition = () => {
   };
 
   instance.onerror = (event) => {
-    console.error("语音识别错误:", event.error);
+    console.error('语音识别错误:', event.error);
     clearInterval(countdownTimer.value); // 出错时清除定时器
     isRecording.value = false;
     alert("语音输入失败,请重试");
@@ -291,8 +290,7 @@ const toggleSpeechInput = () => {
     recognition.value = initSpeechRecognition();
     if (!recognition.value) return;
 
-    navigator.mediaDevices
-      .getUserMedia({ audio: true })
+    navigator.mediaDevices.getUserMedia({ audio: true })
       .then(() => {
         recognition.value.start();
         isRecording.value = true;