centaline-data-driven-v3 0.0.83 → 0.0.84

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.83",
3
+ "version": "0.0.84",
4
4
  "private": false,
5
5
  "description": "centaline-data-driven-v3",
6
6
  "main": "dist/centaline-data-driven-v3.umd.js",
@@ -3,12 +3,10 @@
3
3
  <!-- 头部 -->
4
4
  <div class="header">
5
5
  <div class="header-item">
6
- <el-icon class="ico-button" @click="hideAI()">
7
- <DArrowLeft />
8
- </el-icon>
6
+ <img class="ico-button" :src="util.getAssetsImage('AIChat.png')" @click="hideAI()">
9
7
  </div>
10
8
  <div class="header-item" v-if="model.controlLabel">
11
- <h3 style="line-height: 25px;">
9
+ <h3 style="line-height: 35px;">
12
10
  {{ model.controlLabel }}</h3>
13
11
  </div>
14
12
  </div>
@@ -19,10 +17,11 @@
19
17
  :class="{ 'user-message': message.sender === 'user', 'ai-message': message.sender === 'ai' }">
20
18
  <template v-if="message.type == 'table'">
21
19
  <div :style="{ 'width': tablewidth - 70 + 'px' }">
22
- <div v-if="JSON.parse(message.content).title" style="margin-bottom: 10px;" v-html="JSON.parse(message.content).title"></div>
20
+ <div v-if="JSON.parse(message.content).title" style="margin-bottom: 10px;"
21
+ v-html="JSON.parse(message.content).title"></div>
23
22
  <template v-for="(row, rowindex) in JSON.parse(message.content).rows" :key="rowindex">
24
- <ct-layout :vmodel="row" :cellLayout="JSON.parse(message.content).cellLayout" :rowindex="rowindex"
25
- @rolRouterclick="rolRouterCellClickHandler"
23
+ <ct-layout :vmodel="row" :cellLayout="JSON.parse(message.content).cellLayout"
24
+ :rowindex="rowindex" @rolRouterclick="rolRouterCellClickHandler"
26
25
  :actionRouter="JSON.parse(message.content).actionRouters">
27
26
  </ct-layout>
28
27
  </template>
@@ -34,10 +33,10 @@
34
33
  </div>
35
34
  </template>
36
35
  </div>
37
- <div v-else class="loading-container">
38
- <div class="loading-circle"></div>
39
- </div>
40
36
  </template>
37
+ <div v-if="afoot" class="loading-container">
38
+ <div class="loading-circle"></div>
39
+ </div>
41
40
  </div>
42
41
 
43
42
  <!-- 输入区域 -->
@@ -46,7 +45,6 @@
46
45
  <textarea ref="textareaRef" class="chat-input" v-model="inputMessage" @keydown="handleKeydown"
47
46
  :placeholder="model.placeholder"></textarea>
48
47
 
49
-
50
48
  </div>
51
49
  <div class="chat-editor-action">
52
50
 
@@ -76,6 +74,8 @@ import { marked } from 'marked';
76
74
  import DOMPurify from 'dompurify'
77
75
  import Router from '../../loader/src/Router';
78
76
  import { RouterClickHandler } from '../../utils/mixins';
77
+ import util from '../../utils/pub-use'
78
+
79
79
 
80
80
  const emit = defineEmits(['loaded', "getRefFieldPara", "hideAI"])
