Selaa lähdekoodia

课堂中心图片问题

11wqe1 11 kuukautta sitten
vanhempi
commit
875e2caf3a

+ 61 - 9
src/components/classRoomHelper/component/dialogArea.vue

@@ -20,7 +20,14 @@
             </div>
             <div class="d_t_c_a_right">
               <div class="d_t_c_a_r_content" style="display: flex;justify-content: space-between;flex-wrap: wrap;" v-if="item.content.includes('图片')">
-                <div  v-for="i in pan(item.aiContent)" :key="i.image">
+                <div
+                  v-if="!pan(item.aiContent).length"
+                  class="d_t_c_a_r_content"
+                  v-loading="item.loading"
+                  v-html="item.aiContent"
+                ></div>
+                
+                <div v-else v-for="i in pan(item.aiContent)">
                     <img style="width: 120px;height: 120px;" :src="i.image" alt="" @click="previewImg(i.image)">
                 </div>
               </div>
@@ -348,14 +355,14 @@ export default {
       if (this.loading) return this.$message.info("请稍等");
       this.cardType = 1;
     },
-    sendFile() {
-      if (this.loading) return this.$message.info("请稍等");
-      this.$message.info("点击了附件");
-    },
-    goTape() {
-      if (this.loading) return this.$message.info("请稍等");
-      this.$message.info(`点击了语音`);
-    },
+    // sendFile() {
+    //   if (this.loading) return this.$message.info("请稍等");
+    //   this.$message.info("点击了附件");
+    // },
+    // goTape() {
+    //   if (this.loading) return this.$message.info("请稍等");
+    //   this.$message.info(`点击了语音`);
+    // },
     send(_text = this.text) {
       if (this.loading || this.chatLoading) return this.$message.info("请稍等");
       if (_text.trim().length == 0) return this.$message.info("请输入内容");
@@ -403,6 +410,51 @@ export default {
         this.getAtAuContent(_uid);
       } else {
         let _uuid = uuidv4();
+
+        if (_text.indexOf("图片") != -1) {
+        // console.log("图片");
+        this.text = "";
+        let params = {
+          page: 1,
+          pagesize: 4,
+          query: _text
+        };
+        // this.$message.info(_text);
+        this.chatList.push({
+          role: "user",
+          content: `${_text}`,
+          uid: _uuid,
+          AI: "AI",
+          aiContent: "",
+          oldContent: "",
+          isShowSynchronization: false,
+          filename: "",
+          index: this.chatList.length,
+          is_mind_map: false,
+          loading: true
+        });
+        this.ajax
+          .post("https://gpt.cocorobo.cn/search_image", params)
+          .then(res => {
+            let data = res.data.FunctionResponse.result;
+            // console.log('res',res.data.FunctionResponse.result);
+            this.chatList.find(i => i.uid == _uuid).aiContent = JSON.stringify(data);
+            this.chatList.find(i => i.uid == _uuid).loading = false;
+            this.chatLoading = false;
+            this.getAiContent(_uuid);
+
+            // console.log('resresresres',res);
+            // if (res.data.FunctionResponse.result == "发送成功") {
+
+            // } else {
+            //   this.$message.warning(res.data.FunctionResponse.result);
+            // }
+          });
+          this.scrollBottom();
+          return;
+      }
+      console.log('没停???');
+
         this.chatList.push({
           role: "user",
           content: `${_text}`,

+ 20 - 14
src/components/classRoomHelper/component/searchArea.vue

@@ -61,7 +61,13 @@
           </div>
           <div class="s_t_c_a_right">
             <div class="s_t_c_a_r_content" style="display: flex;justify-content: space-between;flex-wrap: wrap;" v-if="item.content.includes('图片')">
-              <div  v-for="i in pan(item.aiContent)" :key="i.image">
+              <div
+                  v-if="!pan(item.aiContent).length"
+                  class="d_t_c_a_r_content"
+                  v-loading="item.loading"
+                  v-html="item.aiContent"
+                ></div>
+              <div v-else  v-for="(i,index) in pan(item.aiContent)" :key=index>
                   <img style="width: 120px;height: 120px;" :src="i.image" alt=""  @click="previewImg(i.image)">
               </div>
             </div>
@@ -197,17 +203,17 @@ export default {
     clear() {
       this.chatList = [];
     },
-    choiceRole() {
-      this.cardType = 1;
-    },
-    sendFile() {
-      if (this.loading) return this.$message.info("请稍等");
-      this.$message.info("点击了附件");
-    },
-    goTape() {
-      if (this.loading) return this.$message.info("请稍等");
-      this.$message.info(`点击了语音`);
-    },
+    // choiceRole() {
+    //   this.cardType = 1;
+    // },
+    // sendFile() {
+    //   if (this.loading) return this.$message.info("请稍等");
+    //   this.$message.info("点击了附件");
+    // },
+    // goTape() {
+    //   if (this.loading) return this.$message.info("请稍等");
+    //   this.$message.info(`点击了语音`);
+    // },
     send(_text = this.text) {
       if (this.loading || this.chatLoading) return this.$message.info("请稍等");
       if (_text.trim().length == 0) return this.$message.info("请输入内容");
@@ -257,14 +263,14 @@ Instruction: Based on the context, follow "Format example", write content.
 视频链接https://www.ted.com/talks/sal_khan_how_ai_could_save_not_destroy_education
 				`;
       } else if (_text.indexOf("图片") != -1) {
-        console.log("图片");
+        // console.log("图片");
         this.text = "";
         let params = {
           page: 1,
           pagesize: 4,
           query: _text
         };
-        this.$message.info(_text);
+        // this.$message.info(_text);
         this.chatList.push({
           role: "user",
           content: `getImage`,

+ 72 - 20
src/components/classRoomHelper/component/taskArea.vue

@@ -68,7 +68,13 @@
           </div>
           <div class="t_t_c_a_right">
             <div class="t_t_c_a_r_content" style="display: flex;justify-content: space-between;flex-wrap: wrap;" v-if="item.content.includes('图片')">
-              <div  v-for="i in pan(item.aiContent)" :key="i.image">
+              <div
+                  v-if="!pan(item.aiContent).length"
+                  class="d_t_c_a_r_content"
+                  v-loading="item.loading"
+                  v-html="item.aiContent"
+                ></div>
+              <div v-else v-for="i in pan(item.aiContent)">
                   <img style="width: 120px;height: 120px;" :src="i.image" alt=""  @click="previewImg(i.image)">
               </div>
             </div>
@@ -269,22 +275,68 @@ export default {
           });
       });
     },
-    choiceRole() {
-      this.cardType = 1;
-    },
-    sendFile() {
-      if (this.loading) return this.$message.info("请稍等");
-      this.$message.info("点击了附件");
-    },
-    goTape() {
-      if (this.loading) return this.$message.info("请稍等");
-      this.$message.info(`点击了语音`);
-    },
+    // choiceRole() {
+    //   this.cardType = 1;
+    // },
+    // sendFile() {
+    //   if (this.loading) return this.$message.info("请稍等");
+    //   this.$message.info("点击了附件");
+    // },
+    // goTape() {
+    //   if (this.loading) return this.$message.info("请稍等");
+    //   this.$message.info(`点击了语音`);
+    // },
     send(_text = this.text) {
       if (this.loading || this.chatLoading) return this.$message.info("请稍等");
       if (_text.trim().length == 0) return this.$message.info("请输入内容");
       this.chatLoading = true;
       let _uuid = uuidv4();
+
+
+      if (_text.indexOf("图片") != -1) {
+        // console.log("图片");
+        this.text = "";
+        let params = {
+          page: 1,
+          pagesize: 4,
+          query: _text
+        };
+        // this.$message.info(_text);
+        this.chatList.push({
+          role: "user",
+          content: `${_text}`,
+          uid: _uuid,
+          AI: "AI",
+          aiContent: "",
+          oldContent: "",
+          isShowSynchronization: false,
+          filename: "",
+          index: this.chatList.length,
+          is_mind_map: false,
+          loading: true
+        });
+        this.ajax
+          .post("https://gpt.cocorobo.cn/search_image", params)
+          .then(res => {
+            let data = res.data.FunctionResponse.result;
+            // console.log('res',res.data.FunctionResponse.result);
+            this.chatList.find(i => i.uid == _uuid).aiContent = JSON.stringify(data);
+            this.chatList.find(i => i.uid == _uuid).loading = false;
+            this.chatLoading = false;
+            this.getAiContent(_uuid);
+
+            // console.log('resresresres',res);
+            // if (res.data.FunctionResponse.result == "发送成功") {
+
+            // } else {
+            //   this.$message.warning(res.data.FunctionResponse.result);
+            // }
+          });
+          this.scrollBottom();
+          return;
+      }
+      console.log('没停???');
+
       this.chatList.push({
         role: "user",
         content: `${_text}`,
@@ -299,6 +351,7 @@ export default {
         loading: true
       });
       this.scrollBottom();
+
       let params = {
         model: "gpt-3.5-turbo",
         temperature: 0,
@@ -426,10 +479,9 @@ Instruction: Based on the context, follow "Format example", write content.
 
 ## 格式要求
 1. 以无序列表的形式输出“课程信息”中的“课程标题”,“主题”,“学科”以及“年级”,若这些条目中的内容为“无”,则不需要输出
------
+
 # Format example
 ## 课程标题:垃圾回收
-主题:无
 学科:无
 年级:无
 课程信息
@@ -487,12 +539,12 @@ Instruction: Based on the context, follow "Format example", write content.
       this.getAiContent(_uuid);
       // this.send(text);
     },
-    sendImage() {
-      this.$message.info("发送图片");
-    },
-    sendVideo() {
-      this.$message.info("发送视频");
-    },
+    // sendImage() {
+    //   this.$message.info("发送图片");
+    // },
+    // sendVideo() {
+    //   this.$message.info("发送视频");
+    // },
     scrollBottom() {
       this.$nextTick(() => {
         this.$refs.chatRef.scrollTop = this.$refs.chatRef.scrollHeight;