liyongli 2 年之前
父节点
当前提交
12a933e46d
共有 1 个文件被更改,包括 13 次插入7 次删除
  1. 13 7
      src/view/chatGptChat/index.vue

+ 13 - 7
src/view/chatGptChat/index.vue

@@ -101,10 +101,13 @@ function saveText() {
     prompt.push(chat.value[i]);
   }
   ChartGpt({
-    prompt: [...prompt, {
+    prompt: [
+      ...prompt,
+      {
         text: inputText.value,
         type: 'user',
-    }],
+      },
+    ],
     userId: userData.value.UserId || '',
     userName: userData.value.UserName || '',
   })
@@ -130,11 +133,14 @@ function saveText() {
       load.value = false;
     });
 }
-function focus(){
-    let t = setTimeout(() => {
-        document.getElementById("van-field-6-input") && document.getElementById("van-field-6-input").scrollIntoView();
-        window.clearTimeout(t);
-    }, 200);
+function focus() {
+  let t = window.setTimeout(() => {
+    window.clearTimeout(t);
+    if (chatEle.value.scrollHeight > chatEle.value.clientHeight) {
+      chatEle.value.scrollTop = chatEle.value.scrollHeight;
+    }
+    document.getElementById("van-field-6-input") && document.getElementById("van-field-6-input").scrollIntoView();
+  }, 500);
 }
 </script>
 <style lang="scss">