@myun/gimi-chat 0.0.2 → 0.0.4
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/dist/apis/fetch.d.ts +64 -0
- package/dist/apis/fetch.js +512 -0
- package/dist/apis/useApi.d.ts +57 -0
- package/dist/apis/useApi.js +378 -0
- package/dist/assets/image/Subtract.png +0 -0
- package/dist/assets/image/ai-logo.png +0 -0
- package/dist/assets/image/copyIcon.png +0 -0
- package/dist/assets/image/deepthinkActive.png +0 -0
- package/dist/assets/image/empty-img-dark.png +0 -0
- package/dist/assets/image/empty-img.png +0 -0
- package/dist/assets/image/like_active.png +0 -0
- package/dist/assets/image/love.png +0 -0
- package/dist/assets/image/retry.png +0 -0
- package/dist/assets/image/soundOut.png +0 -0
- package/dist/assets/image/unlike_active.png +0 -0
- package/dist/assets/image/unlove.png +0 -0
- package/dist/assets/lottie/ai-bg.json +1704 -0
- package/dist/assets/lottie/ai-loading.json +192 -0
- package/dist/assets/lottie/ai-output-loading.json +272 -0
- package/dist/assets/lottie/ai-output-normal.json +17694 -0
- package/dist/assets/lottie/ai-output-strengthen.json +17321 -0
- package/dist/assets/lottie/ai-voice-play.json +1 -0
- package/dist/assets/lottie/living.json +705 -0
- package/dist/assets/lottie/myun-living.json +726 -0
- package/dist/assets/lottie/myun-loading.json +530 -0
- package/dist/components/ai-chat-dialogue/index.d.ts +16 -0
- package/dist/components/ai-chat-dialogue/index.js +1056 -0
- package/dist/components/ai-chat-dialogue/index.module.scss +272 -0
- package/dist/components/ai-chat-dialogue/message-parser.d.ts +36 -0
- package/dist/components/ai-chat-dialogue/message-parser.js +52 -0
- package/dist/components/ai-chat-dialogue/tlv.d.ts +7 -0
- package/dist/components/ai-chat-dialogue/tlv.js +32 -0
- package/dist/components/ai-chat-dialogue/volc-voice-call-client.d.ts +47 -0
- package/dist/components/ai-chat-dialogue/volc-voice-call-client.js +246 -0
- package/dist/components/ai-correction/index.d.ts +5 -0
- package/dist/components/ai-correction/index.js +45 -0
- package/dist/components/ai-loading/index.d.ts +3 -0
- package/dist/components/ai-loading/index.js +14 -0
- package/dist/components/ai-loading/index.module.scss +11 -0
- package/dist/components/answer-item/index.d.ts +27 -0
- package/dist/components/answer-item/index.js +194 -0
- package/dist/components/answer-item/index.module.scss +295 -0
- package/dist/components/ask-card/index.d.ts +10 -0
- package/dist/components/ask-card/index.js +76 -0
- package/dist/components/ask-card/index.module.scss +125 -0
- package/dist/components/chat-input/index.d.ts +31 -0
- package/dist/components/chat-input/index.js +433 -0
- package/dist/components/chat-input/index.module.scss +44 -0
- package/dist/components/chat-voice/VoiceCommunication.d.ts +7 -0
- package/dist/components/chat-voice/VoiceCommunication.js +69 -0
- package/dist/components/chat-voice/VoiceRecord.d.ts +7 -0
- package/dist/components/chat-voice/VoiceRecord.js +34 -0
- package/dist/components/conversation-delete/index.d.ts +5 -0
- package/dist/components/conversation-delete/index.js +24 -0
- package/dist/components/dots-loading/index.d.ts +2 -0
- package/dist/components/dots-loading/index.js +11 -0
- package/dist/components/dots-loading/index.module.scss +45 -0
- package/dist/components/empty/index.d.ts +9 -0
- package/dist/components/empty/index.js +32 -0
- package/dist/components/empty/index.module.scss +27 -0
- package/dist/components/excel-components/ExcelCard.d.ts +11 -0
- package/dist/components/excel-components/ExcelCard.js +35 -0
- package/dist/components/excel-components/ExcelExcuting.d.ts +10 -0
- package/dist/components/excel-components/ExcelExcuting.js +263 -0
- package/dist/components/excel-components/ExcelFailCard.d.ts +9 -0
- package/dist/components/excel-components/ExcelFailCard.js +20 -0
- package/dist/components/excel-components/ExcelSuccessCard.d.ts +5 -0
- package/dist/components/excel-components/ExcelSuccessCard.js +50 -0
- package/dist/components/excel-components/index.module.scss +210 -0
- package/dist/components/excel-components/styles.module.scss +186 -0
- package/dist/components/file-card/fileCardSidebar.d.ts +8 -0
- package/dist/components/file-card/fileCardSidebar.js +56 -0
- package/dist/components/file-card/index.d.ts +15 -0
- package/dist/components/file-card/index.js +97 -0
- package/dist/components/file-card/index.module.scss +139 -0
- package/dist/components/file-preview/index.d.ts +3 -0
- package/dist/components/file-preview/index.js +229 -0
- package/dist/components/file-preview/index.module.scss +120 -0
- package/dist/components/file-upload/index.d.ts +16 -0
- package/dist/components/file-upload/index.js +238 -0
- package/dist/components/file-upload/uploadV1.d.ts +16 -0
- package/dist/components/file-upload/uploadV1.js +267 -0
- package/dist/components/gimi-sidebar/index.d.ts +17 -0
- package/dist/components/gimi-sidebar/index.js +41 -0
- package/dist/components/gimi-sidebar/index.module.scss +136 -0
- package/dist/components/header/index.d.ts +5 -0
- package/dist/components/header/index.js +20 -0
- package/dist/components/header/index.module.scss +26 -0
- package/dist/components/iconfont-com/index.d.ts +11 -0
- package/dist/components/iconfont-com/index.js +29 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/knowledge-trace/KnowledgeIconComponent.d.ts +7 -0
- package/dist/components/knowledge-trace/KnowledgeIconComponent.js +101 -0
- package/dist/components/knowledge-trace/classList.d.ts +6 -0
- package/dist/components/knowledge-trace/classList.js +72 -0
- package/dist/components/knowledge-trace/documentList.d.ts +6 -0
- package/dist/components/knowledge-trace/documentList.js +75 -0
- package/dist/components/knowledge-trace/index.d.ts +18 -0
- package/dist/components/knowledge-trace/index.js +155 -0
- package/dist/components/knowledge-trace/index.module.scss +262 -0
- package/dist/components/knowledge-trace/interfaces.d.ts +166 -0
- package/dist/components/knowledge-trace/interfaces.js +1 -0
- package/dist/components/knowledge-trace/videoList.d.ts +6 -0
- package/dist/components/knowledge-trace/videoList.js +91 -0
- package/dist/components/lottie-img/index.d.ts +8 -0
- package/dist/components/lottie-img/index.js +99 -0
- package/dist/components/message-actions/CopyButton.d.ts +7 -0
- package/dist/components/message-actions/CopyButton.js +33 -0
- package/dist/components/message-actions/LikeButton.d.ts +7 -0
- package/dist/components/message-actions/LikeButton.js +34 -0
- package/dist/components/message-actions/RegenerateButton.d.ts +5 -0
- package/dist/components/message-actions/RegenerateButton.js +27 -0
- package/dist/components/message-actions/UnLikeButton.d.ts +7 -0
- package/dist/components/message-actions/UnLikeButton.js +34 -0
- package/dist/components/message-actions/VoicePlay.d.ts +10 -0
- package/dist/components/message-actions/VoicePlay.js +74 -0
- package/dist/components/message-list/index.d.ts +19 -0
- package/dist/components/message-list/index.js +167 -0
- package/dist/components/message-list/index.module.scss +304 -0
- package/dist/components/no-microphone-root/index.d.ts +6 -0
- package/dist/components/no-microphone-root/index.js +36 -0
- package/dist/components/no-microphone-root/index.module.scss +42 -0
- package/dist/components/preset-agent-content/index.d.ts +8 -0
- package/dist/components/preset-agent-content/index.js +24 -0
- package/dist/components/preset-agent-content/index.module.scss +48 -0
- package/dist/components/quoted-content/index.d.ts +0 -0
- package/dist/components/quoted-content/index.js +171 -0
- package/dist/components/quoted-content/index.module.scss +76 -0
- package/dist/components/reasoning-content/index.d.ts +6 -0
- package/dist/components/reasoning-content/index.js +116 -0
- package/dist/components/reasoning-content/index.module.scss +164 -0
- package/dist/components/reference-content/index.d.ts +28 -0
- package/dist/components/reference-content/index.js +125 -0
- package/dist/components/reference-content/index.module.scss +73 -0
- package/dist/components/templates/CommonChat.d.ts +5 -0
- package/dist/components/templates/CommonChat.js +218 -0
- package/dist/components/templates/GimiChatComponent.d.ts +4 -0
- package/dist/components/templates/GimiChatComponent.js +23 -0
- package/dist/components/templates/demo/demo.d.ts +2 -0
- package/dist/components/templates/demo/demo.js +110 -0
- package/dist/components/templates/index.module.scss +119 -0
- package/dist/components/upload-list/index.d.ts +15 -0
- package/dist/components/upload-list/index.js +90 -0
- package/dist/components/upload-list/index.module.scss +119 -0
- package/dist/components/voice-bars/index.d.ts +4 -0
- package/dist/components/voice-bars/index.js +174 -0
- package/dist/components/voice-check-dialog/index.d.ts +8 -0
- package/dist/components/voice-check-dialog/index.js +163 -0
- package/dist/components/voice-check-dialog/index.module.scss +9 -0
- package/dist/components/voice-recording/index.d.ts +9 -0
- package/dist/components/voice-recording/index.js +54 -0
- package/dist/components/voice-recording/index.module.scss +41 -0
- package/dist/components/work-flow-content/demo.d.ts +3 -0
- package/dist/components/work-flow-content/demo.js +11 -0
- package/dist/components/work-flow-content/index.d.ts +6 -0
- package/dist/components/work-flow-content/index.js +55 -0
- package/dist/components/work-flow-content/index.module.scss +23 -0
- package/dist/constants.d.ts +24 -0
- package/dist/constants.js +24 -0
- package/dist/hooks/useChatActions.d.ts +12 -0
- package/dist/hooks/useChatActions.js +207 -0
- package/dist/hooks/useChatHistory.d.ts +8 -0
- package/dist/hooks/useChatHistory.js +225 -0
- package/dist/hooks/useChatMessage.d.ts +49 -0
- package/dist/hooks/useChatMessage.js +87 -0
- package/dist/hooks/useChatRecommend.d.ts +8 -0
- package/dist/hooks/useChatRecommend.js +126 -0
- package/dist/hooks/useChatStream.d.ts +20 -0
- package/dist/hooks/useChatStream.js +244 -0
- package/dist/hooks/useChatUI.d.ts +32 -0
- package/dist/hooks/useChatUI.js +134 -0
- package/dist/hooks/useChatVoice.d.ts +11 -0
- package/dist/hooks/useChatVoice.js +379 -0
- package/dist/hooks/useCommonChatAPI.d.ts +27 -0
- package/dist/hooks/useCommonChatAPI.js +1276 -0
- package/dist/hooks/useFile.d.ts +13 -0
- package/dist/hooks/useFile.js +288 -0
- package/dist/hooks/useKnowledgeService.d.ts +17 -0
- package/dist/hooks/useKnowledgeService.js +210 -0
- package/dist/hooks/useLastEventId.d.ts +8 -0
- package/dist/hooks/useLastEventId.js +66 -0
- package/dist/hooks/useLongPoll.d.ts +3 -0
- package/dist/hooks/useLongPoll.js +111 -0
- package/dist/hooks/useScroll.d.ts +4 -0
- package/dist/hooks/useScroll.js +172 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/chatMessage.d.ts +139 -0
- package/dist/interfaces/fileInterface.d.ts +10 -0
- package/dist/interfaces/fileInterface.js +11 -0
- package/dist/interfaces/knowledgeTrace.d.ts +177 -0
- package/dist/store/hooks.d.ts +4 -0
- package/dist/store/hooks.js +3 -0
- package/dist/store/index.d.ts +7 -0
- package/dist/store/index.js +7 -0
- package/dist/store/slices/gimiMenuSlice.d.ts +95 -0
- package/dist/store/slices/gimiMenuSlice.js +251 -0
- package/dist/utils/chatInputUtil.d.ts +19 -0
- package/dist/utils/chatInputUtil.js +45 -0
- package/dist/utils/tools.d.ts +50 -0
- package/dist/utils/tools.js +474 -0
- package/dist/utils/voice-stream.d.ts +119 -0
- package/dist/utils/voice-stream.js +1162 -0
- package/package.json +2 -3
- package/LICENSE +0 -21
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.loading_dots {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
gap: 8px;
|
|
6
|
+
|
|
7
|
+
.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
|
+
&:first-child {
|
|
15
|
+
/* First dot starts from left, moves to right */
|
|
16
|
+
animation-name: swapLeftToRight;
|
|
17
|
+
}
|
|
18
|
+
&:last-child {
|
|
19
|
+
/* Second dot starts from right, moves to left */
|
|
20
|
+
animation-name: swapRightToLeft;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Animation for first dot: move from left to right */
|
|
26
|
+
@keyframes swapLeftToRight {
|
|
27
|
+
0%,
|
|
28
|
+
100% {
|
|
29
|
+
transform: translateX(0);
|
|
30
|
+
}
|
|
31
|
+
50% {
|
|
32
|
+
transform: translateX(16px);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Animation for second dot: move from right to left */
|
|
37
|
+
@keyframes swapRightToLeft {
|
|
38
|
+
0%,
|
|
39
|
+
100% {
|
|
40
|
+
transform: translateX(0);
|
|
41
|
+
}
|
|
42
|
+
50% {
|
|
43
|
+
transform: translateX(-16px);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -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.scss";
|
|
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,27 @@
|
|
|
1
|
+
.emptyShow {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
height: 100%;
|
|
7
|
+
// margin-top: 60px;
|
|
8
|
+
img {
|
|
9
|
+
width: 165px;
|
|
10
|
+
// height: 110px;
|
|
11
|
+
}
|
|
12
|
+
p {
|
|
13
|
+
color: #7d91b3;
|
|
14
|
+
margin-top: 10px;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
.dark {
|
|
18
|
+
img {
|
|
19
|
+
width: 119px;
|
|
20
|
+
height: 98px;
|
|
21
|
+
}
|
|
22
|
+
p {
|
|
23
|
+
color: white;
|
|
24
|
+
margin-top: 12px;
|
|
25
|
+
font-size: 20px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -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.scss";
|
|
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.scss";
|
|
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,50 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FileCard, MultipleFileCard } from "../file-card";
|
|
3
|
+
var transforata = function transforata(data) {
|
|
4
|
+
var fileName = data.file_name || '文件下载.xlsx';
|
|
5
|
+
var size = data.size || '0.0KB';
|
|
6
|
+
var downloadUrl = data.result_url || '';
|
|
7
|
+
var tempArr = fileName.split('.');
|
|
8
|
+
var fileType = (tempArr === null || tempArr === void 0 ? void 0 : tempArr.length) > 1 ? tempArr.pop() : 'xlsx';
|
|
9
|
+
return {
|
|
10
|
+
fileName: fileName,
|
|
11
|
+
fileType: fileType,
|
|
12
|
+
size: size,
|
|
13
|
+
downloadUrl: downloadUrl
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
var ExcelSuccessCard = function ExcelSuccessCard(_ref) {
|
|
17
|
+
var value = _ref.value;
|
|
18
|
+
var skillDetail = [];
|
|
19
|
+
try {
|
|
20
|
+
skillDetail = typeof value === 'string' ? JSON.parse(value) : value;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
// console.error(error);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 新天工数据格式
|
|
27
|
+
if (Array.isArray(skillDetail)) {
|
|
28
|
+
var renderData = skillDetail.map(function (item) {
|
|
29
|
+
return transforata(item);
|
|
30
|
+
});
|
|
31
|
+
return /*#__PURE__*/React.createElement(MultipleFileCard, {
|
|
32
|
+
list: renderData
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 老天工数据格式
|
|
37
|
+
var _transforata = transforata(skillDetail),
|
|
38
|
+
fileName = _transforata.fileName,
|
|
39
|
+
downloadUrl = _transforata.downloadUrl,
|
|
40
|
+
size = _transforata.size,
|
|
41
|
+
fileType = _transforata.fileType;
|
|
42
|
+
return /*#__PURE__*/React.createElement(FileCard, {
|
|
43
|
+
fileName: fileName,
|
|
44
|
+
fileType: fileType,
|
|
45
|
+
size: size,
|
|
46
|
+
downloadUrl: downloadUrl,
|
|
47
|
+
downloadText: "\u4E0B\u8F7D"
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
export default ExcelSuccessCard;
|