centaline-data-driven-v3 0.0.80 → 0.0.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "centaline-data-driven-v3",
3
- "version": "0.0.80",
3
+ "version": "0.0.82",
4
4
  "private": false,
5
5
  "description": "centaline-data-driven-v3",
6
6
  "main": "dist/centaline-data-driven-v3.umd.js",
@@ -17,7 +17,8 @@
17
17
  <template v-for="message in model.messages">
18
18
  <div :key="message.id" class="message" v-if="message.content"
19
19
  :class="{ 'user-message': message.sender === 'user', 'ai-message': message.sender === 'ai' }">
20
- <div class="chat-message" :style="{color:message.type=='error'?'red':''}" v-html="htmlContent(message)">
20
+ <div class="chat-message" :style="{ color: message.type == 'error' ? 'red' : '' }"
21
+ v-html="htmlContent(message)">
21
22
  </div>
22
23
  </div>
23
24
  <div v-else class="loading-container">
@@ -29,8 +30,9 @@
29
30
  <!-- 输入区域 -->
30
31
  <div class="chat-editor" v-if="showAI">
31
32
  <div class="chat-input-editor-container">
32
- <textarea ref="textareaRef" class="chat-input" v-model="inputMessage" @keydown="handleKeydown"
33
- placeholder="输入你的消息..."></textarea>
33
+ <textarea ref="textareaRef" class="chat-input"
34
+ v-model="inputMessage" @keydown="handleKeydown"
35
+ :placeholder="model.placeholder"></textarea>
34
36
 
35
37
 
36
38
  </div>
@@ -55,7 +57,7 @@
55
57
 
56
58
 
57
59
  <script setup lang="ts">
58
- import { ref, reactive, nextTick, watch, computed } from 'vue'
60
+ import { ref, onActivated, nextTick, watch, computed } from 'vue'
59
61
  import AIChat from '../../loader/src/AIChat'
60
62
  import common from '../../utils/common'
61
63
  import { marked } from 'marked';
@@ -139,6 +141,13 @@ function load(data) {
139
141
  action();
140
142
  }
141
143
 
144
+ onActivated(() => {
145
+ nextTick(() => {
146
+ if (inputMessage.value) {
147
+ inputMessage.value.focus();
148
+ }
149
+ })
150
+ })
142
151
  // Marked 配置
143
152
  marked.setOptions({
144
153
  breaks: true,
@@ -194,7 +203,6 @@ const sendMessage = async () => {
194
203
  sender: 'ai',
195
204
  type: ''
196
205
  })
197
-
198
206
  // AI回复
199
207
  await fetchAIResponse({
200
208
  "query": inputMessage.value
@@ -207,7 +215,7 @@ const addMessage = (message) => {
207
215
  ...message,
208
216
  timestamp: new Date()
209
217
  })
210
- scheduleScroll()
218
+ scheduleScroll(true);
211
219
  }
212
220
  // 添加消息通用方法
213
221
  const appendMessage = (message) => {
@@ -222,13 +230,13 @@ const UpdateMessageType = (type) => {
222
230
  }
223
231
 
224
232
  // 防抖滚动
225
- const scheduleScroll = () => {
233
+ const scheduleScroll = (flagScroll) => {
226
234
  if (!scrollPending) {
227
235
  if (messagesContainer.value) {
228
236
  const container = messagesContainer.value;
229
237
 
230
238
  const distanceToBottom = container.scrollHeight - (container.scrollTop + container.clientHeight);
231
- if (distanceToBottom <= 20) {
239
+ if (flagScroll || distanceToBottom <= 20) {
232
240
  scrollPending = true
233
241
  nextTick(() => {
234
242
  if (messagesContainer.value) {
@@ -507,12 +515,12 @@ function hideAI() {
507
515
  background-color: #fff;
508
516
  display: flex;
509
517
  flex-direction: row;
510
- /* 子元素水平排列 */
511
- gap: 5px;
518
+ /* 子元素水平排列
519
+ gap: 5px; */
512
520
 
513
521
  /* 子元素之间的间距为5像素 */
514
522
  .header-item {
515
- padding: 10px;
523
+ padding: 10px 0px 10px 10px;
516
524
  }
517
525
  }
518
526
 
@@ -637,9 +645,9 @@ function hideAI() {
637
645
  overflow: auto;
638
646
  resize: none;
639
647
  /* 禁用手动调整大小 */
640
- min-height: 20px;
648
+ min-height: 40px;
641
649
  /* 设置最大高度 */
642
- max-height: 55px;
650
+ max-height: 65px;
643
651
  /* 设置最大高度 */
644
652
  }
645
653
 
@@ -648,6 +656,10 @@ function hideAI() {
648
656
  outline: none;
649
657
  }
650
658
 
659
+ .chat-input::placeholder {
660
+ color: #a8abb2;
661
+ opacity: 1;
662
+ }
651
663
  .chat-editor-action {
652
664
  display: flex;
653
665
  justify-content: space-between;
@@ -6,7 +6,9 @@ function loadFromModel(source, messages, router) {
6
6
 
7
7
  var init = function (data) {
8
8
  var rtn = {
9
-
9
+ get placeholder() {
10
+ return source.placeholder1 || '输入你的消息...';
11
+ },
10
12
  messages:messages,
11
13
  get action() {
12
14
  return router && router.action ? router.action : "";//上传完整地址
@@ -14,6 +16,7 @@ function loadFromModel(source, messages, router) {
14
16
  set action(v) {
15
17
  router.action = v;
16
18
  },
19
+
17
20
  getFormObj() {
18
21
  var rtnFormObj = {};
19
22
  var that = this;