81
81
  const props = defineProps({
@@ -239,8 +239,10 @@ const addMessage = (message) => {
239
239
  }
240
240
  // 添加消息通用方法
241
241
  const appendMessage = (message) => {
242
- model.value.messages[model.value.messages.length - 1].content = model.value.messages[model.value.messages.length - 1].content + message;
243
- scheduleScroll()
242
+ if (!isStopped) {
243
+ model.value.messages[model.value.messages.length - 1].content = model.value.messages[model.value.messages.length - 1].content + message;
244
+ scheduleScroll()
245
+ }
244
246
  }
245
247
 
246
248
  const UpdateMessageType = (type) => {
@@ -253,11 +255,10 @@ const UpdateMessageType = (type) => {
253
255
  const scheduleScroll = (flagScroll) => {
254
256
  if (!scrollPending) {
255
257
  if (messagesContainer.value) {
256
- const container = messagesContainer.value;
257
-
258
- const distanceToBottom = container.scrollHeight - (container.scrollTop + container.clientHeight);
258
+ const distanceToBottom = getDistanceToBottom();
259
+ console.log(flagScroll, distanceToBottom)
259
260
  if (flagScroll || distanceToBottom <= 20) {
260
- scrollPending = true
261
+ scrollPending = true;
261
262
  nextTick(() => {
262
263
  if (messagesContainer.value) {
263
264
  messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight
@@ -269,6 +270,18 @@ const scheduleScroll = (flagScroll) => {
269
270
  }
270
271
  }
271
272
 
273
+ const getDistanceToBottom = () => {
274
+ let rtn = 0;
275
+
276
+ if (messagesContainer.value) {
277
+ const container = messagesContainer.value;
278
+
279
+ rtn = container.scrollHeight - (container.scrollTop + container.clientHeight);
280
+ }
281
+
282
+ return rtn;
283
+
284
+ }
272
285
  //获取关联列返回对象
273
286
  function getRefFieldJson() {
274
287
  let rtn = {};
@@ -385,9 +398,7 @@ const fetchAIResponse = async (params) => {
385
398
  });
386
399
  }).then(() => {
387
400
  // 在所有行处理完毕后执行 startTypingEffect
388
- if (outtext.value == '') {
389
-
390
- }
401
+
391
402
  let TemplateType = getTemplateType(outtext.value);
392
403
  UpdateMessageType(TemplateType);
393
404
 
@@ -403,7 +414,12 @@ const fetchAIResponse = async (params) => {
403
414
  });
404
415
  data.actionRouters = actionRouters
405
416
  }
417
+ const flagScroll = (getDistanceToBottom() <= 20) ? true : false;
406
418
  appendMessage(JSON.stringify(data));
419
+
420
+
421
+ setTimeout(() => scheduleScroll(flagScroll), 500);
422
+
407
423
  } else {
408
424
  startTypingEffect(outtext.value);
409
425
  }
@@ -517,35 +533,33 @@ const getTemplateType = (fullText) => {
517
533
 
518
534
 
519
535
  function startTypingEffect(fullText) {
520
-
521
536
  let index = 0;
522
- let timer = setInterval(() => {
523
- // 检查索引是否超出字符串长度
524
- if (index >= fullText.length) {
525
- clearInterval(timer); // 清除定时器
526
- return;
527
- }
537
+ outtext.value = ''; // 清空内容
528
538
 
539
+ function typeNext() {
529
540
  // 随机生成3到10之间的字符数
530
- const randomChars = Math.floor(Math.random() * 8) + 3; // 3到10(包括3和10)
541
+ const randomChars = Math.floor(Math.random() * 5) + 8;
531
542
  const charsToLoad = Math.min(randomChars, fullText.length - index);
532
543
 
533
- // 获取当前要加载的字符
544
+ // 获取并显示当前字符
534
545
  const currentChars = fullText.substring(index, index + charsToLoad);
535
- // 显示字符
536
546
  appendMessage(currentChars);
537
- // 更新索引
538
547
  index += charsToLoad;
539
548
 
540
- // 检查是否已经加载完成
541
- if (index >= fullText.length) {
542
- clearInterval(timer); // 清除定时器
549
+ // 递归条件判断
550
+ if (index < fullText.length && !isStopped) {
551
+ setTimeout(typeNext, 100); // 继续下一次迭代
552
+ } else {
553
+ // 全部完成后执行
554
+ outtext.value = '';
543
555
  }
544
- }, 100); // 每100毫秒加载10个字符
545
- outtext.value = '';
546
-
556
+ }
557
+
558
+ // 启动首次调用
559
+ setTimeout(typeNext, 100);
547
560
  }
548
561
 
562
+
549
563
  function hideAI() {
550
564
  emit("hideAI", false);
551
565
 
@@ -598,7 +612,7 @@ function rolRouterCellClickHandler(routerKey, rowindex, forname, forrowindex, fl
598
612
 
599
613
  /* 子元素之间的间距为5像素 */
600
614
  .header-item {
601
- padding: 10px 0px 10px 10px;
615
+ padding: 3px 0px 0px 8px;
602
616
  }
603
617
  }
604
618
 
@@ -793,9 +807,8 @@ function rolRouterCellClickHandler(routerKey, rowindex, forname, forrowindex, fl
793
807
 
794
808
  .ico-button {
795
809
  cursor: pointer;
796
- width: 25px;
797
- height: 25px;
798
- background-color: #DBEAFE;
810
+ width: 35px;
811
+ height: 35px;
799
812
  }
800
813
 
801
814