test-chat-sdk 0.0.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.
Files changed (208) hide show
  1. package/.prettierrc.js +24 -0
  2. package/README.md +46 -0
  3. package/config/env.js +104 -0
  4. package/config/getHttpsConfig.js +66 -0
  5. package/config/jest/babelTransform.js +29 -0
  6. package/config/jest/cssTransform.js +14 -0
  7. package/config/jest/fileTransform.js +40 -0
  8. package/config/modules.js +134 -0
  9. package/config/paths.js +77 -0
  10. package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
  11. package/config/webpack.config.js +785 -0
  12. package/config/webpackDevServer.config.js +127 -0
  13. package/dist/Chat/AgentList/index.d.ts +9 -0
  14. package/dist/Chat/ChatFooter/index.d.ts +17 -0
  15. package/dist/Chat/Conversation/index.d.ts +11 -0
  16. package/dist/Chat/MessageContainer/index.d.ts +19 -0
  17. package/dist/Chat/MobileAgents/index.d.ts +11 -0
  18. package/dist/Chat/components/AgentTip/index.d.ts +8 -0
  19. package/dist/Chat/components/ConversationModal/index.d.ts +10 -0
  20. package/dist/Chat/components/CopilotAvatar/index.d.ts +2 -0
  21. package/dist/Chat/components/Message.d.ts +10 -0
  22. package/dist/Chat/components/RecommendQuestions/index.d.ts +6 -0
  23. package/dist/Chat/components/Text.d.ts +9 -0
  24. package/dist/Chat/constants.d.ts +19 -0
  25. package/dist/Chat/index.d.ts +17 -0
  26. package/dist/Chat/service.d.ts +11 -0
  27. package/dist/Chat/type.d.ts +97 -0
  28. package/dist/Copilot/constants.d.ts +11 -0
  29. package/dist/Copilot/index.d.ts +13 -0
  30. package/dist/ShowCase/index.d.ts +8 -0
  31. package/dist/ShowCase/service.d.ts +2 -0
  32. package/dist/ShowCase/type.d.ts +11 -0
  33. package/dist/common/constants.d.ts +58 -0
  34. package/dist/common/env.d.ts +3 -0
  35. package/dist/common/type.d.ts +247 -0
  36. package/dist/components/ChatItem/ExecuteItem.d.ts +25 -0
  37. package/dist/components/ChatItem/ExpandParseTip.d.ts +20 -0
  38. package/dist/components/ChatItem/FilterItem.d.ts +17 -0
  39. package/dist/components/ChatItem/Loading.d.ts +2 -0
  40. package/dist/components/ChatItem/ParseTip.d.ts +26 -0
  41. package/dist/components/ChatItem/ParseTipUtils.d.ts +10 -0
  42. package/dist/components/ChatItem/SimilarQuestionItem.d.ts +10 -0
  43. package/dist/components/ChatItem/SqlItem.d.ts +17 -0
  44. package/dist/components/ChatItem/SwitchEntity.d.ts +9 -0
  45. package/dist/components/ChatItem/Text.d.ts +6 -0
  46. package/dist/components/ChatItem/Typing.d.ts +2 -0
  47. package/dist/components/ChatItem/index.d.ts +33 -0
  48. package/dist/components/ChatMsg/ApplyAuth/index.d.ts +7 -0
  49. package/dist/components/ChatMsg/Bar/index.d.ts +13 -0
  50. package/dist/components/ChatMsg/DateOptions/index.d.ts +9 -0
  51. package/dist/components/ChatMsg/FilterSection/index.d.ts +8 -0
  52. package/dist/components/ChatMsg/MarkDown/index.d.ts +10 -0
  53. package/dist/components/ChatMsg/Message/index.d.ts +18 -0
  54. package/dist/components/ChatMsg/MetricCard/PeriodCompareItem.d.ts +7 -0
  55. package/dist/components/ChatMsg/MetricCard/index.d.ts +10 -0
  56. package/dist/components/ChatMsg/MetricTrend/MetricInfo.d.ts +8 -0
  57. package/dist/components/ChatMsg/MetricTrend/MetricTrendChart.d.ts +14 -0
  58. package/dist/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.d.ts +12 -0
  59. package/dist/components/ChatMsg/MetricTrend/index.d.ts +16 -0
  60. package/dist/components/ChatMsg/NoPermissionChart/index.d.ts +8 -0
  61. package/dist/components/ChatMsg/Pie/PieChart.d.ts +11 -0
  62. package/dist/components/ChatMsg/Pie/index.d.ts +14 -0
  63. package/dist/components/ChatMsg/Table/index.d.ts +12 -0
  64. package/dist/components/ChatMsg/Text/index.d.ts +9 -0
  65. package/dist/components/ChatMsg/WebPage/index.d.ts +8 -0
  66. package/dist/components/ChatMsg/index.d.ts +15 -0
  67. package/dist/components/DrillDownDimensions/DimensionSection.d.ts +11 -0
  68. package/dist/components/DrillDownDimensions/index.d.ts +13 -0
  69. package/dist/components/IconFont/index.d.ts +3 -0
  70. package/dist/components/MetricOptions/index.d.ts +11 -0
  71. package/dist/components/RecommendOptions/index.d.ts +9 -0
  72. package/dist/components/Tools/FeedbackModal.d.ts +9 -0
  73. package/dist/components/Tools/index.d.ts +12 -0
  74. package/dist/demo/Chat.d.ts +2 -0
  75. package/dist/demo/ChatDemo.d.ts +4 -0
  76. package/dist/demo/CopilotDemo.d.ts +2 -0
  77. package/dist/hooks/index.d.ts +3 -0
  78. package/dist/hooks/useComposing.d.ts +5 -0
  79. package/dist/hooks/useExportByEcharts.d.ts +10 -0
  80. package/dist/hooks/useMethodRegister.d.ts +4 -0
  81. package/dist/index.d.ts +10 -0
  82. package/dist/index.es.js +1 -0
  83. package/dist/service/axiosInstance.d.ts +3 -0
  84. package/dist/service/index.d.ts +25 -0
  85. package/dist/utils/utils.d.ts +45 -0
  86. package/package.json +214 -0
  87. package/public/favicon.ico +0 -0
  88. package/public/index.html +43 -0
  89. package/public/manifest.json +15 -0
  90. package/public/robots.txt +3 -0
  91. package/rollup/rollup.config.mjs +37 -0
  92. package/rollup/rollup.esm.config.mjs +21 -0
  93. package/rollup/rollup.umd.config.mjs +30 -0
  94. package/scripts/build.js +217 -0
  95. package/scripts/start.js +154 -0
  96. package/scripts/test.js +52 -0
  97. package/src/Chat/AgentList/index.tsx +52 -0
  98. package/src/Chat/AgentList/style.module.less +83 -0
  99. package/src/Chat/ChatFooter/index.tsx +423 -0
  100. package/src/Chat/ChatFooter/style.module.less +225 -0
  101. package/src/Chat/Conversation/index.tsx +236 -0
  102. package/src/Chat/Conversation/style.module.less +171 -0
  103. package/src/Chat/MessageContainer/index.tsx +145 -0
  104. package/src/Chat/MessageContainer/style.module.less +53 -0
  105. package/src/Chat/MobileAgents/index.tsx +62 -0
  106. package/src/Chat/MobileAgents/style.module.less +55 -0
  107. package/src/Chat/components/AgentTip/index.tsx +48 -0
  108. package/src/Chat/components/AgentTip/style.module.less +44 -0
  109. package/src/Chat/components/ConversationModal/index.tsx +65 -0
  110. package/src/Chat/components/CopilotAvatar/index.tsx +8 -0
  111. package/src/Chat/components/CopilotAvatar/style.module.less +13 -0
  112. package/src/Chat/components/Message.tsx +38 -0
  113. package/src/Chat/components/RecommendQuestions/index.tsx +64 -0
  114. package/src/Chat/components/RecommendQuestions/style.module.less +36 -0
  115. package/src/Chat/components/Text.tsx +42 -0
  116. package/src/Chat/components/style.module.less +311 -0
  117. package/src/Chat/constants.ts +37 -0
  118. package/src/Chat/index.tsx +526 -0
  119. package/src/Chat/service.ts +49 -0
  120. package/src/Chat/style.module.less +119 -0
  121. package/src/Chat/type.ts +107 -0
  122. package/src/Copilot/constants.ts +11 -0
  123. package/src/Copilot/index.tsx +149 -0
  124. package/src/Copilot/style.module.less +151 -0
  125. package/src/ShowCase/index.tsx +120 -0
  126. package/src/ShowCase/service.ts +12 -0
  127. package/src/ShowCase/style.module.less +46 -0
  128. package/src/ShowCase/type.ts +14 -0
  129. package/src/common/constants.ts +93 -0
  130. package/src/common/env.ts +5 -0
  131. package/src/common/type.ts +270 -0
  132. package/src/components/ChatItem/ExecuteItem.tsx +210 -0
  133. package/src/components/ChatItem/ExpandParseTip.tsx +333 -0
  134. package/src/components/ChatItem/FilterItem.tsx +209 -0
  135. package/src/components/ChatItem/Loading.tsx +14 -0
  136. package/src/components/ChatItem/ParseTip.tsx +322 -0
  137. package/src/components/ChatItem/ParseTipUtils.tsx +205 -0
  138. package/src/components/ChatItem/SimilarQuestionItem.tsx +84 -0
  139. package/src/components/ChatItem/SqlItem.tsx +410 -0
  140. package/src/components/ChatItem/SwitchEntity.tsx +52 -0
  141. package/src/components/ChatItem/Text.tsx +17 -0
  142. package/src/components/ChatItem/Typing.tsx +19 -0
  143. package/src/components/ChatItem/index.tsx +843 -0
  144. package/src/components/ChatItem/style.less +670 -0
  145. package/src/components/ChatMsg/ApplyAuth/index.tsx +30 -0
  146. package/src/components/ChatMsg/ApplyAuth/style.less +13 -0
  147. package/src/components/ChatMsg/Bar/index.tsx +208 -0
  148. package/src/components/ChatMsg/Bar/style.less +60 -0
  149. package/src/components/ChatMsg/DateOptions/index.tsx +46 -0
  150. package/src/components/ChatMsg/DateOptions/style.less +43 -0
  151. package/src/components/ChatMsg/FilterSection/index.tsx +42 -0
  152. package/src/components/ChatMsg/FilterSection/style.less +37 -0
  153. package/src/components/ChatMsg/MarkDown/index.tsx +26 -0
  154. package/src/components/ChatMsg/MarkDown/style.less +9 -0
  155. package/src/components/ChatMsg/Message/index.tsx +105 -0
  156. package/src/components/ChatMsg/Message/style.less +119 -0
  157. package/src/components/ChatMsg/MetricCard/PeriodCompareItem.tsx +29 -0
  158. package/src/components/ChatMsg/MetricCard/index.tsx +80 -0
  159. package/src/components/ChatMsg/MetricCard/style.less +126 -0
  160. package/src/components/ChatMsg/MetricTrend/MetricInfo.tsx +60 -0
  161. package/src/components/ChatMsg/MetricTrend/MetricTrendChart.tsx +235 -0
  162. package/src/components/ChatMsg/MetricTrend/MultiMetricsTrendChart.tsx +162 -0
  163. package/src/components/ChatMsg/MetricTrend/index.tsx +127 -0
  164. package/src/components/ChatMsg/MetricTrend/style.less +195 -0
  165. package/src/components/ChatMsg/NoPermissionChart/index.tsx +28 -0
  166. package/src/components/ChatMsg/NoPermissionChart/style.less +26 -0
  167. package/src/components/ChatMsg/Pie/PieChart.tsx +120 -0
  168. package/src/components/ChatMsg/Pie/index.tsx +88 -0
  169. package/src/components/ChatMsg/Pie/style.less +43 -0
  170. package/src/components/ChatMsg/Table/index.tsx +103 -0
  171. package/src/components/ChatMsg/Table/style.less +131 -0
  172. package/src/components/ChatMsg/Text/index.tsx +70 -0
  173. package/src/components/ChatMsg/Text/style.less +38 -0
  174. package/src/components/ChatMsg/WebPage/index.tsx +125 -0
  175. package/src/components/ChatMsg/index.tsx +428 -0
  176. package/src/components/ChatMsg/style.less +28 -0
  177. package/src/components/DrillDownDimensions/DimensionSection.tsx +99 -0
  178. package/src/components/DrillDownDimensions/index.tsx +76 -0
  179. package/src/components/DrillDownDimensions/style.less +64 -0
  180. package/src/components/IconFont/index.tsx +7 -0
  181. package/src/components/MetricOptions/index.tsx +75 -0
  182. package/src/components/MetricOptions/style.less +69 -0
  183. package/src/components/RecommendOptions/index.tsx +126 -0
  184. package/src/components/RecommendOptions/style.less +24 -0
  185. package/src/components/Tools/FeedbackModal.tsx +55 -0
  186. package/src/components/Tools/index.tsx +126 -0
  187. package/src/components/Tools/style.less +67 -0
  188. package/src/demo/Chat.tsx +73 -0
  189. package/src/demo/ChatDemo.tsx +14 -0
  190. package/src/demo/CopilotDemo.tsx +43 -0
  191. package/src/demo/style.module.less +19 -0
  192. package/src/hooks/index.ts +3 -0
  193. package/src/hooks/useComposing.ts +31 -0
  194. package/src/hooks/useExportByEcharts.ts +41 -0
  195. package/src/hooks/useMethodRegister.ts +25 -0
  196. package/src/index.tsx +44 -0
  197. package/src/service/axiosInstance.ts +58 -0
  198. package/src/service/index.ts +174 -0
  199. package/src/setupProxy.js +18 -0
  200. package/src/setupTests.ts +5 -0
  201. package/src/styles/global.less +52 -0
  202. package/src/styles/index.less +39 -0
  203. package/src/styles/reboot.less +14 -0
  204. package/src/styles/variables.less +80 -0
  205. package/src/typings.d.ts +179 -0
  206. package/src/utils/utils.ts +346 -0
  207. package/tsconfig.build.json +20 -0
  208. package/tsconfig.json +27 -0
