yt-chat-components 0.9.9 → 1.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.
@@ -0,0 +1,848 @@
1
+ /* global wx */
2
+ import React from 'react';
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 { getFlowInfo, 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, Skeleton, Drawer } 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
+ import icon_history from '../../assets/aicenter/icon_history.png';
17
+ import icon_agents from '../../assets/aicenter/icon_agents.png';
18
+ import icon_history_upload from '../../assets/aicenter/icon_history_upload.png';
19
+ import icon_history_headerbg from '../../assets/aicenter/icon_history_headerbg.png';
20
+ import icon_history_add from '../../assets/aicenter/icon_history_add.png';
21
+ import self_knowledge from '../../assets/aicenter/self_knowledge.png';
22
+ import self_skills from '../../assets/aicenter/self_skills.png';
23
+ import ChatWidget from "../chatWidget";
24
+
25
+
26
+ const style=`
27
+ .p_closeImg {
28
+ width: 14px;
29
+ cursor: pointer;
30
+ }
31
+
32
+ .p_toolDialog {
33
+ display: flex;
34
+ height:100%;
35
+ background:url('https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/ai_modal_bg.png');
36
+ background-size: cover;
37
+ border-radius:8px;
38
+ }
39
+
40
+ .p_toolDialog .p_toolLeft {
41
+ display: flex;
42
+ flex-direction: column;
43
+ align-items: center;
44
+ width: 300px;
45
+ padding: 1.7rem 1.6rem 1.7rem 1.6rem;
46
+
47
+ border-top-left-radius: 8px;
48
+ border-bottom-left-radius: 8px;
49
+ }
50
+
51
+ .p_toolDialog .p_toolLeft .p_toolLogo {
52
+ user-select: none;
53
+ display: flex;
54
+ align-items: center;
55
+ }
56
+
57
+ .p_toolDialog .p_toolLeft .p_toolLogo .p_logoImg {
58
+ width: 48px;
59
+ }
60
+
61
+ .p_toolDialog .p_toolLeft .p_toolLogo .p_logoText {
62
+ font-weight: bold;
63
+ margin-left: 10px;
64
+ font-size: 30px;
65
+ background: linear-gradient(to right, #1551FF, #8F4BFF);
66
+ -webkit-background-clip: text;
67
+ -webkit-text-fill-color: transparent;
68
+ }
69
+
70
+ .p_toolDialog .p_toolLeft .p_historyDialog {
71
+ user-select: none;
72
+ margin-top: 20px;
73
+ margin-bottom: 20px;
74
+ border-radius: 10px;
75
+ flex: 1;
76
+ width: 100%;
77
+ background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%);
78
+ border-image: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0)) 1 1;
79
+ backdrop-filter: blur(10px);
80
+ position: relative;
81
+ max-height:calc(100% - 5.5rem - 60px);
82
+ }
83
+
84
+ .p_toolDialog .p_toolLeft .p_historyDialog ::-webkit-scrollbar-thumb {
85
+ border-radius: 10px;
86
+ -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
87
+ background: #535353 !important;
88
+ }
89
+
90
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyTitle {
91
+ padding: 1.3rem 16px 0 16px;
92
+ display: flex;
93
+ align-items: center;
94
+ }
95
+
96
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyTitle .p_historyImg {
97
+ width: 25px;
98
+ }
99
+
100
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyTitle .p_dialogTitle {
101
+ margin-left: 10px;
102
+ font-weight: 500;
103
+ font-size: 18px;
104
+ color: #333333;
105
+ line-height: 16px;
106
+ text-align: left;
107
+ font-style: normal;
108
+ }
109
+
110
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyListEmpty {
111
+ position: absolute;
112
+ top: 50%;
113
+ left: 50%;
114
+ transform: translate(-50%, -50%);
115
+ text-align: center;
116
+ font-size: 12px;
117
+ color: #999999;
118
+ max-height: calc(100% - 3rem);
119
+
120
+ }
121
+
122
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyList {
123
+ height: calc(100% - 3rem);
124
+ margin-top: 10px;
125
+ overflow-y: auto;
126
+ scrollbar-width: none !important; /* firefox */
127
+ }
128
+
129
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyList::-webkit-scrollbar{
130
+ display:none;
131
+ }
132
+
133
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyList:hover {
134
+ scrollbar-width: thin !important; /* firefox */
135
+ scrollbar-color: #ced4e3 transparent;
136
+ }
137
+
138
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyList .p_historyItem {
139
+ padding: 7px 16px;
140
+ }
141
+
142
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyList .p_historyItem .p_activeHistoryName {
143
+ color: #1552FF !important;
144
+ }
145
+
146
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyList .p_historyItem .p_historyName {
147
+ color: #333333;
148
+ overflow: hidden;
149
+ text-overflow: ellipsis;
150
+ white-space: nowrap;
151
+ cursor: pointer;
152
+ }
153
+
154
+ .p_toolDialog .p_toolLeft .p_historyDialog .p_historyList .p_historyItem .p_historyName:hover {
155
+ color: #171717;
156
+ }
157
+
158
+ .p_toolDialog .p_toolRight {
159
+ flex: 1;
160
+ }
161
+
162
+ .p_toolRightToRight {
163
+ width:300px;
164
+ display:flex;
165
+ flex-direction:column;
166
+ padding:2rem 1.6rem 1.8rem 1.6rem
167
+ }
168
+ .rightInnerContainer{
169
+ height:calc(100% - 80px);
170
+ flex:1;
171
+ display:flex;
172
+ flex-direction:column;
173
+ justify-content: space-between;
174
+ }
175
+ .p_toolRightToRight .rightSideTitle{
176
+ margin-bottom:1.4rem;
177
+ margin-top:10px;
178
+ margin-top:0;
179
+ font-size:18px;
180
+ font-weight:500;
181
+ display:flex;
182
+ align-items: center;
183
+ }
184
+ .p_toolRightToRight .rightSideTitle img{
185
+ margin-right:4px;
186
+ }
187
+
188
+ .p_toolRightToRight .rightSideTitle .titleSideColumn{
189
+ color:#1551FF;
190
+ }
191
+
192
+ .p_toolRightToRight .rightSkillContainer{
193
+ min-height:40%;
194
+ }
195
+ .p_toolRightToRight .rightSkillContainer .rightSkillList{
196
+ display: flex;
197
+ flex-wrap: wrap;
198
+ grid-template-columns: repeat(3, 1fr);
199
+ gap: 10px;
200
+ }
201
+ .p_toolRightToRight .rightSkillContainer .rightSkillList .rightSkillItem{
202
+ text-align: center;
203
+ cursor:pointer;
204
+ width:30%;
205
+ }
206
+ .p_toolRightToRight .rightSkillContainer .rightSkillList .rightSkillItem img{
207
+ width: 40px;
208
+ height: 40px;
209
+ border-radius:10px;
210
+ }
211
+ .p_toolRightToRight .rightSkillContainer .rightSkillList .rightSkillItem p{
212
+ margin-top:0px;
213
+ margin-bottom:4px;
214
+ overflow: hidden;
215
+ text-overflow: ellipsis;
216
+ white-space: nowrap;
217
+ color: #333333;
218
+ }
219
+ .p_toolRightToRight .rightKnowledgeTitle{
220
+ nargin-top: 2.2rem;
221
+ margin-bottom: 1.4rem;
222
+ font-size:18px;
223
+ font-weight:500;
224
+ display:flex;
225
+ align-items: center;
226
+ }
227
+
228
+ .p_toolRightToRight .rightKnowledgeTitle img{
229
+ margin-right:4px;
230
+ }
231
+
232
+ .p_toolRightToRight .rightKnowledgeContainer{
233
+ position:relative;
234
+ }
235
+ .p_toolRightToRight .rightMoreButton{
236
+ background: url(${moreAi});
237
+ background-size: 85% auto;
238
+ background-repeat: no-repeat;
239
+ background-position: bottom;
240
+ position: absolute;
241
+ bottom: 8px;
242
+ left: 0;
243
+ width: 100%;
244
+ height: 100%;
245
+ z-index: 1;
246
+ display: flex;
247
+ justify-content: center;
248
+ align-items: flex-end;
249
+ }
250
+ .p_toolRightToRight .rightMoreButton div{
251
+ width:calc(100% - 50px);
252
+ padding: 16px 16px 10px 20px;
253
+ font-weight: 500;
254
+ color: #ffffff;
255
+ line-height: 17px;
256
+ font-size: 12px;
257
+ cursor:pointer;
258
+ }
259
+
260
+ .p_newDialog {
261
+ width: 252px;
262
+ height: 40px;
263
+ min-height:40px;
264
+ background: linear-gradient( 45deg, #1551FF 0%, #8F4BFF 100%);
265
+ margin-top: 20px;
266
+ border-radius: 20px;
267
+ cursor: pointer;
268
+ display: flex;
269
+ align-items: center;
270
+ justify-content: center;
271
+ }
272
+
273
+ .p_newDialog img {
274
+ width: 18px;
275
+ }
276
+
277
+ .p_newDialog .p_newDialogText {
278
+ color: #fff;
279
+ margin-left: 6px;
280
+ }
281
+
282
+ .drawer-history-header {
283
+ margin-top: 40px;
284
+ }
285
+
286
+ .drawer-history-header-title {
287
+ display: flex;
288
+ flex-direction: row;
289
+ align-items: center;
290
+
291
+ > img {
292
+ width:35px
293
+ }
294
+
295
+ > span {
296
+ }
297
+ }
298
+
299
+ .drawer-history-header .drawer-history-header-tool {
300
+
301
+ > img {
302
+ }
303
+
304
+ > span {
305
+ }
306
+ }
307
+
308
+ .drawer-history-content {
309
+ }
310
+ .drawer-history-footer {
311
+ }
312
+
313
+ `
314
+
315
+ const defaultList = [
316
+ {
317
+ backgroundImg: 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/drop-down-item-card-01.png',
318
+ title: '我这学期的课程安排是什么样?',
319
+ },
320
+ {
321
+ backgroundImg: 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/drop-down-item-card-02.png',
322
+ title: '我上个学期的成绩是多少?',
323
+ },
324
+ {
325
+ backgroundImg: 'https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/smartSchool/appCreator/ai/drop-down-item-card-03.png',
326
+ title: '哪里可以找到心理咨询服务?',
327
+ },
328
+ ];
329
+
330
+ const formatFileSize = (bytes) => {
331
+ // 如果字节数为0,直接返回
332
+ if(isEmpty(bytes)) {
333
+ return { formattedSize: 0, unit: 'B' };
334
+ }
335
+ if(bytes === 0) return { formattedSize: 0, unit: 'B' };
336
+
337
+ // 定义单位和对应的字节数(1024进制)
338
+ const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
339
+ // 计算合适的单位索引
340
+ const index = Math.floor(Math.log(bytes) / Math.log(1024));
341
+ // 将字节数转换为目标单位
342
+ const size = bytes / Math.pow(1024, index);
343
+ // 保留两位小数,并去除多余的0
344
+ const formattedSize = size.toFixed(2).replace(/\.?0+$/, '');
345
+ return { formattedSize, unit: units[index] }
346
+ }
347
+
348
+
349
+ const api_key = 'sk-mniUFDpcWwvNF3iFzssXa6etN-S_Y4AApyHYcBU44L0';
350
+
351
+
352
+ export class MobileChatPage extends React.Component {
353
+ state = {
354
+ historyList: [], // 历史对话列表
355
+ sessionId: uuidv4(), // 当前激活的对话对应的sessionId
356
+ dropDownList: [],
357
+ sceneInfo: {},
358
+ currentFlow: {},
359
+ historyDrawerVisible: false, // 抽屉历史记录状态
360
+ agentDrawerVisible: false, // 多智能体切换抽屉状态
361
+ };
362
+
363
+ async componentDidMount() {
364
+ if(isEmpty(this.props.sceneId)){
365
+ // 兼容非场景打开的情况
366
+ this.getHistoryList({},true);
367
+ }else{
368
+ const sceneData = await this.getSceneInfo();
369
+ if(isEmpty(sceneData)) {
370
+ this.getHistoryList({},true);
371
+ } else {
372
+ this.setWindowTitle(sceneData.name)
373
+ this.getHistoryList(sceneData,true);
374
+ }
375
+ }
376
+ }
377
+
378
+ setWindowTitle = (title) => {
379
+ if (!isEmpty(title)){
380
+ document.title = title;
381
+ window.document.title = title;
382
+ }
383
+ }
384
+
385
+ getCurrentFlowHistory=(flowId)=>{
386
+ let { userInfo = {} } = this.props;
387
+ const { sessionId } = this.state;
388
+ if(isEmpty(userInfo.code)) {
389
+ userInfo.code = sessionId;
390
+ }
391
+ const operationId = userInfo['code'] || '';
392
+ console.log('getCurrentFlowHistory', flowId, operationId)
393
+ getHistoryList(this.props.hostUrl, flowId, operationId).then((res) => {
394
+ if(res.status === 200){
395
+ console.log('getCurrentFlowHistory', res.data)
396
+ this.setState({ historyList: res.data });
397
+ }
398
+ });
399
+ }
400
+
401
+ // 获取历史对话列表
402
+ getHistoryList = (sceneData, isRefreshWords) => {
403
+ const { sceneId, appId: flowId, isShowSideLeft } = this.props;
404
+ if(isEmpty(sceneId)){
405
+ // 单独组件情况
406
+ if(isRefreshWords){
407
+ this.getFlowInfo().then(currentFlow=>{
408
+ const dropDownList = this.getDropDownList(currentFlow.welcome_words);
409
+ this.setState({ dropDownList, currentFlow })
410
+ })
411
+ }
412
+ if(isShowSideLeft) {
413
+ this.getCurrentFlowHistory(flowId)
414
+ }
415
+ }else{
416
+ const currentScene = sceneData||this.state.sceneInfo;
417
+ const currentFlow = currentScene.flows[0];
418
+ console.log('getHistoryList', sceneData, currentFlow)
419
+ const dropDownList = this.getDropDownList(currentFlow.welcome_words);
420
+ if(!isEmpty(sceneData)){
421
+ this.setState({ currentFlow, dropDownList })
422
+ }else if(isEmpty(this.state.sceneInfo)){
423
+ this.setState({ dropDownList:defaultList })
424
+ }
425
+ if(isShowSideLeft) {
426
+ this.getCurrentFlowHistory(currentFlow.id)
427
+ }
428
+ }
429
+ };
430
+
431
+ getSceneInfo = async ()=>{
432
+ const res = await getSceneInfo(this.props.hostUrl, this.props.sceneId, api_key);
433
+ if(res.status === 200){
434
+ this.setState({ sceneInfo: res.data });
435
+ }
436
+ return res.data;
437
+ }
438
+
439
+ getFlowInfo = async () => {
440
+ const res = await getFlowInfo(this.props.hostUrl, this.props.appId, api_key);
441
+ if(res.status === 200) {
442
+ this.setState({ sceneInfo: res.data });
443
+ }
444
+ return res.data;
445
+ }
446
+
447
+ // 新建对话
448
+ newDialog = () => {
449
+ if(this.state.dropDownList) {
450
+ messageTip.info("当前已是最新对话")
451
+ return;
452
+ }
453
+ this.setState({ sessionId: uuidv4() });
454
+ this.setState({ dropDownList: this.getDropDownList(this.state.currentFlow.welcome_words), drawerVisible: false })
455
+ }
456
+
457
+ updateSessionId = (sessionId) => {
458
+ this.setState({ sessionId });
459
+ };
460
+
461
+ getDropDownList = (welcome_words)=>{
462
+ if(isEmpty(welcome_words)){
463
+ return defaultList;
464
+ }
465
+ return welcome_words.map((question,index)=>(
466
+ {
467
+ backgroundImg:defaultList[index].backgroundImg,
468
+ title:question,
469
+ }
470
+ ))
471
+ }
472
+
473
+ render() {
474
+ const {
475
+ title,
476
+ appId: flowId,
477
+ hostUrl,
478
+ setDialogVisible,
479
+ userInfo,
480
+ boxStyle,
481
+ isShowSideRight,
482
+ isShowSideLeft = true,
483
+ tags = [],
484
+ agentUrl = aiAvatarPng,
485
+ agentName = '校园智多星',
486
+ logoWidth = '42px',
487
+ logoFontSize = '26px',
488
+ isTitleSideIcon = false,// 是否将左侧历史顶部icon移到中间顶部左侧蓝点位置
489
+ modalIndex,
490
+ isShowVoiceButton,
491
+ isShowUploadButton,
492
+ dropManUrl,
493
+ modalWidth,
494
+ isLogin = false,
495
+ isShowLogin = false,
496
+ loginBtnClick,
497
+ } = this.props;
498
+ const { sceneInfo, currentFlow = {} } = this.state;
499
+ const { flows = [], name: sceneName, character } = sceneInfo;
500
+ return (
501
+ <div style={boxStyle}>
502
+ <style dangerouslySetInnerHTML={{ __html: style }}></style>
503
+ <div style={{ position: 'absolute', top: '15px', right: '14px', zIndex: modalIndex }}>
504
+ {isFunction(setDialogVisible) &&
505
+ <img onClick={() => setDialogVisible(false)} className="p_closeImg" src={closePng}/>}
506
+ </div>
507
+ <div className="p_toolDialog" style={{borderRadius:0, backgroundImage:'url(https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/kai_yuan/yt/agent_list_bg2.png)'}}>
508
+ {
509
+ isShowSideLeft && (
510
+ <>
511
+ <img
512
+ src={icon_history}
513
+ style={{
514
+ width: '40px',
515
+ height: '40px',
516
+ position: 'absolute',
517
+ left: '0px',
518
+ top: '0px',
519
+ zIndex: 1000
520
+ }}
521
+ onClick={() => this.setState({drawerVisible: true})}
522
+ />
523
+ <Drawer
524
+ title={null}
525
+ closable={false}
526
+ placement="left"
527
+ width={'80%'}
528
+ bodyStyle={{padding: 0}}
529
+ onClose={() => this.setState({drawerVisible: false})}
530
+ open={this.state.drawerVisible}
531
+ >
532
+ <div className="drawer-history-header" style={{marginTop:0, padding: '54px 14px 14px 14px', background: 'linear-gradient( 71deg, #E1E9FF 0%, #FFFFFF 100%)', position: "relative"}}>
533
+ <img src={icon_history_headerbg} style={{position: 'absolute', right: 0, bottom: 0, width: '40%', zIndex:0}}/>
534
+ <div className="drawer-history-header-title" style={{display: 'flex', flexDirection: 'row', alignItems: 'center'}}>
535
+ <img style={{width: 35}} src={agentUrl}/>
536
+ <span style={{fontSize: 24, marginLeft: 10}}>{agentName}</span>
537
+ </div>
538
+ <div className="drawer-history-header-tool" style={{display: 'flex',flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', marginTop: 32 }}>
539
+ <div
540
+ style={{display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', marginRight: 20, height: 44,background: '#fff', borderRadius: 5,width: '45%'}}
541
+ onClick={() => {this.newDialog()}}
542
+ >
543
+ <img src={icon_history_add} style={{width: '20px', height: '20px', marginRight: 10}}/>
544
+ <span>新建对话</span>
545
+ </div>
546
+ <div
547
+ style={{
548
+ display: 'flex',
549
+ flexDirection: 'row',
550
+ alignItems: 'center',
551
+ justifyContent: 'center',
552
+ marginRight: 20,
553
+ height: 44,
554
+ background: '#fff',
555
+ borderRadius: 5,
556
+ width: '45%',
557
+ zIndex: 0
558
+ }}
559
+ onClick={() => messageTip.info("敬请期待")}
560
+ >
561
+ <img src={icon_history_upload} style={{width: '20px', height: '20px', marginRight: 10}}/>
562
+ <span>个人知识库</span>
563
+ </div>
564
+ </div>
565
+ </div>
566
+ <div
567
+ className="p_historyDialog"
568
+ style={{
569
+ height: 'calc(100% - 179px - 114px)',
570
+ boxSizing: 'border-box',
571
+ userSelect: 'none',
572
+ flex: 1,
573
+ padding: '30px 14px 0 14px',
574
+ background: 'linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 100%)',
575
+ borderImage: 'linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(255, 255, 255, 0)) 1 1',
576
+ backdropFilter: 'blur(10px)',
577
+ position: 'relative',
578
+ }}
579
+ >
580
+ <div className="p_historyTitle" style={{display: 'flex', flexDirection: 'row', alignItems: 'center', marginBottom: 20}}>
581
+ <img className="p_historyImg" src={historyPng} style={{width: '20px', height: '20px', marginRight: 10}}/>
582
+ <div className="p_dialogTitle" style={{fontSize: 18, fontWeight: 400, color: '#333'}}>对话记录</div>
583
+ </div>
584
+ {this.state.historyList.length > 0 ? (
585
+ <div className="p_historyList" style={{overflowY: 'auto',height: 'calc(100% - 50px)'}}>
586
+ {this.state.historyList?.map((item) => (
587
+ <div
588
+ key={item.session_id}
589
+ className="p_historyItem"
590
+ style={{
591
+ display: 'flex',
592
+ height: 44,
593
+ alignItems: 'center',
594
+ paddingLeft: 30,
595
+ paddingRight: 30,
596
+ fontWeight: 400,
597
+ fontSize: 14,
598
+ color: '#333',
599
+ borderRadius: 10,
600
+ background: item.session_id === this.state.sessionId ? '#F5F5FF' : '#fff',
601
+ }}
602
+ onClick={() => {
603
+ this.setState({dropDownList: undefined, drawerVisible: false})
604
+ this.updateSessionId(item.session_id);
605
+ }}
606
+ >
607
+ <div
608
+ className={`p_historyName ${
609
+ item.session_id === this.state.sessionId ? 'p_activeHistoryName' : ''
610
+ }`}
611
+ style={{
612
+ whiteSpace: 'nowrap',
613
+ overflow: 'hidden',
614
+ textOverflow: 'ellipsis',
615
+ color: item.session_id === this.state.sessionId ? '#1551FF' : '#333',
616
+ }}
617
+ >
618
+ {item.text}
619
+ </div>
620
+ </div>
621
+ ))}
622
+ </div>
623
+ ) : (
624
+ <div className="p_historyListEmpty" style={{display: 'flex', flexDirection: 'column', alignItems: 'center', marginTop: 50}}>
625
+ <img src={historyListEmptyPng} style={{width: '100px', height: '100px', marginBottom: 20}}/>
626
+ <div className="p_historyListEmptyText" style={{fontSize: 16, color: '#999' }}>暂无对话记录</div>
627
+ </div>
628
+ )}
629
+ </div>
630
+ <div style={{display: 'flex', justifyContent: 'center', alignItems: 'center', marginTop: 20, marginBottom: 50}}>
631
+ {
632
+ isShowLogin &&
633
+ <div
634
+ style={{
635
+ display: 'flex',
636
+ justifyContent: 'center',
637
+ alignItems: 'center',
638
+ width: '80%',
639
+ height: 44,
640
+ color: '#fff',
641
+ background: 'linear-gradient( 30deg, #1551FF 0%, #8F4BFF 100%)',
642
+ borderRadius: 10
643
+ }}
644
+ onClick={() => {
645
+ if (isFunction(loginBtnClick)){
646
+ loginBtnClick()
647
+ }else {
648
+ if (typeof wx !== 'undefined' && wx.miniProgram) {
649
+ wx.miniProgram.navigateTo({url: '/pages/login/index'});
650
+ }
651
+ }
652
+ }}
653
+ >
654
+ {isLogin ? '退出登录' : '登录'}
655
+ </div>
656
+ }
657
+ </div>
658
+ </Drawer>
659
+ </>
660
+ )
661
+ }
662
+ <div className="p_toolRight">
663
+ <ChatWidget
664
+ input_container_style={{zIndex:2}}
665
+ chat_window_style={{paddingTop: 0}}
666
+ bot_message_style={{background: '#fff'}}
667
+ window_title={currentFlow?.name || title}
668
+ flow_id={currentFlow?.id || flowId}
669
+ tags={currentFlow?.keywords || tags}
670
+ host_url={hostUrl}
671
+ api_key={api_key}
672
+ session_id={this.state.sessionId}
673
+ userInfo={userInfo}
674
+ getHistoryList={this.getHistoryList}
675
+ setDropDownList={(list) => this.setState({dropDownList: list})}
676
+ dropDownList={this.state.dropDownList}
677
+ baseConfig={{isTitleSideIcon, logoWidth, agentUrl}}
678
+ isShowVoiceButton={isShowVoiceButton}
679
+ isShowUploadButton={isShowUploadButton}
680
+ dropManUrl={character || dropManUrl}
681
+ modalWidth={modalWidth}
682
+ isMobile={true}
683
+ isShowChatHeader={false}
684
+ />
685
+ </div>
686
+ {
687
+ isShowSideRight && (
688
+ <>
689
+ <img
690
+ src={icon_agents}
691
+ style={{
692
+ width: '60px',
693
+ height: '60px',
694
+ position: 'absolute',
695
+ right: '0px',
696
+ bottom: '200px',
697
+ zIndex: 1000
698
+ }}
699
+ onClick={() => this.setState({agentDrawerVisible: true})}
700
+ />
701
+ <Drawer
702
+ title={'专项技能'}
703
+ // closable={false}
704
+ placement="right"
705
+ width={'100%'}
706
+ style={{
707
+ backgroundImage: 'url(https://trans-from-yuntu-resourse.oss-cn-beijing.aliyuncs.com/kai_yuan/yt/agent_list_bg.png)',
708
+ backgroundSize: 'cover',
709
+ backgroundRepeat: 'no-repeat',
710
+ backgroundPosition: 'center'
711
+ }}
712
+ bodyStyle={{
713
+ padding: 0,
714
+ }}
715
+ onClose={() => this.setState({agentDrawerVisible: false})}
716
+ open={this.state.agentDrawerVisible}
717
+ >
718
+ <div
719
+ className={"p_toolRightToRight"}
720
+ style={{
721
+ width:'100%',
722
+ display:'flex',
723
+ boxSizing:'border-box',
724
+ flexDirection:'column',
725
+ padding: '1rem 1rem 1rem 1rem',
726
+ }}
727
+ >
728
+ <div
729
+ className={"rightInnerContainer"}
730
+ style={{
731
+ width:'100%',
732
+ display:'flex',
733
+ flexDirection:'row',
734
+ justifyContent:'space-between',
735
+
736
+ }}
737
+ >
738
+ <div style={{width:'100%'}}>
739
+ {/*<h3 className={"rightSideTitle"}>*/}
740
+ {/* <img width={15} src={self_skills}/>*/}
741
+ {/* <span style={{color: "#333333"}}>专项技能</span>*/}
742
+ {/*</h3>*/}
743
+ {
744
+ isEmpty(flows) ?
745
+ <Skeleton
746
+ title={false}
747
+ active
748
+ paragraph={{rows: 5, width: '100%'}}
749
+ />
750
+ :
751
+ <div className={"rightSkillContainer"} style={{width:'100%'}}>
752
+ <div
753
+ className={"rightSkillList"}
754
+ style={{
755
+ width:'100%',
756
+ display: 'grid',
757
+ gridTemplateColumns: 'repeat(2, 1fr)', /* 每行 2 列 */
758
+ gap: 20 /* 设置列和行之间的间距 */
759
+ }}>
760
+ {flows.slice(0, 12).map((item) => (
761
+ <div
762
+ key={item.id}
763
+ className={"rightSkillItem"}
764
+ style={{
765
+ display: 'flex',
766
+ flexDirection: 'column',
767
+ background: '#fff',
768
+ borderRadius: 22,
769
+ opacity: 0.7,
770
+ width:'100%',
771
+ height: '45vw',
772
+ boxSizing: 'border-box',
773
+ padding: '18px',
774
+ }}
775
+ onClick={() => {
776
+ // 右侧点击一个技能,更新sessionId,切换当前flow信息,重新查询历史记录
777
+ this.setState({
778
+ sessionId: uuidv4(),
779
+ currentFlow: item,
780
+ dropDownList: this.getDropDownList(item.welcome_words),
781
+ agentDrawerVisible: false,
782
+ });
783
+ this.setWindowTitle(item.name)
784
+ this.getCurrentFlowHistory(item.id);
785
+ }}
786
+ >
787
+ <img
788
+ src={item.icon}
789
+ alt={item.name}
790
+ style={{width: '40px', height: '40px'}}
791
+ />
792
+ <div style={{marginTop: '12px', color: '#333333', fontWeight: "bold", fontSize: '14px', textAlign: "left"}}>{item.name}</div>
793
+ <div style={{marginTop: '8px', color: '#333333', fontSize: '10px', textAlign: "left"}}>{item.content}</div>
794
+ </div>
795
+ ))}
796
+ </div>
797
+ </div>
798
+ }
799
+ </div>
800
+ {/*<div>*/}
801
+ {/* <h3 className={"rightKnowledgeTitle"}>*/}
802
+ {/* <img width={15} src={self_knowledge}/>*/}
803
+ {/* <span style={{color: "#333333"}}>个人知识库</span>*/}
804
+ {/* </h3>*/}
805
+ {/* {*/}
806
+ {/* isEmpty(currentFlow) ?*/}
807
+ {/* <Skeleton*/}
808
+ {/* title={false}*/}
809
+ {/* active*/}
810
+ {/* paragraph={{rows: 5, width: '100%'}}*/}
811
+ {/* /> :*/}
812
+ {/* <div className={"rightKnowledgeContainer"}>*/}
813
+ {/* <img src={moreBg}/>*/}
814
+ {/* <div style={{position: 'absolute', top: '40px', left: '16px'}}>*/}
815
+ {/* <div>文件总数<span style={{*/}
816
+ {/* padding: 8,*/}
817
+ {/* fontSize: '20px',*/}
818
+ {/* fontWeight: 700*/}
819
+ {/* }}>{currentFlow.k_count || 0}</span>个*/}
820
+ {/* </div>*/}
821
+ {/* <div style={{marginTop: 10}}>文件总量<span style={{*/}
822
+ {/* padding: 8,*/}
823
+ {/* fontSize: '20px',*/}
824
+ {/* fontWeight: 700*/}
825
+ {/* }}>{formatFileSize(currentFlow.k_size).formattedSize}</span>{formatFileSize(currentFlow.k_size).unit}*/}
826
+ {/* </div>*/}
827
+ {/* </div>*/}
828
+ {/* <div className={"rightMoreButton"}>*/}
829
+ {/* <div className={"rightMoreTitle"}*/}
830
+ {/* onClick={() => messageTip.info("敬请期待")}>训练你的专属知识库*/}
831
+ {/* </div>*/}
832
+ {/* </div>*/}
833
+ {/* </div>*/}
834
+ {/* }*/}
835
+ {/*</div>*/}
836
+ </div>
837
+ </div>
838
+ </Drawer>
839
+ </>
840
+ )
841
+ }
842
+ </div>
843
+ </div>
844
+ );
845
+ }
846
+ }
847
+
848
+ export default MobileChatPage;