Browse Source

添加ai对话框

xiaoguang_li 1 month ago
parent
commit
a71925ac25
1 changed files with 8 additions and 5 deletions
  1. 8 5
      desktop/core/src/desktop/templates/assist.mako

+ 8 - 5
desktop/core/src/desktop/templates/assist.mako

@@ -2796,7 +2796,7 @@ from desktop.views import _ko
         <!-- 输入区域 -->
         <div class="input-area">
             <textarea rows="1" class="user-input clearable" placeholder="请输入你的问题..."
-                      data-bind="clearable: query, textInput: query, event: { keydown: ask, input: autoResize} "></textarea>
+                      data-bind=" textInput: query, event: { keydown: ask, input: autoResize} "></textarea>
         <!--    <button class="send-btn" data-bind="click: answer">发送</button>-->
         </div>
       </div>
@@ -2812,9 +2812,15 @@ from desktop.views import _ko
 
         self.activeType = ko.observable();
         self.availableTypes = ko.observableArray(window.IS_EMBEDDED ? ['Impala'] : ['Hive', 'Impala', 'Pig']);
-        self.query = ko.observable().extend({ rateLimit: 400 });
+        self.query = ko.observable().extend({ rateLimit: 1000 });
         self.messages = ko.observableArray([]);
 
+        self.query.subscribe(function (newValue, oldValue) {
+            let inputTextArea = $('.user-input')[0]
+            if (inputTextArea) {
+                self.autoResize(null, { target: inputTextArea } );
+            }
+        });
         self.availableTypes().forEach(function (type) {
           self.initFunctions(type);
         });
@@ -2877,9 +2883,6 @@ from desktop.views import _ko
         self.messages.push({type:'ai', content: '感谢提问!我已经收到你的消息:' + self.query().trim()});
 
         self.query('');
-
-        // 清空输入框后 调用 autoResize
-        self.autoResize(data, event);
       };
 
       ChatPanel.prototype.initFunctions = function (dialect) {