@myun/gimi-chat 0.9.11 → 0.9.13
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/useApi.js +3 -1
- package/dist/components/answer-item/index.js +13 -0
- package/dist/components/custom-render/WordCard.d.ts +8 -0
- package/dist/components/custom-render/WordCard.js +62 -0
- package/dist/components/excel-components/ExcelSuccessCard.js +1 -1
- package/dist/components/file-card/index.d.ts +2 -0
- package/dist/components/file-card/index.js +14 -5
- package/dist/hooks/useChatStream.js +3 -1
- package/dist/hooks/useCommonChatAPI.js +3 -2
- package/dist/i18n/locales/en-US.js +1 -1
- package/dist/i18n/locales/zh-CN.js +1 -1
- package/dist/umd/index.min.js +1 -1
- package/dist/utils/tools.d.ts +1 -0
- package/dist/utils/tools.js +13 -1
- package/package.json +1 -1
package/dist/apis/useApi.js
CHANGED
|
@@ -3,6 +3,7 @@ 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 { getTimeZone } from "../utils/tools";
|
|
6
7
|
var useApi = function useApi(baseUrl, authToken) {
|
|
7
8
|
var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'zh-cn';
|
|
8
9
|
var token = authToken;
|
|
@@ -14,7 +15,8 @@ var useApi = function useApi(baseUrl, authToken) {
|
|
|
14
15
|
'Authorization': 'Bearer ' + token,
|
|
15
16
|
'X-Mc-Domain': location.hostname,
|
|
16
17
|
'Content-Type': 'application/json',
|
|
17
|
-
'Language': locale
|
|
18
|
+
'Language': locale,
|
|
19
|
+
'X-Timezone': getTimeZone()
|
|
18
20
|
}
|
|
19
21
|
});
|
|
20
22
|
var getAiCorrection = /*#__PURE__*/function () {
|
|
@@ -10,6 +10,7 @@ import WorkFlowContent from "../work-flow-content";
|
|
|
10
10
|
import ExcelSuccessCard from "../excel-components/ExcelSuccessCard";
|
|
11
11
|
import KnowledgeIconGroup from "../knowledge-trace/KnowledgeIconComponent";
|
|
12
12
|
import ExcelCard from "../excel-components/ExcelCard";
|
|
13
|
+
import WordCard from "../custom-render/WordCard";
|
|
13
14
|
import { IconTickCircle } from '@douyinfe/semi-icons';
|
|
14
15
|
import VoicePlay from "../message-actions/VoicePlay";
|
|
15
16
|
import { useAppSelector } from "../../store/hooks";
|
|
@@ -111,6 +112,18 @@ var AnswerItem = function AnswerItem(_ref) {
|
|
|
111
112
|
value: newVal
|
|
112
113
|
});
|
|
113
114
|
}
|
|
115
|
+
}, {
|
|
116
|
+
type: 'word',
|
|
117
|
+
component: function component(value) {
|
|
118
|
+
var newVal = {
|
|
119
|
+
content: value.value,
|
|
120
|
+
onDownloadCallback: onDownloadCallback,
|
|
121
|
+
model: model
|
|
122
|
+
};
|
|
123
|
+
return /*#__PURE__*/React.createElement(WordCard, {
|
|
124
|
+
value: newVal
|
|
125
|
+
});
|
|
126
|
+
}
|
|
114
127
|
}, {
|
|
115
128
|
type: 'knowledge',
|
|
116
129
|
component: function component(value) {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { FileCard, MultipleFileCard } from "../file-card";
|
|
4
|
+
var transforata = function transforata(data, t) {
|
|
5
|
+
var fileName = data.fileName || t('excel.defaultFileName') + '.docx';
|
|
6
|
+
var size = data.size || '0.0KB';
|
|
7
|
+
var downloadUrl = data.fileAddr || '';
|
|
8
|
+
var tempArr = fileName.split('.');
|
|
9
|
+
var fileType = (tempArr === null || tempArr === void 0 ? void 0 : tempArr.length) > 1 ? tempArr.pop() : 'docx';
|
|
10
|
+
return {
|
|
11
|
+
fileName: fileName,
|
|
12
|
+
fileType: fileType,
|
|
13
|
+
size: size,
|
|
14
|
+
downloadUrl: downloadUrl
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var WordCard = function WordCard(_ref) {
|
|
18
|
+
var _detail, _detail2;
|
|
19
|
+
var value = _ref.value;
|
|
20
|
+
var _useTranslation = useTranslation(),
|
|
21
|
+
t = _useTranslation.t;
|
|
22
|
+
var _ref2 = value || {},
|
|
23
|
+
content = _ref2.content,
|
|
24
|
+
onDownloadCallback = _ref2.onDownloadCallback,
|
|
25
|
+
model = _ref2.model;
|
|
26
|
+
var detail = {};
|
|
27
|
+
try {
|
|
28
|
+
detail = typeof content === 'string' ? JSON.parse(content) : content;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error(error);
|
|
31
|
+
return content;
|
|
32
|
+
}
|
|
33
|
+
if (((_detail = detail) === null || _detail === void 0 ? void 0 : _detail.code) !== 0) return content;
|
|
34
|
+
var skillDetail = ((_detail2 = detail) === null || _detail2 === void 0 || (_detail2 = _detail2.data) === null || _detail2 === void 0 ? void 0 : _detail2.list) || [];
|
|
35
|
+
if (Array.isArray(skillDetail)) {
|
|
36
|
+
var renderData = skillDetail.map(function (item) {
|
|
37
|
+
return transforata(item, t);
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/React.createElement(MultipleFileCard, {
|
|
40
|
+
list: renderData,
|
|
41
|
+
onDownloadCallback: onDownloadCallback,
|
|
42
|
+
model: model,
|
|
43
|
+
showAll: true
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
var _transforata = transforata(skillDetail, t),
|
|
47
|
+
fileName = _transforata.fileName,
|
|
48
|
+
downloadUrl = _transforata.downloadUrl,
|
|
49
|
+
size = _transforata.size,
|
|
50
|
+
fileType = _transforata.fileType;
|
|
51
|
+
return /*#__PURE__*/React.createElement(FileCard, {
|
|
52
|
+
fileName: fileName,
|
|
53
|
+
fileType: fileType,
|
|
54
|
+
size: size,
|
|
55
|
+
downloadUrl: downloadUrl,
|
|
56
|
+
downloadText: t('excel.download'),
|
|
57
|
+
onDownloadCallback: onDownloadCallback,
|
|
58
|
+
model: model,
|
|
59
|
+
disablePreview: true
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
export default WordCard;
|
|
@@ -2,7 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { useTranslation } from 'react-i18next';
|
|
3
3
|
import { FileCard, MultipleFileCard } from "../file-card";
|
|
4
4
|
var transforata = function transforata(data, t) {
|
|
5
|
-
var fileName = data.file_name || t('excel.defaultFileName');
|
|
5
|
+
var fileName = data.file_name || t('excel.defaultFileName') + '.xlsx';
|
|
6
6
|
var size = data.size || '0.0KB';
|
|
7
7
|
var downloadUrl = data.result_url || '';
|
|
8
8
|
var tempArr = fileName.split('.');
|
|
@@ -9,10 +9,12 @@ export interface IFileCardProps {
|
|
|
9
9
|
export declare const FileCard: React.FC<IFileCardProps & {
|
|
10
10
|
downloadText?: string;
|
|
11
11
|
model: 'fullscreen' | 'sidebar';
|
|
12
|
+
disablePreview?: boolean;
|
|
12
13
|
}>;
|
|
13
14
|
export declare const MultipleFileCard: React.FC<{
|
|
14
15
|
list: IFileCardProps[];
|
|
15
16
|
onDownloadCallback?: () => void;
|
|
16
17
|
model: 'fullscreen' | 'sidebar';
|
|
18
|
+
showAll?: boolean;
|
|
17
19
|
}>;
|
|
18
20
|
export default MultipleFileCard;
|
|
@@ -14,16 +14,23 @@ export var FileCard = function FileCard(_ref) {
|
|
|
14
14
|
fileType = _ref.fileType,
|
|
15
15
|
downloadText = _ref.downloadText,
|
|
16
16
|
onDownloadCallback = _ref.onDownloadCallback,
|
|
17
|
-
model = _ref.model
|
|
17
|
+
model = _ref.model,
|
|
18
|
+
_ref$disablePreview = _ref.disablePreview,
|
|
19
|
+
disablePreview = _ref$disablePreview === void 0 ? false : _ref$disablePreview;
|
|
18
20
|
var _useTranslation = useTranslation(),
|
|
19
21
|
t = _useTranslation.t;
|
|
20
22
|
var dispatch = useAppDispatch();
|
|
23
|
+
var fileImgMap = {
|
|
24
|
+
"docx": "https://simg01.gaodunwangxiao.com/uploadfiles/tmp/upload/202604/22/2fe5c_20260422110615.png",
|
|
25
|
+
"xlsx": "https://simg01.gaodunwangxiao.com/uploadimgs/tmp/upload/202512/19/b8723_20251219094824.png"
|
|
26
|
+
};
|
|
21
27
|
var handleDownLoad = function handleDownLoad(_event) {
|
|
22
28
|
_event.stopPropagation();
|
|
23
|
-
downloadExcelByUrl(downloadUrl, decodeURIComponent(fileName) || t('file.defaultFileName'));
|
|
29
|
+
downloadExcelByUrl(downloadUrl, decodeURIComponent(fileName) || t('file.defaultFileName') + '.' + fileType);
|
|
24
30
|
onDownloadCallback === null || onDownloadCallback === void 0 || onDownloadCallback();
|
|
25
31
|
};
|
|
26
32
|
var previewExcel = function previewExcel() {
|
|
33
|
+
if (disablePreview) return;
|
|
27
34
|
if (model === 'sidebar') {
|
|
28
35
|
window.open("https://view.officeapps.live.com/op/embed.aspx?src=".concat(encodeURIComponent(downloadUrl)), '_blank');
|
|
29
36
|
return;
|
|
@@ -42,7 +49,7 @@ export var FileCard = function FileCard(_ref) {
|
|
|
42
49
|
}, /*#__PURE__*/React.createElement("div", {
|
|
43
50
|
className: styles.icon
|
|
44
51
|
}, /*#__PURE__*/React.createElement("img", {
|
|
45
|
-
src:
|
|
52
|
+
src: fileImgMap[fileType] || fileImgMap['xlsx'],
|
|
46
53
|
alt: ""
|
|
47
54
|
})), /*#__PURE__*/React.createElement("div", {
|
|
48
55
|
className: styles.left
|
|
@@ -72,12 +79,14 @@ export var FileCard = function FileCard(_ref) {
|
|
|
72
79
|
export var MultipleFileCard = function MultipleFileCard(_ref2) {
|
|
73
80
|
var list = _ref2.list,
|
|
74
81
|
onDownloadCallback = _ref2.onDownloadCallback,
|
|
75
|
-
model = _ref2.model
|
|
82
|
+
model = _ref2.model,
|
|
83
|
+
_ref2$showAll = _ref2.showAll,
|
|
84
|
+
showAll = _ref2$showAll === void 0 ? false : _ref2$showAll;
|
|
76
85
|
var dispatch = useAppDispatch();
|
|
77
86
|
var _useTranslation2 = useTranslation(),
|
|
78
87
|
t = _useTranslation2.t;
|
|
79
88
|
var renderList = [];
|
|
80
|
-
var hasMore = (list === null || list === void 0 ? void 0 : list.length) > 2;
|
|
89
|
+
var hasMore = !showAll && (list === null || list === void 0 ? void 0 : list.length) > 2;
|
|
81
90
|
if (hasMore) {
|
|
82
91
|
renderList = list.slice(0, 2);
|
|
83
92
|
} else {
|
|
@@ -14,6 +14,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
14
14
|
import { useLastEventId } from "./useLastEventId";
|
|
15
15
|
import { useAppSelector, useAppDispatch } from "../store/hooks";
|
|
16
16
|
import { setIsMsgRecieving } from "../store/slices/gimiMenuSlice";
|
|
17
|
+
import { getTimeZone } from "../utils/tools";
|
|
17
18
|
/**
|
|
18
19
|
* 处理流式聊天逻辑
|
|
19
20
|
*/
|
|
@@ -106,7 +107,8 @@ export var useChatStream = function useChatStream(platform) {
|
|
|
106
107
|
'Cache-Control': 'no-cache',
|
|
107
108
|
Connection: 'keep-alive',
|
|
108
109
|
Authorization: "Bearer ".concat(tokenRef.current),
|
|
109
|
-
'Language': i18n.language
|
|
110
|
+
'Language': i18n.language,
|
|
111
|
+
'X-Timezone': getTimeZone()
|
|
110
112
|
}, method === 'POST' ? {
|
|
111
113
|
'Content-Type': 'application/json'
|
|
112
114
|
} : {}),
|
|
@@ -24,7 +24,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
24
24
|
import { Toast } from "@douyinfe/semi-ui";
|
|
25
25
|
import { useAppDispatch, useAppSelector } from "../store/hooks";
|
|
26
26
|
import { setMessageList, setFileList, setConversationId, setAgentDetail, setBusinessParams, setAutoLoadConversation, updateState, closeSidebar } from "../store/slices/gimiMenuSlice";
|
|
27
|
-
import { fileValidation, parseMessageContent, processString } from "../utils/tools";
|
|
27
|
+
import { fileValidation, getTimeZone, parseMessageContent, processString } from "../utils/tools";
|
|
28
28
|
import { filterPropmptFromUserInput } from "../utils/tools";
|
|
29
29
|
import { useChatMessage } from "./useChatMessage";
|
|
30
30
|
import { useChatStream } from "./useChatStream";
|
|
@@ -738,7 +738,8 @@ var useCommonChatAPI = function useCommonChatAPI(props) {
|
|
|
738
738
|
headers: {
|
|
739
739
|
'Content-Type': 'application/json',
|
|
740
740
|
Authorization: "Bearer ".concat(tokenRef.current),
|
|
741
|
-
'Language': i18n.language
|
|
741
|
+
'Language': i18n.language,
|
|
742
|
+
'X-Timezone': getTimeZone()
|
|
742
743
|
},
|
|
743
744
|
signal: signal,
|
|
744
745
|
body: JSON.stringify(params)
|
|
@@ -193,7 +193,7 @@ var enUS = {
|
|
|
193
193
|
'excel.finishing': 'Analysis complete. Result is being generated and prepared for presentation...',
|
|
194
194
|
'excel.finished': 'Analysis complete. Result is being generated and prepared for presentation',
|
|
195
195
|
'excel.retry': 'Retry',
|
|
196
|
-
'excel.defaultFileName': 'Download
|
|
196
|
+
'excel.defaultFileName': 'Download',
|
|
197
197
|
'excel.download': 'Download',
|
|
198
198
|
// AI Chat Dialogue
|
|
199
199
|
'aiDialogue.newConversation': 'New Chat',
|
|
@@ -193,7 +193,7 @@ var zhCN = {
|
|
|
193
193
|
'excel.finishing': '分析完成,结果载体即将生成,正准备呈现...',
|
|
194
194
|
'excel.finished': '分析完成,结果载体即将生成,正在准备呈现',
|
|
195
195
|
'excel.retry': '重试',
|
|
196
|
-
'excel.defaultFileName': '
|
|
196
|
+
'excel.defaultFileName': '文件下载',
|
|
197
197
|
'excel.download': '下载',
|
|
198
198
|
// AI Chat Dialogue
|
|
199
199
|
'aiDialogue.newConversation': '新对话',
|