From 0d9844060912192819486a499ad987d216e33b6e Mon Sep 17 00:00:00 2001
From: 康鲁杰 <60095866+KangLujie@users.noreply.github.com>
Date: 星期四, 29 五月 2025 16:40:58 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 easegen-front/src/views/dialogue/index.vue |   86 ++++++++++++++++++++++++++++---------------
 1 files changed, 56 insertions(+), 30 deletions(-)

diff --git a/easegen-front/src/views/dialogue/index.vue b/easegen-front/src/views/dialogue/index.vue
index e9cc1e1..2299f01 100644
--- a/easegen-front/src/views/dialogue/index.vue
+++ b/easegen-front/src/views/dialogue/index.vue
@@ -1,43 +1,69 @@
 <template>
-<div>
-  <div class="remote-container"></div>
-</div>
+  <div>
+    <div class="remote-container" classNamev>
+    </div>
+  </div>
 </template>
 
 <script>
-import DUIX from 'duix-guiji-light'
-import {getDuixSign} from "../../api/dialogue";
-import * as pptTemplateApi from "../../api/pptTemplate";
-
+import DUIX from 'duix-guiji-light';
+import {getDuixSign} from "../../api/dialogue/index.ts";
 export default {
-  name: "index"
-}
-const tempConversationId ='dev-'+ Math.random().toString(36).substring(2, 11);
-const duix = new DUIX()
+  name: "index",
+  mounted() {
+    this.$nextTick(() => {
+      this.initDuix();
+    });
+  },
+  methods: {
 
-  getDuixSign().then(res => {
-    if (res.code === 200) {
-      duix.init({
-        sign: res.data.sign,
-        containerLable: '.remote-container',
-        conversationId: tempConversationId,
-      })
-    }
-  })
-duix.on('getDuixSign', () => {
-  // start session
-  duix.start({
-    conversationId: tempConversationId,
-    openAsr: true
-  }).then(res => {
-    console.info(res)
-  })
-})
+    async initDuix() {
+      // 1. 妫�鏌ュ鍣ㄦ槸鍚﹀瓨鍦�
+      const container = document.querySelector('.remote-container');
+      if (!container) {
+        console.error("閿欒锛氭湭鎵惧埌 .remote-container 鍏冪礌");
+        return;
+      }
+
+      // 2. 鑾峰彇 Token
+      let token;
+      try {
+        const res = await getDuixSign();
+        token = res.data?.sign || res.sign || res;
+        if (!token) throw new Error("Token 涓虹┖");
+      } catch (err) {
+        console.error("鑾峰彇绛惧悕澶辫触:", err);
+        return;
+      }
+
+      // 3. 鍒濆鍖� DUIX
+      const duix = new DUIX();
+      const conversationId = 'dev-'+ Math.random().toString(36).substring(2, 11);;
+
+      try {
+        await duix.init({
+          sign: token,
+          containerLable: '.remote-container', // 娉ㄦ剰锛氬彲鑳芥槸 containerLabel锛堟鏌ユ嫾鍐欙級
+          conversationId: conversationId,
+        });
+        // 4. 鐩戝惉浜嬩欢
+        duix.on('getDuixSign', () => {
+          duix.start({conversationId, openAsr: true})
+            .then(() => console.log("DUIX 鍚姩鎴愬姛"))
+            .catch(err => console.error("DUIX 鍚姩澶辫触:", err));
+        });
+      } catch (initErr) {
+        console.error("DUIX 鍒濆鍖栧け璐�:", initErr);
+      }
+    },
+  },
+};
 </script>
 
 <style scoped>
-.remote-container{
+.remote-container {
   width: 500px;
   height: 500px;
+  border: 1px solid red; /* 璋冭瘯鏃堕珮浜鍣� */
 }
 </style>

--
Gitblit v1.9.3