@myun/gimi-chat 0.7.7 → 0.7.9

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.
@@ -3,7 +3,7 @@ import { Tooltip } from '@douyinfe/semi-ui';
3
3
  import styles from "./index.module.css";
4
4
  import { downloadExcelByUrl } from "../../utils/tools";
5
5
  import { useAppDispatch } from "../../store/hooks";
6
- import { setFilePreviewState, setShowSidebarFileList, setSidebarFileList } from "../../store/slices/gimiMenuSlice";
6
+ import { setFilePreviewState, openSidebar } from "../../store/slices/gimiMenuSlice";
7
7
  import classNames from 'classnames';
8
8
  import { IconChevronRightStroked } from '@douyinfe/semi-icons';
9
9
  export var FileCard = function FileCard(_ref) {
@@ -78,11 +78,13 @@ export var MultipleFileCard = function MultipleFileCard(_ref2) {
78
78
  } else {
79
79
  renderList = list;
80
80
  }
81
- var openSidebar = function openSidebar() {
82
- dispatch(setShowSidebarFileList({
83
- showSidebarFileList: true
81
+ var openSidebarHandler = function openSidebarHandler() {
82
+ dispatch(openSidebar({
83
+ type: 'fileList',
84
+ data: {
85
+ fileList: list
86
+ }
84
87
  }));
85
- dispatch(setSidebarFileList(list));
86
88
  };
87
89
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
88
90
  className: styles.main
@@ -99,7 +101,7 @@ export var MultipleFileCard = function MultipleFileCard(_ref2) {
99
101
  });
100
102
  }), hasMore && /*#__PURE__*/React.createElement("div", {
101
103
  className: styles.all,
102
- onClick: openSidebar
104
+ onClick: openSidebarHandler
103
105
  }, "\u5168\u90E8", /*#__PURE__*/React.createElement(IconChevronRightStroked, null))));
104
106
  };
105
107
  export default MultipleFileCard;
@@ -7,7 +7,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
7
7
  import styles from "./index.module.css";
8
8
  import { knowledgeConstants } from "../../constants";
9
9
  import { useAppDispatch, useAppSelector } from "../../store/hooks";
10
- import { setShowKonwledgeTrace, setKonwledgeTraceState } from "../../store/slices/gimiMenuSlice";
10
+ import { openSidebar } from "../../store/slices/gimiMenuSlice";
11
11
  import React from 'react';