@@ -0,0 +1,55 @@
1
+ .mobileAgents {
2
+ :global {
3
+ .ant-drawer-content {
4
+ border-top-left-radius: 12px;
5
+ border-top-right-radius: 12px;
6
+
7
+ .ant-drawer-header {
8
+ padding: 16px 12px;
9
+ }
10
+
11
+ .ant-drawer-body {
12
+ padding: 12px;
13
+ }
14
+ }
15
+ }
16
+
17
+ .agentListContent {
18
+ display: flex;
19
+ flex-direction: column;
20
+ row-gap: 12px;
21
+
22
+ .agentItem {
23
+ padding: 12px 16px;
24
+ background-color: #f5f7f9;
25
+ border: 1px solid transparent;
26
+ border-radius: 10px;
27
+
28
+ &.active {
29
+ border: 1px solid var(--chat-blue);
30
+ }
31
+
32
+ .agentTitleBar {
33
+ display: flex;
34
+ align-items: center;
35
+ column-gap: 6px;
36
+
37
+ .avatar {
38
+ font-size: 24px;
39
+ }
40
+
41
+ .agentName {
42
+ color: var(--text-color);
43
+ font-weight: 500;
44
+ }
45
+ }
46
+
47
+ .agentDesc {
48
+ margin-top: 8px;
49
+ color: var(--text-color-third);
50
+ font-size: 13px;
51
+ line-height: 24px;
52
+ }
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,48 @@
1
+ import LeftAvatar from '../CopilotAvatar';
2
+ import Message from '../Message';
3
+ import styles from './style.module.less';
4
+ import { AgentType } from '../../type';
5
+ import { isMobile } from '../../../utils/utils';
6
+
7
+ type Props = {
8
+ currentAgent?: AgentType;
9
+ onSendMsg: (value: string) => void;
10
+ };
11
+
12
+ const AgentTip: React.FC<Props> = ({ currentAgent, onSendMsg }) => {
13
+ if (!currentAgent) {
14
+ return null;
15
+ }
16
+ return (
17
+ <div className={styles.agentTip}>
18
+ {!isMobile && <LeftAvatar />}
19
+ <Message position="left" bubbleClassName={styles.agentTipMsg}>
20
+ <div className={styles.title}>
21
+ 您好,智能助理【{currentAgent.name}
22
+ 】将与您对话,试着问:
23
+ </div>
24
+ <div className={styles.content}>
25
+ <div className={styles.examples}>
26
+ {currentAgent.examples?.length > 0 ? (
27
+ currentAgent.examples.map(example => (
28
+ <div
29
+ key={example}
30
+ className={styles.example}
31
+ onClick={() => {
32
+ onSendMsg(example);
33
+ }}
34
+ >
35
+ “{example}”
36
+ </div>
37
+ ))
38
+ ) : (
39
+ <div className={styles.example}>{currentAgent.description}</div>
40
+ )}
41
+ </div>
42
+ </div>
43
+ </Message>
44
+ </div>
45
+ );
46
+ };
47
+
48
+ export default AgentTip;
@@ -0,0 +1,44 @@
1
+ .agentTip {
2
+ display: flex;
3
+
4
+ .agentTipMsg {
5
+ padding: 12px 20px 20px !important;
6
+
7
+ .title {
8
+ margin-bottom: 12px;
9
+ font-size: 14px;
10
+ }
11
+
12
+ .content {
13
+ display: flex;
14
+ flex-direction: column;
15
+ flex-wrap: wrap;
16
+ margin-top: 10px;
17
+ column-gap: 14px;
18
+
19
+ .topBar {
20
+ .tip {
21
+ margin-top: 2px;
22
+ font-size: 13px;
23
+ }
24
+ }
25
+
26
+ .examples {
27
+ display: flex;
28
+ flex-direction: column;
29
+ font-size: 13px;
30
+ row-gap: 8px;
31
+
32
+ .example {
33
+ color: var(--chat-blue);
34
+ cursor: pointer;
35
+ }
36
+ }
37
+
38
+ &.fullscreen {
39
+ flex: none;
40
+ width: 280px;
41
+ }
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,65 @@
1
+ import { Form, Input, Modal } from 'antd';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { updateConversationName } from '../../service';
4
+ import type { ConversationDetailType } from '../../type';
5
+
6
+ const FormItem = Form.Item;
7
+
8
+ type Props = {
9
+ visible: boolean;
10
+ editConversation?: ConversationDetailType;
11
+ onClose: () => void;
12
+ onFinish: (conversationName: string) => void;
13
+ };
14
+
15
+ const layout = {
16
+ labelCol: { span: 6 },
17
+ wrapperCol: { span: 18 },
18
+ };
19
+
20
+ const ConversationModal: React.FC<Props> = ({ visible, editConversation, onClose, onFinish }) => {
21
+ const [form] = Form.useForm();
22
+ const [loading, setLoading] = useState(false);
23
+ const conversationNameInputRef = useRef<any>();
24
+
25
+ useEffect(() => {
26
+ if (visible) {
27
+ form.setFieldsValue({ conversationName: editConversation!.chatName });
28
+ setTimeout(() => {
29
+ conversationNameInputRef.current.focus({
30
+ cursor: 'all',
31
+ });
32
+ }, 0);
33
+ }
34
+ }, [visible]);
35
+
36
+ const onConfirm = async () => {
37
+ const values = await form.validateFields();
38
+ setLoading(true);
39
+ await updateConversationName(values.conversationName, editConversation!.chatId);
40
+ setLoading(false);
41
+ onFinish(values.conversationName);
42
+ };
43
+
44
+ return (
45
+ <Modal
46
+ title="修改问答名称"
47
+ open={visible}
48
+ onCancel={onClose}
49
+ onOk={onConfirm}
50
+ confirmLoading={loading}
51
+ >
52
+ <Form {...layout} form={form}>
53
+ <FormItem name="conversationName" label="名称" rules={[{ required: true }]}>
54
+ <Input
55
+ placeholder="请输入问答名称"
56
+ ref={conversationNameInputRef}
57
+ onPressEnter={onConfirm}
58
+ />
59
+ </FormItem>
60
+ </Form>
61
+ </Modal>
62
+ );
63
+ };
64
+
65
+ export default ConversationModal;
@@ -0,0 +1,8 @@
1
+ import IconFont from '../../../components/IconFont';
2
+ import styles from './style.module.less';
3
+
4
+ const CopilotAvatar = () => {
5
+ return <IconFont type="icon-zhinengsuanfa" className={styles.leftAvatar} />;
6
+ };
7
+
8
+ export default CopilotAvatar;
@@ -0,0 +1,13 @@
1
+ .leftAvatar {
2
+ display: flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ width: 40px;
6
+ height: 40px;
7
+ margin-right: 6px;
8
+ margin-right: 6px;
9
+ color: var(--chat-blue);
10
+ font-size: 40px;
11
+ background-color: #fff;
12
+ border-radius: 50%;
13
+ }
@@ -0,0 +1,38 @@
1
+ import classNames from 'classnames';
2
+ import styles from './style.module.less';
3
+ import { ReactNode } from 'react';
4
+
5
+ type Props = {
6
+ position: 'left' | 'right';
7
+ width?: number | string;
8
+ height?: number | string;
9
+ bubbleClassName?: string;
10
+ children?: ReactNode;
11
+ };
12
+
13
+ const Message: React.FC<Props> = ({ position, width, height, children, bubbleClassName }) => {
14
+ const messageClass = classNames(styles.message, {
15
+ [styles.left]: position === 'left',
16
+ [styles.right]: position === 'right',
17
+ });
18
+
19
+ return (
20
+ <div className={messageClass} style={{ width }}>
21
+ <div className={styles.messageContent}>
22
+ <div className={styles.messageBody}>
23
+ <div
24
+ className={`${styles.bubble}${bubbleClassName ? ` ${bubbleClassName}` : ''}`}
25
+ style={{ height }}
26
+ onClick={e => {
27
+ e.stopPropagation();
28
+ }}
29
+ >
30
+ {children}
31
+ </div>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ );
36
+ };
37
+
38
+ export default Message;
@@ -0,0 +1,64 @@
1
+ import { useEffect, useState } from 'react';
2
+ import LeftAvatar from '../CopilotAvatar';
3
+ import Message from '../Message';
4
+ import styles from './style.module.less';
5
+ import { queryRecommendQuestions } from '../../service';
6
+ import { isMobile } from '../../../utils/utils';
7
+
8
+ type Props = {
9
+ onSelectQuestion: (value: string) => void;
10
+ };
11
+
12
+ const RecommendQuestions: React.FC<Props> = ({ onSelectQuestion }) => {
13
+ const [questions, setQuestions] = useState<string[]>([]);
14
+ const [loading, setLoading] = useState(false);
15
+
16
+ const initData = async () => {
17
+ setLoading(true);
18
+ const res = await queryRecommendQuestions();
19
+ setLoading(false);
20
+ setQuestions(
21
+ res.data?.reduce((result: any[], item: any) => {
22
+ result = [
23
+ ...result,
24
+ ...item.recommendedQuestions.slice(0, 20).map((item: any) => item.question),
25
+ ];
26
+ return result;
27
+ }, []) || []
28
+ );
29
+ };
30
+
31
+ useEffect(() => {
32
+ initData();
33
+ }, []);
34
+
35
+ return (
36
+ <div className={styles.recommendQuestions}>
37
+ {!isMobile && <LeftAvatar />}
38
+ {loading ? (
39
+ <></>
40
+ ) : questions.length > 0 ? (
41
+ <Message position="left" bubbleClassName={styles.recommendQuestionsMsg}>
42
+ <div className={styles.title}>推荐问题:</div>
43
+ <div className={styles.content}>
44
+ {questions.map((question, index) => (
45
+ <div
46
+ key={`${question}_${index}`}
47
+ className={styles.question}
48
+ onClick={() => {
49
+ onSelectQuestion(question);
50
+ }}
51
+ >
52
+ {question}
53
+ </div>
54
+ ))}
55
+ </div>
56
+ </Message>
57
+ ) : (
58
+ <Message position="left">您好,请问有什么我可以帮您吗?</Message>
59
+ )}
60
+ </div>
61
+ );
62
+ };
63
+
64
+ export default RecommendQuestions;
@@ -0,0 +1,36 @@
1
+ .recommendQuestions {
2
+ display: flex;
3
+
4
+ .recommendQuestionsMsg {
5
+ padding: 12px 20px 20px !important;
6
+
7
+ .title {
8
+ margin-bottom: 12px;
9
+ font-weight: 500;
10
+ font-size: 14px;
11
+ }
12
+
13
+ .content {
14
+ display: flex;
15
+ flex-wrap: wrap;
16
+ align-items: center;
17
+ column-gap: 16px;
18
+ row-gap: 20px;
19
+
20
+ .question {
21
+ height: 22px;
22
+ padding: 0 6px;
23
+ color: var(--text-color);
24
+ font-size: 12px;
25
+ line-height: 22px;
26
+ background-color: #f4f4f4;
27
+ border-radius: 11px;
28
+ cursor: pointer;
29
+
30
+ &:hover {
31
+ color: var(--chat-blue);
32
+ }
33
+ }
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,42 @@
1
+ import { isMobile } from '../../utils/utils';
2
+ import { Avatar } from 'antd';
3
+ import classNames from 'classnames';
4
+ import LeftAvatar from './CopilotAvatar';
5
+ import Message from './Message';
6
+ import styles from './style.module.less';
7
+ import { userAvatarUrl } from '../../common/env';
8
+ import IconFont from '../../components/IconFont';
9
+
10
+ type Props = {
11
+ position: 'left' | 'right';
12
+ data: any;
13
+ quote?: string;
14
+ anonymousUser?: boolean;
15
+ };
16
+
17
+ const Text: React.FC<Props> = ({ position, data, quote, anonymousUser }) => {
18
+ const textWrapperClass = classNames(styles.textWrapper, {
19
+ [styles.rightTextWrapper]: position === 'right',
20
+ });
21
+ const rightAvatarUrl = userAvatarUrl;
22
+ return (
23
+ <div className={textWrapperClass}>
24
+ {!isMobile && position === 'left' && <LeftAvatar />}
25
+ <Message position={position} bubbleClassName={styles.textBubble}>
26
+ {position === 'right' && quote && <div className={styles.quote}>{quote}</div>}
27
+ <div className={styles.text}>{data}</div>
28
+ </Message>
29
+ {!isMobile && position === 'right' && rightAvatarUrl && (
30
+ <Avatar
31
+ shape="circle"
32
+ size={40}
33
+ src={anonymousUser ? undefined : rightAvatarUrl}
34
+ icon={<IconFont type="icon-geren" />}
35
+ className={styles.rightAvatar}
36
+ />
37
+ )}
38
+ </div>
39
+ );
40
+ };
41
+
42
+ export default Text;