Przeglądaj źródła

fix:修复口语作业chrome浏览器不兼容问题

lalala 10 miesięcy temu
rodzic
commit
24cdd6a335
2 zmienionych plików z 20 dodań i 4 usunięć
  1. 2 2
      src/router/index.ts
  2. 18 2
      src/views/AiSpeakingPage/SpeakingPage.vue

+ 2 - 2
src/router/index.ts

@@ -19,8 +19,8 @@ const router = createRouter({
     {
       path: "/",
       redirect: () => {
-        window.location.href = "https://p-nju.seec.seecoder.cn/login?from=https://air-nju.seec.seecoder.cn";
-        // window.location.href = "http://localhost:8000/login?from=http://localhost:4000";
+       // window.location.href = "https://p-nju.seec.seecoder.cn/login?from=https://air-nju.seec.seecoder.cn";
+         window.location.href = "http://localhost:8000/login?from=http://localhost:4000";
         // {本地门户首页地址}?from={本地eai首页地址}
         return "/"; // 占位返回值,实际不会执行
     },

+ 18 - 2
src/views/AiSpeakingPage/SpeakingPage.vue

@@ -70,7 +70,7 @@
                     :value="voice.code"
                   >
                   <div style="display: flex; align-items: center;">
-                    <el-avatar :src="voice.avatar" size="small" style="margin-right: 10px;"></el-avatar>
+                    <el-avatar :src="voice.avatar || voiceOptions[0]?.avatar" size="small" style="margin-right: 10px;"></el-avatar>
                     <span>{{ voice.name }}</span>
                     <el-button
                       @click.stop="toggleAudio(voice)"
@@ -112,7 +112,7 @@
               }"
             >
               <el-avatar
-                :src="message.sender === 'user' ? userAvatar : (message.voiceCode !== null ? voiceOptions[message.voiceCode].avatar : voiceOptions[voiceCode].avatar)"
+                :src="message.sender === 'user' ? userAvatar : getAvatar(message.voiceCode)"
                 size="small"
                 style="flex-shrink:0"
                 shape="circle"
@@ -766,6 +766,22 @@ const saveHomework = async () => {
   }
 };
 
+// 安全的头像获取方法
+const getAvatar = (voiceCode) => {
+  if (voiceCode === null || voiceCode === undefined) {
+    return voiceOptions.value[0]?.avatar || userAvatar;
+  }
+  return voiceOptions.value[voiceCode]?.avatar || voiceOptions.value[0]?.avatar || gavinAvatar;
+};
+
+// 安全的语音选项获取方法
+const getVoiceOption = (voiceCode) => {
+  if (voiceCode === null || voiceCode === undefined) {
+    return voiceOptions.value[0];
+  }
+  return voiceOptions.value[voiceCode] || voiceOptions.value[0];
+};
+
 // 文档预览相关
 const open = ref(false)
 const alertProps = reactive({