SyuanYu 3 månader sedan
förälder
incheckning
2ea671b6ef
2 ändrade filer med 26 tillägg och 51 borttagningar
  1. 0 47
      src/router/index.js
  2. 26 4
      src/views/HomeView.vue

+ 0 - 47
src/router/index.js

@@ -2,7 +2,6 @@ import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router
 import HomeView from '../views/HomeView.vue'
 import BrandSearch from '../views/BrandSearch.vue'
 import RtspStream from '../views/RtspStream.vue'
-// import ArTourView from '../views/ArTourView.vue'
 
 const router = createRouter({
   history: createWebHashHistory(),
@@ -22,52 +21,6 @@ const router = createRouter({
       name: 'RtspStream',
       component: RtspStream,
     },
-    // 定位點網址設定
-    // {
-    //   path: '/b1-1',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/b1-2',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/b1-3',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/b1-4',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/b1-5',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/1f-6',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/1f-7',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/2f-8',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/89f-9',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/88f-10',
-    //   component: HomeView,
-    // },
-    // {
-    //   path: '/ar-tour',
-    //   name: 'ar-tour',
-    //   component: ArTourView
-    // },
   ]
 })
 

+ 26 - 4
src/views/HomeView.vue

@@ -194,8 +194,8 @@ let questions = reactive([
 
 // 傳送訊息 (如 type="text" 代表為純文字訊息,不需語音回覆)
 async function sendMessage(type = "") {
-  let question = userMessage.value;
-  qaQuery.push(question);
+  let message = userMessage.value;
+  qaQuery.push(message);
 
   if (userMessage.value === "") {
     return;
@@ -203,7 +203,7 @@ async function sendMessage(type = "") {
     // 使用者訊息
     messages.value.push({
       label: "text",
-      body: question,
+      body: message,
       author: "user",
     });
 
@@ -227,6 +227,28 @@ async function sendMessage(type = "") {
   let url = "https://api.itri-101-5g.com/v1/qa/";
 
   try {
+    let isVideoCache = await getVideoCache(message); // 判斷使用者問題是否有 Video Cache
+
+    console.log("isVideoCache", isVideoCache);
+
+    // 如果有 Video Cache 則不需回傳工研院回答
+    if (isVideoCache) {
+      console.log("Cache:", videoCacheData.value);
+
+      // AI 客服回傳訊息
+      messages.value.push({
+        label: "text",
+        author: "ai",
+        body: videoCacheData.value.answer,
+      });
+      // handleVideoCache(); // 播放 Video Cache
+      // if (audioFile.value && type !== "text") {
+      //   messageSaveMp3(message, videoCacheData.value.answer, []);
+      // } else {
+      //   messageSave(message, videoCacheData.value.answer, []);
+      // }
+      return;
+    }
     // // 使用者訊息
     // messages.value.push({
     //   label: "text",
@@ -255,7 +277,7 @@ async function sendMessage(type = "") {
         }
       )
       .then((response) => {
-        messageSave(question, response.data);
+        messageSave(message, response.data);
 
         // AI 客服回傳訊息
         messages.value.push({