paul-ai-assistant 1.0.2 → 1.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/6254.async.js +490 -490
- package/dist/7084.async.js +247 -0
- package/dist/customer-service-typewriter/index.html +44 -0
- package/dist/demos.async.js +384 -10
- package/dist/demos__customerServiceTypewriter__index.md.async.js +2 -0
- package/dist/dumi__tmp-production__dumi__theme__ContextWrapper.async.js +1 -1
- package/dist/meta__demos.async.js +1601 -1
- package/dist/meta__docs.async.js +29 -28
- package/dist/preload_helper.js +1 -1
- package/dist/umi.js +47 -47
- package/dist/~demos/demos-customer-service-typewriter-demo-customer-service-demo/index.html +44 -0
- package/dist/~demos/demos-customer-service-typewriter-demo-smart-scroll-demo/index.html +44 -0
- package/es/AssistantChat/AssistantChatApp/const.js +1 -1
- package/es/AssistantChat/AssistantChatApp/index.js +1 -1
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/component/TraceComponent.js +4 -4
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/index.js +4 -5
- package/es/AssistantChat/AssistantChatCard/LlmGenerateCard/index.js +2 -2
- package/es/AssistantChat/AssistantChatCard/LlmGenerateCardV5/index.js +1 -1
- package/es/AssistantChat/AssistantChatCard/OperationCard/Copy/index.js +1 -1
- package/es/AssistantChat/AssistantChatCard/OperationCard/CopyRequestId/index.js +1 -1
- package/es/AssistantChat/AssistantChatCard/OperationCard/FeedBack/index.js +2 -2
- package/es/AssistantChat/AssistantChatCard/OperationCard/ShareButton/index.js +1 -1
- package/es/AssistantChat/AssistantChatCard/OperationCard/index.js +1 -1
- package/es/AssistantChat/AssistantChatCard/UserQueryCardRender/AttachmentsRender.js +4 -4
- package/es/AssistantChat/AssistantChatCard/UserQueryCardRender/ImageRender.js +6 -6
- package/es/AssistantChat/AssistantChatInput/index.js +7 -5
- package/es/common/registerAssistChatForm.js +8 -5
- package/es/components/AgentCardSubmit/index.js +1 -2
- package/es/components/AgentResult/index.js +1 -1
- package/es/components/AgentSchemaForm/ScreenshotView.js +1 -1
- package/es/components/AgentSchemaForm/index.js +5 -5
- package/es/components/ArrayInput/index.js +1 -1
- package/es/components/InspectionCard/index.js +1 -1
- package/es/components/LlmMarkDown/MdAmarkGuess/index.js +1 -1
- package/es/components/LlmMarkDown/MdAmarkReference/index.js +3 -3
- package/es/components/LlmMarkDown/index.js +1 -1
- package/es/components/LlmModelChange/index.js +2 -2
- package/es/components/LlmReference/index.js +9 -9
- package/es/components/LlmTraceComponents/Disassemble/index.js +2 -2
- package/es/components/LlmTraceComponents/Rewrite/index.js +2 -2
- package/es/components/MarkDown/index.js +42 -13
- package/es/components/ModelSelect/ModeDropdown.js +1 -1
- package/es/components/ModelSelect/const.js +3 -3
- package/es/components/PaulButtonGroup/Select.js +2 -2
- package/es/components/PaulButtonGroup/index.js +2 -2
- package/es/components/PopAuth/index.js +2 -2
- package/es/components/SchemaInput/SchemaInputCore/index.js +1 -1
- package/es/components/SchemaInput/SimpleJSONEditor/index.js +1 -1
- package/es/components/SelectBlurry/index.js +2 -2
- package/es/components/ShareModal/index.js +2 -2
- package/es/components/ShareOperationBar/index.js +2 -2
- package/es/components/TextContent/index.js +3 -3
- package/es/components/TraceWithAgent/index.js +4 -9
- package/es/context/index.js +2 -1
- package/es/context/utils/messages.js +2 -2
- package/es/context/utils/send.js +3 -3
- package/es/context/utils/tool.js +2 -2
- package/es/utils/CSEIconTool.js +1 -1
- package/es/utils/apushAssistant.js +2 -3
- package/es/utils/clientPlugin.js +1 -1
- package/es/utils/common.js +17 -0
- package/es/utils/event.js +87 -0
- package/es/utils/formDataFormat.js +1 -1
- package/es/utils/formatData.js +1 -1
- package/es/utils/helpers.js +78 -0
- package/es/utils/log.js +1 -1
- package/es/utils/request.js +74 -0
- package/es/utils/send.js +1 -1
- package/es/utils/uploadImage.js +1 -1
- package/package.json +6 -19
- package/dist/2517.async.js +0 -247
- package/es/AssistantChat/AssistantChatApp/CardMatchRender/index.d.ts +0 -8
- package/es/AssistantChat/AssistantChatApp/OperationMatchRender/index.d.ts +0 -9
- package/es/AssistantChat/AssistantChatApp/const.d.ts +0 -51
- package/es/AssistantChat/AssistantChatApp/index.d.ts +0 -4
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/TemplateCard.d.ts +0 -3
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/common/types.d.ts +0 -3
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/component/TemplateHeader.d.ts +0 -5
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/component/TemplateHtml.d.ts +0 -7
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/component/TemplateParagraph.d.ts +0 -3
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/component/TemplateTitle.d.ts +0 -3
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/component/TraceComponent.d.ts +0 -3
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/context/index.d.ts +0 -29
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/index.d.ts +0 -4
- package/es/AssistantChat/AssistantChatCard/AgentCardRender/utils.d.ts +0 -2
- package/es/AssistantChat/AssistantChatCard/AgentCommonCard/index.d.ts +0 -4
- package/es/AssistantChat/AssistantChatCard/AgentExecutionCard/index.d.ts +0 -16
- package/es/AssistantChat/AssistantChatCard/LlmGenerateCard/index.d.ts +0 -14
- package/es/AssistantChat/AssistantChatCard/LlmGenerateCardV5/index.d.ts +0 -78
- package/es/AssistantChat/AssistantChatCard/OperationCard/AigcTipsRender/index.d.ts +0 -7
- package/es/AssistantChat/AssistantChatCard/OperationCard/Copy/index.d.ts +0 -7
- package/es/AssistantChat/AssistantChatCard/OperationCard/CopyRequestId/index.d.ts +0 -3
- package/es/AssistantChat/AssistantChatCard/OperationCard/FeedBack/index.d.ts +0 -11
- package/es/AssistantChat/AssistantChatCard/OperationCard/ShareButton/index.d.ts +0 -3
- package/es/AssistantChat/AssistantChatCard/OperationCard/index.d.ts +0 -4
- package/es/AssistantChat/AssistantChatCard/UserQueryCardRender/AttachmentsRender.d.ts +0 -21
- package/es/AssistantChat/AssistantChatCard/UserQueryCardRender/ImageRender.d.ts +0 -7
- package/es/AssistantChat/AssistantChatCard/UserQueryCardRender/index.d.ts +0 -8
- package/es/AssistantChat/AssistantChatCard/index.d.ts +0 -5
- package/es/AssistantChat/AssistantChatInput/index.d.ts +0 -5
- package/es/AssistantChat/AssistantToolApp/const.d.ts +0 -12
- package/es/AssistantChat/AssistantToolApp/index.d.ts +0 -4
- package/es/AssistantChat/AssistantToolExecutionApp/const.d.ts +0 -7
- package/es/AssistantChat/AssistantToolExecutionApp/index.d.ts +0 -4
- package/es/AssistantChat/AssistentError/index.d.ts +0 -5
- package/es/AssistantChat/index.d.ts +0 -6
- package/es/AssistantChat/logCallback/aTagLog.d.ts +0 -1
- package/es/AssistantChat/logCallback/copyLog.d.ts +0 -3
- package/es/ErrorBoundary/ErrorBoundaryFallback/index.d.ts +0 -5
- package/es/ErrorBoundary/index.d.ts +0 -22
- package/es/common/registerAssistChatForm.d.ts +0 -2
- package/es/components/AgentCardSubmit/index.d.ts +0 -20
- package/es/components/AgentResult/index.d.ts +0 -8
- package/es/components/AgentSchemaForm/ScreenshotView.d.ts +0 -12
- package/es/components/AgentSchemaForm/_interface.d.ts +0 -37
- package/es/components/AgentSchemaForm/index.d.ts +0 -9
- package/es/components/AgentText/index.d.ts +0 -4
- package/es/components/AigcTips/index.d.ts +0 -9
- package/es/components/ArrayInput/index.d.ts +0 -3
- package/es/components/AssistantDrawer/index.d.ts +0 -22
- package/es/components/EmptyIcon/index.d.ts +0 -3
- package/es/components/HeaderSvgIcon/index.d.ts +0 -3
- package/es/components/InspectionCard/index.d.ts +0 -66
- package/es/components/InspectionCard/result.d.ts +0 -13
- package/es/components/LlmMarkDown/MdAmarkGuess/index.d.ts +0 -16
- package/es/components/LlmMarkDown/MdAmarkReference/index.d.ts +0 -21
- package/es/components/LlmMarkDown/index.d.ts +0 -30
- package/es/components/LlmModelChange/index.d.ts +0 -57
- package/es/components/LlmReference/index.d.ts +0 -25
- package/es/components/LlmTitle/index.d.ts +0 -14
- package/es/components/LlmTrace/index.d.ts +0 -17
- package/es/components/LlmTraceComponents/Disassemble/index.d.ts +0 -24
- package/es/components/LlmTraceComponents/ReadResource/index.d.ts +0 -24
- package/es/components/LlmTraceComponents/Rewrite/index.d.ts +0 -23
- package/es/components/LlmTraceComponents/TraceMarkDown/index.d.ts +0 -22
- package/es/components/LlmTraceComponents/const.d.ts +0 -25
- package/es/components/LlmTraceV2/index.d.ts +0 -56
- package/es/components/LlmTraceV3/components/TraceContentComponents/BusinessFlow/index.d.ts +0 -13
- package/es/components/LlmTraceV3/components/TraceContentComponents/CodeBlock/index.d.ts +0 -18
- package/es/components/LlmTraceV3/components/TraceContentComponents/DeepThinking/index.d.ts +0 -13
- package/es/components/LlmTraceV3/components/TraceContentComponents/InfoMissing/index.d.ts +0 -13
- package/es/components/LlmTraceV3/components/TraceContentComponents/LinkList/index.d.ts +0 -20
- package/es/components/LlmTraceV3/components/TraceContentComponents/SearchResults/index.d.ts +0 -13
- package/es/components/LlmTraceV3/components/TraceContentComponents/TaskPlanning/index.d.ts +0 -12
- package/es/components/LlmTraceV3/components/TraceContentComponents/ToolCall/index.d.ts +0 -13
- package/es/components/LlmTraceV3/components/TraceContentComponents/ToolResult/index.d.ts +0 -13
- package/es/components/LlmTraceV3/components/TraceContentComponents/const.d.ts +0 -32
- package/es/components/LlmTraceV3/components/TraceGroup/index.d.ts +0 -8
- package/es/components/LlmTraceV3/components/TraceHeader/index.d.ts +0 -8
- package/es/components/LlmTraceV3/components/TraceItem/index.d.ts +0 -8
- package/es/components/LlmTraceV3/components/TraceSlide/index.d.ts +0 -30
- package/es/components/LlmTraceV3/components/TraceStatusIcon/index.d.ts +0 -8
- package/es/components/LlmTraceV3/hooks/useGroupCollapse.d.ts +0 -18
- package/es/components/LlmTraceV3/hooks/useItemCollapse.d.ts +0 -18
- package/es/components/LlmTraceV3/hooks/useTraceAnimation.d.ts +0 -15
- package/es/components/LlmTraceV3/hooks/useTraceCollapse.d.ts +0 -17
- package/es/components/LlmTraceV3/index.d.ts +0 -11
- package/es/components/LlmTraceV3/types.d.ts +0 -263
- package/es/components/LlmTraceV3/utils/collapseLogic.d.ts +0 -26
- package/es/components/LlmTraceV3/utils/traceHelpers.d.ts +0 -42
- package/es/components/MarkDown/index.d.ts +0 -11
- package/es/components/ModelSelect/ModeDropdown.d.ts +0 -8
- package/es/components/ModelSelect/const.d.ts +0 -30
- package/es/components/ModelSelect/index.d.ts +0 -4
- package/es/components/PaulButtonGroup/Select.d.ts +0 -3
- package/es/components/PaulButtonGroup/index.d.ts +0 -16
- package/es/components/PopAuth/index.d.ts +0 -4
- package/es/components/ReferenceInfoItem/index.d.ts +0 -49
- package/es/components/ReferenceTag/index.d.ts +0 -11
- package/es/components/SchemaInput/SchemaInputCore/index.d.ts +0 -4
- package/es/components/SchemaInput/SchemaInputCore/utils.d.ts +0 -1
- package/es/components/SchemaInput/SimpleJSONEditor/index.d.ts +0 -4
- package/es/components/SchemaInput/index.d.ts +0 -8
- package/es/components/SelectBlurry/index.d.ts +0 -3
- package/es/components/SendMessageSvgIcon/index.d.ts +0 -3
- package/es/components/ShareContent/index.d.ts +0 -21
- package/es/components/ShareModal/index.d.ts +0 -15
- package/es/components/ShareOperationBar/index.d.ts +0 -4
- package/es/components/TextContent/index.d.ts +0 -14
- package/es/components/TraceMarkdownWithCard/index.d.ts +0 -6
- package/es/components/TraceWithAgent/index.d.ts +0 -23
- package/es/constants/assistChatEvent.d.ts +0 -33
- package/es/constants/common.d.ts +0 -71
- package/es/constants/logTrace.d.ts +0 -3
- package/es/constants/reference.d.ts +0 -109
- package/es/constants/traceDataStatus.d.ts +0 -34
- package/es/context/index.d.ts +0 -13
- package/es/context/utils/messages.d.ts +0 -33
- package/es/context/utils/send.d.ts +0 -29
- package/es/context/utils/tool.d.ts +0 -19
- package/es/index.d.ts +0 -37
- package/es/interface/IAgent.d.ts +0 -12
- package/es/interface/IChatBottom.d.ts +0 -69
- package/es/interface/IChatCard.d.ts +0 -40
- package/es/interface/IChatContext.d.ts +0 -59
- package/es/interface/IChatRef.d.ts +0 -75
- package/es/interface/IGuessQuestion.d.ts +0 -43
- package/es/interface/IMessage.d.ts +0 -17
- package/es/interface/ISend.d.ts +0 -19
- package/es/interface/index.d.ts +0 -272
- package/es/utils/CSEIconTool.d.ts +0 -8
- package/es/utils/apushAssistant.d.ts +0 -73
- package/es/utils/clientPlugin.d.ts +0 -3
- package/es/utils/common.d.ts +0 -10
- package/es/utils/copyToClipboard.d.ts +0 -2
- package/es/utils/formDataFormat.d.ts +0 -3
- package/es/utils/formatData.d.ts +0 -14
- package/es/utils/log.d.ts +0 -18
- package/es/utils/parseUrl.d.ts +0 -9
- package/es/utils/screenshot.d.ts +0 -45
- package/es/utils/send.d.ts +0 -10
- package/es/utils/uploadImage.d.ts +0 -9
- package/es/utils/websocketLogger.d.ts +0 -176
|
@@ -7,10 +7,11 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
7
7
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
8
|
var _excluded = ["inline", "className", "children"],
|
|
9
9
|
_excluded2 = ["data", "linkTarget", "className"],
|
|
10
|
-
_excluded3 = ["remarkPlugins", "rehypePlugins", "components"]
|
|
10
|
+
_excluded3 = ["remarkPlugins", "rehypePlugins", "components", "previewImg"],
|
|
11
|
+
_excluded4 = ["node", "src", "alt"],
|
|
12
|
+
_excluded5 = ["node"];
|
|
11
13
|
import React, { useEffect, useRef } from 'react';
|
|
12
|
-
import { previewImg } from
|
|
13
|
-
import { MarkDown } from '@alife/magic-chat-ui';
|
|
14
|
+
import { previewImg } from "../../utils/helpers";
|
|
14
15
|
import katex from 'katex';
|
|
15
16
|
import mermaid from 'mermaid';
|
|
16
17
|
import rehypeHighlight from 'rehype-highlight';
|
|
@@ -19,6 +20,7 @@ import rehypeRaw from 'rehype-raw';
|
|
|
19
20
|
import remarkGfm from 'remark-gfm';
|
|
20
21
|
import remarkMath from 'remark-math';
|
|
21
22
|
import 'katex/dist/katex.min.css';
|
|
23
|
+
import ReactMarkdown from 'react-markdown';
|
|
22
24
|
import "./index.scss";
|
|
23
25
|
// LaTeX 渲染组件
|
|
24
26
|
var LatexBlock = function LatexBlock(_ref) {
|
|
@@ -190,6 +192,7 @@ export default (function (_ref5) {
|
|
|
190
192
|
var extraRemarkPlugins = otherProps.remarkPlugins,
|
|
191
193
|
extraRehypePlugins = otherProps.rehypePlugins,
|
|
192
194
|
extraComponents = otherProps.components,
|
|
195
|
+
customPreviewImg = otherProps.previewImg,
|
|
193
196
|
restProps = _objectWithoutProperties(otherProps, _excluded3);
|
|
194
197
|
var finalRemarkPlugins = [[remarkGfm, {
|
|
195
198
|
singleTilde: false
|
|
@@ -204,19 +207,45 @@ export default (function (_ref5) {
|
|
|
204
207
|
rehypeRaw,
|
|
205
208
|
// 继承默认:支持 HTML
|
|
206
209
|
rehypeKatex].concat(_toConsumableArray(extraRehypePlugins || []));
|
|
210
|
+
var defaultPreviewImg = function defaultPreviewImg(src) {
|
|
211
|
+
if (customPreviewImg) {
|
|
212
|
+
customPreviewImg(src);
|
|
213
|
+
} else {
|
|
214
|
+
previewImg(src);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
207
217
|
var finalComponents = _objectSpread({
|
|
208
|
-
code: CodeBlock
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return
|
|
218
|
+
code: CodeBlock,
|
|
219
|
+
// 自定义代码块,支持 Mermaid
|
|
220
|
+
img: function img(_ref6) {
|
|
221
|
+
var node = _ref6.node,
|
|
222
|
+
src = _ref6.src,
|
|
223
|
+
alt = _ref6.alt,
|
|
224
|
+
props = _objectWithoutProperties(_ref6, _excluded4);
|
|
225
|
+
return /*#__PURE__*/React.createElement("img", _extends({
|
|
226
|
+
src: src,
|
|
227
|
+
alt: alt,
|
|
228
|
+
onClick: function onClick() {
|
|
229
|
+
return defaultPreviewImg(src);
|
|
230
|
+
},
|
|
231
|
+
style: {
|
|
232
|
+
cursor: 'pointer'
|
|
233
|
+
}
|
|
234
|
+
}, props));
|
|
216
235
|
},
|
|
217
|
-
|
|
236
|
+
a: function a(_ref7) {
|
|
237
|
+
var node = _ref7.node,
|
|
238
|
+
props = _objectWithoutProperties(_ref7, _excluded5);
|
|
239
|
+
return /*#__PURE__*/React.createElement("a", _extends({
|
|
240
|
+
target: linkTarget
|
|
241
|
+
}, props));
|
|
242
|
+
}
|
|
243
|
+
}, extraComponents || {});
|
|
244
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
245
|
+
className: "assist-chat-markdown-content ".concat(className)
|
|
246
|
+
}, /*#__PURE__*/React.createElement(ReactMarkdown, _extends({
|
|
218
247
|
remarkPlugins: finalRemarkPlugins,
|
|
219
248
|
rehypePlugins: finalRehypePlugins,
|
|
220
249
|
components: finalComponents
|
|
221
|
-
}, restProps), data);
|
|
250
|
+
}, restProps), data));
|
|
222
251
|
});
|
|
@@ -6,7 +6,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
6
6
|
* @description 模式选择的Dropdown
|
|
7
7
|
*/
|
|
8
8
|
import React, { useEffect, useRef, useState } from 'react';
|
|
9
|
-
import { Dropdown, Tooltip } from '
|
|
9
|
+
import { Dropdown, Tooltip } from 'antd';
|
|
10
10
|
import classNames from 'classnames';
|
|
11
11
|
import { FEATURE_MODE_TYPE_KEY, FEATURE_MODE_TYPE_MAP } from "./const";
|
|
12
12
|
import "./index.scss";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { GlobalOutlined, AppstoreOutlined } from '@ant-design/icons';
|
|
4
4
|
export var AIGC_MODE_TYPE_V2 = {
|
|
5
5
|
REASONING_QWEN: 'REASONING_QWEN',
|
|
6
6
|
REASONING_DEEPSEEK: 'REASONING_DEEPSEEK'
|
|
@@ -13,7 +13,7 @@ export var FEATURE_MODE_TYPE_KEY = {
|
|
|
13
13
|
};
|
|
14
14
|
export var FEATURE_MODE_TYPE_MAP = _defineProperty(_defineProperty(_defineProperty({}, FEATURE_MODE_TYPE_KEY.AUTO, '自动'), FEATURE_MODE_TYPE_KEY.ON, '开'), FEATURE_MODE_TYPE_KEY.OFF, '关闭');
|
|
15
15
|
export var AIGC_MODE_TYPE_V2_LIST = [{
|
|
16
|
-
icon: /*#__PURE__*/React.createElement(
|
|
16
|
+
icon: /*#__PURE__*/React.createElement(AppstoreOutlined, null),
|
|
17
17
|
value: AIGC_MODE_TYPE_V2.REASONING_QWEN,
|
|
18
18
|
label: AIGC_MODE_TYPE_V2_MAP[AIGC_MODE_TYPE_V2.REASONING_QWEN],
|
|
19
19
|
balloonText: '',
|
|
@@ -36,7 +36,7 @@ export var AIGC_MODE_TYPE_V2_LIST = [{
|
|
|
36
36
|
describe: '快速直接回答问题'
|
|
37
37
|
}]
|
|
38
38
|
}, {
|
|
39
|
-
icon: /*#__PURE__*/React.createElement(
|
|
39
|
+
icon: /*#__PURE__*/React.createElement(GlobalOutlined, null),
|
|
40
40
|
value: AIGC_MODE_TYPE_V2.REASONING_DEEPSEEK,
|
|
41
41
|
label: AIGC_MODE_TYPE_V2_MAP[AIGC_MODE_TYPE_V2.REASONING_DEEPSEEK],
|
|
42
42
|
balloonText: '',
|
|
@@ -8,8 +8,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
8
8
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
9
9
|
var _excluded = ["value", "onChange", "apiConfig", "fieldMapping"];
|
|
10
10
|
import React, { useState } from 'react';
|
|
11
|
-
import { Select } from '
|
|
12
|
-
import { customRequest } from
|
|
11
|
+
import { Select } from 'antd';
|
|
12
|
+
import { customRequest } from "../../utils/request";
|
|
13
13
|
import { useDebounceFn } from 'ahooks';
|
|
14
14
|
import { get } from 'lodash';
|
|
15
15
|
export default (function (props) {
|
|
@@ -9,8 +9,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
9
9
|
* value: { {configId: 29, opType: 'createSubmit'}, title: "提交" }
|
|
10
10
|
*/
|
|
11
11
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
12
|
-
import { Button, Form, Input, Modal, Space } from '
|
|
13
|
-
import { customRequest } from
|
|
12
|
+
import { Button, Form, Input, Modal, Space } from 'antd';
|
|
13
|
+
import { customRequest } from "../../utils/request";
|
|
14
14
|
import { REQUEST_SUCCESS_CODE } from "../../constants/common";
|
|
15
15
|
import Select from "./Select";
|
|
16
16
|
import "./index.scss";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import React, { useEffect, useState } from 'react';
|
|
4
|
-
import { Button, message } from '
|
|
5
|
-
import { customRequest } from
|
|
4
|
+
import { Button, message } from 'antd';
|
|
5
|
+
import { customRequest } from "../../utils/request";
|
|
6
6
|
import { debounce } from 'lodash';
|
|
7
7
|
import "./index.scss";
|
|
8
8
|
var PopAuth = function PopAuth(props) {
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import React, { useEffect, useState } from 'react';
|
|
5
|
-
import { Input, Radio } from '
|
|
5
|
+
import { Input, Radio } from 'antd';
|
|
6
6
|
import SimpleJSONEditor from "../SimpleJSONEditor";
|
|
7
7
|
import "./index.scss";
|
|
8
8
|
function SchemaInputCore(props) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import { Input } from '
|
|
3
|
+
import { Input } from 'antd';
|
|
4
4
|
import "./index.scss";
|
|
5
5
|
function SimpleJSONEditor(props) {
|
|
6
6
|
var onChange = props.onChange,
|
|
@@ -4,8 +4,8 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
5
|
var _excluded = ["query", "dataApi", "fieldNames", "method"];
|
|
6
6
|
import React, { useEffect, useState } from 'react';
|
|
7
|
-
import { message, Select } from '
|
|
8
|
-
import { customRequest } from
|
|
7
|
+
import { message, Select } from 'antd';
|
|
8
|
+
import { customRequest } from "../../utils/request";
|
|
9
9
|
import { debounce } from 'lodash';
|
|
10
10
|
var SelectBlurry = function SelectBlurry(props) {
|
|
11
11
|
var query = props.query,
|
|
@@ -2,8 +2,8 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import React, { useContext, useState } from 'react';
|
|
5
|
-
import { Button, Input, message, Modal, Select } from '
|
|
6
|
-
import { customRequest } from
|
|
5
|
+
import { Button, Input, message, Modal, Select } from 'antd';
|
|
6
|
+
import { customRequest } from "../../utils/request";
|
|
7
7
|
import { AssistantChatContext } from "../../context";
|
|
8
8
|
import { CSECustomIcon } from "../../utils/CSEIconTool";
|
|
9
9
|
import ShareContent from "../ShareContent";
|
|
@@ -2,8 +2,8 @@ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import React, { useContext, useState } from 'react';
|
|
5
|
-
import { Button, message } from '
|
|
6
|
-
import { customRequest } from
|
|
5
|
+
import { Button, message } from 'antd';
|
|
6
|
+
import { customRequest } from "../../utils/request";
|
|
7
7
|
import { AssistantChatContext } from "../../context";
|
|
8
8
|
import { CSECustomIcon } from "../../utils/CSEIconTool";
|
|
9
9
|
import { processAgentCardRenderScreenshot } from "../../utils/screenshot";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
-
import { Button } from '
|
|
4
|
-
import {
|
|
3
|
+
import { Button } from 'antd';
|
|
4
|
+
import { DownOutlined, UpOutlined } from '@ant-design/icons';
|
|
5
5
|
import { formatTextContentHtml } from "../../utils/formatData";
|
|
6
6
|
import "./index.scss";
|
|
7
7
|
/**
|
|
@@ -32,6 +32,6 @@ var TextContent = function TextContent(props) {
|
|
|
32
32
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
33
33
|
type: "link",
|
|
34
34
|
onClick: toggleCollapse
|
|
35
|
-
}, collapse ? '查看更多' : '收起', collapse ? /*#__PURE__*/React.createElement(
|
|
35
|
+
}, collapse ? '查看更多' : '收起', collapse ? /*#__PURE__*/React.createElement(DownOutlined, null) : /*#__PURE__*/React.createElement(UpOutlined, null))));
|
|
36
36
|
};
|
|
37
37
|
export default TextContent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { TeamOutlined } from '@ant-design/icons';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import InspectionCard from "../InspectionCard";
|
|
7
7
|
import MarkDown from "../MarkDown";
|
|
@@ -69,15 +69,10 @@ var TraceWithAgent = function TraceWithAgent(props) {
|
|
|
69
69
|
className: "agent-content-item"
|
|
70
70
|
}, /*#__PURE__*/React.createElement("div", {
|
|
71
71
|
className: "agent-icon-tips"
|
|
72
|
-
},
|
|
73
|
-
size: "small",
|
|
72
|
+
}, /*#__PURE__*/React.createElement(TeamOutlined, {
|
|
74
73
|
style: {
|
|
75
|
-
marginRight: 3
|
|
76
|
-
|
|
77
|
-
}) : /*#__PURE__*/React.createElement(TeamF, {
|
|
78
|
-
size: "small",
|
|
79
|
-
style: {
|
|
80
|
-
marginRight: 3
|
|
74
|
+
marginRight: 3,
|
|
75
|
+
fontSize: 12
|
|
81
76
|
}
|
|
82
77
|
}), subItem.type === 'tool' ? '工具调用' : '业务流调用'), /*#__PURE__*/React.createElement("div", {
|
|
83
78
|
className: "agent-content-item-name"
|
package/es/context/index.js
CHANGED
|
@@ -7,7 +7,8 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
|
|
|
7
7
|
var _excluded = ["children", "bizId", "bizDomain", "locateAfterSingleMessageUpdate", "dataSource", "interruptLlmMessageScroll", "toolConfig", "placeholder", "messageCardWidth", "enableWsConnectCallback", "onSend", "assistantChat", "log", "logTrace", "messagesMaxLength", "mode", "activeToken", "onStopMessage", "imConnectCallback", "chatTitle", "isAssistant", "isThirdEmbed", "getApiHost"],
|
|
8
8
|
_excluded2 = ["chatType", "onSuccessCallback"];
|
|
9
9
|
import React, { createContext, useEffect, useRef, useState } from 'react';
|
|
10
|
-
import { event
|
|
10
|
+
import { event } from "../utils/event";
|
|
11
|
+
import { getWorkId } from "../utils/helpers";
|
|
11
12
|
import { FEATURE_MODE_TYPE_KEY } from "../components/ModelSelect/const";
|
|
12
13
|
import { ASSIST_CHAT_EVENT } from "../constants/assistChatEvent";
|
|
13
14
|
import { CHAT_TYPE, ChatTypeEnum, COPILOT_TOOL_TYPE_ENUM, initPlaceholder } from "../constants/common";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import { event } from
|
|
4
|
-
import { customRequest } from
|
|
3
|
+
import { event } from "../../utils/event";
|
|
4
|
+
import { customRequest } from "../../utils/request";
|
|
5
5
|
import { ASSIST_CHAT_EVENT } from "../../constants/assistChatEvent";
|
|
6
6
|
import { REQUEST_SUCCESS_CODE } from "../../constants/common";
|
|
7
7
|
import { countScrollDelay, locateToDialogId } from "../../utils/common";
|
package/es/context/utils/send.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import { message } from '
|
|
4
|
-
import { customRequest } from
|
|
5
|
-
import { getWorkId } from
|
|
3
|
+
import { message } from 'antd';
|
|
4
|
+
import { customRequest } from "../../utils/request";
|
|
5
|
+
import { getWorkId } from "../../utils/helpers";
|
|
6
6
|
import { AGENT_TPYE, CHAT_TYPE, REQUEST_SUCCESS_CODE, SEARCH_TYPE } from "../../constants/common";
|
|
7
7
|
import { LOG_TRACE_TYPE_ENUMS } from "../../constants/logTrace";
|
|
8
8
|
export var sendMessageRequest = function sendMessageRequest(_ref) {
|
package/es/context/utils/tool.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import { message } from '
|
|
4
|
-
import { customRequest } from
|
|
3
|
+
import { message } from 'antd';
|
|
4
|
+
import { customRequest } from "../../utils/request";
|
|
5
5
|
import { REQUEST_SUCCESS_CODE } from "../../constants/common";
|
|
6
6
|
|
|
7
7
|
// 工具搜索
|
package/es/utils/CSEIconTool.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var _window;
|
|
2
|
-
import { createFromIconfontCN } from '@
|
|
2
|
+
import { createFromIconfontCN } from '@ant-design/icons';
|
|
3
3
|
var CSECustomIcon = createFromIconfontCN({
|
|
4
4
|
scriptUrl: ((_window = window) === null || _window === void 0 ? void 0 : _window.uniqueIconfontSymbolUrl) || '//at.alicdn.com/t/a/font_2186508_s77dlziunf.js'
|
|
5
5
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { event } from
|
|
3
|
-
import
|
|
4
|
-
import { customRequest } from '@alife/magic-request';
|
|
2
|
+
import { event } from "./event";
|
|
3
|
+
import { customRequest } from "./request";
|
|
5
4
|
import { JsonParse } from "./formatData";
|
|
6
5
|
import { AesCustomLogEventEnum } from "./log";
|
|
7
6
|
import { logger } from "./websocketLogger";
|
package/es/utils/clientPlugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { customRequest } from
|
|
2
|
+
import { customRequest } from "./request";
|
|
3
3
|
export var sendMsgToPlugin = function sendMsgToPlugin(serviceId, executionId, values) {
|
|
4
4
|
window.dispatchEvent(new CustomEvent('TicketScriptEvent', {
|
|
5
5
|
detail: {
|
package/es/utils/common.js
CHANGED
|
@@ -6,6 +6,23 @@ export var getSelectedText = function getSelectedText() {
|
|
|
6
6
|
return (_window = window) === null || _window === void 0 || (_window = _window.getSelection()) === null || _window === void 0 ? void 0 : _window.toString();
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* 预览图片
|
|
11
|
+
* @param url 图片URL
|
|
12
|
+
*/
|
|
13
|
+
export var previewImg = function previewImg(url) {
|
|
14
|
+
if (!url) return;
|
|
15
|
+
var img = new Image();
|
|
16
|
+
img.src = url;
|
|
17
|
+
var newWindow = window.open('');
|
|
18
|
+
if (newWindow) {
|
|
19
|
+
newWindow.document.body.appendChild(img);
|
|
20
|
+
newWindow.document.title = '图片预览';
|
|
21
|
+
newWindow.document.body.style.cssText = 'margin: 0; display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f0f0f0;';
|
|
22
|
+
img.style.cssText = 'max-width: 100%; max-height: 100vh; object-fit: contain;';
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
9
26
|
// 滚动到指定消息
|
|
10
27
|
export var locateToDialogId = function locateToDialogId(dialogId) {
|
|
11
28
|
var element = document.getElementById(dialogId);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
/**
|
|
5
|
+
* @description 事件发布订阅工具,替代 @alife/goc-utils 的 event
|
|
6
|
+
*/
|
|
7
|
+
var EventEmitter = /*#__PURE__*/function () {
|
|
8
|
+
function EventEmitter() {
|
|
9
|
+
_classCallCheck(this, EventEmitter);
|
|
10
|
+
_defineProperty(this, "events", new Map());
|
|
11
|
+
}
|
|
12
|
+
_createClass(EventEmitter, [{
|
|
13
|
+
key: "on",
|
|
14
|
+
value:
|
|
15
|
+
/**
|
|
16
|
+
* 订阅事件
|
|
17
|
+
*/
|
|
18
|
+
function on(eventName, callback) {
|
|
19
|
+
if (!this.events.has(eventName)) {
|
|
20
|
+
this.events.set(eventName, new Set());
|
|
21
|
+
}
|
|
22
|
+
this.events.get(eventName).add(callback);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 取消订阅
|
|
27
|
+
*/
|
|
28
|
+
}, {
|
|
29
|
+
key: "off",
|
|
30
|
+
value: function off(eventName, callback) {
|
|
31
|
+
var callbacks = this.events.get(eventName);
|
|
32
|
+
if (callbacks) {
|
|
33
|
+
callbacks.delete(callback);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 发布事件
|
|
39
|
+
*/
|
|
40
|
+
}, {
|
|
41
|
+
key: "emit",
|
|
42
|
+
value: function emit(eventName) {
|
|
43
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
44
|
+
args[_key - 1] = arguments[_key];
|
|
45
|
+
}
|
|
46
|
+
var callbacks = this.events.get(eventName);
|
|
47
|
+
if (callbacks) {
|
|
48
|
+
callbacks.forEach(function (callback) {
|
|
49
|
+
try {
|
|
50
|
+
callback.apply(void 0, args);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error("Event callback error for \"".concat(eventName, "\":"), error);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 一次性订阅
|
|
60
|
+
*/
|
|
61
|
+
}, {
|
|
62
|
+
key: "once",
|
|
63
|
+
value: function once(eventName, callback) {
|
|
64
|
+
var _this = this;
|
|
65
|
+
var onceCallback = function onceCallback() {
|
|
66
|
+
callback.apply(void 0, arguments);
|
|
67
|
+
_this.off(eventName, onceCallback);
|
|
68
|
+
};
|
|
69
|
+
this.on(eventName, onceCallback);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 移除某个事件的所有监听器
|
|
74
|
+
*/
|
|
75
|
+
}, {
|
|
76
|
+
key: "removeAllListeners",
|
|
77
|
+
value: function removeAllListeners(eventName) {
|
|
78
|
+
if (eventName) {
|
|
79
|
+
this.events.delete(eventName);
|
|
80
|
+
} else {
|
|
81
|
+
this.events.clear();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}]);
|
|
85
|
+
return EventEmitter;
|
|
86
|
+
}(); // 导出单例
|
|
87
|
+
export var event = new EventEmitter();
|
package/es/utils/formatData.js
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 工具函数集合,替代 @alife/goc-utils
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 生成唯一ID
|
|
7
|
+
* 替代 getWorkId
|
|
8
|
+
*/
|
|
9
|
+
export var getWorkId = function getWorkId() {
|
|
10
|
+
return "".concat(Date.now(), "-").concat(Math.random().toString(36).substring(2, 11));
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 预览图片
|
|
15
|
+
* 替代 previewImg
|
|
16
|
+
*/
|
|
17
|
+
export var previewImg = function previewImg(url) {
|
|
18
|
+
if (!url) return;
|
|
19
|
+
|
|
20
|
+
// 创建预览容器
|
|
21
|
+
var overlay = document.createElement('div');
|
|
22
|
+
overlay.style.cssText = "\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.8);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 9999;\n cursor: zoom-out;\n ";
|
|
23
|
+
var img = document.createElement('img');
|
|
24
|
+
img.src = url;
|
|
25
|
+
img.style.cssText = "\n max-width: 90%;\n max-height: 90%;\n object-fit: contain;\n ";
|
|
26
|
+
overlay.appendChild(img);
|
|
27
|
+
document.body.appendChild(overlay);
|
|
28
|
+
|
|
29
|
+
// 点击关闭
|
|
30
|
+
overlay.addEventListener('click', function () {
|
|
31
|
+
document.body.removeChild(overlay);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// ESC 关闭
|
|
35
|
+
var handleKeydown = function handleKeydown(e) {
|
|
36
|
+
if (e.key === 'Escape') {
|
|
37
|
+
document.body.removeChild(overlay);
|
|
38
|
+
document.removeEventListener('keydown', handleKeydown);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
document.addEventListener('keydown', handleKeydown);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 将 URL 转换为链接
|
|
46
|
+
* 替代 urlToLink
|
|
47
|
+
*/
|
|
48
|
+
export var urlToLink = function urlToLink(text) {
|
|
49
|
+
if (!text) return '';
|
|
50
|
+
var urlRegex = /(https?:\/\/[^\s<>"{}|\\^`[\]]+)/g;
|
|
51
|
+
return text.replace(urlRegex, '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>');
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 检查是否为函数
|
|
56
|
+
* 替代 isFunc
|
|
57
|
+
*/
|
|
58
|
+
export var isFunc = function isFunc(fn) {
|
|
59
|
+
return typeof fn === 'function';
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 获取环境变量
|
|
64
|
+
* 替代 getEnv
|
|
65
|
+
*/
|
|
66
|
+
export var getEnv = function getEnv() {
|
|
67
|
+
var host = window.location.host;
|
|
68
|
+
if (host.includes('localhost') || host.includes('127.0.0.1')) {
|
|
69
|
+
return 'local';
|
|
70
|
+
}
|
|
71
|
+
if (host.includes('pre-') || host.includes('pre.')) {
|
|
72
|
+
return 'pre';
|
|
73
|
+
}
|
|
74
|
+
if (host.includes('daily') || host.includes('dev')) {
|
|
75
|
+
return 'daily';
|
|
76
|
+
}
|
|
77
|
+
return 'prod';
|
|
78
|
+
};
|
package/es/utils/log.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import { isFunc } from
|
|
2
|
+
import { isFunc } from "./helpers";
|
|
3
3
|
export var AesCustomLogEventEnum = /*#__PURE__*/function (AesCustomLogEventEnum) {
|
|
4
4
|
AesCustomLogEventEnum["APUSH_MSG"] = "apush-msg";
|
|
5
5
|
AesCustomLogEventEnum["APUSH_CONNECT"] = "apush-connect";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
|
+
/**
|
|
6
|
+
* @description HTTP 请求工具函数,替代 @alife/magic-request
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 自定义请求函数
|
|
11
|
+
* @param options 请求配置
|
|
12
|
+
* @returns Promise<any>
|
|
13
|
+
*/
|
|
14
|
+
export var customRequest = /*#__PURE__*/function () {
|
|
15
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
16
|
+
var method, url, query, _options$headers, headers, requestUrl, requestOptions, searchParams, queryString, response, data;
|
|
17
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
method = options.method, url = options.url, query = options.query, _options$headers = options.headers, headers = _options$headers === void 0 ? {} : _options$headers;
|
|
21
|
+
requestUrl = url;
|
|
22
|
+
requestOptions = {
|
|
23
|
+
method: method,
|
|
24
|
+
credentials: 'include',
|
|
25
|
+
headers: _objectSpread({
|
|
26
|
+
'Content-Type': 'application/json'
|
|
27
|
+
}, headers)
|
|
28
|
+
};
|
|
29
|
+
if (method === 'GET') {
|
|
30
|
+
// GET 请求:将 query 参数拼接到 URL
|
|
31
|
+
if (query && Object.keys(query).length > 0) {
|
|
32
|
+
searchParams = new URLSearchParams();
|
|
33
|
+
Object.entries(query).forEach(function (_ref2) {
|
|
34
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
35
|
+
key = _ref3[0],
|
|
36
|
+
value = _ref3[1];
|
|
37
|
+
if (value !== undefined && value !== null) {
|
|
38
|
+
searchParams.append(key, String(value));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
queryString = searchParams.toString();
|
|
42
|
+
requestUrl = url.includes('?') ? "".concat(url, "&").concat(queryString) : "".concat(url, "?").concat(queryString);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
// POST/PUT/DELETE 请求:将 query 作为请求体
|
|
46
|
+
if (query) {
|
|
47
|
+
requestOptions.body = JSON.stringify(query);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
_context.prev = 4;
|
|
51
|
+
_context.next = 7;
|
|
52
|
+
return fetch(requestUrl, requestOptions);
|
|
53
|
+
case 7:
|
|
54
|
+
response = _context.sent;
|
|
55
|
+
_context.next = 10;
|
|
56
|
+
return response.json();
|
|
57
|
+
case 10:
|
|
58
|
+
data = _context.sent;
|
|
59
|
+
return _context.abrupt("return", data);
|
|
60
|
+
case 14:
|
|
61
|
+
_context.prev = 14;
|
|
62
|
+
_context.t0 = _context["catch"](4);
|
|
63
|
+
console.error('Request failed:', _context.t0);
|
|
64
|
+
throw _context.t0;
|
|
65
|
+
case 18:
|
|
66
|
+
case "end":
|
|
67
|
+
return _context.stop();
|
|
68
|
+
}
|
|
69
|
+
}, _callee, null, [[4, 14]]);
|
|
70
|
+
}));
|
|
71
|
+
return function customRequest(_x) {
|
|
72
|
+
return _ref.apply(this, arguments);
|
|
73
|
+
};
|
|
74
|
+
}();
|
package/es/utils/send.js
CHANGED
package/es/utils/uploadImage.js
CHANGED
|
@@ -5,7 +5,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
5
5
|
* @author cherry.zj
|
|
6
6
|
* @description 图片上传和预览
|
|
7
7
|
*/
|
|
8
|
-
import { customRequest } from
|
|
8
|
+
import { customRequest } from "./request";
|
|
9
9
|
var queryDownloadUrl = function queryDownloadUrl(params) {
|
|
10
10
|
return customRequest({
|
|
11
11
|
method: 'GET',
|