yt-chat-components 0.1.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.
- package/.idea/langflow-embedded-chat.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/sonarlint/issuestore/0/f/0f8c0c92cf798431ebb931ff6e997b1af86ecee5 +0 -0
- package/.idea/sonarlint/issuestore/3/9/39129446b425a1d640160c068e4194e96639eedf +0 -0
- package/.idea/sonarlint/issuestore/4/a/4a2f33951ce07c1ff7184f91877aa13db05d3785 +0 -0
- package/.idea/sonarlint/issuestore/4/a/4a7b99bdbee5792679d347b6474463bf5e14b66d +0 -0
- package/.idea/sonarlint/issuestore/4/b/4b6989b8ccae808ebc45d02230d336ea53800365 +0 -0
- package/.idea/sonarlint/issuestore/6/c/6c024c1d0ad64656b9d4b0695ec3c49c0454addf +0 -0
- package/.idea/sonarlint/issuestore/8/d/8d6123af13a140f93e06299fff7ea23c547e9ec8 +0 -0
- package/.idea/sonarlint/issuestore/8/e/8ec9a00bfd09b3190ac6b22251dbb1aa95a0579d +0 -0
- package/.idea/sonarlint/issuestore/d/9/d938938695d447dadda115e28781c6541f53fc4f +0 -0
- package/.idea/sonarlint/issuestore/index.pb +19 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +274 -0
- package/build/asset-manifest.json +16 -0
- package/build/index.html +1 -0
- package/build/static/css/main.6f7c593d.css +2 -0
- package/build/static/css/main.6f7c593d.css.map +1 -0
- package/build/static/js/bundle.min.js +2 -0
- package/build/static/js/bundle.min.js.LICENSE.txt +124 -0
- package/build/static/js/main.cb252095.js +3 -0
- package/build/static/js/main.cb252095.js.LICENSE.txt +134 -0
- package/build/static/js/main.cb252095.js.map +1 -0
- package/build/static/media/aiavatar.74bafa995cce4c01b804.png +0 -0
- package/build/static/media/history-list-empty.1eb65b1550aef4e8c8a4.png +0 -0
- package/build/static/media/moreBg.9fc998472925cecd89f2.png +0 -0
- package/package.json +75 -0
- package/public/index.html +47 -0
- package/src/YtChatView/chatWidget/chatWindow/chatMessage/index.module.css +86 -0
- package/src/YtChatView/chatWidget/chatWindow/chatMessage/index.tsx +211 -0
- package/src/YtChatView/chatWidget/chatWindow/chatPlaceholder/index.module.css +9 -0
- package/src/YtChatView/chatWidget/chatWindow/chatPlaceholder/index.tsx +23 -0
- package/src/YtChatView/chatWidget/chatWindow/controllers/index.ts +236 -0
- package/src/YtChatView/chatWidget/chatWindow/index.module.css +197 -0
- package/src/YtChatView/chatWidget/chatWindow/index.tsx +791 -0
- package/src/YtChatView/chatWidget/chatWindow/types/chatWidget/index.ts +37 -0
- package/src/YtChatView/chatWidget/chatWindow/utils.ts +75 -0
- package/src/YtChatView/chatWidget/index.tsx +2289 -0
- package/src/YtChatView/logoBtn/index.css +4 -0
- package/src/YtChatView/logoBtn/index.jsx +65 -0
- package/src/YtChatView/logoSplitBtn/index.css +4 -0
- package/src/YtChatView/logoSplitBtn/index.jsx +67 -0
- package/src/YtChatView/previewDialog/index.jsx +431 -0
- package/src/YtChatView/previewDialog/index.module.css +144 -0
- package/src/assets/aicenter/add.png +0 -0
- package/src/assets/aicenter/aiavatar.png +0 -0
- package/src/assets/aicenter/aicenterbg.png +0 -0
- package/src/assets/aicenter/aicenterbgdark.png +0 -0
- package/src/assets/aicenter/close.png +0 -0
- package/src/assets/aicenter/closex.png +0 -0
- package/src/assets/aicenter/copy.png +0 -0
- package/src/assets/aicenter/file.png +0 -0
- package/src/assets/aicenter/fileupload.png +0 -0
- package/src/assets/aicenter/history-list-empty.png +0 -0
- package/src/assets/aicenter/history.png +0 -0
- package/src/assets/aicenter/luyin.png +0 -0
- package/src/assets/aicenter/moreAi.png +0 -0
- package/src/assets/aicenter/moreBg.png +0 -0
- package/src/assets/aicenter/play-run.gif +0 -0
- package/src/assets/aicenter/play.png +0 -0
- package/src/assets/aicenter/send-img.png +0 -0
- package/src/assets/aicenter/send-question-black.png +0 -0
- package/src/assets/aicenter/send-question.png +0 -0
- package/src/assets/aicenter/sendmessage.png +0 -0
- package/src/assets/aicenter/sound-wave.gif +0 -0
- package/src/assets/aicenter/toLeft.png +0 -0
- package/src/assets/aicenter/toRight.png +0 -0
- package/src/assets/aicenter/type-excel.png +0 -0
- package/src/assets/aicenter/type-markdown.png +0 -0
- package/src/assets/aicenter/type-mobi.png +0 -0
- package/src/assets/aicenter/type-pdf.png +0 -0
- package/src/assets/aicenter/type-rpub.png +0 -0
- package/src/assets/aicenter/type-text.png +0 -0
- package/src/assets/aicenter/type-word.png +0 -0
- package/src/assets/aicenter/upfile.png +0 -0
- package/src/chatPlaceholder/index.tsx +18 -0
- package/src/chatWidget/chatTrigger/index.tsx +15 -0
- package/src/chatWidget/chatWindow/chatMessage/index.tsx +42 -0
- package/src/chatWidget/chatWindow/index.tsx +426 -0
- package/src/chatWidget/index.tsx +2195 -0
- package/src/chatWidget/utils.ts +76 -0
- package/src/controllers/index.ts +205 -0
- package/src/index.tsx +60 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/setupTests.ts +5 -0
- package/src/types/chatWidget/index.ts +13 -0
- package/tsconfig.json +26 -0
- package/webpack.config.js +51 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ToolDialog from "../previewDialog";
|
|
3
|
+
import { Modal } from 'antd';
|
|
4
|
+
import './index.css'
|
|
5
|
+
|
|
6
|
+
class LogoBtn extends React.Component {
|
|
7
|
+
state={
|
|
8
|
+
isShow:false
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
render() {
|
|
12
|
+
const { left, right, top, bottom, width, height, iconUrl, title, flowId, hostUrl, userInfo, tags,boxStyle } = this.props;
|
|
13
|
+
const iconConfig = {
|
|
14
|
+
width: `${width || 100}px`,
|
|
15
|
+
height: `${height || 100}px`,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if(left){
|
|
19
|
+
iconConfig.left = `${left}px`;
|
|
20
|
+
}else if(right){
|
|
21
|
+
iconConfig.right = `${right}px`;
|
|
22
|
+
}else {
|
|
23
|
+
iconConfig.right = `50px`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if(top){
|
|
27
|
+
iconConfig.top = `${top}px`;
|
|
28
|
+
}else if(bottom){
|
|
29
|
+
iconConfig.bottom = `${bottom}px`;
|
|
30
|
+
}else {
|
|
31
|
+
iconConfig.bottom = `50px`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
// <div style={{ position: "relative", width: "100vw", height: "100vh", background:'transparent' }}>
|
|
36
|
+
<div style={{ position: "absolute", ...iconConfig }}>
|
|
37
|
+
<img src={iconUrl} style={{ width: "100%", height: "100%" }} onClick={(event) => this.setState({ isShow: true })}/>
|
|
38
|
+
<Modal
|
|
39
|
+
wrapClassName={'yt-chat-modal'}
|
|
40
|
+
open={this.state.isShow}
|
|
41
|
+
width={1000}
|
|
42
|
+
closable={false}
|
|
43
|
+
onCancel={() => this.setState({ isShow: false })}
|
|
44
|
+
footer={null}
|
|
45
|
+
centered={true}
|
|
46
|
+
>
|
|
47
|
+
<ToolDialog
|
|
48
|
+
title={title}
|
|
49
|
+
flowId={flowId}
|
|
50
|
+
hostUrl={hostUrl}
|
|
51
|
+
setDialogVisible={() => {
|
|
52
|
+
this.setState({ isShow: false })
|
|
53
|
+
}}
|
|
54
|
+
userInfo={userInfo || {}}
|
|
55
|
+
tags={tags || []}
|
|
56
|
+
boxStyle={boxStyle || { position: 'relative', height: '700px' }}
|
|
57
|
+
/>
|
|
58
|
+
</Modal>
|
|
59
|
+
</div>
|
|
60
|
+
// </div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default LogoBtn;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ToolDialog from "../previewDialog";
|
|
3
|
+
import { Modal } from 'antd';
|
|
4
|
+
import './index.css'
|
|
5
|
+
|
|
6
|
+
class LogoSplitBtn extends React.Component {
|
|
7
|
+
state={
|
|
8
|
+
isShow:false
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
render() {
|
|
12
|
+
const { left, right, top, bottom, width, height, iconUrl, title, flowId, hostUrl, userInfo, tags,boxStyle, sceneId} = this.props;
|
|
13
|
+
const iconConfig = {
|
|
14
|
+
width: `${width || 100}px`,
|
|
15
|
+
height: `${height || 100}px`,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if(left){
|
|
19
|
+
iconConfig.left = `${left}px`;
|
|
20
|
+
}else if(right){
|
|
21
|
+
iconConfig.right = `${right}px`;
|
|
22
|
+
}else {
|
|
23
|
+
iconConfig.right = `50px`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if(top){
|
|
27
|
+
iconConfig.top = `${top}px`;
|
|
28
|
+
}else if(bottom){
|
|
29
|
+
iconConfig.bottom = `${bottom}px`;
|
|
30
|
+
}else {
|
|
31
|
+
iconConfig.bottom = `50px`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
// <div style={{ position: "relative", width: "100vw", height: "100vh", background:'transparent' }}>
|
|
36
|
+
<div style={{ position: "absolute", ...iconConfig }}>
|
|
37
|
+
<img src={iconUrl} style={{ width: "100%", height: "100%" }} onClick={(event) => this.setState({ isShow: true })}/>
|
|
38
|
+
<Modal
|
|
39
|
+
wrapClassName={'yt-chat-modal'}
|
|
40
|
+
open={this.state.isShow}
|
|
41
|
+
width={1300}
|
|
42
|
+
closable={false}
|
|
43
|
+
onCancel={() => this.setState({ isShow: false })}
|
|
44
|
+
footer={null}
|
|
45
|
+
centered={true}
|
|
46
|
+
>
|
|
47
|
+
<ToolDialog
|
|
48
|
+
title={title}
|
|
49
|
+
flowId={flowId}
|
|
50
|
+
hostUrl={hostUrl}
|
|
51
|
+
setDialogVisible={() => {
|
|
52
|
+
this.setState({ isShow: false })
|
|
53
|
+
}}
|
|
54
|
+
userInfo={userInfo || {}}
|
|
55
|
+
tags={tags || []}
|
|
56
|
+
boxStyle={boxStyle || { position: 'relative', height: '700px' }}
|
|
57
|
+
isShowSideRight={true}
|
|
58
|
+
sceneId={sceneId}
|
|
59
|
+
/>
|
|
60
|
+
</Modal>
|
|
61
|
+
</div>
|
|
62
|
+
// </div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default LogoSplitBtn;
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ChatWidget from '../chatWidget/index';
|
|
3
|
+
import aiAvatarPng from '../../assets/aicenter/aiavatar.png';
|
|
4
|
+
import historyPng from '../../assets/aicenter/history.png';
|
|
5
|
+
import closePng from '../../assets/aicenter/close.png';
|
|
6
|
+
import { getHistoryList, getSceneInfo } from '../chatWidget/chatWindow/controllers/index';
|
|
7
|
+
import './index.module.css'
|
|
8
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
9
|
+
import historyListEmptyPng from '../../assets/aicenter/history-list-empty.png';
|
|
10
|
+
import addPng from '../../assets/aicenter/add.png';
|
|
11
|
+
import {isEmpty, isFunction} from "lodash";
|
|
12
|
+
import { Button, message as messageTip, Progress } from 'antd'
|
|
13
|
+
import { CloseOutlined } from "@ant-design/icons";
|
|
14
|
+
import moreAi from '../../assets/aicenter/moreAi.png';
|
|
15
|
+
import moreBg from '../../assets/aicenter/moreBg.png';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const style=`
|
|
19
|
+
.p_closeImg {
|
|
20
|
+
width: 14px;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.p_toolDialog {
|
|
25
|
+
display: flex;
|
|
26
|
+
height:100%;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.p_toolDialog .p_toolLeft {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
align-items: center;
|
|
33
|
+
width: 300px;
|
|
34
|
+
height: 100%;
|
|
35
|
+
background: linear-gradient(180deg, #CFDAFC 0%, #F0F3FF 100%);
|
|
36
|
+
padding: 24px;
|
|
37
|
+
border-top-left-radius: 8px;
|
|
38
|
+
border-bottom-left-radius: 8px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.p_toolDialog .p_toolLeft .p_toolLogo {
|
|
42
|
+
user-select: none;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.p_toolDialog .p_toolLeft .p_toolLogo .p_logoImg {
|
|
48
|
+
width: 60px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.p_toolDialog .p_toolLeft .p_toolLogo .p_logoText {
|
|
52
|
+
font-weight: bold;
|
|
53
|
+
margin-left: 10px;
|
|
54
|
+
padding-top: 16px;
|
|
55
|
+
font-size: 30px;
|
|
56
|
+
background: linear-gradient(to right, #1551FF, #8F4BFF);
|
|
57
|
+
-webkit-background-clip: text;
|
|
58
|
+
-webkit-text-fill-color: transparent;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.p_toolDialog .p_toolLeft .p_historyDialog {
|
|
62
|
+
user-select: none;
|
|
63
|
+
margin-top: 20px;
|
|
64
|
+
margin-bottom: 20px;
|
|
65
|
+
border-radius: 10px;
|
|
66
|
+
flex: 1;
|
|
67
|
+
width: 100%;
|
|
68
|
+
background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
|
|
69
|
+
border-image: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0)) 1 1;
|
|
70
|
+
backdrop-filter: blur(10px);
|
|
71
|
+
position: relative;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.p_toolDialog .p_toolLeft .p_historyDialog ::-webkit-scrollbar-thumb {
|
|
75
|
+
border-radius: 10px;
|
|
76
|
+
-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
|
|
77
|
+
background: #535353 !important;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyTitle {
|
|
81
|
+
padding: 16px 16px 0 16px;
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyTitle .p_historyImg {
|
|
87
|
+
width: 20px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyTitle .p_dialogTitle {
|
|
91
|
+
font-weight: bold;
|
|
92
|
+
font-size: 16px;
|
|
93
|
+
margin-left: 10px;
|
|
94
|
+
color: #666666;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyListEmpty {
|
|
98
|
+
position: absolute;
|
|
99
|
+
top: 50%;
|
|
100
|
+
left: 50%;
|
|
101
|
+
transform: translate(-50%, -50%);
|
|
102
|
+
text-align: center;
|
|
103
|
+
font-size: 12px;
|
|
104
|
+
color: #999999;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyList {
|
|
108
|
+
margin-top: 10px;
|
|
109
|
+
// height: 360px;
|
|
110
|
+
overflow-y: auto;
|
|
111
|
+
scrollbar-width: none !important; /* firefox */
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyList:hover {
|
|
115
|
+
scrollbar-width: thin !important; /* firefox */
|
|
116
|
+
scrollbar-color: #ced4e3 transparent;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyList .p_historyItem {
|
|
120
|
+
padding: 7px 16px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyList .p_historyItem .p_activeHistoryName {
|
|
124
|
+
color: #1552FF !important;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyList .p_historyItem .p_historyName {
|
|
128
|
+
color: #333333;
|
|
129
|
+
overflow: hidden;
|
|
130
|
+
text-overflow: ellipsis;
|
|
131
|
+
white-space: nowrap;
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.p_toolDialog .p_toolLeft .p_historyDialog .p_historyList .p_historyItem .p_historyName:hover {
|
|
136
|
+
color: #171717;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.p_toolDialog .p_toolRight {
|
|
140
|
+
flex: 1;
|
|
141
|
+
// width: calc(100% - 300px - 300px);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.p_toolRightToRight{
|
|
145
|
+
width:300px;
|
|
146
|
+
display:flex;
|
|
147
|
+
flex-direction:column;
|
|
148
|
+
padding:24px;
|
|
149
|
+
}
|
|
150
|
+
.rightInnerContainer{
|
|
151
|
+
height:calc(100% - 80px);
|
|
152
|
+
flex:1;
|
|
153
|
+
}
|
|
154
|
+
.p_toolRightToRight .rightSideTitle{
|
|
155
|
+
margin-bottom:40px;
|
|
156
|
+
margin-top:0;
|
|
157
|
+
font-size:18px;
|
|
158
|
+
font-weight:500;
|
|
159
|
+
}
|
|
160
|
+
.p_toolRightToRight .rightSideTitle .titleSideColumn{
|
|
161
|
+
color:#1551FF;
|
|
162
|
+
}
|
|
163
|
+
.p_toolRightToRight .rightSkillContainer{
|
|
164
|
+
min-height:40%;
|
|
165
|
+
}
|
|
166
|
+
.p_toolRightToRight .rightSkillContainer .rightSkillList{
|
|
167
|
+
display: grid;
|
|
168
|
+
grid-template-columns: repeat(3, 1fr);
|
|
169
|
+
gap: 10px;
|
|
170
|
+
margin-bottom: 20px;
|
|
171
|
+
}
|
|
172
|
+
.p_toolRightToRight .rightSkillContainer .rightSkillList .rightSkillItem{
|
|
173
|
+
text-align: center;
|
|
174
|
+
cursor:pointer;
|
|
175
|
+
}
|
|
176
|
+
.p_toolRightToRight .rightSkillContainer .rightSkillList .rightSkillItem img{
|
|
177
|
+
width: 40px;
|
|
178
|
+
height: 40px;
|
|
179
|
+
}
|
|
180
|
+
.p_toolRightToRight .rightSkillContainer .rightSkillList .rightSkillItem p{
|
|
181
|
+
overflow: hidden;
|
|
182
|
+
text-overflow: ellipsis;
|
|
183
|
+
white-space: nowrap;
|
|
184
|
+
width:80px;
|
|
185
|
+
}
|
|
186
|
+
.p_toolRightToRight .rightKnowledgeTitle{
|
|
187
|
+
margin-bottom:64px;
|
|
188
|
+
font-size:18px;
|
|
189
|
+
font-weight:500;
|
|
190
|
+
}
|
|
191
|
+
.p_toolRightToRight .rightKnowledgeContainer{
|
|
192
|
+
position:relative;
|
|
193
|
+
}
|
|
194
|
+
.p_toolRightToRight .rightMoreButton{
|
|
195
|
+
background: url(${moreAi});
|
|
196
|
+
background-size: 85% auto;
|
|
197
|
+
background-repeat: no-repeat;
|
|
198
|
+
background-position: bottom;
|
|
199
|
+
position: absolute;
|
|
200
|
+
bottom: 8px;
|
|
201
|
+
left: 0;
|
|
202
|
+
width: 100%;
|
|
203
|
+
height: 100%;
|
|
204
|
+
z-index: 1;
|
|
205
|
+
display: flex;
|
|
206
|
+
justify-content: center;
|
|
207
|
+
align-items: flex-end;
|
|
208
|
+
}
|
|
209
|
+
.p_toolRightToRight .rightMoreButton div{
|
|
210
|
+
width:calc(100% - 50px);
|
|
211
|
+
padding: 16px 16px 10px 20px;
|
|
212
|
+
font-weight: 500;
|
|
213
|
+
color: #ffffff;
|
|
214
|
+
line-height: 17px;
|
|
215
|
+
font-size: 12px;
|
|
216
|
+
cursor:pointer;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.p_newDialog {
|
|
220
|
+
width: 252px;
|
|
221
|
+
height: 40px;
|
|
222
|
+
background: linear-gradient(244deg, #828EFE 0%, #4B4FFF 100%);
|
|
223
|
+
margin-top: 20px;
|
|
224
|
+
border-radius: 20px;
|
|
225
|
+
cursor: pointer;
|
|
226
|
+
display: flex;
|
|
227
|
+
align-items: center;
|
|
228
|
+
justify-content: center;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.p_newDialog img {
|
|
232
|
+
width: 18px;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.p_newDialog .p_newDialogText {
|
|
236
|
+
color: #fff;
|
|
237
|
+
margin-left: 6px;
|
|
238
|
+
}
|
|
239
|
+
`
|
|
240
|
+
|
|
241
|
+
const defaultList = [
|
|
242
|
+
{
|
|
243
|
+
backgroundImg: 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/drop-down-item-card-01.png',
|
|
244
|
+
title: '我这学期的课程安排是什么样?',
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
backgroundImg: 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/drop-down-item-card-02.png',
|
|
248
|
+
title: '我上个学期的成绩是多少?',
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
backgroundImg: 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/drop-down-item-card-03.png',
|
|
252
|
+
title: '哪里可以找到心理咨询服务?',
|
|
253
|
+
},
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
const api_key = 'sk-mniUFDpcWwvNF3iFzssXa6etN-S_Y4AApyHYcBU44L0';
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
class ToolDialog extends React.Component {
|
|
261
|
+
state = {
|
|
262
|
+
historyList: [], // 历史对话列表
|
|
263
|
+
sessionId: uuidv4(), // 当前激活的对话对应的sessionId
|
|
264
|
+
dropDownList: [],
|
|
265
|
+
sceneInfo: {},
|
|
266
|
+
currentFlow: {},
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
async componentDidMount() {
|
|
270
|
+
const sceneData = await this.getSceneInfo();
|
|
271
|
+
console.log("sceneData",sceneData)
|
|
272
|
+
if(isEmpty(sceneData)) {
|
|
273
|
+
this.getHistoryList();
|
|
274
|
+
} else {
|
|
275
|
+
this.getHistoryList(sceneData);
|
|
276
|
+
}
|
|
277
|
+
this.setState({dropDownList:defaultList})
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
getCurrentFlowHistory=(flowId)=>{
|
|
281
|
+
const operationId = this.props.userInfo['code'] | '';
|
|
282
|
+
getHistoryList(this.props.hostUrl, flowId, operationId).then((res) => {
|
|
283
|
+
if(res.status === 200){
|
|
284
|
+
this.setState({ historyList: res.data });
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// 获取历史对话列表
|
|
290
|
+
getHistoryList = (sceneData) => {
|
|
291
|
+
const realFlowId = sceneData.flows[0].id || this.props.flowId;
|
|
292
|
+
this.setState({ currentFlow: sceneData.flows[0] })
|
|
293
|
+
this.getCurrentFlowHistory(realFlowId)
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
getSceneInfo = async ()=>{
|
|
297
|
+
const res = await getSceneInfo(this.props.hostUrl, this.props.sceneId,api_key);
|
|
298
|
+
if(res.status === 200){
|
|
299
|
+
this.setState({ sceneInfo: res.data });
|
|
300
|
+
}
|
|
301
|
+
return res.data;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// 新建对话
|
|
305
|
+
newDialog = () => {
|
|
306
|
+
if(this.state.dropDownList) {
|
|
307
|
+
messageTip.info("当前已是最新对话")
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
this.setState({ sessionId: uuidv4() });
|
|
311
|
+
this.setState({ dropDownList: defaultList })
|
|
312
|
+
}
|
|
313
|
+
updateSessionId = (sessionId) => {
|
|
314
|
+
this.setState({ sessionId });
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
render() {
|
|
318
|
+
const dialogHeight = 650;
|
|
319
|
+
const { title, flowId, hostUrl, setDialogVisible, userInfo, tags, boxStyle, isShowSideRight } = this.props;
|
|
320
|
+
const { dropDownList, sceneInfo, currentFlow } = this.state;
|
|
321
|
+
const { flows=[], name: sceneName } = sceneInfo;
|
|
322
|
+
return (
|
|
323
|
+
<div style={boxStyle}>
|
|
324
|
+
<style dangerouslySetInnerHTML={{ __html: style }}></style>
|
|
325
|
+
<div style={{ position: 'absolute', top: '18px', right: '18px', zIndex: 999 }}>
|
|
326
|
+
{isFunction(setDialogVisible) &&
|
|
327
|
+
<img onClick={() => setDialogVisible(false)} className="p_closeImg" src={closePng}/>}
|
|
328
|
+
</div>
|
|
329
|
+
<div className="p_toolDialog">
|
|
330
|
+
<div className="p_toolLeft">
|
|
331
|
+
<div className="p_toolLogo">
|
|
332
|
+
<img className="p_logoImg" src={aiAvatarPng}/>
|
|
333
|
+
<div className="p_logoText">校园智多星</div>
|
|
334
|
+
</div>
|
|
335
|
+
<div className="p_historyDialog">
|
|
336
|
+
<div className="p_historyTitle">
|
|
337
|
+
<img className="p_historyImg" src={historyPng}/>
|
|
338
|
+
<div className="p_dialogTitle">对话列表</div>
|
|
339
|
+
</div>
|
|
340
|
+
{this.state.historyList.length > 0 ? (
|
|
341
|
+
<div className="p_historyList">
|
|
342
|
+
{this.state.historyList?.map((item) => (
|
|
343
|
+
<div
|
|
344
|
+
key={item.session_id}
|
|
345
|
+
className="p_historyItem"
|
|
346
|
+
onClick={() => {
|
|
347
|
+
this.setState({ dropDownList: undefined })
|
|
348
|
+
this.updateSessionId(item.session_id);
|
|
349
|
+
}}
|
|
350
|
+
>
|
|
351
|
+
<div
|
|
352
|
+
className={`p_historyName ${
|
|
353
|
+
item.session_id === this.state.sessionId ? 'p_activeHistoryName' : ''
|
|
354
|
+
}`}
|
|
355
|
+
>
|
|
356
|
+
{item.text}
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
))}
|
|
360
|
+
</div>
|
|
361
|
+
) : (
|
|
362
|
+
<div className="p_historyListEmpty">
|
|
363
|
+
<img src={historyListEmptyPng}/>
|
|
364
|
+
<div className="p_historyListEmptyText">暂无对话记录</div>
|
|
365
|
+
</div>
|
|
366
|
+
)}
|
|
367
|
+
</div>
|
|
368
|
+
<div className="p_newDialog" onClick={() => {
|
|
369
|
+
this.newDialog()
|
|
370
|
+
}}>
|
|
371
|
+
<img src={addPng}/>
|
|
372
|
+
<div className="p_newDialogText">新建对话</div>
|
|
373
|
+
</div>
|
|
374
|
+
</div>
|
|
375
|
+
<div className="p_toolRight">
|
|
376
|
+
<ChatWidget
|
|
377
|
+
window_title={currentFlow.name}
|
|
378
|
+
flow_id={currentFlow.id}
|
|
379
|
+
tags={tags}
|
|
380
|
+
host_url={hostUrl}
|
|
381
|
+
// height={dialogHeight + 'px'}
|
|
382
|
+
api_key={api_key}
|
|
383
|
+
session_id={this.state.sessionId}
|
|
384
|
+
userInfo={userInfo}
|
|
385
|
+
getHistoryList={this.getHistoryList}
|
|
386
|
+
setDropDownList={(list) => this.setState({ dropDownList: list })}
|
|
387
|
+
dropDownList={dropDownList}
|
|
388
|
+
/>
|
|
389
|
+
</div>
|
|
390
|
+
{
|
|
391
|
+
isShowSideRight&&
|
|
392
|
+
<div className={"p_toolRightToRight"}>
|
|
393
|
+
<div className={"rightInnerContainer"}>
|
|
394
|
+
<h3 className={"rightSideTitle"} ><span className={"titleSideColumn"} >▎</span>专项技能</h3>
|
|
395
|
+
<div className={"rightSkillContainer"}>
|
|
396
|
+
<div className={"rightSkillList"}>
|
|
397
|
+
{flows.slice(0,9).map((item) => (
|
|
398
|
+
<div className={"rightSkillItem"} key={item.id} onClick={()=>{
|
|
399
|
+
// 右侧点击一个技能,更新sessionId,切换当前flow信息,重新查询历史记录
|
|
400
|
+
this.setState({ sessionId: uuidv4(),currentFlow: item});
|
|
401
|
+
this.getCurrentFlowHistory(item.id);
|
|
402
|
+
}}>
|
|
403
|
+
<img
|
|
404
|
+
src={item.icon}
|
|
405
|
+
alt={item.name}/>
|
|
406
|
+
<p>{item.name}</p>
|
|
407
|
+
</div>
|
|
408
|
+
))}
|
|
409
|
+
</div>
|
|
410
|
+
</div>
|
|
411
|
+
<h4 className={"rightKnowledgeTitle"} style={{ marginBottom: '36px' }}><span style={{color:"#1551FF"}}>▎</span>个人知识库</h4>
|
|
412
|
+
<div className={"rightKnowledgeContainer"} style={{ marginBottom: '20px' }}>
|
|
413
|
+
<img src={moreBg}/>
|
|
414
|
+
<div style={{position:'absolute', top:'40px',left:'16px'}}>
|
|
415
|
+
<div>文件总数<span style={{padding:8,fontSize:'20px',fontWeight:700}}>180</span>个</div>
|
|
416
|
+
<div style={{marginTop:10}}>文件总量<span style={{padding:8,fontSize:'20px',fontWeight:700}}>200</span>GB</div>
|
|
417
|
+
</div>
|
|
418
|
+
<div className={"rightMoreButton"}>
|
|
419
|
+
<div className={"rightMoreTitle"} onClick={()=>messageTip.info("敬请期待")}>训练你的专属知识库</div>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
</div>
|
|
423
|
+
</div>
|
|
424
|
+
}
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export default ToolDialog;
|