@myun/gimi-chat 0.0.3 → 0.0.5

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.
Files changed (206) hide show
  1. package/dist/apis/fetch.d.ts +64 -0
  2. package/dist/apis/fetch.js +512 -0
  3. package/dist/apis/useApi.d.ts +57 -0
  4. package/dist/apis/useApi.js +378 -0
  5. package/dist/assets/image/Subtract.png +0 -0
  6. package/dist/assets/image/ai-logo.png +0 -0
  7. package/dist/assets/image/copyIcon.png +0 -0
  8. package/dist/assets/image/deepthinkActive.png +0 -0
  9. package/dist/assets/image/empty-img-dark.png +0 -0
  10. package/dist/assets/image/empty-img.png +0 -0
  11. package/dist/assets/image/like_active.png +0 -0
  12. package/dist/assets/image/love.png +0 -0
  13. package/dist/assets/image/retry.png +0 -0
  14. package/dist/assets/image/soundOut.png +0 -0
  15. package/dist/assets/image/unlike_active.png +0 -0
  16. package/dist/assets/image/unlove.png +0 -0
  17. package/dist/assets/lottie/ai-bg.json +1704 -0
  18. package/dist/assets/lottie/ai-loading.json +192 -0
  19. package/dist/assets/lottie/ai-output-loading.json +272 -0
  20. package/dist/assets/lottie/ai-output-normal.json +17694 -0
  21. package/dist/assets/lottie/ai-output-strengthen.json +17321 -0
  22. package/dist/assets/lottie/ai-voice-play.json +1 -0
  23. package/dist/assets/lottie/living.json +705 -0
  24. package/dist/assets/lottie/myun-living.json +726 -0
  25. package/dist/assets/lottie/myun-loading.json +530 -0
  26. package/dist/components/ai-chat-dialogue/index.d.ts +16 -0
  27. package/dist/components/ai-chat-dialogue/index.js +1056 -0
  28. package/dist/components/ai-chat-dialogue/index.module.css +230 -0
  29. package/dist/components/ai-chat-dialogue/message-parser.d.ts +36 -0
  30. package/dist/components/ai-chat-dialogue/message-parser.js +52 -0
  31. package/dist/components/ai-chat-dialogue/tlv.d.ts +7 -0
  32. package/dist/components/ai-chat-dialogue/tlv.js +32 -0
  33. package/dist/components/ai-chat-dialogue/volc-voice-call-client.d.ts +47 -0
  34. package/dist/components/ai-chat-dialogue/volc-voice-call-client.js +246 -0
  35. package/dist/components/ai-correction/index.d.ts +5 -0
  36. package/dist/components/ai-correction/index.js +45 -0
  37. package/dist/components/ai-loading/index.d.ts +3 -0
  38. package/dist/components/ai-loading/index.js +14 -0
  39. package/dist/components/ai-loading/index.module.css +11 -0
  40. package/dist/components/answer-item/index.d.ts +27 -0
  41. package/dist/components/answer-item/index.js +194 -0
  42. package/dist/components/answer-item/index.module.css +266 -0
  43. package/dist/components/ask-card/index.d.ts +10 -0
  44. package/dist/components/ask-card/index.js +76 -0
  45. package/dist/components/ask-card/index.module.css +122 -0
  46. package/dist/components/chat-input/index.d.ts +31 -0
  47. package/dist/components/chat-input/index.js +433 -0
  48. package/dist/components/chat-input/index.module.css +42 -0
  49. package/dist/components/chat-voice/VoiceCommunication.d.ts +7 -0
  50. package/dist/components/chat-voice/VoiceCommunication.js +69 -0
  51. package/dist/components/chat-voice/VoiceRecord.d.ts +7 -0
  52. package/dist/components/chat-voice/VoiceRecord.js +34 -0
  53. package/dist/components/conversation-delete/index.d.ts +5 -0
  54. package/dist/components/conversation-delete/index.js +24 -0
  55. package/dist/components/dots-loading/index.d.ts +2 -0
  56. package/dist/components/dots-loading/index.js +11 -0
  57. package/dist/components/dots-loading/index.module.css +41 -0
  58. package/dist/components/empty/index.d.ts +9 -0
  59. package/dist/components/empty/index.js +32 -0
  60. package/dist/components/empty/index.module.css +24 -0
  61. package/dist/components/excel-components/ExcelCard.d.ts +11 -0
  62. package/dist/components/excel-components/ExcelCard.js +35 -0
  63. package/dist/components/excel-components/ExcelExcuting.d.ts +10 -0
  64. package/dist/components/excel-components/ExcelExcuting.js +263 -0
  65. package/dist/components/excel-components/ExcelFailCard.d.ts +9 -0
  66. package/dist/components/excel-components/ExcelFailCard.js +20 -0
  67. package/dist/components/excel-components/ExcelSuccessCard.d.ts +5 -0
  68. package/dist/components/excel-components/ExcelSuccessCard.js +50 -0
  69. package/dist/components/excel-components/index.module.css +212 -0
  70. package/dist/components/excel-components/styles.module.css +178 -0
  71. package/dist/components/file-card/fileCardSidebar.d.ts +8 -0
  72. package/dist/components/file-card/fileCardSidebar.js +56 -0
  73. package/dist/components/file-card/index.d.ts +15 -0
  74. package/dist/components/file-card/index.js +97 -0
  75. package/dist/components/file-card/index.module.css +139 -0
  76. package/dist/components/file-preview/index.d.ts +3 -0
  77. package/dist/components/file-preview/index.js +227 -0
  78. package/dist/components/file-preview/index.module.css +83 -0
  79. package/dist/components/file-upload/index.d.ts +16 -0
  80. package/dist/components/file-upload/index.js +238 -0
  81. package/dist/components/file-upload/uploadV1.d.ts +16 -0
  82. package/dist/components/file-upload/uploadV1.js +267 -0
  83. package/dist/components/gimi-sidebar/index.d.ts +17 -0
  84. package/dist/components/gimi-sidebar/index.js +41 -0
  85. package/dist/components/gimi-sidebar/index.module.css +118 -0
  86. package/dist/components/header/index.d.ts +5 -0
  87. package/dist/components/header/index.js +20 -0
  88. package/dist/components/header/index.module.css +19 -0
  89. package/dist/components/iconfont-com/index.d.ts +11 -0
  90. package/dist/components/iconfont-com/index.js +29 -0
  91. package/dist/components/index.d.ts +1 -0
  92. package/dist/components/index.js +1 -0
  93. package/dist/components/knowledge-trace/KnowledgeIconComponent.d.ts +7 -0
  94. package/dist/components/knowledge-trace/KnowledgeIconComponent.js +101 -0
  95. package/dist/components/knowledge-trace/classList.d.ts +6 -0
  96. package/dist/components/knowledge-trace/classList.js +72 -0
  97. package/dist/components/knowledge-trace/documentList.d.ts +6 -0
  98. package/dist/components/knowledge-trace/documentList.js +75 -0
  99. package/dist/components/knowledge-trace/index.d.ts +18 -0
  100. package/dist/components/knowledge-trace/index.js +155 -0
  101. package/dist/components/knowledge-trace/index.module.css +254 -0
  102. package/dist/components/knowledge-trace/interfaces.d.ts +166 -0
  103. package/dist/components/knowledge-trace/interfaces.js +1 -0
  104. package/dist/components/knowledge-trace/videoList.d.ts +6 -0
  105. package/dist/components/knowledge-trace/videoList.js +91 -0
  106. package/dist/components/lottie-img/index.d.ts +8 -0
  107. package/dist/components/lottie-img/index.js +99 -0
  108. package/dist/components/message-actions/CopyButton.d.ts +7 -0
  109. package/dist/components/message-actions/CopyButton.js +33 -0
  110. package/dist/components/message-actions/LikeButton.d.ts +7 -0
  111. package/dist/components/message-actions/LikeButton.js +34 -0
  112. package/dist/components/message-actions/RegenerateButton.d.ts +5 -0
  113. package/dist/components/message-actions/RegenerateButton.js +27 -0
  114. package/dist/components/message-actions/UnLikeButton.d.ts +7 -0
  115. package/dist/components/message-actions/UnLikeButton.js +34 -0
  116. package/dist/components/message-actions/VoicePlay.d.ts +10 -0
  117. package/dist/components/message-actions/VoicePlay.js +74 -0
  118. package/dist/components/message-list/index.d.ts +19 -0
  119. package/dist/components/message-list/index.js +164 -0
  120. package/dist/components/message-list/index.module.css +261 -0
  121. package/dist/components/no-microphone-root/index.d.ts +6 -0
  122. package/dist/components/no-microphone-root/index.js +36 -0
  123. package/dist/components/no-microphone-root/index.module.css +48 -0
  124. package/dist/components/preset-agent-content/index.d.ts +8 -0
  125. package/dist/components/preset-agent-content/index.js +24 -0
  126. package/dist/components/preset-agent-content/index.module.css +46 -0
  127. package/dist/components/quoted-content/index.d.ts +0 -0
  128. package/dist/components/quoted-content/index.js +171 -0
  129. package/dist/components/quoted-content/index.module.css +80 -0
  130. package/dist/components/reasoning-content/index.d.ts +6 -0
  131. package/dist/components/reasoning-content/index.js +116 -0
  132. package/dist/components/reasoning-content/index.module.css +169 -0
  133. package/dist/components/reference-content/index.d.ts +28 -0
  134. package/dist/components/reference-content/index.js +125 -0
  135. package/dist/components/reference-content/index.module.css +84 -0
  136. package/dist/components/templates/CommonChat.d.ts +5 -0
  137. package/dist/components/templates/CommonChat.js +218 -0
  138. package/dist/components/templates/GimiChatComponent.d.ts +4 -0
  139. package/dist/components/templates/GimiChatComponent.js +23 -0
  140. package/dist/components/templates/demo/demo.d.ts +2 -0
  141. package/dist/components/templates/demo/demo.js +109 -0
  142. package/dist/components/templates/index.module.css +109 -0
  143. package/dist/components/upload-list/index.d.ts +15 -0
  144. package/dist/components/upload-list/index.js +90 -0
  145. package/dist/components/upload-list/index.module.css +119 -0
  146. package/dist/components/voice-bars/index.d.ts +4 -0
  147. package/dist/components/voice-bars/index.js +174 -0
  148. package/dist/components/voice-check-dialog/index.d.ts +8 -0
  149. package/dist/components/voice-check-dialog/index.js +163 -0
  150. package/dist/components/voice-check-dialog/index.module.css +9 -0
  151. package/dist/components/voice-recording/index.d.ts +9 -0
  152. package/dist/components/voice-recording/index.js +54 -0
  153. package/dist/components/voice-recording/index.module.css +41 -0
  154. package/dist/components/work-flow-content/demo.d.ts +3 -0
  155. package/dist/components/work-flow-content/demo.js +11 -0
  156. package/dist/components/work-flow-content/index.d.ts +6 -0
  157. package/dist/components/work-flow-content/index.js +55 -0
  158. package/dist/components/work-flow-content/index.module.css +24 -0
  159. package/dist/constants.d.ts +24 -0
  160. package/dist/constants.js +24 -0
  161. package/dist/hooks/useChatActions.d.ts +12 -0
  162. package/dist/hooks/useChatActions.js +207 -0
  163. package/dist/hooks/useChatHistory.d.ts +8 -0
  164. package/dist/hooks/useChatHistory.js +225 -0
  165. package/dist/hooks/useChatMessage.d.ts +49 -0
  166. package/dist/hooks/useChatMessage.js +87 -0
  167. package/dist/hooks/useChatRecommend.d.ts +8 -0
  168. package/dist/hooks/useChatRecommend.js +126 -0
  169. package/dist/hooks/useChatStream.d.ts +20 -0
  170. package/dist/hooks/useChatStream.js +244 -0
  171. package/dist/hooks/useChatUI.d.ts +32 -0
  172. package/dist/hooks/useChatUI.js +134 -0
  173. package/dist/hooks/useChatVoice.d.ts +11 -0
  174. package/dist/hooks/useChatVoice.js +379 -0
  175. package/dist/hooks/useCommonChatAPI.d.ts +27 -0
  176. package/dist/hooks/useCommonChatAPI.js +1276 -0
  177. package/dist/hooks/useFile.d.ts +13 -0
  178. package/dist/hooks/useFile.js +288 -0
  179. package/dist/hooks/useKnowledgeService.d.ts +17 -0
  180. package/dist/hooks/useKnowledgeService.js +210 -0
  181. package/dist/hooks/useLastEventId.d.ts +8 -0
  182. package/dist/hooks/useLastEventId.js +66 -0
  183. package/dist/hooks/useLongPoll.d.ts +3 -0
  184. package/dist/hooks/useLongPoll.js +111 -0
  185. package/dist/hooks/useScroll.d.ts +4 -0
  186. package/dist/hooks/useScroll.js +172 -0
  187. package/dist/index.d.ts +1 -0
  188. package/dist/index.js +1 -0
  189. package/dist/interfaces/chatMessage.d.ts +139 -0
  190. package/dist/interfaces/fileInterface.d.ts +10 -0
  191. package/dist/interfaces/fileInterface.js +11 -0
  192. package/dist/interfaces/knowledgeTrace.d.ts +177 -0
  193. package/dist/store/hooks.d.ts +4 -0
  194. package/dist/store/hooks.js +3 -0
  195. package/dist/store/index.d.ts +7 -0
  196. package/dist/store/index.js +7 -0
  197. package/dist/store/slices/gimiMenuSlice.d.ts +95 -0
  198. package/dist/store/slices/gimiMenuSlice.js +251 -0
  199. package/dist/utils/chatInputUtil.d.ts +19 -0
  200. package/dist/utils/chatInputUtil.js +45 -0
  201. package/dist/utils/tools.d.ts +50 -0
  202. package/dist/utils/tools.js +474 -0
  203. package/dist/utils/voice-stream.d.ts +119 -0
  204. package/dist/utils/voice-stream.js +1162 -0
  205. package/package.json +5 -6
  206. package/LICENSE +0 -21
