浏览代码

feat: 自动焦点

zhangyuhan 5 月之前
父节点
当前提交
b393c9de65
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      apps/mobile/src/views/ai-search/index.vue

+ 10 - 0
apps/mobile/src/views/ai-search/index.vue

@@ -174,6 +174,8 @@ function doSelectPrompt(item) {
   promptModel.value.show = false
   promptModel.value.type = ''
 
+  triggerFocus()
+
   that.$nextTick(() => {
     getQuestionInputHeight()
   })
@@ -597,6 +599,7 @@ const askModel = ref({
 function resetQuestion(item) {
   changeInputHeight()
   questionModel.value.input = item.message
+  triggerFocus()
   that.$nextTick(() => {
     getQuestionInputHeight()
   })
@@ -855,6 +858,13 @@ function echoPageState() {
   }
 }
 
+function triggerFocus () {
+  questionInputEl.value.focus()
+  that.$nextTick(() => {
+    questionInputEl.value.focus()
+  })
+}
+
 // 初始化事件
 function init() {
   if (localStorage.getItem('ai-search-cache') === 'use') {