Quellcode durchsuchen

perf: 完善文生图功能

1. 优化图片的展示
zhupei vor 1 Jahr
Ursprung
Commit
e579d011cd

+ 28 - 22
src/components/DialogWrap.vue

@@ -377,6 +377,7 @@ export default defineComponent({
 
     const addData = (data) => {
       dialogList.splice(dialogIndex, 1, data);
+      
       randomKey.value = Math.random();
       scrollToEnd();
     };
@@ -479,8 +480,16 @@ export default defineComponent({
     const answerCode = ref(undefined);
     const answerSql = ref(undefined);
     const addQuestion = (question, file = null) => {
-      let result = { question, capacity: null, answer: "", other: null, file: null, };
+      let result = { 
+        question, 
+        capacity: null, 
+        answer: "", 
+        other: null, 
+        file: null, 
+      };
+
       addData(result);
+
       return result;
     };
     const addAnswer = (data) => {
@@ -701,14 +710,6 @@ export default defineComponent({
         }
 
         if (msg_type === "close") {
-          if (!answerData.value) {
-            answerLoaded();
-            answerData.value = getHTML(message);
-            addAnswer(loadingData.value);
-          }
-          stopWriting();
-          answerData.value = "";
-          isLoaded.value = false;
 
           /**
            * 在小数绘图对话结束时
@@ -723,24 +724,33 @@ export default defineComponent({
 
             // 小数绘图
             if(res_data.message_files){
-              console.log(11);
               const arr = [];
 
               if(Array.isArray(res_data.message_files)){
-                console.log(12);
-
                 res_data.message_files.forEach((item, index) => {
-                  console.log(13, index);
-                  arr.push(item.url);
+                  arr.push(item);
                 });
 
-                console.log(arr, 'arr');
-
                 fullImageUrls.url = arr;
               }else{
                 fullImageUrls.url = arr;
               }
             }
+
+            answerLoaded();
+            
+            stopWriting();
+            answerData.value = "";
+            isLoaded.value = false;
+          }else{
+            if (!answerData.value) {
+              answerLoaded();
+              answerData.value = getHTML(message);
+              addAnswer(loadingData.value);
+            }
+            stopWriting();
+            answerData.value = "";
+            isLoaded.value = false;
           }
         }
 
@@ -778,7 +788,9 @@ export default defineComponent({
 
         const question = chat_type === "report" ? value.inputs.report_name : value;
         const data = addQuestion(question);
+        
         loadingData.value = addLoading(data);
+        
 
         let sendData = {
           message: value
@@ -792,12 +804,6 @@ export default defineComponent({
           sendData = value;
         }
 
-          // chat_type === "report" || chat_type === "excel"
-          //   ? value
-          //   : {
-          //     message: value
-          //   };
-
         if (chat_type === 'doc') {
           sendData.doc_ids = [helper.read('docId')];
         }

+ 7 - 5
src/components/MessagePicUpload.vue

@@ -35,18 +35,20 @@ export default defineComponent({
     setup(props) {
         const { helper } = inject("$global");
         const value = ref("");
+        const ask_times = ref(0);
         const maxLength = ref(6000);
         const sendMessage = () => {
             const msg_str = value.value;
 
             if (msg_str.length > 0 && !props.readonly) {
-                // console.log("1234444");
-                // const eventName = props.eventName || "send-message";
-                // console.log("1234444", eventName, msg_str);
-                // helper.$bus.emit(eventName, msg_str);
+                if(ask_times.value === 0){
+                    helper.$bus.emit('open-dialog', msg_str);
+                }else{
+                    helper.$bus.emit('send-message', msg_str);
+                }
 
-                helper.$bus.emit('open-dialog', msg_str);
                 value.value = "";
+                ask_times.value = ask_times.value + 1;
             }
         };
         const clearMessage = () => {

+ 0 - 1
src/components/PictureCards.vue

@@ -282,7 +282,6 @@ export default defineComponent({
     };
 
     const onBeforeRemove = (data) => {
-      console.log('data', data)
       fileList.value = fileList.value.filter((item) => item.id !== data.uid);
       return true;
     };

+ 2 - 1
src/components/answer-effect/apply-image-display.js

@@ -27,7 +27,8 @@ export default function applyImageDisplay(container_klass, img_list) {
                 if (img_src) {
                     // 合法的src
                     // data_src = `${img_server}${img_src}`
-                    data_src = item.getAttribute('data-src');
+                    data_src = `/api/files/image/${img_src}`;
+                    // data_src = item.getAttribute('data-src');
                 } else {
                     // 非法的src
                     data_src = item.getAttribute('data-src');

+ 1 - 1
src/components/answer-pictures/AnwserPictureResult.vue

@@ -21,6 +21,7 @@
                             width: '100%',
                         }"
                         :hide-footer="true"
+                        show-loader
                     />
                 </a-carousel-item>
             </a-carousel>
@@ -86,7 +87,6 @@ const handleNext = () => {
     const next_index = cur_index.value + 1;
 
     if(next_index > image_total){
-        console.log('已经是最后一张了');
         return;
     }else{
         cur_index.value = next_index;

+ 10 - 1
src/components/dialog-wrap/Answer.vue

@@ -3,7 +3,7 @@
 </template>
 
 <script setup>
-import { ref, onBeforeUnmount, onMounted, reactive, nextTick, inject, computed } from "vue";
+import { ref, onBeforeUnmount, onMounted, reactive, nextTick, inject, computed, watch } from "vue";
 
 import formatAnwserString from '../answer-effect/format-anwser-string';
 
@@ -56,6 +56,15 @@ const anwser_klass = computed(() => {
     return `${props.chat_type}-${props.agentId}-answer-content-${props.index}`;
 });
 
+watch(props.special_4_image, () => {
+    const container_klass = anwser_klass.value;
+
+    /**
+     * 小数绘图的文生图 图片效果
+     */
+    applyImageDisplay(container_klass, props.special_4_image);
+});
+
 onMounted(() => {
     const container_klass = anwser_klass.value;