Explorar el Código

修复了登录页的 Bug,优化了样式

dangdang hace 6 días
padre
commit
99b3a0afaa
Se han modificado 10 ficheros con 364 adiciones y 131 borrados
  1. 1 1
      default.conf
  2. BIN
      public/image0.jpg
  3. BIN
      public/image0.webp
  4. BIN
      public/image1.webp
  5. BIN
      public/image2.webp
  6. 1 0
      public/vite.svg
  7. 353 128
      src/views/ChatTts.vue
  8. 1 1
      src/views/DetailView.vue
  9. 7 0
      src/views/utils/api.js
  10. 1 1
      vite.config.js

+ 1 - 1
default.conf

@@ -14,7 +14,7 @@ server {
 
     set $stg_token "C1qziFGlIv3tnCQxcFaStrLuZOO2ZZXjN7FB_G0WlrOLjclfObbSaXAKzl4RWwQBf_0Zhsm0CoVvdVsYMD18iM_LJrxtn7LHJJQuF9UoUuF3fvqOwrG4EF6Z4GahtxtQ2oeaPQBBNKlgVW1xUW7tkhEdXWqzDHPA_I_91Lczk0PI4guhx1c88Hst4-HI8pdMbiUdEJzj3d3a2W06Fa0XA9Q0taAwaRd1k9jUrDVyj9GfS84_SIgJF4SPjWVfsraV79ieb_StgRcUwZjbscGPMlifnJD6F00wwNbxG7AuCHbl3EtMfSed1vuVx3AsizIckwzIVSVRpOGw72cdAMui-I6es9Ozj2ITzSa5KgyXEpX4qCHF1VcCM1wlHLQ_5hLnJIi4r8NsnJPsxMYrTw";
 
-    set $prd_token "mVcexzY_mjtGAL5_exPlmAyfOJxuuEthWY1mk9tUFC_HwceY58uRZ2WDhz7-ttexCdUtFN8C7V636_jIq6fzaSfqIj8OQyhUPKPMa2eZjLlblT77ySqBt_lYM6iEAhrj7-raGmySMmkLS4Rqh651Ak2tqmUbjS64cqv5ofMsuadOCg1J-CtLFt7NeSoU4N3Kpm5MJ_4sOFBhQGfBym88dcwxosFl9LbvhpyleXFf6fOZkkOj0l2X8Nr2pfNjYs3_VOmCQxrxXh1XZ_a1v9qj5_rA9k9wGNNQfmr2JwJTUT4V9NwtNq94gNFt8C0J6MWKVE2eyr25Rke8tkKu3CGNNmspmEFpr6LavPlaWnWOIh9CRJ1cIDB70pg_JD2l0nPTkPbtaTQaIGTz";
+    set $prd_token "2g4pgi27kWjPBjaKoHSfZAyfOJxuuEthWY1mk9tUbyPSrr6sn_6aPGaTxT7_ldXoKIJuMt8C7V636_jIq6fzaSfqIj8OQyhUPKPMa2eZjLlblT77ySqBt_lYM6iEAhrj7-raGmySMmkLS4Rqh651Ak2tqmUbjS64cqv5ofMsuadOCg1J-CtLFt7NeSoU4N3Kpm5MJ_4sOFBhQGfBym88dcwxosFl9LbvhpyleXFf6fOZkkOj0l2X8Nr2pfNjYs3_VOmCQxrxXh1XZ_a1v9qj5_rA9k9wGNNQfmr2JwJTUT4V9NwtNq94gNFt8C0J6MWKRHvYyb2XRkaCnEKu8QiNElcIwU9l9azouu5Lc3uafG1dd98yFm9I784oNWvIpVjUrsTkFiJxNGTz";
     
     location /openapi-stg/ {
         rewrite ^/openapi-stg/(.*)$ /$1 break;

BIN
public/image0.jpg


BIN
public/image0.webp


BIN
public/image1.webp


BIN
public/image2.webp


+ 1 - 0
public/vite.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

+ 353 - 128
src/views/ChatTts.vue

@@ -9,12 +9,15 @@ import axios from "axios";
 import { fetchEventSource } from "@microsoft/fetch-event-source";
 import { useRoute, useRouter } from "vue-router";
 import delay from "delay";
+import { fetchTaskStatus } from "./utils/api";
 
 const route = useRoute();
 const router = useRouter();
 const conversationId = computed(() => route.query.taskId); // 会话ID
 const round = computed(() => route.query.round); // 轮次
 const sessionId = ref("");
+const taskStatus = ref(false)
+const loading = ref(true);  //初始化进入的加载状态
 
 const currentRate = ref(0);
 const currentRound = computed(() => {
@@ -53,19 +56,10 @@ const updateChatList = async (message = "", loading = true) => {
       clearInterval(timer);
     }
   }, 50);
-
-  // chatList.value = chatList.value.map((item) =>
-  //   item.loading
-  //     ? message
-  //       ? { ...item, text: message, loading }
-  //       : { ...item, loading }
-  //     : item
-  // );
-  // localStorage.setItem("chatHistory", JSON.stringify(chatList.value));
 };
 
 // 创建一个队列实例,设置并发数为 1
-const queue = new PQueue({ concurrency: 1 });
+const queue = new PQueue({ concurrency: 3 });
 const queue1 = new PQueue({ concurrency: 1 });
 const queue2 = new PQueue({ concurrency: 1 });
 
@@ -77,13 +71,13 @@ let lastStrIndex = 0;
 
 // 将字符串根据标点符号断句分割,并添加到messageQueue中
 const splitMessage = async (str) => {
-  const punctuation = ["。", "!", "?", ";", ":"];
+  const punctuation = ["。","," ,"!", "?", ";", ":"];
 
   for (let i = lastStrIndex; i < str.length; i++) {
     if (punctuation.includes(str[i])) {
       const message = str.slice(lastStrIndex, i + 1);
       console.log(message, "==========");
-      await playTTS(message);
+      playTTS(message);
       lastStrIndex = i + 1; // 更新上一个字符串的结束位置
     }
   }
@@ -125,113 +119,334 @@ const handleStopRecord = (message) => {
   sessionId.value = generateSessionId();
   chatGpt(message);
 };
+// let audioQueue = [];  // 音频队列,保存按请求顺序的音频数据
+// let playingQueue = []; // 用来记录当前正在播放的音频序号
+// let isPlaying = false;  // 当前是否正在播放
+// let orderId = 0;  // 请求顺序号
 
-const playTTS1 = async (ttsMessage) => {
-  try {
-    const res = await axios.post(
-      `/openapi-stg/ai/voice/tts/v2`,
-      { sessionId: "N7FB_G0WlrOLjc", text: ttsMessage },
-      {
-        responseType: "arraybuffer",
-        headers: {
-          "X-Ai-TTS-Appid": "2b1317fb5b284b308dc90a6fdeae6c4e",
-        },
-      }
-    );
-    console.log(res.data);
+// 用来控制正在播放音频的锁定机制
+let playingLock = false;  // 标识是否正在播放
 
-    queue1.add(async () => {
-      // 播放获取到的音频
-      await playAudio(res.data);
-    });
-  } catch (error) {
-    console.error("Error calling TTS API:", error);
-  }
-};
 
+let audioQueue = [];  // 音频队列,保存按请求顺序的音频数据
+let playingQueue = []; // 记录已播放的音频序号
+let isPlaying = false;  // 当前是否正在播放
+let orderId = 0;  // 请求顺序号
+
+// 1. 发起 TTS 请求(修改后)
 const playTTS = async (ttsMessage) => {
-  try {
-    const res = await axios.get(
-      `/openapi-prd/ai/ttt/synthesize?text=${ttsMessage}&sessionId=${sessionId.value}`,
-      {
-        responseType: "arraybuffer",
-      }
-    );
-    console.log(res.data);
+  queue.add(async () => {
+    const currentOrderId = orderId++;  // 先获取顺序号再发送请求
+
+    try {
+      const res = await axios.get(
+        `/openapi-prd/ai/ttt/synthesize?text=${ttsMessage}&sessionId=${sessionId.value}`,
+        { responseType: "arraybuffer" }
+      );
+      
+      // 即使请求失败也要保持队列连续性(新增部分)
+      const audioItem = {
+        orderId: currentOrderId,
+        audioData: res.data || null,
+        status: res.data ? 'valid' : 'invalid'
+      };
+      
+      audioQueue.push(audioItem);
+      audioQueue.sort((a, b) => a.orderId - b.orderId);  // 保持队列有序
+
+      if (!isPlaying) await playNextAudio();
+    } catch (error) {
+      console.error("调用 TTS API 时出错:", error);
+      // 请求失败时插入占位符保持顺序(关键修复)
+      audioQueue.push({ 
+        orderId: currentOrderId,
+        audioData: null,
+        status: 'invalid'
+      });
+      audioQueue.sort((a, b) => a.orderId - b.orderId);
+      if (!isPlaying) await playNextAudio();
+    }
+  });
+};
 
-    queue1.add(async () => {
-      // 播放获取到的音频
-      await playAudio(res.data);
-    });
-  } catch (error) {
-    console.error("Error calling TTS API:", error);
+// 2. 播放下一个音频(修改后)
+const playNextAudio = async () => {
+  // if (audioQueue.length === 0) {
+  //   isPlaying = false;
+  //   console.log("所有音频播放完毕.");
+  //   return;
+  // }
+  if (audioQueue.length === 0 && playingQueue.length > 0) {
+  const maxPlayed = Math.max(...playingQueue);
+  if (orderId > maxPlayed + 1) {
+    console.log("仍有未完成请求,暂不重置");
+  } else {
+    isPlaying = false;
+    // 新增:当队列完全播放完毕时重置所有状态
+    audioQueue = [];
+    playingQueue = [];
+    orderId = 0;  // 可选:如果需要重置顺序号
+    console.log("所有音频播放完毕,已重置播放队列.");
+    return;
+  }
   }
-};
 
-const playAudio1 = (audioData, options = {}) => {
-  return new Promise((resolve, reject) => {
-    const blob = new Blob([audioData], { type: "audio/wav" });
-    const url = URL.createObjectURL(blob);
-    const audio = new Audio(url);
+  const nextAudio = getNextAudioToPlay();
+  if (!nextAudio) {
+    console.log("等待后续音频数据...");
+    return;
+  }
 
-    audio.setAttribute("id", "audio");
-    audio.setAttribute("autoplay", "autoplay");
+  try {
+    isPlaying = true;
+    console.log(`正在播放音频,序号:${nextAudio.orderId}`);
 
-    if (options.volume) {
-      audio.volume = options.volume; // 设置音量
+    if (nextAudio.status === 'valid') {
+      await playAudio(nextAudio.audioData);
+    } else {
+      console.warn(`跳过无效音频,序号:${nextAudio.orderId}`);
     }
 
-    audio.onended = () => {
-      URL.revokeObjectURL(url);
-      resolve();
-    };
-
-    audio.onerror = (error) => {
-      URL.revokeObjectURL(url);
-      reject(error);
-    };
+    // 更新播放状态(优化处理)
+    playingQueue = [...new Set([...playingQueue, nextAudio.orderId])].sort((a, b) => a - b);
+    audioQueue = audioQueue.filter(audio => audio.orderId !== nextAudio.orderId);
 
-    audio
-      .play()
-      .then(() => console.log("Audio playing"))
-      .catch(reject);
-  });
+    // 立即尝试播放下一个(优化播放流程)
+    isPlaying = false;
+    await playNextAudio();
+  } catch (error) {
+    console.error(`播放失败,序号:${nextAudio.orderId}`, error);
+    audioQueue = audioQueue.filter(audio => audio.orderId !== nextAudio.orderId);
+    isPlaying = false;
+    await playNextAudio();
+  }
 };
 
-const playAudio = (audioData, options = {}) => {
+// 获取下一个应该播放的音频(修改后)
+const getNextAudioToPlay = () => {
+  // 获取当前应该播放的最小序号
+  const expectedOrderId = playingQueue.length > 0 
+    ? Math.max(...playingQueue) + 1 
+    : 0;
+
+  // 查找第一个匹配的有效音频(新增有效性检查)
+  const nextAudio = audioQueue.find(audio => 
+    audio.orderId === expectedOrderId &&
+    audio.status === 'valid'
+  );
+
+  // 如果找不到有效音频但有序号匹配的无效项,跳过该序号
+  if (!nextAudio) {
+    const invalidAudio = audioQueue.find(audio => 
+      audio.orderId === expectedOrderId
+    );
+    
+    if (invalidAudio) {
+      console.warn(`检测到无效音频,自动跳过序号:${expectedOrderId}`);
+      playingQueue.push(expectedOrderId);
+      return getNextAudioToPlay(); // 递归处理
+    }
+  }
+
+  return nextAudio || null;
+};
+// 1. 发起 TTS 请求
+
+// const playTTS = async (ttsMessage) => {
+//   queue.add(async () => {
+//     const currentOrderId = orderId++;
+
+//     try {
+//       const res = await axios.get(
+//         `/openapi-prd/ai/ttt/synthesize?text=${ttsMessage}&sessionId=${sessionId.value}`,
+//         { responseType: "arraybuffer" }
+//       );
+//       if (!res.data || res.data.byteLength === 0) {
+//         console.error("音频数据无效,无法播放.");
+//         return;
+//       }
+//       // 按顺序存入音频队列
+//       audioQueue.push({ orderId: currentOrderId, audioData: res.data });
+
+//       // 仅在没有播放时启动播放
+//       if (!isPlaying) {
+//         await playNextAudio();
+//       }
+//     } catch (error) {
+//       console.error("调用 TTS API 时出错:", error);
+//     }
+//   });
+// };
+// 2. 播放下一个音频
+// const playNextAudio = async () => {
+//   // 如果播放队列为空,停止播放
+//   if (audioQueue.length === 0) {
+//     isPlaying = false;  // 播放完所有音频
+//     // audioQueue = []; // 确保列表为空
+//     console.log("所有音频播放完毕.");
+//     return;
+//   }
+
+//   // 找到队列中最小序号的音频,确保顺序播放
+//   const nextAudio = getNextAudioToPlay();
+//   console.log(nextAudio,"没有找到下一个应该播放的音频,队列尚未按顺序准备好.");
+
+//   // 如果找不到下一个应该播放的音频,表示队列还没有按顺序准备好
+//   if (!nextAudio) {
+//     console.log("没有找到下一个应该播放的音频,队列尚未按顺序准备好.");
+//     console.log("当前音频队列:", audioQueue);  // 打印当前音频队列
+//     console.log("当前已播放的序列:", playingQueue);  // 打印已经播放的音频序列
+//     return;
+//   }
+
+//   // 打印正在播放的音频序号
+//   console.log(`正在播放音频,序号:${nextAudio.orderId}`);
+
+//   try {
+//     isPlaying = true;  // 标记当前正在播放
+//     playingLock = true;  // 锁定播放,避免新的音频插入
+
+//     // 播放当前音频
+//     await playAudio(nextAudio.audioData);
+
+//     // 播放完成后,移除已播放的音频
+//     audioQueue = audioQueue.filter(audio => audio.orderId !== nextAudio.orderId);
+//     playingQueue.push(nextAudio.orderId);  // 将已播放的序号添加到播放记录
+
+//     // 输出音频播放完成的日志
+//     console.log(`音频序号 ${nextAudio.orderId} 播放完成,等待播放下一个包...`);
+
+//     // 解除锁定,等待下一个音频播放
+//     playingLock = false;
+
+//     // 使用定时器周期性检查是否可以播放下一个音频
+//     const checkNextAudioTimer = setInterval(async () => {
+//       if (!playingLock) {
+//         await playNextAudio();
+//         clearInterval(checkNextAudioTimer);  // 清除定时器
+//       }
+//     }, 300); // 每秒检查一次
+//   } catch (error) {
+//     console.error(`播放音频序号 ${nextAudio.orderId} 时出错:`, error);
+//     // 如果某个音频播放失败,跳过这个音频,继续播放下一个
+//     audioQueue = audioQueue.filter(audio => audio.orderId !== nextAudio.orderId);  // 移除报错的音频
+//     playingQueue.push(nextAudio.orderId);  // 将已播放的序号添加到播放记录
+//     playingLock = false;  // 解除锁定
+//     // 继续播放下一个音频
+//     await playNextAudio();
+//   }
+// };
+
+// 获取下一个应该播放的音频(保证顺序)
+// const getNextAudioToPlay = () => {
+//   // 检查音频队列中是否有下一个应该播放的音频
+//   console.log("检查下一个播放的音频...");
+//   for (let i = 0; i < audioQueue.length; i++) {
+//     const audio = audioQueue[i];
+//     // 找到最小的序号,即请求的顺序号
+//     if (audio.orderId === playingQueue.length) {
+//       console.log(`找到了下一个应该播放的音频,序号:${audio.orderId}`);
+//       return audio;
+//     }
+//   }
+//   console.log("没有找到下一个应该播放的音频,返回 null");
+//   return null;  // 如果没有找到匹配的音频,返回 null
+// };
+
+// 播放音频的方法
+const playAudio = (audioData) => {
   return new Promise((resolve, reject) => {
-    const audioContext = new (window.AudioContext ||
-      window.webkitAudioContext)();
+    const audioContext = new (window.AudioContext || window.webkitAudioContext)();
     const blob = new Blob([audioData], { type: "audio/wav" });
     const url = URL.createObjectURL(blob);
     const audioBufferSourceNode = audioContext.createBufferSource();
 
     fetch(url)
-      .then((response) => response.arrayBuffer())
-      .then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer))
-      .then((audioBuffer) => {
-        audioBufferSourceNode.buffer = audioBuffer;
-        audioBufferSourceNode.connect(audioContext.destination);
-
-        if (options.volume) {
-          audioBufferSourceNode.gain.value = options.volume; // 设置音量
-        }
-
-        audioBufferSourceNode.start(0);
-
-        audioBufferSourceNode.onended = () => {
-          URL.revokeObjectURL(url);
-          resolve();
-        };
-
-        audioBufferSourceNode.onerror = (error) => {
-          URL.revokeObjectURL(url);
-          reject(error);
-        };
-      })
-      .catch(reject);
+        .then((response) => {
+          if (!response.ok) {
+            console.error("音频文件请求失败: ", response.statusText);
+            reject(new Error("音频文件请求失败"));
+            return;
+          }
+          return response.arrayBuffer();
+        })
+        .then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer))
+        .then((audioBuffer) => {
+          audioBufferSourceNode.buffer = audioBuffer;
+          audioBufferSourceNode.connect(audioContext.destination);
+
+          audioBufferSourceNode.start(0);
+
+          // 当音频播放完毕时,调用 resolve
+          audioBufferSourceNode.onended = () => {
+            URL.revokeObjectURL(url);
+            resolve();  // 播放完成后,继续播放下一个
+          };
+
+          audioBufferSourceNode.onerror = (error) => {
+            console.error("音频播放错误:", error);
+            URL.revokeObjectURL(url);
+            reject(error);  // 播放失败时,返回错误
+          };
+        })
+        .catch((error) => {
+          console.error("音频加载或解码时出错:", error);
+          reject(error);  // 如果解码或播放出错,reject
+        });
   });
 };
+// const playTTS1 = async (ttsMessage) => {
+//   try {
+//     const res = await axios.post(
+//       `/openapi-stg/ai/voice/tts/v2`,
+//       { sessionId: "N7FB_G0WlrOLjc", text: ttsMessage },
+//       {
+//         responseType: "arraybuffer",
+//         headers: {
+//           "X-Ai-TTS-Appid": "2b1317fb5b284b308dc90a6fdeae6c4e",
+//         },
+//       }
+//     );
+//     console.log(res.data);
+
+//     queue1.add(async () => {
+//       // 播放获取到的音频
+//       await playAudio(res.data);
+//     });
+//   } catch (error) {
+//     console.error("Error calling TTS API:", error);
+//   }
+// };
+
+// const playAudio1 = (audioData, options = {}) => {
+//   return new Promise((resolve, reject) => {
+//     const blob = new Blob([audioData], { type: "audio/wav" });
+//     const url = URL.createObjectURL(blob);
+//     const audio = new Audio(url);
+
+//     audio.setAttribute("id", "audio");
+//     audio.setAttribute("autoplay", "autoplay");
+
+//     if (options.volume) {
+//       audio.volume = options.volume; // 设置音量
+//     }
+
+//     audio.onended = () => {
+//       URL.revokeObjectURL(url);
+//       resolve();
+//     };
+
+//     audio.onerror = (error) => {
+//       URL.revokeObjectURL(url);
+//       reject(error);
+//     };
+
+//     audio
+//       .play()
+//       .then(() => console.log("Audio playing"))
+//       .catch(reject);
+//   });
+// };
 
 const chatGpt = async (userMessage) => {
   const downloadUrl = "/openapi-prd/ai/intelligent-tutoring/task/dialogue";
@@ -265,38 +480,17 @@ const chatGpt = async (userMessage) => {
             queue.add(async () => {
               await splitMessage(responseText);
             });
-            // const timer = setInterval(() => {
-            //   i = i + 1;
-            //   //updateChatList(responseText.substring(0, i));
-            //   queue2.add(
-            //     async () => await updateChatList(responseText.substring(0, i))
-            //   );
-            //   if (i >= responseText.length) {
-            //     clearInterval(timer);
-            //   }
-            //   console.log(
-            //     i,
-            //     responseText.substring(i),
-            //     "=======responseText.substring(i)"
-            //   );
-            //   if (
-            //     responseText.substring(i).indexOf("[DONE]") === 0 ||
-            //     responseText.substring(i).indexOf("[DONE]") === 1
-            //   ) {
-            //     console.log("========done===========");
-            //     updateChatList("", false);
-            //     // 保存聊天记录到本地
-            //     const chatHistory = JSON.stringify(chatList.value);
-            //     localStorage.setItem("chatHistory", chatHistory);
-            //   }
-            //}, 200);
-
+            
             queue2.add(async () => await updateChatList(responseText));
+            
             //updateChatList(responseText);
           }
         },
       }
     );
