zhangnuoyan %!s(int64=2) %!d(string=hai) anos
pai
achega
c139bbab48
Modificáronse 2 ficheiros con 20 adicións e 7 borrados
  1. 11 3
      src/components/DialogWrap.vue
  2. 9 4
      src/views/Home.vue

+ 11 - 3
src/components/DialogWrap.vue

@@ -247,10 +247,14 @@ export default defineComponent({
         const dialogScroll = ref("");
         const scrollToEnd = async () => {
             await nextTick();
-            dialogScroll.value.scrollTop = dialogScroll.value.scrollHeight;
+            if (dialogScroll.value) {
+                dialogScroll.value.scrollTop = dialogScroll.value.scrollHeight;
+            }
         };
+        let questionInterval = null;
         let answerInterval = null;
         const stopWriting = () => {
+            window.clearInterval(questionInterval);
             window.clearInterval(answerInterval);
             emit("set-readonly", false);
             dialogList[dialogIndex].other = {
@@ -278,13 +282,13 @@ export default defineComponent({
             let result = { question: "", capacity: null, answer: "", other: null, file: null };
             // 第一步,输入问题
             const step1 = () => {
-                const interval = setInterval(() => {
+                questionInterval = setInterval(() => {
                     if (num1 < p1.length + 1) {
                         result.question = p1.slice(0, num1);
                         num1 += 1;
                         addData(result);
                     } else {
-                        window.clearInterval(interval);
+                        window.clearInterval(questionInterval);
                         // 如果有文件,显示上传文件
                         if (file) {
                             result.file = file;
@@ -376,6 +380,7 @@ export default defineComponent({
         onBeforeUnmount(() => {
             helper.$bus.off("send-message");
             helper.$bus.off("clear-message");
+            helper.$bus.off("stop-writing");
         });
         onMounted(() => {
             helper.$bus.on("send-message", (value) => {
@@ -384,6 +389,9 @@ export default defineComponent({
             helper.$bus.on("clear-message", () => {
                 dialogList.splice(0);
             });
+            helper.$bus.on("stop-writing", () => {
+                stopWriting();
+            });
         });
         return {
             randomKey,

+ 9 - 4
src/views/Home.vue

@@ -28,7 +28,7 @@
                         <section>
                             <Answer v-if="navIndex === 0 && !showDialog" />
                             <dialog-wrap
-                                v-show="showDialog"
+                                v-if="showDialog"
                                 :agentInfo="data"
                                 :userInfo="userInfo"
                                 :isSetting="false"
@@ -37,7 +37,7 @@
                             />
                         </section>
                         <footer>
-                            <message-input :readonly="readonly" />
+                            <message-input :readonly="readonly" eventName="open-dialog" />
                         </footer>
                         <a-tooltip :content="closeOthers ? '收起' : '展开'">
                             <div @click="openAll">
@@ -98,6 +98,8 @@ export default defineComponent({
             } else {
                 swiperNumber.value = 4;
             }
+            helper.$bus.emit("stop-writing");
+            showDialog.value = false;
         };
         const setReadonly = (status) => {
             readonly.value = status;
@@ -106,12 +108,15 @@ export default defineComponent({
             console.log(id);
         };
         onMounted(() => {
-            helper.$bus.on("send-message", () => {
+            helper.$bus.on("open-dialog", (value) => {
                 showDialog.value = true;
+                setTimeout(() => {
+                    helper.$bus.emit("send-message", value);
+                }, 300);
             });
         });
         onBeforeUnmount(() => {
-            helper.$bus.off("send-message");
+            helper.$bus.off("open-dialog");
         });
         return {
             navIndex,