12
12
  var KnowledgeIcon = function KnowledgeIcon(_ref) {
13
13
  var url = _ref.url;
@@ -37,13 +37,15 @@ export var KnowledgeIconComponent = function KnowledgeIconComponent(_ref2) {
37
37
  var iconUrl = type === 'video' ? knowledgeConstants.VIDEO_ICON_KNOWLADGE_TRACE_ADDRESS : type === 'document' ? knowledgeConstants.DOCUMENT_ICON_ADDRESS : knowledgeConstants.CLASS_ICON_ADDRESS;
38
38
  var handleIconClick = function handleIconClick() {
39
39
  if (isMsgRecieving && isLastMessage) return; // 最新一条正在流式输出的消息,不打开溯源面板
40
- dispatch(setKonwledgeTraceState({
41
- type: type,
42
- resources: resources,
43
- messageId: messageId
44
- }));
45
- dispatch(setShowKonwledgeTrace({
46
- showKonwledgeTrace: true
40
+ dispatch(openSidebar({
41
+ type: 'knowledgeTrace',
42
+ data: {
43
+ knowledgeTrace: {
44
+ type: type,
45
+ resources: resources,
46
+ messageId: messageId
47
+ }
48
+ }
47
49
  }));
48
50
  };
49
51
  return /*#__PURE__*/React.createElement("div", {
@@ -2,7 +2,7 @@ import styles from "./index.module.css";
2
2
  import React from 'react';
3
3
  import { IconSearchStroked, IconChevronRightStroked } from '@douyinfe/semi-icons';
4
4
  import { useAppDispatch } from "../../store/hooks";
5
- import { setShowSidebarReasoningSearch, setSidebarReasoningSearchList } from "../../store/slices/gimiMenuSlice";
5
+ import { openSidebar } from "../../store/slices/gimiMenuSlice";
6
6
  var ReasoningSearch = function ReasoningSearch(_ref) {
7
7
  var value = _ref.value;
8
8
  var dispatch = useAppDispatch();
@@ -12,20 +12,22 @@ var ReasoningSearch = function ReasoningSearch(_ref) {
12
12
  } catch (error) {
13
13
  return '';
14
14
  }
15
- var openSidebar = function openSidebar() {
15
+ var openSidebarHandler = function openSidebarHandler() {
16
16
  var list = (searchResult.results || []).map(function (item) {
17
17
  return item['text_card'];
18
18
  });
19
19
  if (list.length > 0) {
20
- dispatch(setShowSidebarReasoningSearch({
21
- showSidebarReasoningSearch: true
20
+ dispatch(openSidebar({
21
+ type: 'reasoningSearch',
22
+ data: {
23
+ reasoningSearchList: list
24
+ }
22
25
  }));
23
- dispatch(setSidebarReasoningSearchList(list));
24
26
  }
25
27
  };
26
28
  return /*#__PURE__*/React.createElement("div", {
27
29
  className: styles.search_button,
28
- onClick: openSidebar
30
+ onClick: openSidebarHandler
29
31
  }, /*#__PURE__*/React.createElement(IconSearchStroked, {
30
32
  className: styles.icon
31
33
  }), /*#__PURE__*/React.createElement("span", {
@@ -5,16 +5,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  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; }
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
7
  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); }
8
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
- 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."); }
10
- 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); }
11
- 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; }
12
- 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; } }
13
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
8
  import React from 'react';
15
9
  import { store } from "../../store";
16
10
  import { useAppDispatch, useAppSelector } from "../../store/hooks";
17
- import { setBaseUrl, setToken, setPlatform, setConversationId, setAgentDetail, setBusinessParams, setQuoteTeachModelList } from "../../store/slices/gimiMenuSlice";
11
+ import { setBaseUrl, setToken, setPlatform, setConversationId, setAgentDetail, setBusinessParams, setQuoteTeachModelList, openSidebar, closeSidebar } from "../../store/slices/gimiMenuSlice";
18
12
  import useCommonChatAPI from "../../hooks/useCommonChatAPI";
19
13
  import { replaceBraces } from "../../utils/tools";
20
14
  import styles from "./index.module.css";
@@ -24,14 +18,11 @@ import PresetAgentContent from "../preset-agent-content";
24
18
  import useChatVoice from "../../hooks/useChatVoice";
25
19
  import { useChatUI } from "../../hooks/useChatUI";
26
20
  import { IconChevronDown } from '@douyinfe/semi-icons';
27
- import KonwledgeTrace from "../knowledge-trace";
28
- import FileCardSideBar from "../file-card/fileCardSidebar";
29
21
  import OfficeFilePreviewPanel from "../file-preview";
30
- import ReasoningSearchSidebar from "../reasoning-search/sidebar";
31
22
  import AiLoading from "../ai-loading";
32
- import SearchCourseListSidebar from "../search-course-list/sidebar";
33
23
  import SearchCourseList from "../search-course-list";
34
24
  import useSearchCourse from "../../hooks/useSearchCase";
25
+ import UnifiedSidebar from "../unified-sidebar";
35
26
  var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
36
27
  var _props$showInput = props.showInput,
37
28
  showInput = _props$showInput === void 0 ? true : _props$showInput,
@@ -83,15 +74,21 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
83
74
  searching = _useSearchCourse.searching,
84
75
  searchCourses = _useSearchCourse.searchCourses,
85
76
  setSearchedCourseList = _useSearchCourse.setSearchedCourseList;
86
- var _React$useState = React.useState(false),
87
- _React$useState2 = _slicedToArray(_React$useState, 2),
88
- showSearchCourseListSidebar = _React$useState2[0],
89
- setShowSearchCourseListSidebar = _React$useState2[1];
77
+ var sidebar = useAppSelector(function (state) {
78
+ return state.gimiMenu.sidebar;
79
+ });
90
80
  var triggerSearchCourseListSidebar = React.useCallback(function () {
91
- setShowSearchCourseListSidebar(function (prev) {
92
- return !prev;
93
- });
94
- }, []);
81
+ if (sidebar.type === 'searchCourseList') {
82
+ dispatch(closeSidebar());
83
+ } else {
84
+ dispatch(openSidebar({
85
+ type: 'searchCourseList',
86
+ data: {
87
+ searchCourseList: searchedCourseList
88
+ }
89
+ }));
90
+ }
91
+ }, [dispatch, sidebar.type, searchedCourseList]);
95
92
  // 搜索相关课程 - 结束
96
93
 
97
94
  var hookParams = React.useMemo(function () {
@@ -195,14 +192,17 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
195
192
  (_chatInputRef$current = chatInputRef.current) === null || _chatInputRef$current === void 0 || _chatInputRef$current.setValue('');
196
193
  // 清空AI搜课结果
197
194
  setSearchedCourseList([]);
198
- setShowSearchCourseListSidebar(false);
195
+ // 只关闭搜索课程列表侧边栏
196
+ if (sidebar.type === 'searchCourseList') {
197
+ dispatch(closeSidebar());
198
+ }
199
199
  var conversationId = store.getState().gimiMenu.conversationId;
200
200
  if (!conversationId) {
201
201
  startConversationAndChat(val);
202
202
  return;
203
203
  }
204
204
  handleSend(val, agent, isSystemAuto);
205
- }, [handleSend, startConversationAndChat, setSearchedCourseList]);
205
+ }, [handleSend, startConversationAndChat, setSearchedCourseList, dispatch, sidebar.type]);
206
206
 
207
207
  // 输入框开头Agent名称
208
208
  var showTitleSlot = React.useMemo(function () {
@@ -285,17 +285,8 @@ var CommonChat = /*#__PURE__*/React.forwardRef(function (props, ref) {
285
285
  questionList: (agentObj === null || agentObj === void 0 ? void 0 : agentObj.questionList) || [],
286
286
  onQuickSend: handleInputSend,
287
287
  layout: 'horizontal'
288
- })), /*#__PURE__*/React.createElement(KonwledgeTrace, _extends({}, props.sidebarConfig, {
289
- isOverFlow: model === 'fullscreen' ? false : true
290
- })), /*#__PURE__*/React.createElement(FileCardSideBar, _extends({}, props.sidebarConfig, {
291
- isOverFlow: model === 'fullscreen' ? false : true
292
- })), /*#__PURE__*/React.createElement(OfficeFilePreviewPanel, null), /*#__PURE__*/React.createElement(ReasoningSearchSidebar, _extends({}, props.sidebarConfig, {
293
- isOverFlow: model === 'fullscreen' ? false : true
294
- })), /*#__PURE__*/React.createElement(SearchCourseListSidebar, _extends({}, props.sidebarConfig, {
295
- show: showSearchCourseListSidebar,
296
- courseList: searchedCourseList,
297
- onClose: triggerSearchCourseListSidebar,
288
+ })), /*#__PURE__*/React.createElement(UnifiedSidebar, _extends({}, props.sidebarConfig, {
298
289
  isOverFlow: model === 'fullscreen' ? false : true
299
- })));
290
+ })), /*#__PURE__*/React.createElement(OfficeFilePreviewPanel, null));
300
291
  });
