@myun/gimi-chat 0.4.7 → 0.5.0

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.
@@ -1,6 +1,6 @@
1
1
  import { FetchResponse } from './fetch';
2
2
  import { IProduct, ITeachingModuleResource, IVideoResource } from '../interfaces/knowledgeTrace';
3
- declare const useApi: (baseUrl?: string, authToken?: string) => {
3
+ export interface IUseApi {
4
4
  getSkillData: (requestId: number) => Promise<FetchResponse<any>>;
5
5
  getProductList: (params: {
6
6
  productIds: string[];
@@ -58,6 +58,7 @@ declare const useApi: (baseUrl?: string, authToken?: string) => {
58
58
  checkRetry: (params: {
59
59
  conversationId: number;
60
60
  }) => Promise<FetchResponse<any>>;
61
- interrupt: (conversationId: number) => any;
62
- };
61
+ interrupt: (conversationId: number) => Promise<FetchResponse<any>>;
62
+ }
63
+ declare const useApi: (baseUrl: string, authToken: string) => IUseApi;
63
64
  export default useApi;
@@ -3,27 +3,10 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
3
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
5
  import { createFetch } from "./fetch";
6
- import { useAppSelector } from "../store/hooks";
7
- import React from 'react';
8
6
  var useApi = function useApi(baseUrl, authToken) {
9
- var storedToken = useAppSelector(function (state) {
10
- return state.gimiMenu.token;
11
- });
12
- var storedBaseURL = useAppSelector(function (state) {
13
- return state.gimiMenu.baseUrl;
14
- });
15
- var token = authToken || storedToken;
16
- var baseURL = baseUrl || storedBaseURL;
17
- var apiRef = React.useRef(createFetch({
18
- baseURL: baseURL,
19
- timeout: 10000,
20
- headers: {
21
- 'Authorization': 'Bearer ' + token,
22
- 'X-Mc-Domain': location.hostname,
23
- 'Content-Type': 'application/json'
24
- }
25
- }));
26
- apiRef.current = createFetch({
7
+ var token = authToken;
8
+ var baseURL = baseUrl;
9
+ var fetchService = createFetch({
27
10
  baseURL: baseURL,
28
11
  timeout: 10000,
29
12
  headers: {
@@ -37,7 +20,7 @@ var useApi = function useApi(baseUrl, authToken) {
37
20
  return _regeneratorRuntime().wrap(function _callee$(_context) {
38
21
  while (1) switch (_context.prev = _context.next) {
39
22
  case 0:
40
- return _context.abrupt("return", apiRef.current.get('/mexam/api/question/user-answer', {
23
+ return _context.abrupt("return", fetchService.get('/mexam/api/question/user-answer', {
41
24
  params: params
42
25
  }));
43
26
  case 1:
@@ -57,7 +40,7 @@ var useApi = function useApi(baseUrl, authToken) {
57
40
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
58
41
  while (1) switch (_context2.prev = _context2.next) {
59
42
  case 0:
60
- return _context2.abrupt("return", apiRef.current.delete('/mbot/web/conversation', {
43
+ return _context2.abrupt("return", fetchService.delete('/mbot/web/conversation', {
61
44
  params: {
62
45
  id: conversationId
63
46
  }
@@ -79,7 +62,7 @@ var useApi = function useApi(baseUrl, authToken) {
79
62
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
80
63
  while (1) switch (_context3.prev = _context3.next) {
81
64
  case 0:
82
- return _context3.abrupt("return", apiRef.current.get('/mcourse/web/agent/detail', {
65
+ return _context3.abrupt("return", fetchService.get('/mcourse/web/agent/detail', {
83
66
  params: {
84
67
  agentId: agentId
85
68
  }
@@ -101,7 +84,7 @@ var useApi = function useApi(baseUrl, authToken) {
101
84
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
102
85
  while (1) switch (_context4.prev = _context4.next) {
103
86
  case 0:
104
- return _context4.abrupt("return", apiRef.current.post('/mbot/web/agent-message/mark', params));
87
+ return _context4.abrupt("return", fetchService.post('/mbot/web/agent-message/mark', params));
105
88
  case 1:
106
89
  case "end":
107
90
  return _context4.stop();
@@ -119,7 +102,7 @@ var useApi = function useApi(baseUrl, authToken) {
119
102
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
120
103
  while (1) switch (_context5.prev = _context5.next) {
121
104
  case 0:
122
- return _context5.abrupt("return", apiRef.current.get('/mbot/web/agent-message/stopStreamOut', {
105
+ return _context5.abrupt("return", fetchService.get('/mbot/web/agent-message/stopStreamOut', {
123
106
  params: params
124
107
  }));
125
108
  case 1:
@@ -139,7 +122,7 @@ var useApi = function useApi(baseUrl, authToken) {
139
122
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
140
123
  while (1) switch (_context6.prev = _context6.next) {
141
124
  case 0:
142
- return _context6.abrupt("return", apiRef.current.post('/mbot/web/agent-message/page/history', params));
125
+ return _context6.abrupt("return", fetchService.post('/mbot/web/agent-message/page/history', params));
143
126
  case 1:
144
127
  case "end":
145
128
  return _context6.stop();
@@ -155,7 +138,7 @@ var useApi = function useApi(baseUrl, authToken) {
155
138
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
156
139
  while (1) switch (_context7.prev = _context7.next) {
157
140
  case 0:
158
- return _context7.abrupt("return", apiRef.current.get('/mbot/web/related-resource/probeQuestion', {
141
+ return _context7.abrupt("return", fetchService.get('/mbot/web/related-resource/probeQuestion', {
159
142
  params: params
160
143
  }));
161
144
  case 1:
@@ -175,7 +158,7 @@ var useApi = function useApi(baseUrl, authToken) {
175
158
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
176
159
  while (1) switch (_context8.prev = _context8.next) {
177
160
  case 0:
178
- return _context8.abrupt("return", apiRef.current.get("/mbot/web/conversation/".concat(conversationId)));
161
+ return _context8.abrupt("return", fetchService.get("/mbot/web/conversation/".concat(conversationId)));
179
162
  case 1:
180
163
  case "end":
181
164
  return _context8.stop();
@@ -193,7 +176,7 @@ var useApi = function useApi(baseUrl, authToken) {
193
176
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
194
177
  while (1) switch (_context9.prev = _context9.next) {
195
178
  case 0:
196
- return _context9.abrupt("return", apiRef.current.get('/mflux/web/tools/request/status', {
179
+ return _context9.abrupt("return", fetchService.get('/mflux/web/tools/request/status', {
197
180
  params: {
198
181
  requestId: requestId
199
182
  }
@@ -215,7 +198,7 @@ var useApi = function useApi(baseUrl, authToken) {
215
198
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
216
199
  while (1) switch (_context10.prev = _context10.next) {
217
200
  case 0:
218
- return _context10.abrupt("return", apiRef.current.post('/mcourse/web/trace/product', {
201
+ return _context10.abrupt("return", fetchService.post('/mcourse/web/trace/product', {
219
202
  params: params
220
203
  }));
221
204
  case 1:
@@ -235,7 +218,7 @@ var useApi = function useApi(baseUrl, authToken) {
235
218
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
236
219
  while (1) switch (_context11.prev = _context11.next) {
237
220
  case 0:
238
- return _context11.abrupt("return", apiRef.current.post('/mcourse/web/trace/resource', params));
221
+ return _context11.abrupt("return", fetchService.post('/mcourse/web/trace/resource', params));
239
222
  case 1:
240
223
  case "end":
241
224
  return _context11.stop();
@@ -253,7 +236,7 @@ var useApi = function useApi(baseUrl, authToken) {
253
236
  return _regeneratorRuntime().wrap(function _callee12$(_context12) {
254
237
  while (1) switch (_context12.prev = _context12.next) {
255
238
  case 0:
256
- return _context12.abrupt("return", apiRef.current.post('/mcourse/web/trace/video', params));
239
+ return _context12.abrupt("return", fetchService.post('/mcourse/web/trace/video', params));
257
240
  case 1:
258
241
  case "end":
259
242
  return _context12.stop();
@@ -271,7 +254,7 @@ var useApi = function useApi(baseUrl, authToken) {
271
254
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
272
255
  while (1) switch (_context13.prev = _context13.next) {
273
256
  case 0:
274
- return _context13.abrupt("return", apiRef.current.post('/mbot/web/conversation', params));
257
+ return _context13.abrupt("return", fetchService.post('/mbot/web/conversation', params));
275
258
  case 1:
276
259
  case "end":
277
260
  return _context13.stop();
@@ -289,7 +272,7 @@ var useApi = function useApi(baseUrl, authToken) {
289
272
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
290
273
  while (1) switch (_context14.prev = _context14.next) {
291
274
  case 0:
292
- return _context14.abrupt("return", apiRef.current.post("/mbot/web/bot/rtc-config/all"));
275
+ return _context14.abrupt("return", fetchService.post("/mbot/web/bot/rtc-config/all"));
293
276
  case 1:
294
277
  case "end":
295
278
  return _context14.stop();
@@ -309,7 +292,7 @@ var useApi = function useApi(baseUrl, authToken) {
309
292
  while (1) switch (_context15.prev = _context15.next) {
310
293
  case 0:
311
294
  roomId = params.roomId, taskId = params.taskId, custom = params.custom;
312
- return _context15.abrupt("return", apiRef.current.post("/mbot/web/bot/startVoiceChat", {
295
+ return _context15.abrupt("return", fetchService.post("/mbot/web/bot/startVoiceChat", {
313
296
  custom: custom,
314
297
  roomId: roomId,
315
298
  taskId: taskId
@@ -333,7 +316,7 @@ var useApi = function useApi(baseUrl, authToken) {
333
316
  while (1) switch (_context16.prev = _context16.next) {
334
317
  case 0:
335
318
  appId = params.appId, roomId = params.roomId, taskId = params.taskId;
336
- return _context16.abrupt("return", apiRef.current.post("/mbot/web/bot/stopVoiceChat", {
319
+ return _context16.abrupt("return", fetchService.post("/mbot/web/bot/stopVoiceChat", {
337
320
  appId: appId,
338
321
  roomId: roomId,
339
322
  taskId: taskId
@@ -356,7 +339,7 @@ var useApi = function useApi(baseUrl, authToken) {
356
339
  while (1) switch (_context17.prev = _context17.next) {
357
340
  case 0:
358
341
  type = _ref17.type;
359
- return _context17.abrupt("return", apiRef.current.get("/mcourse/web/user-first-use/check-and-mark?featureType=".concat(type)));
342
+ return _context17.abrupt("return", fetchService.get("/mcourse/web/user-first-use/check-and-mark?featureType=".concat(type)));
360
343
  case 2:
361
344
  case "end":
362
345
  return _context17.stop();
@@ -370,7 +353,7 @@ var useApi = function useApi(baseUrl, authToken) {
370
353
 
371
354
  /** 手动打断当前语音对话 */
372
355
  var interrupt = function interrupt(conversationId) {
373
- return apiRef.current.post('/api/voice/interrupt', {
356
+ return fetchService.post('/api/voice/interrupt', {
374
357
  conversationId: conversationId
375
358
  });
376
359
  };
@@ -381,7 +364,7 @@ var useApi = function useApi(baseUrl, authToken) {
381
364
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
382
365
  while (1) switch (_context18.prev = _context18.next) {
383
366
  case 0:
384
- return _context18.abrupt("return", apiRef.current.post('/mcourse/web/wisdomClass/quote/getVideoList', params));
367
+ return _context18.abrupt("return", fetchService.post('/mcourse/web/wisdomClass/quote/getVideoList', params));
385
368
  case 1:
386
369
  case "end":
387
370
  return _context18.stop();
@@ -399,7 +382,7 @@ var useApi = function useApi(baseUrl, authToken) {
399
382
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
400
383
  while (1) switch (_context19.prev = _context19.next) {
401
384
  case 0:
402
- return _context19.abrupt("return", apiRef.current.post('/mcourse/web/wisdomClass/quote/getProductList', params));
385
+ return _context19.abrupt("return", fetchService.post('/mcourse/web/wisdomClass/quote/getProductList', params));
403
386
  case 1:
404
387
  case "end":
405
388
  return _context19.stop();
@@ -415,7 +398,7 @@ var useApi = function useApi(baseUrl, authToken) {
415
398
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
416
399
  while (1) switch (_context20.prev = _context20.next) {
417
400
  case 0:
418
- return _context20.abrupt("return", apiRef.current.get('/mbot/web/agent-message/retry/judge', {
401
+ return _context20.abrupt("return", fetchService.get('/mbot/web/agent-message/retry/judge', {
419
402
  params: params
420
403
  }));
421
404
  case 1:
@@ -30,6 +30,7 @@ var HistoryList = function HistoryList() {
30
30
  return state.gimiMenu;
31
31
  }),
32
32
  baseUrl = _useAppSelector.baseUrl,
33
+ token = _useAppSelector.token,
33
34
  conversationId = _useAppSelector.conversationId,
34
35
  historyList = _useAppSelector.historyList,
35
36
  loadingMore = _useAppSelector.loadingMore,
@@ -37,7 +38,7 @@ var HistoryList = function HistoryList() {
37
38
  hasMore = _useAppSelector$hasMo === void 0 ? true : _useAppSelector$hasMo,
38
39
  loading = _useAppSelector.loading,
39
40
  params = _useAppSelector.params;
40
- var _useApi = useApi(),
41
+ var _useApi = useApi(baseUrl, token),
41
42
  deleteConversationById = _useApi.deleteConversationById;
42
43
  var _useState = useState(null),
43
44
  _useState2 = _slicedToArray(_useState, 2),
@@ -36,7 +36,7 @@ var Chat = function Chat(props) {
36
36
  var reloadHistoryList = useCallback(function () {
37
37
  if (historyList.findIndex(function (item) {
38
38
  return item.id === conversationId;
39
- }) !== 0) {
39
+ }) === -1) {
40
40
  dispatch(updateParams({
41
41
  pageIndex: 1,
42
42
  pageSize: 50
@@ -46,6 +46,7 @@ var Chat = function Chat(props) {
46
46
  pageSize: 50
47
47
  }));
48
48
  }
49
+ return true;
49
50
  }, [conversationId, dispatch, historyList]);
50
51
  var _useApi = useApi(baseUrl, token),
51
52
  getAgentDetail = _useApi.getAgentDetail;
@@ -2,9 +2,17 @@ import React from 'react';
2
2
  import { store } from "../../store";
3
3
  import { Provider } from 'react-redux';
4
4
  import Chat from "../core/chat";
5
+ import ChatContext from "../../components/templates/chatContext";
6
+ import useApi from "../../apis/useApi";
5
7
  var Index = function Index(props) {
8
+ var _props$chat, _props$chat2;
9
+ var apiService = useApi(((_props$chat = props.chat) === null || _props$chat === void 0 ? void 0 : _props$chat.baseUrl) || '', ((_props$chat2 = props.chat) === null || _props$chat2 === void 0 ? void 0 : _props$chat2.token) || '');
6
10
  return /*#__PURE__*/React.createElement(Provider, {
7
11
  store: store
8
- }, /*#__PURE__*/React.createElement(Chat, props));
12
+ }, /*#__PURE__*/React.createElement(ChatContext.Provider, {
13
+ value: {
14
+ apiService: apiService
15
+ }
16
+ }, /*#__PURE__*/React.createElement(Chat, props)));
9
17
  };
10
18
  export default Index;
@@ -30,7 +30,8 @@ import useScroll from "../../hooks/useScroll";
30
30
  // import { useUnload } from '@/utils/custom-hooks';
31
31
  import { VolcVoiceCallClient } from "./volc-voice-call-client";
32
32
  import { AGENT_BRIEF, parseVolcBinaryMessage } from "./message-parser";
33
- import useApi from "../../apis/useApi";
33
+ import { useContext } from 'react';
34
+ import ChatContext from "../templates/chatContext";
34
35
  import { Spin } from '@douyinfe/semi-ui';
35
36
  import { createPortal } from 'react-dom';
36
37
  import { useDispatch } from 'react-redux';
@@ -95,12 +96,14 @@ var AiExplain = function AiExplain(_ref) {
95
96
  _useScroll2 = _slicedToArray(_useScroll, 2),
96
97
  throttledScrollToBottom = _useScroll2[0],
97
98
  scrollBottomForce = _useScroll2[1];
98
- var _useApi = useApi(),
99
- _startVoiceChat = _useApi.startVoiceChat,
100
- _stopVoiceChat = _useApi.stopVoiceChat,
101
- getUserFirstUse = _useApi.getUserFirstUse,
102
- getRtcConfig = _useApi.getRtcConfig,
103
- interrupt = _useApi.interrupt;
99
+ var _useContext = useContext(ChatContext),
100
+ apiService = _useContext.apiService;
101
+ var _ref2 = apiService,
102
+ _startVoiceChat = _ref2.startVoiceChat,
103
+ _stopVoiceChat = _ref2.stopVoiceChat,
104
+ getUserFirstUse = _ref2.getUserFirstUse,
105
+ getRtcConfig = _ref2.getRtcConfig,
106
+ interrupt = _ref2.interrupt;
104
107
  var dispatch = useDispatch();
105
108
  var UNSUPPORTED_CALL_MSG_KEY = 'ai-chat-unsupported-call';
106
109
  var unsupportedShownRef = useRef(false);
@@ -246,7 +249,7 @@ var AiExplain = function AiExplain(_ref) {
246
249
 
247
250
  // 静音
248
251
  var handleVoice = /*#__PURE__*/function () {
249
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(flag) {
252
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(flag) {
250
253
  var enable, _clientRef$current;
251
254
  return _regeneratorRuntime().wrap(function _callee$(_context) {
252
255
  while (1) switch (_context.prev = _context.next) {
@@ -306,7 +309,7 @@ var AiExplain = function AiExplain(_ref) {
306
309
  }, _callee, null, [[4, 11]]);
307
310
  }));
308
311
  return function handleVoice(_x) {
309
- return _ref2.apply(this, arguments);
312
+ return _ref3.apply(this, arguments);
310
313
  };
311
314
  }();
312
315
 
@@ -360,7 +363,7 @@ var AiExplain = function AiExplain(_ref) {
360
363
  return mergedList;
361
364
  }
362
365
  var initClient = /*#__PURE__*/function () {
363
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
366
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
364
367
  var _data$VoiceChat;
365
368
  var res, data, rtc, startVoiceChatParams, stopVoiceChatParams, client;
366
369
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
@@ -499,12 +502,12 @@ var AiExplain = function AiExplain(_ref) {
499
502
  unsupportedShownRef.current = true;
500
503
  }
501
504
  Toast.warning({
502
- id: UNSUPPORTED_CALL_MSG_KEY,
503
505
  content: '后续流程暂不支持通话展示,可挂断后继续',
504
506
  duration: 0,
505
507
  style: {
506
508
  marginTop: '30vh'
507
- }
509
+ },
510
+ zIndex: 1000
508
511
  });
509
512
  return;
510
513
  }
@@ -579,13 +582,13 @@ var AiExplain = function AiExplain(_ref) {
579
582
  }, _callee2, null, [[0, 5]]);
580
583
  }));
581
584
  return function initClient() {
582
- return _ref3.apply(this, arguments);
585
+ return _ref4.apply(this, arguments);
583
586
  };
584
587
  }();
585
588
 
586
589
  // 断开连接
587
590
  var handleDisconnect = /*#__PURE__*/function () {
588
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
591
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
589
592
  var _clientRef$current3, _clientRef$current4;
590
593
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
591
594
  while (1) switch (_context3.prev = _context3.next) {
@@ -619,12 +622,12 @@ var AiExplain = function AiExplain(_ref) {
619
622
  }, _callee3, null, [[0, 9]]);
620
623
  }));
621
624
  return function handleDisconnect() {
622
- return _ref4.apply(this, arguments);
625
+ return _ref5.apply(this, arguments);
623
626
  };
624
627
  }();
625
628
  // 启动 RTC 连接、初始化客户端、加入房间
626
629
  var handleConnect = /*#__PURE__*/function () {
627
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
630
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
628
631
  var _clientRef$current5, _ref1$current;
629
632
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
630
633
  while (1) switch (_context4.prev = _context4.next) {
@@ -665,12 +668,12 @@ var AiExplain = function AiExplain(_ref) {
665
668
  }, _callee4, null, [[0, 9]]);
666
669
  }));
667
670
  return function handleConnect() {
668
- return _ref5.apply(this, arguments);
671
+ return _ref6.apply(this, arguments);
669
672
  };
670
673
  }();
671
674
  // 重新连接逻辑
672
675
  var reconnect = /*#__PURE__*/function () {
673
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
676
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
674
677
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
675
678
  while (1) switch (_context5.prev = _context5.next) {
676
679
  case 0:
@@ -686,7 +689,7 @@ var AiExplain = function AiExplain(_ref) {
686
689
  }, _callee5);
687
690
  }));
688
691
  return function reconnect() {
689
- return _ref6.apply(this, arguments);
692
+ return _ref7.apply(this, arguments);
690
693
  };
691
694
  }();
692
695
 
@@ -718,7 +721,7 @@ var AiExplain = function AiExplain(_ref) {
718
721
  }, 400);
719
722
  // 返回文字对话并断连接
720
723
  var handleBack = /*#__PURE__*/function () {
721
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
724
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
722
725
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
723
726
  while (1) switch (_context6.prev = _context6.next) {
724
727
  case 0:
@@ -744,12 +747,12 @@ var AiExplain = function AiExplain(_ref) {
744
747
  }, _callee6);
745
748
  }));
746
749
  return function handleBack() {
747
- return _ref7.apply(this, arguments);
750
+ return _ref8.apply(this, arguments);
748
751
  };
749
752
  }();
750
753
  /** 获取用户是否是首次进入 */
751
754
  var getUserFirstUseInfo = /*#__PURE__*/function () {
752
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
755
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
753
756
  var res;
754
757
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
755
758
  while (1) switch (_context7.prev = _context7.next) {
@@ -782,7 +785,7 @@ var AiExplain = function AiExplain(_ref) {
782
785
  }, _callee7, null, [[0, 9]]);
783
786
  }));
784
787
  return function getUserFirstUseInfo() {
785
- return _ref8.apply(this, arguments);
788
+ return _ref9.apply(this, arguments);
786
789
  };
787
790
  }();
788
791
 
@@ -900,7 +903,7 @@ var AiExplain = function AiExplain(_ref) {
900
903
  useEffect(function () {
901
904
  // 监听页面可见性变化(比如用户切到其他标签页)
902
905
  var handleVisibilityChange = /*#__PURE__*/function () {
903
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
906
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
904
907
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
905
908
  while (1) switch (_context8.prev = _context8.next) {
906
909
  case 0:
@@ -926,13 +929,13 @@ var AiExplain = function AiExplain(_ref) {
926
929
  }, _callee8);
927
930
  }));
928
931
  return function handleVisibilityChange() {
929
- return _ref9.apply(this, arguments);
932
+ return _ref10.apply(this, arguments);
930
933
  };
931
934
  }();
932
935
  // 获取用户首次使用信息
933
936
  getUserFirstUseInfo();
934
937
  var handleLineChange = /*#__PURE__*/function () {
935
- var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
938
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
936
939
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
937
940
  while (1) switch (_context9.prev = _context9.next) {
938
941
  case 0:
@@ -949,7 +952,7 @@ var AiExplain = function AiExplain(_ref) {
949
952
  }, _callee9);
950
953
  }));
951
954
  return function handleLineChange() {
952
- return _ref10.apply(this, arguments);
955
+ return _ref11.apply(this, arguments);
953
956
  };
954
957
  }();
955
958
  // 挂载时绑定监听
@@ -974,12 +977,12 @@ var AiExplain = function AiExplain(_ref) {
974
977
  placement: "bottomRight",
975
978
  overlayClassName: "out-tooltip ai-chat-tooltip",
976
979
  visible: isFirstUse,
977
- title: showCaptions ? '点击可关闭字幕' : '点击可开启字幕'
980
+ content: showCaptions ? '点击可关闭字幕' : '点击可开启字幕'
978
981
  }, /*#__PURE__*/React.createElement("div", {
979
982
  className: styles.rightWrap
980
983
  }, /*#__PURE__*/React.createElement(Tooltip, {
981
984
  placement: "bottom",
982
- title: showCaptions ? '关闭字幕' : '打开字幕',
985
+ content: showCaptions ? '关闭字幕' : '打开字幕',
983
986
  overlayClassName: "ai-chat-tooltip"
984
987
  }, /*#__PURE__*/React.createElement("div", {
985
988
  className: styles.iconWrap
@@ -1023,11 +1026,11 @@ var AiExplain = function AiExplain(_ref) {
1023
1026
  }, /*#__PURE__*/React.createElement(Tooltip, {
1024
1027
  placement: "top",
1025
1028
  visible: isFirstUse,
1026
- title: audioEnabled ? '关闭麦克风' : '打开麦克风',
1029
+ content: audioEnabled ? '关闭麦克风' : '打开麦克风',
1027
1030
  overlayClassName: "ai-chat-tooltip"
1028
1031
  }, /*#__PURE__*/React.createElement(Tooltip, {
1029
1032
  placement: "top",
1030
- title: audioEnabled ? '关闭麦克风' : '打开麦克风',
1033
+ content: audioEnabled ? '关闭麦克风' : '打开麦克风',
1031
1034
  overlayClassName: "ai-chat-tooltip"
1032
1035
  }, /*#__PURE__*/React.createElement("div", {
1033
1036
  className: classNames(styles.btnItem, isDisable ? styles.disable : ''),
@@ -1040,11 +1043,11 @@ var AiExplain = function AiExplain(_ref) {
1040
1043
  })))), /*#__PURE__*/React.createElement(Tooltip, {
1041
1044
  placement: "top",
1042
1045
  visible: isFirstUse,
1043
- title: '挂断电话',
1046
+ content: '挂断电话',
1044
1047
  overlayClassName: "ai-chat-tooltip"
1045
1048
  }, /*#__PURE__*/React.createElement(Tooltip, {
1046
1049
  placement: "top",
1047
- title: '挂断电话',
1050
+ content: '挂断电话',
1048
1051
  overlayClassName: "ai-chat-tooltip"
1049
1052
  }, /*#__PURE__*/React.createElement("div", {
1050
1053
  className: styles.btnItem,
@@ -1,6 +1,6 @@
1
1
  @charset "UTF-8";
2
2
  .aiChat {
3
- z-index: 99999;
3
+ z-index: 999;
4
4
  position: fixed;
5
5
  inset: 0;
6
6
  }
@@ -32,7 +32,7 @@ interface IAIInputProps {
32
32
  titleSlot?: string;
33
33
  showDefaultPrompt?: boolean;
34
34
  onConversationCreated?: (conversationId: number) => void;
35
- onMicHangUp?: () => void;
35
+ onMicHangUp?: () => boolean;
36
36
  initQuoteSource?: {
37
37
  teachModelId: number;
38
38
  teachModelName: string;
@@ -15,7 +15,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
15
15
  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; }
16
16
  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; } }
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
- import React from "react";
18
+ import React, { useContext } from "react";
19
19
  import { AIChatInput, Divider } from '@douyinfe/semi-ui';
20
20
  import { transformToInputSlots } from "../../utils/chatInputUtil";
21
21
  import VoiceCheckDialog from "../voice-check-dialog";
@@ -29,7 +29,7 @@ import FileUpload from "../file-upload";
29
29
  import { useAppSelector, useAppDispatch } from "../../store/hooks";
30
30
  import { setAutoLoadConversation, setConversationId, setFileList } from "../../store/slices/gimiMenuSlice";
31
31
  import { Toast } from "@douyinfe/semi-ui";
32
- import useApi from "../../apis/useApi";
32
+ import ChatContext from "../templates/chatContext";
33
33
  import UploadList from "../upload-list";
34
34
  import { FileStatus } from "../../interfaces/fileInterface";
35
35
  import LottieImg from "../lottie-img";
@@ -97,8 +97,10 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
97
97
  _React$useState6 = _slicedToArray(_React$useState5, 2),
98
98
  hasContent = _React$useState6[0],
99
99
  setHasContent = _React$useState6[1];
100
- var _useApi = useApi(),
101
- createRoomId = _useApi.createRoomId;
100
+ var _useContext = useContext(ChatContext),
101
+ apiService = _useContext.apiService;
102
+ var _ref = apiService,
103
+ createRoomId = _ref.createRoomId;
102
104
  React.useEffect(function () {
103
105
  var _props$defaultPrompt;
104
106
  if (!props.defaultPrompt) return;
@@ -279,7 +281,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
279
281
  }, _callee, null, [[2, 7], [13, 20]]);
280
282
  })), [dispatch, isMsgRecieving, props, bussinessParams]);
281
283
  var stopRecording = React.useCallback( /*#__PURE__*/function () {
282
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(enableInput) {
284
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(enableInput) {
283
285
  var _props$shortAsrClick;
284
286
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
285
287
  while (1) switch (_context2.prev = _context2.next) {
@@ -293,7 +295,7 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
293
295
  }, _callee2);
294
296
  }));
295
297
  return function (_x) {
296
- return _ref2.apply(this, arguments);
298
+ return _ref3.apply(this, arguments);
297
299
  };
298
300
  }(), [props]);
299
301
  var VoiceTools = React.useMemo(function () {
@@ -407,16 +409,18 @@ var ChatInput = /*#__PURE__*/React.forwardRef(function (props, ref) {
407
409
  }, "\u6B63\u5728\u83B7\u53D6\u8BED\u97F3\u5185\u5BB9...")));
408
410
  }, [fileList, props.isRecording, props.isVoiceGetting, messageList, quoteProductList, quoteTeachModelList, handleDelFile, handleReTry]);
409
411
  var handleHangUp = function handleHangUp() {
410
- var _props$onHistoryReloa;
412
+ var continueFlag = true;
411
413
  if (props.onMicHangUp) {
412
- props.onMicHangUp();
413
- return;
414
+ continueFlag = props.onMicHangUp();
414
415
  }
415
416
  // 重置自动加载会话设置
416
417
  dispatch(setAutoLoadConversation({
417
418
  autoLoadConversation: true
418
419
  }));
419
- (_props$onHistoryReloa = props.onHistoryReload) === null || _props$onHistoryReloa === void 0 || _props$onHistoryReloa.call(props);
420
+ if (continueFlag) {
421
+ var _props$onHistoryReloa;
422
+ (_props$onHistoryReloa = props.onHistoryReload) === null || _props$onHistoryReloa === void 0 || _props$onHistoryReloa.call(props);
423
+ }
420
424
  };
421
425
  var handleInterrupt = function handleInterrupt() {
422
426
  var _props$onInterrupt;
@@ -30,6 +30,9 @@ var KonwledgeTrace = function KonwledgeTrace(_ref) {
30
30
  var konwledgeTraceState = useAppSelector(function (state) {
31
31
  return state.gimiMenu.konwledgeTraceState;
32
32
  });
33
+ var isMsgRecieving = useAppSelector(function (state) {
34
+ return state.gimiMenu.isMsgRecieving;
35
+ });
33
36
  var dispatch = useAppDispatch();
34
37
  var _React$useState = React.useState([]),
35
38
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -71,7 +74,7 @@ var KonwledgeTrace = function KonwledgeTrace(_ref) {
71
74
  });
72
75
  }
73
76
  }, [kowledgeTraceList]);
74
- var _useKnowledgeService = useKnowledgeService(kowledgeTraceList),
77
+ var _useKnowledgeService = useKnowledgeService(kowledgeTraceList, isMsgRecieving),
75
78
  videoSliceList = _useKnowledgeService.videoSliceList,
76
79
  documentList = _useKnowledgeService.documentList,
77
80
  productList = _useKnowledgeService.productList,