@fe-free/ai 4.1.17 → 4.1.18
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/CHANGELOG.md +9 -0
- package/package.json +4 -4
- package/src/messages/messages.tsx +21 -15
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/ai",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"lodash-es": "^4.17.21",
|
|
20
20
|
"uuid": "^13.0.0",
|
|
21
21
|
"zustand": "^4.5.7",
|
|
22
|
-
"@fe-free/core": "4.1.
|
|
22
|
+
"@fe-free/core": "4.1.18"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"antd": "^5.27.1",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"i18next-icu": "^2.4.1",
|
|
30
30
|
"react": "^19.2.0",
|
|
31
31
|
"react-i18next": "^16.4.0",
|
|
32
|
-
"@fe-free/icons": "4.1.
|
|
33
|
-
"@fe-free/tool": "4.1.
|
|
32
|
+
"@fe-free/icons": "4.1.18",
|
|
33
|
+
"@fe-free/tool": "4.1.18"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -38,10 +38,13 @@ function Messages<AIData>(props: MessagesProps<AIData>) {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
element.
|
|
44
|
-
|
|
41
|
+
// 延迟下,因为 markdown 可能没渲染出来
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
const element = document.querySelector(`[data-uuid="${lastMessage.uuid}"]`);
|
|
44
|
+
if (element) {
|
|
45
|
+
element.scrollIntoView({ behavior: 'smooth' });
|
|
46
|
+
}
|
|
47
|
+
}, 100);
|
|
45
48
|
}, [lastMessage?.uuid]);
|
|
46
49
|
|
|
47
50
|
// 数据更新是,如果 dom 处于可视区域,则滚动
|
|
@@ -50,19 +53,22 @@ function Messages<AIData>(props: MessagesProps<AIData>) {
|
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
// 延迟下,因为 markdown 可能没渲染出来
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
const element = document.querySelector(`[data-uuid="${lastMessage.uuid}"]`);
|
|
59
|
+
if (!element) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
57
62
|
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
const { top: listTop, bottom: listBottom } = ref.current!.getBoundingClientRect();
|
|
64
|
+
const { top, bottom } = element.getBoundingClientRect();
|
|
60
65
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
// 如果最后一个元素可见,则滚动到底部
|
|
67
|
+
const isVisible = top < listBottom && bottom > listTop;
|
|
68
|
+
if (isVisible) {
|
|
69
|
+
element.scrollIntoView({ behavior: 'smooth' });
|
|
70
|
+
}
|
|
71
|
+
}, 100);
|
|
66
72
|
}, [lastMessage?.updatedAt, lastMessage?.uuid, ref]);
|
|
67
73
|
|
|
68
74
|
return (
|