301
292
  export default CommonChat;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface FileListContentProps {
3
+ isOverFlow: boolean;
4
+ }
5
+ declare const FileListContent: React.FC<FileListContentProps>;
6
+ export default FileListContent;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import styles from "../file-card/index.module.css";
3
+ import { useAppSelector } from "../../store/hooks";
4
+ import { FileCard } from "../file-card";
5
+ var FileListContent = function FileListContent(_ref) {
6
+ var isOverFlow = _ref.isOverFlow;
7
+ var sidebar = useAppSelector(function (state) {
8
+ return state.gimiMenu.sidebar;
9
+ });
10
+ var fileList = sidebar.fileList;
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ className: styles.list
13
+ }, /*#__PURE__*/React.createElement("span", {
14
+ className: styles.total
15
+ }, "\u672C\u5BF9\u8BDD\u5171".concat((fileList === null || fileList === void 0 ? void 0 : fileList.length) || 0, "\u4E2A\u6587\u6863")), fileList.map(function (file, index) {
16
+ return /*#__PURE__*/React.createElement(FileCard, {
17
+ fileName: file.fileName,
18
+ fileType: file.fileType,
19
+ size: file.size,
20
+ downloadUrl: file.downloadUrl,
21
+ key: index,
22
+ model: isOverFlow ? 'sidebar' : 'fullscreen'
23
+ });
24
+ }));
25
+ };
26
+ export default FileListContent;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ export declare type KonwledgeType = 'video' | 'document' | 'product';
3
+ interface KnowledgeTraceContentProps {
4
+ onCurrentTraceVideoClick?: (time?: string) => void;
5
+ }
6
+ declare const KnowledgeTraceContent: React.FC<KnowledgeTraceContentProps>;
7
+ export default KnowledgeTraceContent;
@@ -0,0 +1,105 @@
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 styles from "../knowledge-trace/index.module.css";
9
+ import { useAppSelector } from "../../store/hooks";
10
+ import { Tabs, TabPane } from '@douyinfe/semi-ui';
11
+ import VideoList from "../knowledge-trace/videoList";
12
+ import DocumentList from "../knowledge-trace/documentList";
13
+ import ClassList from "../knowledge-trace/classList";
14
+ import { getKnowledgeTraceListFromConent } from "../../utils/tools";
15
+ import useKnowledgeService from "../../hooks/useKnowledgeService";
16
+ import AiLoading from "../ai-loading";
17
+ var KnowledgeTraceContent = function KnowledgeTraceContent(_ref) {
18
+ var onCurrentTraceVideoClick = _ref.onCurrentTraceVideoClick;
19
+ var sidebar = useAppSelector(function (state) {
20
+ return state.gimiMenu.sidebar;
21
+ });
22
+ var messageList = useAppSelector(function (state) {
23
+ return state.gimiMenu.messageList;
24
+ });
25
+ var konwledgeTraceState = sidebar.knowledgeTrace;
26
+ var _React$useState = React.useState([]),
27
+ _React$useState2 = _slicedToArray(_React$useState, 2),
28
+ tabList = _React$useState2[0],
29
+ setTabList = _React$useState2[1];
30
+ var _React$useState3 = React.useState(''),
31
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
32
+ activeKey = _React$useState4[0],
33
+ setActiveKey = _React$useState4[1];
34
+ var messageListRef = React.useRef(messageList);
35
+ messageListRef.current = messageList;
36
+ var kowledgeTraceList = React.useMemo(function () {
37
+ var chatList = messageListRef.current;
38
+ var matchIndex = chatList.findIndex(function (item) {
39
+ return item.id === konwledgeTraceState.messageId;
40
+ });
41
+ var matchMessage = chatList[matchIndex];
42
+ var sendMessage = chatList[matchIndex - 1];
43
+ if (!matchMessage) return [];
44
+ return getKnowledgeTraceListFromConent(matchMessage, sendMessage);
45
+ }, [konwledgeTraceState.messageId]);
46
+ React.useEffect(function () {
47
+ if ((kowledgeTraceList === null || kowledgeTraceList === void 0 ? void 0 : kowledgeTraceList.length) > 0) {
48
+ setTabList(function () {
49
+ return kowledgeTraceList.map(function (item) {
50
+ return {
51
+ name: item.type === 'document' ? '文档' : item.type === 'video' ? '视频' : '课程',
52
+ type: item.type
53
+ };
54
+ });
55
+ });
56
+ }
57
+ }, [kowledgeTraceList]);
58
+ var _useKnowledgeService = useKnowledgeService(kowledgeTraceList),
59
+ videoSliceList = _useKnowledgeService.videoSliceList,
60
+ documentList = _useKnowledgeService.documentList,
61
+ productList = _useKnowledgeService.productList,
62
+ isLoading = _useKnowledgeService.isLoading;
63
+ React.useEffect(function () {
64
+ setActiveKey(konwledgeTraceState.type);
65
+ }, [konwledgeTraceState.type]);
66
+ var handleTabChange = function handleTabChange(activeKey) {
67
+ setActiveKey(activeKey);
68
+ };
69
+ var tabContent = React.useMemo(function () {
70
+ if (isLoading) return /*#__PURE__*/React.createElement(AiLoading, null);
71
+ switch (activeKey) {
72
+ case 'video':
73
+ return /*#__PURE__*/React.createElement(VideoList, {
74
+ list: videoSliceList,
75
+ onCurrentTraceVideoClick: onCurrentTraceVideoClick
76
+ });
77
+ case 'product':
78
+ return /*#__PURE__*/React.createElement(ClassList, {
79
+ list: productList
80
+ });
81
+ case 'document':
82
+ return /*#__PURE__*/React.createElement(DocumentList, {
83
+ list: documentList
84
+ });
85
+ default:
86
+ return null;
87
+ }
88
+ }, [activeKey, videoSliceList, productList, documentList, isLoading, onCurrentTraceVideoClick]);
89
+ if (!(kowledgeTraceList !== null && kowledgeTraceList !== void 0 && kowledgeTraceList.length)) return null;
90
+ return /*#__PURE__*/React.createElement("div", {
91
+ className: styles.tabs
92
+ }, (tabList === null || tabList === void 0 ? void 0 : tabList.length) > 1 ? /*#__PURE__*/React.createElement(Tabs, {
93
+ type: "button",
94
+ size: "small",
95
+ activeKey: activeKey,
96
+ onChange: handleTabChange
97
+ }, tabList.map(function (tab) {
98
+ return /*#__PURE__*/React.createElement(TabPane, {
99
+ tab: tab.name,
100
+ itemKey: tab.type,
101
+ key: tab.type
102
+ }, tabContent);
103
+ })) : tabContent);
104
+ };
105
+ export default KnowledgeTraceContent;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ReasoningSearchContent: React.FC;
3
+ export default ReasoningSearchContent;
@@ -0,0 +1,75 @@
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 styles from "../reasoning-search/index.module.css";
9
+ import { useAppSelector } from "../../store/hooks";
10
+ import { Badge } from '@douyinfe/semi-ui';
11
+ import GHIcon from "../../assets/image/gtrs_logo_lt.png";
12
+ var getFaviconByUrl = function getFaviconByUrl(url) {
13
+ try {
14
+ var urlObj = new URL(url);
15
+ return "".concat(urlObj.origin, "/favicon.ico");
16
+ } catch (_unused) {
17
+ return '';
18
+ }
19
+ };
20
+ var IconComponent = function IconComponent(_ref) {
21
+ var iconUrl = _ref.iconUrl;
22
+ var _React$useState = React.useState(false),
23
+ _React$useState2 = _slicedToArray(_React$useState, 2),
24
+ iconError = _React$useState2[0],
25
+ setIconError = _React$useState2[1];
26
+ if (iconError || !iconUrl) {
27
+ return /*#__PURE__*/React.createElement("img", {
28
+ src: GHIcon,
29
+ alt: "icon",
30
+ className: styles.icon
31
+ });
32
+ }
33
+ return /*#__PURE__*/React.createElement("img", {
34
+ src: iconUrl,
35
+ alt: "icon",
36
+ className: styles.icon,
37
+ onError: function onError() {
38
+ return setIconError(true);
39
+ }
40
+ });
41
+ };
42
+ var ReasoningSearchContent = function ReasoningSearchContent() {
43
+ var sidebar = useAppSelector(function (state) {
44
+ return state.gimiMenu.sidebar;
45
+ });
46
+ var sidebarReasoningSearchList = sidebar.reasoningSearchList;
47
+ return /*#__PURE__*/React.createElement("div", {
48
+ className: styles.list
49
+ }, sidebarReasoningSearchList.map(function (item, index) {
50
+ var iconUrl = getFaviconByUrl(item.url);
51
+ return /*#__PURE__*/React.createElement("div", {
52
+ key: index,
53
+ className: styles.item
54
+ }, /*#__PURE__*/React.createElement("div", {
55
+ className: styles.item_title,
56
+ onClick: function onClick() {
57
+ return window.open(item.url);
58
+ }
59
+ }, item.title), /*#__PURE__*/React.createElement("div", {
60
+ className: styles.item_footer
61
+ }, /*#__PURE__*/React.createElement("div", {
62
+ className: styles.footer_left
63
+ }, /*#__PURE__*/React.createElement(IconComponent, {
64
+ iconUrl: iconUrl,
65
+ item: item
66
+ }), /*#__PURE__*/React.createElement("span", null, item.sitename)), /*#__PURE__*/React.createElement(Badge, {
67
+ style: {
68
+ background: 'rgba(240, 240, 243, 1)',
69
+ color: 'rgba(154, 167, 183, 1)'
70
+ },
71
+ count: index + 1
72
+ })));
73
+ }));
74
+ };
75
+ export default ReasoningSearchContent;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const SearchCourseListContent: React.FC;
3
+ export default SearchCourseListContent;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import styles from "../search-course-list/index.module.css";
3
+ import { useAppSelector } from "../../store/hooks";
4
+ import { CourseCard } from "../search-course-list";
5
+ var SearchCourseListContent = function SearchCourseListContent() {
6
+ var sidebar = useAppSelector(function (state) {
7
+ return state.gimiMenu.sidebar;
8
+ });
9
+ var courseList = sidebar.searchCourseList;
10
+ return /*#__PURE__*/React.createElement("div", {
11
+ className: styles.list
12
+ }, /*#__PURE__*/React.createElement("span", {
13
+ className: styles.total
14
+ }, "\u672C\u5BF9\u8BDD\u5171".concat((courseList === null || courseList === void 0 ? void 0 : courseList.length) || 0, "\u4E2A\u8BFE\u7A0B")), courseList.map(function (item) {
15
+ return /*#__PURE__*/React.createElement(CourseCard, {
16
+ key: item.productId,
17
+ item: item
18
+ });
19
+ }));
20
+ };
21
+ export default SearchCourseListContent;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ interface UnifiedSidebarProps {
3
+ sidebarTargetElm?: HTMLElement;
4
+ isOverFlow: boolean;
5
+ className?: string;
6
+ style?: React.CSSProperties;
7
+ onCurrentTraceVideoClick?: (time?: string) => void;
8
+ }
9
+ declare const UnifiedSidebar: React.FC<UnifiedSidebarProps>;
10
+ export default UnifiedSidebar;
@@ -0,0 +1,64 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import { useAppSelector, useAppDispatch } from "../../store/hooks";
3
+ import { closeSidebar } from "../../store/slices/gimiMenuSlice";
4
+ import GimiSideBar from "../gimi-sidebar";
5
+ import KnowledgeTraceContent from "./KnowledgeTraceContent";
6
+ import FileListContent from "./FileListContent";
7
+ import ReasoningSearchContent from "./ReasoningSearchContent";
8
+ import SearchCourseListContent from "./SearchCourseListContent";
9
+ var sidebarTitleMap = {
10
+ knowledgeTrace: '引用来源',
11
+ fileList: '全部',
12
+ reasoningSearch: '搜索来源',
13
+ searchCourseList: '搜索结果'
14
+ };
15
+ var UnifiedSidebar = function UnifiedSidebar(_ref) {
16
+ var sidebarTargetElm = _ref.sidebarTargetElm,
17
+ isOverFlow = _ref.isOverFlow,
18
+ className = _ref.className,
19
+ style = _ref.style,
20
+ onCurrentTraceVideoClick = _ref.onCurrentTraceVideoClick;
21
+ var dispatch = useAppDispatch();
22
+ var sidebar = useAppSelector(function (state) {
23
+ return state.gimiMenu.sidebar;
24
+ });
25
+ var handleClose = useCallback(function () {
26
+ dispatch(closeSidebar());
27
+ }, [dispatch]);
28
+ var title = useMemo(function () {
29
+ if (!sidebar.type) return '';
30
+ if (sidebar.type === 'reasoningSearch') {
31
+ return "".concat(sidebarTitleMap.reasoningSearch, " ").concat(sidebar.reasoningSearchList.length);
32
+ }
33
+ return sidebarTitleMap[sidebar.type];
34
+ }, [sidebar.type, sidebar.reasoningSearchList.length]);
35
+ var renderContent = useCallback(function () {
36
+ switch (sidebar.type) {
37
+ case 'knowledgeTrace':
38
+ return /*#__PURE__*/React.createElement(KnowledgeTraceContent, {
39
+ onCurrentTraceVideoClick: onCurrentTraceVideoClick
40
+ });
41
+ case 'fileList':
42
+ return /*#__PURE__*/React.createElement(FileListContent, {
43
+ isOverFlow: isOverFlow
44
+ });
45
+ case 'reasoningSearch':
46
+ return /*#__PURE__*/React.createElement(ReasoningSearchContent, null);
47
+ case 'searchCourseList':
48
+ return /*#__PURE__*/React.createElement(SearchCourseListContent, null);
49
+ default:
50
+ return null;
51
+ }
52
+ }, [sidebar.type, isOverFlow, onCurrentTraceVideoClick]);
53
+ if (!sidebar.type) return null;
54
+ return /*#__PURE__*/React.createElement(GimiSideBar, {
55
+ show: !!sidebar.type,
56
+ isOverFlow: isOverFlow,
57
+ title: title,
58
+ handleClose: handleClose,
59
+ className: className,
60
+ style: style,
61
+ sidebarTargetElm: sidebarTargetElm
62
+ }, renderContent() || undefined);
63
+ };
64
+ export default UnifiedSidebar;
@@ -22,7 +22,7 @@ import ChatContext from "../components/templates/chatContext";
22
22
  import React, { useRef } from 'react';
