@fe-free/ai 4.1.22 → 4.1.23

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @fe-free/ai
2
2
 
3
+ ## 4.1.23
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: ai
8
+ - @fe-free/core@4.1.23
9
+ - @fe-free/icons@4.1.23
10
+ - @fe-free/tool@4.1.23
11
+
3
12
  ## 4.1.22
4
13
 
5
14
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/ai",
3
- "version": "4.1.22",
3
+ "version": "4.1.23",
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"
22
+ "@fe-free/core": "4.1.23"
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.22",
33
- "@fe-free/tool": "4.1.22"
32
+ "@fe-free/icons": "4.1.23",
33
+ "@fe-free/tool": "4.1.23"
34
34
  },
35
35
  "scripts": {
36
36
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -1,6 +1,7 @@
1
1
  import { Think } from '@ant-design/x';
2
2
  import Icons from '@fe-free/icons';
3
3
  import classNames from 'classnames';
4
+ import { useCallback, useEffect, useState } from 'react';
4
5
  import ThinkIcon from '../svgs/think.svg?react';
5
6
 
6
7
  interface MessageThinkProps {
@@ -18,10 +19,28 @@ function MessageThink({
18
19
  icon,
19
20
  loading,
20
21
  children,
21
- expanded,
22
+ expanded: propsExpanded,
22
23
  onClick,
23
24
  className,
24
25
  }: MessageThinkProps) {
26
+ const [expanded, setExpanded] = useState(propsExpanded || false);
27
+
28
+ useEffect(() => {
29
+ setExpanded(propsExpanded || false);
30
+ }, [propsExpanded]);
31
+
32
+ useEffect(() => {
33
+ // 如果 propsExpanded 未定义,则根据 loading 状态设置 expanded
34
+ if (propsExpanded === undefined && loading !== undefined) {
35
+ setExpanded(loading ? true : false);
36
+ }
37
+ }, [propsExpanded, loading]);
38
+
39
+ const handleClick = useCallback(() => {
40
+ setExpanded(!expanded);
41
+ onClick?.();
42
+ }, [expanded, onClick]);
43
+
25
44
  return (
26
45
  <Think
27
46
  title={title}
@@ -29,7 +48,7 @@ function MessageThink({
29
48
  loading={loading}
30
49
  blink={loading}
31
50
  expanded={expanded}
32
- onClick={onClick}
51
+ onClick={handleClick}
33
52
  className={classNames('fea-message-think', className)}
34
53
  >
35
54
  {children}