@@ -0,0 +1,69 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React from 'react';
8
+ import { Toast, Tooltip } from '@douyinfe/semi-ui';
9
+ // import useVoiceFirstUse from '@/hooks/useVoiceFirstUse';
10
+
11
+ var ICON_ADDRESS = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/12/0812c_20260112171004.png';
12
+ var VoiceCommunication = function VoiceCommunication(props) {
13
+ var _React$useState = React.useState(false),
14
+ _React$useState2 = _slicedToArray(_React$useState, 2),
15
+ showToast = _React$useState2[0],
16
+ setShowToast = _React$useState2[1];
17
+ // const { isVoiceCallFirstUse } = useVoiceFirstUse('voiceCall');
18
+ var isVoiceCallFirstUse = false;
19
+ var timerRef = React.useRef(undefined);
20
+ React.useEffect(function () {
21
+ if (isVoiceCallFirstUse) {
22
+ setShowToast(true);
23
+ if (timerRef.current) {
24
+ clearTimeout(timerRef.current);
25
+ }
26
+ timerRef.current = setTimeout(function () {
27
+ setShowToast(false);
28
+ }, 10000);
29
+ }
30
+ return function () {
31
+ if (timerRef.current) {
32
+ clearTimeout(timerRef.current);
33
+ }
34
+ };
35
+ }, [isVoiceCallFirstUse]);
36
+ var handleClick = function handleClick() {
37
+ if (props.disabled) {
38
+ Toast.warning('当前流程不支持语音通话');
39
+ return;
40
+ }
41
+ props.onClick();
42
+ };
43
+ return /*#__PURE__*/React.createElement(Tooltip, {
44
+ content: '语音通话',
45
+ visible: showToast,
46
+ onVisibleChange: function onVisibleChange(isVisible) {
47
+ return setShowToast(isVisible);
48
+ }
49
+ }, /*#__PURE__*/React.createElement("div", {
50
+ style: {
51
+ display: 'flex',
52
+ alignItems: 'center',
53
+ justifyContent: 'center',
54
+ width: '32px',
55
+ height: '32px',
56
+ cursor: props.disabled ? 'not-allowed' : 'pointer',
57
+ fontSize: '20px'
58
+ },
59
+ onClick: handleClick
60
+ }, /*#__PURE__*/React.createElement("img", {
61
+ style: {
62
+ width: '32px',
63
+ height: '32px'
64
+ },
65
+ src: ICON_ADDRESS,
66
+ alt: "\u8BED\u97F3\u901A\u8BDD"
67
+ })));
68
+ };
69
+ export default VoiceCommunication;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface IProps {
3
+ onClick: (ignoreMsg?: boolean | undefined) => Promise<void>;
4
+ disabled: boolean | undefined;
5
+ }
6
+ declare const VoiceRecord: (props: IProps) => React.JSX.Element;
7
+ export default VoiceRecord;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { Tooltip, Toast } from '@douyinfe/semi-ui';
3
+ var ICON_ADDRESS = 'https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202601/04/be8de_20260104155638.png';
4
+ var VoiceRecord = function VoiceRecord(props) {
5
+ var handleClick = function handleClick() {
6
+ if (props.disabled) {
7
+ Toast.warning('当前流程不支持语音输入');
8
+ return;
9
+ }
10
+ props.onClick();
11
+ };
12
+ return /*#__PURE__*/React.createElement(Tooltip, {
13
+ content: '语音输入'
14
+ }, /*#__PURE__*/React.createElement("div", {
15
+ style: {
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ justifyContent: 'center',
19
+ width: '32px',
20
+ height: '32px',
21
+ cursor: props.disabled ? 'not-allowed' : 'pointer',
22
+ fontSize: '20px'
23
+ },
24
+ onClick: handleClick
25
+ }, /*#__PURE__*/React.createElement("img", {
26
+ style: {
27
+ width: '32px',
28
+ height: '32px'
29
+ },
30
+ src: ICON_ADDRESS,
31
+ alt: "\u8BED\u97F3\u8F93\u5165"
32
+ })));
33
+ };
34
+ export default VoiceRecord;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare const ConversationDelete: React.FC<{
3
+ onDelete: () => void;
4
+ }>;
5
+ export default ConversationDelete;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { Popconfirm, Button } from '@douyinfe/semi-ui';
3
+ import { IconDeleteStroked } from '@douyinfe/semi-icons';
4
+ var ConversationDelete = function ConversationDelete(_ref) {
5
+ var onDelete = _ref.onDelete;
6
+ var onConfirm = function onConfirm() {
7
+ onDelete();
8
+ };
9
+ var onCancel = function onCancel() {
10
+ // 取消删除
11
+ };
12
+ return /*#__PURE__*/React.createElement(Popconfirm, {
13
+ title: "\u786E\u5B9A\u662F\u5426\u8981\u5220\u9664\u4F1A\u8BDD\uFF1F",
14
+ content: "\u6B64\u64CD\u4F5C\u5C06\u4E0D\u53EF\u9006",
15
+ onConfirm: onConfirm,
16
+ onCancel: onCancel
17
+ }, /*#__PURE__*/React.createElement(Button, {
18
+ icon: /*#__PURE__*/React.createElement(IconDeleteStroked, {
19
+ size: "large"
20
+ }),
21
+ theme: "borderless"
22
+ }));
23
+ };
24
+ export default ConversationDelete;
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export default function LoadingDots(): React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import styles from "./index.module.css";
2
+ import React from 'react';
3
+ export default function LoadingDots() {
4
+ return /*#__PURE__*/React.createElement("div", {
5
+ className: styles.loading_dots
6
+ }, /*#__PURE__*/React.createElement("div", {
7
+ className: styles.loading_dots__dot
8
+ }), /*#__PURE__*/React.createElement("div", {
9
+ className: styles.loading_dots__dot
10
+ }));
11
+ }
@@ -0,0 +1,41 @@
1
+ .loading_dots {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ gap: 8px;
6
+ }
7
+ .loading_dots .loading_dots__dot {
8
+ width: 8px;
9
+ height: 8px;
10
+ background-color: #000;
11
+ border-radius: 50%;
12
+ /* Changed animation to swap positions left-right */
13
+ animation: swap 1.2s infinite ease-in-out;
14
+ }
15
+ .loading_dots .loading_dots__dot:first-child {
16
+ /* First dot starts from left, moves to right */
17
+ animation-name: swapLeftToRight;
18
+ }
19
+ .loading_dots .loading_dots__dot:last-child {
20
+ /* Second dot starts from right, moves to left */
21
+ animation-name: swapRightToLeft;
22
+ }
23
+
24
+ /* Animation for first dot: move from left to right */
25
+ @keyframes swapLeftToRight {
26
+ 0%, 100% {
27
+ transform: translateX(0);
28
+ }
29
+ 50% {
30
+ transform: translateX(16px);
31
+ }
32
+ }
33
+ /* Animation for second dot: move from right to left */
34
+ @keyframes swapRightToLeft {
35
+ 0%, 100% {
36
+ transform: translateX(0);
37
+ }
38
+ 50% {
39
+ transform: translateX(-16px);
40
+ }
41
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ interface IProps {
3
+ title?: string;
4
+ style?: React.CSSProperties;
5
+ imgStyle?: React.CSSProperties;
6
+ dark?: boolean;
7
+ }
8
+ declare const EmptyShow: React.FC<IProps>;
9
+ export default EmptyShow;
@@ -0,0 +1,32 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
4
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
+ /*
6
+ * @Date: 2022-06-21 09:37:01
7
+ * @LastEditors: Chuying
8
+ * @LastEditTime: 2024-05-14 11:01:02
9
+ * @Description:
10
+ */
11
+ import styles from "./index.module.css";
12
+ import EmptyImg from "../../assets/image/empty-img.png";
13
+ import EmptyImgDark from "../../assets/image/empty-img-dark.png";
14
+ import classNames from 'classnames';
15
+ import React from 'react';
16
+ var EmptyShow = function EmptyShow(_ref) {
17
+ var style = _ref.style,
18
+ _ref$imgStyle = _ref.imgStyle,
19
+ imgStyle = _ref$imgStyle === void 0 ? {} : _ref$imgStyle,
20
+ title = _ref.title,
21
+ _ref$dark = _ref.dark,
22
+ dark = _ref$dark === void 0 ? false : _ref$dark;
23
+ return /*#__PURE__*/React.createElement("div", {
24
+ className: classNames(styles.emptyShow, _defineProperty({}, styles.dark, dark)),
25
+ style: style
26
+ }, /*#__PURE__*/React.createElement("img", {
27
+ src: dark ? EmptyImgDark : EmptyImg,
28
+ style: imgStyle,
29
+ alt: ""
30
+ }), /*#__PURE__*/React.createElement("p", null, title || '暂无内容'));
31
+ };
32
+ export default EmptyShow;
@@ -0,0 +1,24 @@
1
+ .emptyShow {
2
+ display: flex;
3
+ align-items: center;
4
+ flex-direction: column;
5
+ justify-content: center;
6
+ height: 100%;
7
+ }
8
+ .emptyShow img {
9
+ width: 165px;
10
+ }
11
+ .emptyShow p {
12
+ color: #7d91b3;
13
+ margin-top: 10px;
14
+ }
15
+
16
+ .dark img {
17
+ width: 119px;
18
+ height: 98px;
19
+ }
20
+ .dark p {
21
+ color: white;
22
+ margin-top: 12px;
23
+ font-size: 20px;
24
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { IChatMessageItem } from '../../interfaces/chatMessage';
3
+ interface IProps {
4
+ item: IChatMessageItem;
5
+ moduleInfo: any;
6
+ onSucess: (pollResult: any, messageId: number) => void;
7
+ onFailure: (pollResult: any, messageId: number) => void;
8
+ onRetry: (pollResult: any, messageId: number) => void;
9
+ }
10
+ declare const ExcelCard: ({ item, moduleInfo, onSucess, onFailure, onRetry }: IProps) => React.JSX.Element;
11
+ export default ExcelCard;
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import ExcelFailCard from "./ExcelFailCard";
3
+ import { ExcelExcutingSteps } from "./ExcelExcuting";
4
+ var ExcelCard = function ExcelCard(_ref) {
5
+ var item = _ref.item,
6
+ moduleInfo = _ref.moduleInfo,
7
+ onSucess = _ref.onSucess,
8
+ onFailure = _ref.onFailure,
9
+ onRetry = _ref.onRetry;
10
+ var renderContent = React.useMemo(function () {
11
+ var skillDetail = moduleInfo.data.results.skillResult;
12
+ switch (skillDetail.requestStatus) {
13
+ // 成功: 成功的情况直接从content的end节点读取信息,不再解析skillResult
14
+ case 1:
15
+ return null;
16
+ case 2:
17
+ // 失败
18
+ return /*#__PURE__*/React.createElement(ExcelFailCard, {
19
+ skillDetail: skillDetail,
20
+ item: item,
21
+ onRetry: onRetry
22
+ });
23
+ default:
24
+ // 执行中
25
+ return /*#__PURE__*/React.createElement(ExcelExcutingSteps, {
26
+ item: item,
27
+ skillDetail: skillDetail,
28
+ onSucess: onSucess,
29
+ onFailure: onFailure
30
+ });
31
+ }
32
+ }, [moduleInfo, item, onRetry, onFailure, onSucess]);
33
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderContent);
34
+ };
35
+ export default ExcelCard;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { IChatMessageItem } from "../../interfaces/chatMessage";
3
+ interface IProps {
4
+ item: IChatMessageItem;
5
+ skillDetail: any;
6
+ onSucess: (pollResult: any, messageId: number) => void;
7
+ onFailure: (pollResult: any, requestId: number) => void;
8
+ }
9
+ export declare const ExcelExcutingSteps: ({ item, skillDetail, onSucess, onFailure }: IProps) => React.JSX.Element;
10
+ export {};
@@ -0,0 +1,263 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
+ import React from "react";
18
+ import { IconTickCircle } from "@douyinfe/semi-icons";
19
+ import styles from "./styles.module.css";
20
+ import LoadingIcon from "../../assets/image/Subtract.png";
21
+ import classNames from "classnames";
22
+ import { useExcelExcuteLongPoll } from "../../hooks/useLongPoll";
23
+ import LoadingDots from "../../components/dots-loading";
24
+ var MOCK_STEPS = [{
25
+ id: 1,
26
+ text: "启动核心分析模块"
27
+ }, {
28
+ id: 2,
29
+ text: "解析关键要素"
30
+ }, {
31
+ id: 3,
32
+ text: "构建多场景解法"
33
+ }, {
34
+ id: 4,
35
+ text: "评估执行策略"
36
+ }, {
37
+ id: 5,
38
+ text: "确定最优路径"
39
+ }, {
40
+ id: 6,
41
+ text: "输出结果载体生成中"
42
+ }];
43
+ export var ExcelExcutingSteps = function ExcelExcutingSteps(_ref) {
44
+ var item = _ref.item,
45
+ skillDetail = _ref.skillDetail,
46
+ onSucess = _ref.onSucess,
47
+ onFailure = _ref.onFailure;
48
+ var requestId = skillDetail.requestId;
49
+ var _React$useState = React.useState([]),
50
+ _React$useState2 = _slicedToArray(_React$useState, 2),
51
+ renderSteps = _React$useState2[0],
52
+ setRenderSteps = _React$useState2[1];
53
+ var setpRef = React.useRef(0);
54
+ var _React$useState3 = React.useState(true),
55
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
56
+ isExpanded = _React$useState4[0],
57
+ setIsExpanded = _React$useState4[1];
58
+ var _React$useState5 = React.useState(""),
59
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
60
+ displayText = _React$useState6[0],
61
+ setDisplayText = _React$useState6[1];
62
+ var _React$useState7 = React.useState(false),
63
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
64
+ isTyping = _React$useState8[0],
65
+ setIsTyping = _React$useState8[1];
66
+ var _React$useState9 = React.useState(""),
67
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
68
+ selectedText = _React$useState10[0],
69
+ setSelectedText = _React$useState10[1];
70
+ var _React$useState11 = React.useState(styles.expanded),
71
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
72
+ contentClass = _React$useState12[0],
73
+ setContentClass = _React$useState12[1];
74
+ var timerRef = React.useRef(undefined);
75
+ var onReady = renderSteps.every(function (item) {
76
+ return item.isCompleted;
77
+ });
78
+ var _ref2 = useExcelExcuteLongPoll(skillDetail.requestStatus, 60000 * 40, requestId),
79
+ pollResult = _ref2.pollResult;
80
+ var isSuccess = (pollResult === null || pollResult === void 0 ? void 0 : pollResult.status) === 0 && (pollResult === null || pollResult === void 0 ? void 0 : pollResult.result.requestStatus) === 1;
81
+
82
+ // 计算时间差(秒)
83
+ var startedTime = item.createdTime ? Math.floor(Date.now() / 1000) - item.createdTime : undefined;
84
+
85
+ // 初始化:挂载时加入步骤并开始打字
86
+ React.useEffect(function () {
87
+ if (MOCK_STEPS.length > 0) {
88
+ var _MOCK_STEPS$startStep;
89
+ var startStep = 0;
90
+ if (startedTime) {
91
+ // 最多到步骤5
92
+ startStep = Math.min(Math.floor(startedTime / 15), 4);
93
+ setpRef.current = startStep + 1;
94
+ }
95
+ if (startStep === 0) {
96
+ setRenderSteps([_objectSpread(_objectSpread({}, MOCK_STEPS[0]), {}, {
97
+ isCompleted: false
98
+ })]);
99
+ } else {
100
+ setRenderSteps(function () {
101
+ var newList = [];
102
+ for (var i = 0; i <= startStep; i++) {
103
+ newList.push(_objectSpread(_objectSpread({}, MOCK_STEPS[i]), {}, {
104
+ isCompleted: i < startStep ? true : false
105
+ }));
106
+ }
107
+ return newList;
108
+ });
109
+ }
110
+ setSelectedText((_MOCK_STEPS$startStep = MOCK_STEPS[startStep]) === null || _MOCK_STEPS$startStep === void 0 ? void 0 : _MOCK_STEPS$startStep.text);
111
+ setDisplayText("");
112
+ setIsTyping(true);
113
+ }
114
+ // 仅在挂载时运行
115
+ }, []);
116
+
117
+ // 打字效果
118
+ React.useEffect(function () {
119
+ if (!isTyping || !selectedText) return;
120
+ var currentIndex = 0;
121
+ var typingInterval = setInterval(function () {
122
+ if (currentIndex <= selectedText.length) {
123
+ setDisplayText(selectedText.slice(0, currentIndex));
124
+ currentIndex++;
125
+ } else {
126
+ clearInterval(typingInterval);
127
+ setIsTyping(false);
128
+ }
129
+ }, 40);
130
+ return function () {
131
+ return clearInterval(typingInterval);
132
+ };
133
+ }, [selectedText, isTyping]);
134
+
135
+ // 打字完成后,等待 3s 推进到下一个步骤并将当前标记为完成
136
+ React.useEffect(function () {
137
+ if (!isTyping && selectedText && displayText === selectedText) {
138
+ // 使用 ref 保存定时器,避免多个定时器并行
139
+ // 并在追加步骤前做去重检查,防止重复追加相同 id 的步骤
140
+ var delayTime = isSuccess ? 1000 : 15000;
141
+ if (!isSuccess && pollResult) {
142
+ clearTimeout(timerRef.current);
143
+ onFailure(pollResult, item.id);
144
+ return;
145
+ }
146
+ timerRef.current = setTimeout(function () {
147
+ if (timerRef.current) {
148
+ clearTimeout(timerRef.current);
149
+ }
150
+ // 如果到了第四步,但轮询结果还未返回,UI卡在第四步
151
+ // 或者网络断开,也不继续暂停执行后续打字步骤
152
+ if (setpRef.current === 5 && !pollResult || !navigator.onLine) {
153
+ return;
154
+ }
155
+ setRenderSteps(function (prevList) {
156
+ var lastIndex = prevList.length;
157
+ if (prevList.length < MOCK_STEPS.length) {
158
+ if (prevList.length === 0) return [_objectSpread(_objectSpread({}, MOCK_STEPS[lastIndex]), {}, {
159
+ isCompleted: false
160
+ })];
161
+ // 如果下一项已经存在(可能由竞态或重复 effect 导致),则不重复追加
162
+ if (prevList.some(function (s) {
163
+ return s.id === MOCK_STEPS[lastIndex].id;
164
+ })) {
165
+ return prevList.map(function (s, idx) {
166
+ return idx === prevList.length - 1 ? _objectSpread(_objectSpread({}, s), {}, {
167
+ isCompleted: true
168
+ }) : s;
169
+ });
170
+ }
171
+ var updated = prevList.map(function (s, idx) {
172
+ return idx === prevList.length - 1 ? _objectSpread(_objectSpread({}, s), {}, {
173
+ isCompleted: true
174
+ }) : s;
175
+ });
176
+ setpRef.current = lastIndex + 1;
177
+ if (lastIndex < MOCK_STEPS.length) {
178
+ // 启动下一个打字
179
+ setSelectedText(MOCK_STEPS[lastIndex].text);
180
+ setDisplayText("");
181
+ setIsTyping(true);
182
+ }
183
+ return [].concat(_toConsumableArray(updated), [_objectSpread(_objectSpread({}, MOCK_STEPS[lastIndex]), {}, {
184
+ isCompleted: false
185
+ })]);
186
+ } else {
187
+ setTimeout(function () {
188
+ // 1s后收起步骤
189
+ setContentClass(styles.collapsing);
190
+ setTimeout(function () {
191
+ setIsExpanded(false);
192
+ setContentClass(styles.expanded);
193
+ }, 500);
194
+ setTimeout(function () {
195
+ // 1.5s后替换为excel卡片
196
+ onSucess(pollResult.result, item.id);
197
+ }, 1500);
198
+ }, 1000);
199
+ // 所有步骤完成
200
+ return prevList.map(function (s) {
201
+ return _objectSpread(_objectSpread({}, s), {}, {
202
+ isCompleted: true
203
+ });
204
+ });
205
+ }
206
+ });
207
+ }, delayTime);
208
+ return function () {
209
+ return clearTimeout(timerRef.current);
210
+ };
211
+ }
212
+ }, [isTyping, selectedText, displayText, isSuccess, item.id, pollResult]);
213
+
214
+ // 处理内容切换时的过渡效果
215
+ React.useEffect(function () {
216
+ if (isExpanded) {
217
+ setContentClass(styles.expanded);
218
+ }
219
+ }, [isExpanded]);
220
+ return /*#__PURE__*/React.createElement("div", {
221
+ className: styles.container
222
+ }, /*#__PURE__*/React.createElement("div", {
223
+ className: styles.aiLoadingSteps
224
+ }, isExpanded ? /*#__PURE__*/React.createElement("div", {
225
+ className: classNames(styles.contentWrapper, contentClass)
226
+ }, /*#__PURE__*/React.createElement("div", {
227
+ className: styles.header
228
+ }, !onReady && /*#__PURE__*/React.createElement("h3", {
229
+ className: styles.title
230
+ }, /*#__PURE__*/React.createElement(LoadingDots, null), '正在分析与生成模版...'), /*#__PURE__*/React.createElement("p", {
231
+ className: styles.description
232
+ }, '正在启动任务处理流程, 结合上下文信息, 系统已进入深度分析阶段, 请稍候5~10分钟。')), /*#__PURE__*/React.createElement("div", {
233
+ className: styles.stepsContainer
234
+ }, renderSteps.map(function (step) {
235
+ return /*#__PURE__*/React.createElement("div", {
236
+ key: step.id,
237
+ className: classNames(step.isCompleted ? "".concat(styles.stepItem, " ").concat(styles.completed) : "".concat(styles.stepActiveItem, " ").concat(styles.active))
238
+ }, /*#__PURE__*/React.createElement("div", {
239
+ className: styles.stepIndicator
240
+ }, step.isCompleted ? /*#__PURE__*/React.createElement(IconTickCircle, {
241
+ className: styles.checkIcon
242
+ }) : /*#__PURE__*/React.createElement("img", {
243
+ src: LoadingIcon,
244
+ className: styles.pendingIcon
245
+ }), step.id !== 6 && /*#__PURE__*/React.createElement("div", {
246
+ className: styles.verticalLine
247
+ })), /*#__PURE__*/React.createElement("div", {
248
+ className: styles.stepContent
249
+ }, !step.isCompleted ? /*#__PURE__*/React.createElement("span", {
250
+ className: styles.stepText
251
+ }, displayText, isTyping && /*#__PURE__*/React.createElement("span", {
252
+ className: styles.cursor
253
+ }, "|")) : /*#__PURE__*/React.createElement("span", {
254
+ className: styles.stepText
255
+ }, step.text)));
256
+ })), onReady && /*#__PURE__*/React.createElement("span", {
257
+ className: styles.finishText
258
+ }, "\u5206\u6790\u5B8C\u6210\uFF0C\u7ED3\u679C\u8F7D\u4F53\u5373\u5C06\u751F\u6210\uFF0C\u6B63\u51C6\u5907\u5448\u73B0...")) : /*#__PURE__*/React.createElement("div", {
259
+ className: classNames(styles.contentWrapper)
260
+ }, /*#__PURE__*/React.createElement("h3", {
261
+ className: styles.title
262
+ }, "\u5206\u6790\u5B8C\u6210\uFF0C\u7ED3\u679C\u8F7D\u4F53\u5373\u5C06\u751F\u6210\uFF0C\u6B63\u5728\u51C6\u5907\u5448\u73B0"))));
263
+ };
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { IChatMessageItem } from '../../interfaces/chatMessage';
3
+ interface IndexProps {
4
+ skillDetail?: any;
5
+ onRetry: any;
6
+ item?: IChatMessageItem;
7
+ }
8
+ declare const ExcelFailCard: React.FC<IndexProps>;
9
+ export default ExcelFailCard;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import styles from "./index.module.css";
3
+ import classNames from 'classnames';
4
+ var ExcelFailCard = function ExcelFailCard(_ref) {
5
+ var item = _ref.item,
6
+ skillDetail = _ref.skillDetail,
7
+ onRetry = _ref.onRetry;
8
+ var message = skillDetail.message;
9
+ return /*#__PURE__*/React.createElement("div", {
10
+ className: styles.excelFail
11
+ }, /*#__PURE__*/React.createElement("div", {
12
+ className: styles.failText
13
+ }, " ", message), /*#__PURE__*/React.createElement("div", {
14
+ className: classNames(styles.Retry, item !== null && item !== void 0 && item.reTryed ? styles.disablebox : ''),
15
+ onClick: function onClick() {
16
+ return onRetry(skillDetail, item === null || item === void 0 ? void 0 : item.id);
17
+ }
18
+ }, "\u91CD\u8BD5"));
19
+ };
20
+ export default ExcelFailCard;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ declare const ExcelSuccessCard: ({ value }: {
3
+ value: any;
4
+ }) => React.JSX.Element | null;
5
+ export default ExcelSuccessCard;