23
23
  import { Toast } from "@douyinfe/semi-ui";
24
24
  import { useAppDispatch, useAppSelector } from "../store/hooks";
25
- import { setMessageList, setFileList, setConversationId, setAgentDetail, setAutoLoadConversation, updateState } from "../store/slices/gimiMenuSlice";
25
+ import { setMessageList, setFileList, setConversationId, setAgentDetail, setAutoLoadConversation, updateState, closeSidebar } from "../store/slices/gimiMenuSlice";
26
26
  import { fileValidation, parseMessageContent, processString } from "../utils/tools";
27
27
  import { filterPropmptFromUserInput } from "../utils/tools";
28
28
  import { useChatMessage } from "./useChatMessage";
@@ -190,23 +190,20 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
190
190
  var clearQuotesFromRedux = React.useCallback(function () {
191
191
  dispatch(updateState({
192
192
  fileList: [],
193
- showKonwledgeTrace: false,
194
- showSidebarFileList: false,
195
- showSidebarReasoningSearch: false,
196
193
  filePreviewState: {
197
194
  show: false,
198
195
  url: '',
199
196
  filename: ''
200
197
  },
201
- // quoteProductList: [],
202
- // quoteTeachModelList: [],
203
198
  konwledgeTraceState: {
204
199
  type: 'video',
205
200
  resources: [],
206
201
  messageId: null
207
202
  },
208
- sidebarReasoningSearchList: []
203
+ sidebarReasoningSearchList: [],
204
+ sidebarFileList: []
209
205
  }));
206
+ dispatch(closeSidebar());
210
207
  }, [dispatch]);
