SyuanYu 7 달 전
부모
커밋
ca05c9e946
1개의 변경된 파일26개의 추가작업 그리고 11개의 파일을 삭제
  1. 26 11
      src/components/Chat.vue

+ 26 - 11
src/components/Chat.vue

@@ -319,6 +319,9 @@ function getLang() {
     case "en-us":
       langVal = "en";
       break;
+    case "ja-jp":
+      langVal = "jp";
+      break;
 
     default:
       break;
@@ -332,7 +335,7 @@ let showAd = ref(false);
 // 取得廣告
 async function setAd() {
   let lang = getLang();
-  console.log("lang", lang);
+
   let url = `https://cmm.ai:9101/ad?language=${lang}`;
 
   try {
@@ -391,6 +394,13 @@ function onLanguageChange(lang) {
   } else if (lang === "English") {
     chooseLang("en-us");
   }
+
+  // 清空音訊
+  if (currentAudio.value) {
+    currentAudio.value.pause();
+    currentAudio.value.currentTime = 0;
+    currentAudio.value = null;
+  }
 }
 
 function chooseLang(lang) {
@@ -433,6 +443,8 @@ function chooseLang(lang) {
     sources = videoSources.value;
   } else if (language === "en-us") {
     sources = videoSourcesEn.value;
+  } else {
+    sources = videoSources.value;
   }
 
   const randomIndex = Math.floor(Math.random() * sources.length);
@@ -1685,10 +1697,10 @@ let langList = reactive([
     lang: "English",
     value: "en-us",
   },
-  // {
-  //   lang: "日本語",
-  //   value: "ja-jp",
-  // },
+  {
+    lang: "日本語",
+    value: "ja-jp",
+  },
   // {
   //   lang: "한국어",
   //   value: "ko-kr",
@@ -2104,7 +2116,6 @@ async function handleAudioToText() {
   isRecording.value = false;
   let audioLang; // 音訊語言
   let lang = localStorage.getItem("lang");
-  console.log("lang", lang);
 
   switch (lang) {
     case "zh-tw":
@@ -2293,7 +2304,9 @@ async function messageSaveMp3(question, answer, data) {
 }
 
 async function getVideoCache(messages) {
-  let url = `https://cmm.ai:9101/video_cache?client_message=${messages}`;
+  let lang = getLang();
+
+  let url = `https://cmm.ai:9101/video_cache?client_message=${messages}&language=${lang}`;
 
   try {
     const response = await axios.post(url);
@@ -2394,7 +2407,9 @@ function handleVoice(state) {
 
 // 回傳未收錄問題
 async function messageNotInCache(question, answer) {
-  let url = `https://cmm.ai:9101/message_not_in_cache?question=${question}&answer=${answer}&client_id=0`;
+  let lang = getLang();
+
+  let url = `https://cmm.ai:9101/message_not_in_cache?question=${question}&answer=${answer}&client_id=0&language=${lang}`;
 
   try {
     const response = await axios.post(url);
@@ -2951,10 +2966,10 @@ async function messageNotInCache(question, answer) {
             >
               <p v-html="message.body.words"></p>
 
-              <button @click="arVideoDialog = true" class="ar-link my-3">
-                <!-- 進行 AR 導覽 -->
+              <!-- 進行 AR 導覽 -->
+              <!-- <button @click="arVideoDialog = true" class="ar-link my-3">
                 {{ t("ar_tour") }}
-              </button>
+              </button> -->
 
               <v-dialog v-model="arVideoDialog" width="auto">
                 <v-card class="ar-card">