@myun/gimi-chat 0.9.10 → 0.9.11

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.
@@ -64,5 +64,5 @@ export interface IUseApi {
64
64
  checkProductType: (productId: number) => Promise<FetchResponse<any>>;
65
65
  getBusinessAgent: (bussinessType: number) => Promise<FetchResponse<any>>;
66
66
  }
67
- declare const useApi: (baseUrl: string, authToken: string) => IUseApi;
67
+ declare const useApi: (baseUrl: string, authToken: string, locale?: string) => IUseApi;
68
68
  export default useApi;
@@ -4,6 +4,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
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
6
  var useApi = function useApi(baseUrl, authToken) {
7
+ var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'zh-cn';
7
8
  var token = authToken;
8
9
  var baseURL = baseUrl;
9
10
  var fetchService = createFetch({
@@ -12,7 +13,8 @@ var useApi = function useApi(baseUrl, authToken) {
12
13
  headers: {
13
14
  'Authorization': 'Bearer ' + token,
14
15
  'X-Mc-Domain': location.hostname,
15
- 'Content-Type': 'application/json'
16
+ 'Content-Type': 'application/json',
17
+ 'Language': locale
16
18
  }
17
19
  });
18
20
  var getAiCorrection = /*#__PURE__*/function () {
@@ -35,7 +35,7 @@ var GimiChatComponent = /*#__PURE__*/React.forwardRef(function (props, ref) {
35
35
  }
36
36
  };
37
37
  });
38
- var apiService = useApi(props.baseUrl, props.token);
38
+ var apiService = useApi(props.baseUrl, props.token, props.locale);
39
39
  return /*#__PURE__*/React.createElement(Provider, {
40
40
  store: store
41
41
  }, /*#__PURE__*/React.createElement(GimiChatI18nProvider, {
@@ -19,7 +19,8 @@ import { setIsMsgRecieving } from "../store/slices/gimiMenuSlice";
19
19
  */
20
20
  export var useChatStream = function useChatStream(platform) {
21
21
  var _useTranslation = useTranslation(),
22
- t = _useTranslation.t;
22
+ t = _useTranslation.t,
23
+ i18n = _useTranslation.i18n;
23
24
  var esAbortRef = useRef(null);
24
25
  var esRef = useRef(null);
25
26
  var ignoreOnMessageRef = useRef(true);
@@ -104,7 +105,8 @@ export var useChatStream = function useChatStream(platform) {
104
105
  Accept: 'text/event-stream',
105
106
  'Cache-Control': 'no-cache',
106
107
  Connection: 'keep-alive',
107
- Authorization: "Bearer ".concat(tokenRef.current)
108
+ Authorization: "Bearer ".concat(tokenRef.current),
109
+ 'Language': i18n.language
108
110
  }, method === 'POST' ? {
109
111
  'Content-Type': 'application/json'
110
112
  } : {}),
@@ -225,7 +227,7 @@ export var useChatStream = function useChatStream(platform) {
225
227
  return function (_x) {
226
228
  return _ref.apply(this, arguments);
227
229
  };
228
- }(), [getLastEventId, saveLastEventId, removeLastEventId, dispatch, platform]);
230
+ }(), [getLastEventId, saveLastEventId, removeLastEventId, dispatch, platform, i18n.language]);
229
231
 
230
232
  /**
231
233
  * 中止流式请求
@@ -36,7 +36,8 @@ import { FileStatus } from "../interfaces/fileInterface";
36
36
  import useChatHistory from "./useChatHistory";
37
37
  var useCommonChatAPI = function useCommonChatAPI(props) {
38
38
  var _useTranslation = useTranslation(),
39
- t = _useTranslation.t;
39
+ t = _useTranslation.t,
40
+ i18n = _useTranslation.i18n;
40
41
  var containerRef = props.containerRef,
41
42
  platform = props.platform,
42
43
  stopTTSByText = props.stopTTSByText,
@@ -736,7 +737,8 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
736
737
  method: 'POST',
737
738
  headers: {
738
739
  'Content-Type': 'application/json',
739
- Authorization: "Bearer ".concat(tokenRef.current)
740
+ Authorization: "Bearer ".concat(tokenRef.current),
741
+ 'Language': i18n.language
740
742
  },
741
743
  signal: signal,
742
744
  body: JSON.stringify(params)