+    setTimeout(() => {
+         handleTaskStatus()
+     },3000)
     //queue2.add(async () => await updateChatList("", false));
   } catch (error) {
     //updateChatList("", false);
@@ -380,23 +574,38 @@ const next = () => {
 };
 
 const loadChatHistory = () => {
+  
   const chatHistory = localStorage.getItem("chatHistory");
+  const chatStatus = localStorage.getItem("status");
   if (chatHistory) {
     const history = JSON.parse(chatHistory);
     history.forEach((item) => {
       chatList.value.push(item);
     });
   }
+  if(chatStatus){
+    taskStatus.value = JSON.parse(chatStatus)
+  }
 };
 
+// 查询任务结束状态
+
+const handleTaskStatus = async () => {
+  const res =  await fetchTaskStatus(conversationId.value)
+  if(res.code == 200){
+    taskStatus.value = res.body
+    localStorage.setItem("status", res.body);
+  }
+}
+
 // 在组件挂载时调用
 onMounted(() => {
   loadChatHistory();
+  setTimeout(() => {
+    loading.value = false;
+  }, 2000);
 });
 
-// onBeforeUnmount(() => {
-//   localStorage.removeItem("chatHistory");
-// });
 </script>
 
 <template>
@@ -412,13 +621,17 @@ onMounted(() => {
       />
     </div>
     <BG />
+    <div class="loading" v-show="loading">
+      <van-loading color="#0094ff" size="26px" vertical>加载中...</van-loading>
+    </div>
+    
     <ChatList :chatList="chatList" />
     <BottomArea
       @startRecord="handleStartRecord"
       @stopRecord="handleStopRecord"
-      v-show="rate < 100"
+      v-show="rate < 100 || taskStatus"
     />
-    <div v-show="rate >= 100" class="next-btn">
+    <div v-show="rate >= 100 || taskStatus" class="next-btn">
       <van-button style="width: 100%" @click="next" type="primary"
         >已完成对话,下一步</van-button
       >
@@ -455,4 +668,16 @@ onMounted(() => {
   box-sizing: border-box;
   padding: 0 20px;
 }
+.loading {
+  position: fixed;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  background-color: rgba(0, 0, 0, 0.5);
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  z-index: 9999;
+}
 </style>

+ 1 - 1
src/views/DetailView.vue

@@ -14,7 +14,6 @@ const selectedRounds = ref(0);
 
 const roleOptions = [
   { text: "销售经理", value: "销售经理" },
-  { text: "销售顾问", value: "销售顾问" },
 ];
 
 const roundsOptions = [
@@ -52,6 +51,7 @@ const handleExam = async () => {
     tutoringRole: selectedRole.value,
     personality: selectedNature.value,
     round: selectedRounds.value,
+    sceneType:"QIRONG_SHICHANG",
   };
   try {
     const { body } = await fetchTaskCreate(data);

+ 7 - 0
src/views/utils/api.js

@@ -16,3 +16,10 @@ export async function fetchTaskScore(conversationId) {
   });
 }
 
+//查询任务结束状态
+
+export async function fetchTaskStatus(conversationId) {
+  return request(`/openapi-prd/ai/intelligent-tutoring/task/endFlag?conversationId=${conversationId}`,{
+    method:"get",
+  });
+}

+ 1 - 1
vite.config.js

@@ -4,7 +4,7 @@ import fs from 'fs'
 
 const stgToken = 'C1qziFGlIv3tnCQxcFaStrLuZOO2ZZXjN7FB_G0WlrOLjclfObbSaXAKzl4RWwQBf_0Zhsm0CoVvdVsYMD18iM_LJrxtn7LHJJQuF9UoUuF3fvqOwrG4EF6Z4GahtxtQ2oeaPQBBNKlgVW1xUW7tkhEdXWqzDHPA_I_91Lczk0PI4guhx1c88Hst4-HI8pdMbiUdEJzj3d3a2W06Fa0XA9Q0taAwaRd1k9jUrDVyj9GfS84_SIgJF4SPjWVfsraV79ieb_StgRcUwZjbscGPMlifnJD6F00wwNbxG7AuCHbl3EtMfSed1vuVx3AsizIckwzIVSVRpOGw72cdAMui-I6es9Ozj2ITzSa5KgyXEpX4qCHF1VcCM1wlHLQ_5hLnJIi4r8NsnJPsxMYrTw'
 
-const prdToken = 'mVcexzY_mjtGAL5_exPlmAyfOJxuuEthWY1mk9tUFC_HwceY58uRZ2WDhz7-ttexCdUtFN8C7V636_jIq6fzaSfqIj8OQyhUPKPMa2eZjLlblT77ySqBt_lYM6iEAhrj7-raGmySMmkLS4Rqh651Ak2tqmUbjS64cqv5ofMsuadOCg1J-CtLFt7NeSoU4N3Kpm5MJ_4sOFBhQGfBym88dcwxosFl9LbvhpyleXFf6fOZkkOj0l2X8Nr2pfNjYs3_VOmCQxrxXh1XZ_a1v9qj5_rA9k9wGNNQfmr2JwJTUT4V9NwtNq94gNFt8C0J6MWKVE2eyr25Rke8tkKu3CGNNmspmEFpr6LavPlaWnWOIh9CRJ1cIDB70pg_JD2l0nPTkPbtaTQaIGTz'
+const prdToken = '2g4pgi27kWjPBjaKoHSfZAyfOJxuuEthWY1mk9tUbyPSrr6sn_6aPGaTxT7_ldXoKIJuMt8C7V636_jIq6fzaSfqIj8OQyhUPKPMa2eZjLlblT77ySqBt_lYM6iEAhrj7-raGmySMmkLS4Rqh651Ak2tqmUbjS64cqv5ofMsuadOCg1J-CtLFt7NeSoU4N3Kpm5MJ_4sOFBhQGfBym88dcwxosFl9LbvhpyleXFf6fOZkkOj0l2X8Nr2pfNjYs3_VOmCQxrxXh1XZ_a1v9qj5_rA9k9wGNNQfmr2JwJTUT4V9NwtNq94gNFt8C0J6MWKRHvYyb2XRkaCnEKu8QiNElcIwU9l9azouu5Lc3uafG1dd98yFm9I784oNWvIpVjUrsTkFiJxNGTz'
 
 // https://vite.dev/config/
 export default defineConfig({