211
208
  var deleteConversation = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
212
209
  var res;
@@ -3,6 +3,15 @@ import type { KonwledgeTraceState } from '../../types/answer';
3
3
  import type { FileItem, IFileCardProps } from '../../types/file';
4
4
  import { IChatMessageItem } from '../../interfaces/chatMessage';
5
5
  import { IReasoningSearchItem } from '../../components/reasoning-search/sidebar';
6
+ import { ICourseItem } from '../../components/search-course-list';
7
+ export declare type SidebarType = 'knowledgeTrace' | 'fileList' | 'reasoningSearch' | 'searchCourseList' | null;
8
+ export interface SidebarState {
9
+ type: SidebarType;
10
+ knowledgeTrace: KonwledgeTraceState;
11
+ fileList: IFileCardProps[];
12
+ reasoningSearchList: IReasoningSearchItem[];
13
+ searchCourseList: ICourseItem[];
14
+ }
6
15
  export interface GimiMenuState {
7
16
  platform: 'myun' | 'preview' | 'damai';
8
17
  token: string;
@@ -33,6 +42,7 @@ export interface GimiMenuState {
33
42
  showSidebarReasoningSearch: boolean;
34
43
  sidebarReasoningSearchList: IReasoningSearchItem[];
35
44
  sidebarFileList: IFileCardProps[];
45
+ sidebar: SidebarState;
36
46
  filePreviewState: {
37
47
  show: boolean;
38
48
  url: string;
@@ -98,6 +108,9 @@ export declare const setAgentDetail: import("@reduxjs/toolkit").ActionCreatorWit
98
108
  autoLoadConversation: boolean;
99
109
  }, "gimiMenu/setAutoLoadConversation">, setShowSidebarReasoningSearch: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
100
110
  showSidebarReasoningSearch: boolean;
101
- }, "gimiMenu/setShowSidebarReasoningSearch">, setSidebarReasoningSearchList: import("@reduxjs/toolkit").ActionCreatorWithPayload<IReasoningSearchItem[], "gimiMenu/setSidebarReasoningSearchList">;
111
+ }, "gimiMenu/setShowSidebarReasoningSearch">, setSidebarReasoningSearchList: import("@reduxjs/toolkit").ActionCreatorWithPayload<IReasoningSearchItem[], "gimiMenu/setSidebarReasoningSearchList">, openSidebar: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
112
+ type: SidebarType;
113
+ data?: Partial<SidebarState> | undefined;
114
+ }, "gimiMenu/openSidebar">, closeSidebar: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"gimiMenu/closeSidebar">, setSidebarKnowledgeTrace: import("@reduxjs/toolkit").ActionCreatorWithPayload<KonwledgeTraceState, "gimiMenu/setSidebarKnowledgeTrace">, setSidebarFileListData: import("@reduxjs/toolkit").ActionCreatorWithPayload<IFileCardProps[], "gimiMenu/setSidebarFileListData">, setSidebarReasoningSearchListData: import("@reduxjs/toolkit").ActionCreatorWithPayload<IReasoningSearchItem[], "gimiMenu/setSidebarReasoningSearchListData">, setSidebarSearchCourseList: import("@reduxjs/toolkit").ActionCreatorWithPayload<ICourseItem[], "gimiMenu/setSidebarSearchCourseList">;
102
115
  declare const reducer: Reducer<GimiMenuState>;
103
116
  export default reducer;