whyuzeim 1.1.41 → 1.1.43
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/cjs/HighlyCustomChat/AIReportMsg/index.d.ts +12 -0
- package/cjs/HighlyCustomChat/AIReportMsg/index.js +95 -0
- package/cjs/HighlyCustomChat/AIReportMsg/style/index.module.scss +0 -0
- package/cjs/HighlyCustomChat/CodeMsg/index.d.ts +12 -0
- package/cjs/HighlyCustomChat/CodeMsg/index.js +97 -0
- package/cjs/HighlyCustomChat/CodeMsg/style/index.moduel.scss +0 -0
- package/cjs/HighlyCustomChat/QuestionButton/index.d.ts +11 -0
- package/cjs/HighlyCustomChat/QuestionButton/index.js +59 -0
- package/cjs/HighlyCustomChat/QuestionButton/style/index.scss +0 -0
- package/cjs/HighlyCustomChat/index.d.ts +3 -0
- package/cjs/HighlyCustomChat/index.js +36 -1
- package/cjs/type.d.ts +72 -0
- package/es/HighlyCustomChat/AIReportMsg/index.d.ts +12 -0
- package/es/HighlyCustomChat/AIReportMsg/index.js +93 -0
- package/es/HighlyCustomChat/AIReportMsg/style/index.module.scss +0 -0
- package/es/HighlyCustomChat/CodeMsg/index.d.ts +12 -0
- package/es/HighlyCustomChat/CodeMsg/index.js +95 -0
- package/es/HighlyCustomChat/CodeMsg/style/index.moduel.scss +0 -0
- package/es/HighlyCustomChat/QuestionButton/index.d.ts +11 -0
- package/es/HighlyCustomChat/QuestionButton/index.js +57 -0
- package/es/HighlyCustomChat/QuestionButton/style/index.scss +0 -0
- package/es/HighlyCustomChat/index.d.ts +3 -0
- package/es/HighlyCustomChat/index.js +36 -1
- package/es/type.d.ts +72 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AIReportMessageExts } from "@components/type";
|
|
2
|
+
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
3
|
+
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
4
|
+
import React from "react";
|
|
5
|
+
interface IAIReportMsg {
|
|
6
|
+
msg: ChatSDK.MessageBody | NoticeMessageBody;
|
|
7
|
+
isMySelf: boolean;
|
|
8
|
+
avatar?: React.ReactNode;
|
|
9
|
+
onReportClick?: (report: AIReportMessageExts) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const AIReportMsg: React.FC<IAIReportMsg>;
|
|
12
|
+
export default AIReportMsg;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var agoraChatUikit = require('agora-chat-uikit');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
var AIReportMsg = function AIReportMsg(props) {
|
|
7
|
+
var msg = props.msg,
|
|
8
|
+
isMySelf = props.isMySelf,
|
|
9
|
+
avatar = props.avatar,
|
|
10
|
+
onReportClick = props.onReportClick;
|
|
11
|
+
var formatMessageTime = function formatMessageTime(timestamp) {
|
|
12
|
+
if (!timestamp) return "";
|
|
13
|
+
var date = new Date(timestamp);
|
|
14
|
+
var now = new Date();
|
|
15
|
+
// 判断是否是同一天
|
|
16
|
+
var isToday = date.toDateString() === now.toDateString();
|
|
17
|
+
if (isToday) {
|
|
18
|
+
// 当天消息只显示时分
|
|
19
|
+
return date.toLocaleString("zh-CN", {
|
|
20
|
+
hour: "2-digit",
|
|
21
|
+
minute: "2-digit",
|
|
22
|
+
hour12: false
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
// 非当天消息显示月日时分
|
|
26
|
+
return date.toLocaleString("zh-CN", {
|
|
27
|
+
month: "2-digit",
|
|
28
|
+
day: "2-digit",
|
|
29
|
+
hour: "2-digit",
|
|
30
|
+
minute: "2-digit",
|
|
31
|
+
hour12: false
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return /*#__PURE__*/React.createElement(agoraChatUikit.BaseMessage, {
|
|
36
|
+
bubbleType: "none",
|
|
37
|
+
reaction: false,
|
|
38
|
+
select: false,
|
|
39
|
+
thread: false,
|
|
40
|
+
direction: isMySelf ? "rtl" : "ltr",
|
|
41
|
+
renderUserProfile: function renderUserProfile() {
|
|
42
|
+
return null;
|
|
43
|
+
},
|
|
44
|
+
nickName: undefined,
|
|
45
|
+
showMessageInfo: false,
|
|
46
|
+
message: msg,
|
|
47
|
+
customAction: {
|
|
48
|
+
visible: false,
|
|
49
|
+
icon: null,
|
|
50
|
+
actions: []
|
|
51
|
+
},
|
|
52
|
+
avatar: avatar
|
|
53
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
55
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
style: {
|
|
57
|
+
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
58
|
+
borderRadius: "9px",
|
|
59
|
+
padding: "10px 12px",
|
|
60
|
+
color: "var(--im-msg-bubble-font-color)"
|
|
61
|
+
},
|
|
62
|
+
className: "w-full flex flex-col gap-4"
|
|
63
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: "flex items-center justify-between"
|
|
65
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: "flex items-center"
|
|
67
|
+
}, /*#__PURE__*/React.createElement("span", null, "\uD83D\uDCE2"), /*#__PURE__*/React.createElement("span", {
|
|
68
|
+
className: "text-lg font-semibold"
|
|
69
|
+
}, "\xA0", msg.customExts.title)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
|
|
70
|
+
className: "cui-message-base-time"
|
|
71
|
+
}, formatMessageTime(msg.time)))), /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: "flex items-center",
|
|
73
|
+
onClick: function onClick() {
|
|
74
|
+
onReportClick && onReportClick(msg.customExts);
|
|
75
|
+
}
|
|
76
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
77
|
+
className: "text-base"
|
|
78
|
+
}, msg.customExts.content), /*#__PURE__*/React.createElement("svg", {
|
|
79
|
+
className: "shrink-0",
|
|
80
|
+
width: "8",
|
|
81
|
+
height: "14",
|
|
82
|
+
viewBox: "0 0 8 14",
|
|
83
|
+
fill: "none",
|
|
84
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
85
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
86
|
+
d: "M1.16667 1L7 7L1.16667 13",
|
|
87
|
+
stroke: "black",
|
|
88
|
+
"stroke-opacity": "0.4",
|
|
89
|
+
"stroke-width": "1.5",
|
|
90
|
+
"stroke-linecap": "round",
|
|
91
|
+
"stroke-linejoin": "round"
|
|
92
|
+
}))))));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
module.exports = AIReportMsg;
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
2
|
+
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
3
|
+
import 'highlight.js/styles/monokai.css';
|
|
4
|
+
import React from "react";
|
|
5
|
+
interface ICodeMsg {
|
|
6
|
+
msg: ChatSDK.MessageBody | NoticeMessageBody;
|
|
7
|
+
isMySelf: boolean;
|
|
8
|
+
avatar?: React.ReactNode;
|
|
9
|
+
onApply?: (code: string) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const CodeMsg: React.FC<ICodeMsg>;
|
|
12
|
+
export default CodeMsg;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var agoraChatUikit = require('agora-chat-uikit');
|
|
4
|
+
var hljs = require('highlight.js');
|
|
5
|
+
require('highlight.js/styles/monokai.css');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
9
|
+
var CodeMsg = function CodeMsg(props) {
|
|
10
|
+
var _msg$msg;
|
|
11
|
+
var msg = props.msg,
|
|
12
|
+
isMySelf = props.isMySelf,
|
|
13
|
+
avatar = props.avatar,
|
|
14
|
+
onApply = props.onApply;
|
|
15
|
+
var rawCode = (_msg$msg = msg.msg) === null || _msg$msg === void 0 ? void 0 : _msg$msg.replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
16
|
+
// 修改高亮代码的函数
|
|
17
|
+
return /*#__PURE__*/React.createElement(agoraChatUikit.BaseMessage, {
|
|
18
|
+
bubbleType: "none",
|
|
19
|
+
reaction: false,
|
|
20
|
+
select: false,
|
|
21
|
+
thread: false,
|
|
22
|
+
direction: isMySelf ? "rtl" : "ltr",
|
|
23
|
+
renderUserProfile: function renderUserProfile() {
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
26
|
+
nickName: undefined,
|
|
27
|
+
showMessageInfo: false,
|
|
28
|
+
message: msg,
|
|
29
|
+
customAction: {
|
|
30
|
+
visible: false,
|
|
31
|
+
icon: null,
|
|
32
|
+
actions: []
|
|
33
|
+
},
|
|
34
|
+
avatar: avatar
|
|
35
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
37
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
style: {
|
|
39
|
+
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
40
|
+
borderRadius: "9px",
|
|
41
|
+
padding: "10px 12px",
|
|
42
|
+
color: "var(--im-msg-bubble-font-color)"
|
|
43
|
+
},
|
|
44
|
+
className: "inline-block"
|
|
45
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: "p-4 flex justify-between items-center flex-shrink-0"
|
|
47
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "flex items-center gap-1 text-white text-[10px] font-normal"
|
|
49
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
50
|
+
width: "11",
|
|
51
|
+
height: "11",
|
|
52
|
+
viewBox: "0 0 11 11",
|
|
53
|
+
fill: "none",
|
|
54
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
55
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
56
|
+
fillRule: "evenodd",
|
|
57
|
+
clipRule: "evenodd",
|
|
58
|
+
d: "M8 0.0214844H2.58333V2.5396H0.0214844V8.01198H2.58333V10.5301H8V8.01198H10.5618V2.5396H8V0.0214844Z",
|
|
59
|
+
fill: "#0083FF"
|
|
60
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
61
|
+
className: "text-[#000]"
|
|
62
|
+
}, "main.py")), /*#__PURE__*/React.createElement("button", {
|
|
63
|
+
onClick: function onClick() {
|
|
64
|
+
onApply && onApply(msg.customExts.code);
|
|
65
|
+
},
|
|
66
|
+
className: "flex items-center h-6 px-2 py-1 bg-white rounded text-black/90 text-[10px] font-normal"
|
|
67
|
+
}, "Apply")), /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: "flex-1 px-4 pt-2 pb-4 gap-2 flex flex-col justify-between h-full overflow-hidden"
|
|
69
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: "code-scroll-container w-full max-h-[300px] overflow-y-auto"
|
|
71
|
+
}, /*#__PURE__*/React.createElement("pre", {
|
|
72
|
+
className: "bg-transparent w-full h-full"
|
|
73
|
+
}, /*#__PURE__*/React.createElement("code", {
|
|
74
|
+
className: "language-python hljs",
|
|
75
|
+
style: {
|
|
76
|
+
display: "block",
|
|
77
|
+
overflow: "auto",
|
|
78
|
+
background: "transparent",
|
|
79
|
+
fontSize: "14px",
|
|
80
|
+
lineHeight: "1.5",
|
|
81
|
+
fontFamily: "Monaco, Consolas, monospace",
|
|
82
|
+
whiteSpace: "pre-wrap",
|
|
83
|
+
wordWrap: "break-word",
|
|
84
|
+
width: "100%",
|
|
85
|
+
maxWidth: "100%",
|
|
86
|
+
padding: "0.5rem"
|
|
87
|
+
},
|
|
88
|
+
dangerouslySetInnerHTML: {
|
|
89
|
+
__html: hljs.highlight(rawCode, {
|
|
90
|
+
language: "python",
|
|
91
|
+
ignoreIllegals: true
|
|
92
|
+
}).value
|
|
93
|
+
}
|
|
94
|
+
})))))));
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
module.exports = CodeMsg;
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
2
|
+
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface IQuestionButtonMsg {
|
|
5
|
+
msg: ChatSDK.MessageBody | NoticeMessageBody;
|
|
6
|
+
isMySelf: boolean;
|
|
7
|
+
avatar?: React.ReactNode;
|
|
8
|
+
onSelectAnswer?: (answer: string) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const QustionButtonMsg: React.FC<IQuestionButtonMsg>;
|
|
11
|
+
export default QustionButtonMsg;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
4
|
+
var agoraChatUikit = require('agora-chat-uikit');
|
|
5
|
+
var antd = require('antd');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
var QustionButtonMsg = function QustionButtonMsg(props) {
|
|
9
|
+
var _context;
|
|
10
|
+
var msg = props.msg,
|
|
11
|
+
isMySelf = props.isMySelf,
|
|
12
|
+
avatar = props.avatar,
|
|
13
|
+
onSelectAnswer = props.onSelectAnswer;
|
|
14
|
+
return /*#__PURE__*/React.createElement(agoraChatUikit.BaseMessage, {
|
|
15
|
+
bubbleType: "none",
|
|
16
|
+
reaction: false,
|
|
17
|
+
select: false,
|
|
18
|
+
thread: false,
|
|
19
|
+
direction: isMySelf ? "rtl" : "ltr",
|
|
20
|
+
renderUserProfile: function renderUserProfile() {
|
|
21
|
+
return null;
|
|
22
|
+
},
|
|
23
|
+
nickName: undefined,
|
|
24
|
+
showMessageInfo: false,
|
|
25
|
+
message: msg,
|
|
26
|
+
customAction: {
|
|
27
|
+
visible: false,
|
|
28
|
+
icon: null,
|
|
29
|
+
actions: []
|
|
30
|
+
},
|
|
31
|
+
avatar: avatar
|
|
32
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
34
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
style: {
|
|
36
|
+
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
37
|
+
borderRadius: "9px",
|
|
38
|
+
padding: "10px 12px",
|
|
39
|
+
color: "var(--im-msg-bubble-font-color)"
|
|
40
|
+
},
|
|
41
|
+
className: "inline-block"
|
|
42
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
className: "cui-message-text"
|
|
44
|
+
}, msg.customExts.content)), /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
className: "flex flex-col gap-3"
|
|
46
|
+
}, _mapInstanceProperty(_context = msg.customExts.guidance_list).call(_context, function (text) {
|
|
47
|
+
return /*#__PURE__*/React.createElement(antd.Button, {
|
|
48
|
+
key: text,
|
|
49
|
+
className: "w-[400px] !h-[45px] !bg-[#2c7cf5]",
|
|
50
|
+
onClick: function onClick() {
|
|
51
|
+
onSelectAnswer && onSelectAnswer(text);
|
|
52
|
+
}
|
|
53
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
54
|
+
className: "text-[#fff]"
|
|
55
|
+
}, text));
|
|
56
|
+
}))));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
module.exports = QustionButtonMsg;
|
|
File without changes
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Conversation } from "agora-chat-uikit";
|
|
3
3
|
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
4
4
|
import { ChatType } from "agora-chat-uikit/types/module/types/messageType";
|
|
5
|
+
import { AIReportMessageExts } from "@components/type";
|
|
5
6
|
import "./style/index.scss";
|
|
6
7
|
export interface IHighlyCustomChat {
|
|
7
8
|
conversationId: string;
|
|
@@ -13,6 +14,8 @@ export interface IHighlyCustomChat {
|
|
|
13
14
|
renderQuestionList?: (cvs: Conversation, sendMessage: (text: string) => void) => React.ReactNode;
|
|
14
15
|
sendMessageSuccessCallback?: (msg: ChatSDK.MessageBody) => void;
|
|
15
16
|
onLoginSuccess?: () => void;
|
|
17
|
+
onApply?: (code: string) => void;
|
|
18
|
+
onReportClick?: (report: AIReportMessageExts) => void;
|
|
16
19
|
}
|
|
17
20
|
declare const HighlyCustomChat: React.FC<IHighlyCustomChat>;
|
|
18
21
|
export default HighlyCustomChat;
|
|
@@ -24,7 +24,10 @@ var type = require('../type.js');
|
|
|
24
24
|
var tools = require('../tools.js');
|
|
25
25
|
var avatar_default = require('../Icon/avatar_default.svg.js');
|
|
26
26
|
var encryption = require('../IM/encryption.js');
|
|
27
|
+
var index$2 = require('./QuestionButton/index.js');
|
|
28
|
+
var index$1 = require('./CodeMsg/index.js');
|
|
27
29
|
require('./style/index.scss');
|
|
30
|
+
var index = require('./AIReportMsg/index.js');
|
|
28
31
|
|
|
29
32
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
33
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), true)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -139,6 +142,8 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
139
142
|
}, formatMessageTime(msg.time)));
|
|
140
143
|
};
|
|
141
144
|
var _renderMessage = function renderMessage(msg) {
|
|
145
|
+
var _userInfo$uid3;
|
|
146
|
+
var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid3 = userInfo.uid) === null || _userInfo$uid3 === void 0 ? void 0 : _userInfo$uid3.toLowerCase());
|
|
142
147
|
if (msg.type === "txt") {
|
|
143
148
|
return renderTxtMsg(msg);
|
|
144
149
|
} else if (msg.type === "img") {
|
|
@@ -192,6 +197,36 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
192
197
|
},
|
|
193
198
|
videoMessage: msg
|
|
194
199
|
});
|
|
200
|
+
} else if (msg.type === "custom" && (msg === null || msg === void 0 ? void 0 : msg.customEvent) === "custom_ai_report") {
|
|
201
|
+
return /*#__PURE__*/React.createElement(index, {
|
|
202
|
+
onReportClick: props.onReportClick,
|
|
203
|
+
msg: msg,
|
|
204
|
+
isMySelf: isMySelf,
|
|
205
|
+
avatar: !isMySelf ? /*#__PURE__*/React.createElement("img", {
|
|
206
|
+
src: headerInfo.headerImageURL || avatar_default,
|
|
207
|
+
className: "w-[48px] h-[48px] rounded-full overflow-hidden object-fit"
|
|
208
|
+
}) : undefined
|
|
209
|
+
});
|
|
210
|
+
} else if (msg.type === "custom" && (msg === null || msg === void 0 ? void 0 : msg.customEvent) === "custom_coding") {
|
|
211
|
+
return /*#__PURE__*/React.createElement(index$1, {
|
|
212
|
+
onApply: props.onApply,
|
|
213
|
+
msg: msg,
|
|
214
|
+
isMySelf: isMySelf,
|
|
215
|
+
avatar: !isMySelf ? /*#__PURE__*/React.createElement("img", {
|
|
216
|
+
src: headerInfo.headerImageURL || avatar_default,
|
|
217
|
+
className: "w-[48px] h-[48px] rounded-full overflow-hidden object-fit"
|
|
218
|
+
}) : undefined
|
|
219
|
+
});
|
|
220
|
+
} else if (msg.type === "custom" && (msg === null || msg === void 0 ? void 0 : msg.customEvent) === "custom_qa_guidance") {
|
|
221
|
+
return /*#__PURE__*/React.createElement(index$2, {
|
|
222
|
+
onSelectAnswer: handleSendMessage,
|
|
223
|
+
msg: msg,
|
|
224
|
+
isMySelf: isMySelf,
|
|
225
|
+
avatar: !isMySelf ? /*#__PURE__*/React.createElement("img", {
|
|
226
|
+
src: headerInfo.headerImageURL || avatar_default,
|
|
227
|
+
className: "w-[48px] h-[48px] rounded-full overflow-hidden object-fit"
|
|
228
|
+
}) : undefined
|
|
229
|
+
});
|
|
195
230
|
} else {
|
|
196
231
|
return undefined;
|
|
197
232
|
}
|
|
@@ -403,7 +438,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
403
438
|
cuiScrollList = document.querySelector(".cui-scrollList div");
|
|
404
439
|
cuiScrollListWrap = document.querySelector(".cui-scrollList");
|
|
405
440
|
if (cuiScrollList) {
|
|
406
|
-
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\"
|
|
441
|
+
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\"></span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
|
|
407
442
|
template = document.createElement('template');
|
|
408
443
|
template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
|
|
409
444
|
node = template.content.firstChild;
|
package/cjs/type.d.ts
CHANGED
|
@@ -1,7 +1,79 @@
|
|
|
1
1
|
import { MessageInputProps, MsgListProps } from "agora-chat-uikit";
|
|
2
|
+
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
3
|
+
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
2
4
|
export type ICommonComponentProps = {
|
|
3
5
|
className?: string;
|
|
4
6
|
style?: React.CSSProperties;
|
|
5
7
|
};
|
|
6
8
|
export declare const commonMessageInputConfig: MessageInputProps;
|
|
7
9
|
export declare const commonMessageProps: MsgListProps['messageProps'];
|
|
10
|
+
/**
|
|
11
|
+
* 自定义IM消息类型
|
|
12
|
+
* 基于Agora的ChatSDK.MessageBody扩展
|
|
13
|
+
*/
|
|
14
|
+
export interface AIReportMessageExts {
|
|
15
|
+
/** 报告标题 */
|
|
16
|
+
title: string;
|
|
17
|
+
/** 报告描述内容 */
|
|
18
|
+
content: string;
|
|
19
|
+
/** token地址 */
|
|
20
|
+
tokenaddress: string;
|
|
21
|
+
/** token铸造平台: pumpfun, moonpump 或 others */
|
|
22
|
+
platform: 'pumpfun' | 'moonpump' | 'others';
|
|
23
|
+
/** 是否已在交易所上架: yes - 已在交易所; no - 内盘 */
|
|
24
|
+
isOnDex: boolean;
|
|
25
|
+
/** token名称 */
|
|
26
|
+
token_name: string;
|
|
27
|
+
/** token符号 */
|
|
28
|
+
token_symbol: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PythonCodeMessageExts {
|
|
31
|
+
/** 代码内容 */
|
|
32
|
+
code: string;
|
|
33
|
+
/** 代码类型 默认‘python’ */
|
|
34
|
+
code_type: string;
|
|
35
|
+
/** 是否显示apply按钮 */
|
|
36
|
+
can_apply: boolean;
|
|
37
|
+
/** 是否显示copy按钮 */
|
|
38
|
+
can_copy: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface QAGuidanceMessageExts {
|
|
41
|
+
/** 引导内容描述 */
|
|
42
|
+
content: string;
|
|
43
|
+
/** 引导词数组,包含0到多个引导选项 */
|
|
44
|
+
guidance_list: string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 自定义消息类型定义
|
|
48
|
+
* 每种类型都与特定的扩展字段结构关联
|
|
49
|
+
*/
|
|
50
|
+
/** AI报告消息 */
|
|
51
|
+
export interface AIReportMessage {
|
|
52
|
+
customEvent: 'custom_ai_report';
|
|
53
|
+
customExts: AIReportMessageExts;
|
|
54
|
+
}
|
|
55
|
+
/** 编程代码消息 */
|
|
56
|
+
export interface PythonCodeMessage {
|
|
57
|
+
customEvent: 'custom_coding';
|
|
58
|
+
customExts: PythonCodeMessageExts;
|
|
59
|
+
}
|
|
60
|
+
/** 问答引导消息 */
|
|
61
|
+
export interface QAGuidanceMessage {
|
|
62
|
+
customEvent: 'custom_qa_guidance';
|
|
63
|
+
customExts: QAGuidanceMessageExts;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 自定义消息类型守卫函数,用于判断和类型转换
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* 判断是否为AI报告消息
|
|
70
|
+
*/
|
|
71
|
+
export declare function isAIReportMessage(msg: ChatSDK.MessageBody | NoticeMessageBody): msg is (ChatSDK.MessageBody | NoticeMessageBody) & AIReportMessage;
|
|
72
|
+
/**
|
|
73
|
+
* 判断是否为编程代码消息
|
|
74
|
+
*/
|
|
75
|
+
export declare function isPythonCodeMessage(msg: ChatSDK.MessageBody | NoticeMessageBody): msg is (ChatSDK.MessageBody | NoticeMessageBody) & PythonCodeMessage;
|
|
76
|
+
/**
|
|
77
|
+
* 判断是否为问答引导消息
|
|
78
|
+
*/
|
|
79
|
+
export declare function isQAGuidanceMessage(msg: ChatSDK.MessageBody | NoticeMessageBody): msg is (ChatSDK.MessageBody | NoticeMessageBody) & QAGuidanceMessage;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AIReportMessageExts } from "@components/type";
|
|
2
|
+
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
3
|
+
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
4
|
+
import React from "react";
|
|
5
|
+
interface IAIReportMsg {
|
|
6
|
+
msg: ChatSDK.MessageBody | NoticeMessageBody;
|
|
7
|
+
isMySelf: boolean;
|
|
8
|
+
avatar?: React.ReactNode;
|
|
9
|
+
onReportClick?: (report: AIReportMessageExts) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const AIReportMsg: React.FC<IAIReportMsg>;
|
|
12
|
+
export default AIReportMsg;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { BaseMessage } from 'agora-chat-uikit';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
var AIReportMsg = function AIReportMsg(props) {
|
|
5
|
+
var msg = props.msg,
|
|
6
|
+
isMySelf = props.isMySelf,
|
|
7
|
+
avatar = props.avatar,
|
|
8
|
+
onReportClick = props.onReportClick;
|
|
9
|
+
var formatMessageTime = function formatMessageTime(timestamp) {
|
|
10
|
+
if (!timestamp) return "";
|
|
11
|
+
var date = new Date(timestamp);
|
|
12
|
+
var now = new Date();
|
|
13
|
+
// 判断是否是同一天
|
|
14
|
+
var isToday = date.toDateString() === now.toDateString();
|
|
15
|
+
if (isToday) {
|
|
16
|
+
// 当天消息只显示时分
|
|
17
|
+
return date.toLocaleString("zh-CN", {
|
|
18
|
+
hour: "2-digit",
|
|
19
|
+
minute: "2-digit",
|
|
20
|
+
hour12: false
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
// 非当天消息显示月日时分
|
|
24
|
+
return date.toLocaleString("zh-CN", {
|
|
25
|
+
month: "2-digit",
|
|
26
|
+
day: "2-digit",
|
|
27
|
+
hour: "2-digit",
|
|
28
|
+
minute: "2-digit",
|
|
29
|
+
hour12: false
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/React.createElement(BaseMessage, {
|
|
34
|
+
bubbleType: "none",
|
|
35
|
+
reaction: false,
|
|
36
|
+
select: false,
|
|
37
|
+
thread: false,
|
|
38
|
+
direction: isMySelf ? "rtl" : "ltr",
|
|
39
|
+
renderUserProfile: function renderUserProfile() {
|
|
40
|
+
return null;
|
|
41
|
+
},
|
|
42
|
+
nickName: undefined,
|
|
43
|
+
showMessageInfo: false,
|
|
44
|
+
message: msg,
|
|
45
|
+
customAction: {
|
|
46
|
+
visible: false,
|
|
47
|
+
icon: null,
|
|
48
|
+
actions: []
|
|
49
|
+
},
|
|
50
|
+
avatar: avatar
|
|
51
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
53
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
54
|
+
style: {
|
|
55
|
+
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
56
|
+
borderRadius: "9px",
|
|
57
|
+
padding: "10px 12px",
|
|
58
|
+
color: "var(--im-msg-bubble-font-color)"
|
|
59
|
+
},
|
|
60
|
+
className: "w-full flex flex-col gap-4"
|
|
61
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: "flex items-center justify-between"
|
|
63
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: "flex items-center"
|
|
65
|
+
}, /*#__PURE__*/React.createElement("span", null, "\uD83D\uDCE2"), /*#__PURE__*/React.createElement("span", {
|
|
66
|
+
className: "text-lg font-semibold"
|
|
67
|
+
}, "\xA0", msg.customExts.title)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
|
|
68
|
+
className: "cui-message-base-time"
|
|
69
|
+
}, formatMessageTime(msg.time)))), /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: "flex items-center",
|
|
71
|
+
onClick: function onClick() {
|
|
72
|
+
onReportClick && onReportClick(msg.customExts);
|
|
73
|
+
}
|
|
74
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
75
|
+
className: "text-base"
|
|
76
|
+
}, msg.customExts.content), /*#__PURE__*/React.createElement("svg", {
|
|
77
|
+
className: "shrink-0",
|
|
78
|
+
width: "8",
|
|
79
|
+
height: "14",
|
|
80
|
+
viewBox: "0 0 8 14",
|
|
81
|
+
fill: "none",
|
|
82
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
83
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
84
|
+
d: "M1.16667 1L7 7L1.16667 13",
|
|
85
|
+
stroke: "black",
|
|
86
|
+
"stroke-opacity": "0.4",
|
|
87
|
+
"stroke-width": "1.5",
|
|
88
|
+
"stroke-linecap": "round",
|
|
89
|
+
"stroke-linejoin": "round"
|
|
90
|
+
}))))));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { AIReportMsg as default };
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
2
|
+
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
3
|
+
import 'highlight.js/styles/monokai.css';
|
|
4
|
+
import React from "react";
|
|
5
|
+
interface ICodeMsg {
|
|
6
|
+
msg: ChatSDK.MessageBody | NoticeMessageBody;
|
|
7
|
+
isMySelf: boolean;
|
|
8
|
+
avatar?: React.ReactNode;
|
|
9
|
+
onApply?: (code: string) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const CodeMsg: React.FC<ICodeMsg>;
|
|
12
|
+
export default CodeMsg;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BaseMessage } from 'agora-chat-uikit';
|
|
2
|
+
import hljs from 'highlight.js';
|
|
3
|
+
import 'highlight.js/styles/monokai.css';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
7
|
+
var CodeMsg = function CodeMsg(props) {
|
|
8
|
+
var _msg$msg;
|
|
9
|
+
var msg = props.msg,
|
|
10
|
+
isMySelf = props.isMySelf,
|
|
11
|
+
avatar = props.avatar,
|
|
12
|
+
onApply = props.onApply;
|
|
13
|
+
var rawCode = (_msg$msg = msg.msg) === null || _msg$msg === void 0 ? void 0 : _msg$msg.replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
|
|
14
|
+
// 修改高亮代码的函数
|
|
15
|
+
return /*#__PURE__*/React.createElement(BaseMessage, {
|
|
16
|
+
bubbleType: "none",
|
|
17
|
+
reaction: false,
|
|
18
|
+
select: false,
|
|
19
|
+
thread: false,
|
|
20
|
+
direction: isMySelf ? "rtl" : "ltr",
|
|
21
|
+
renderUserProfile: function renderUserProfile() {
|
|
22
|
+
return null;
|
|
23
|
+
},
|
|
24
|
+
nickName: undefined,
|
|
25
|
+
showMessageInfo: false,
|
|
26
|
+
message: msg,
|
|
27
|
+
customAction: {
|
|
28
|
+
visible: false,
|
|
29
|
+
icon: null,
|
|
30
|
+
actions: []
|
|
31
|
+
},
|
|
32
|
+
avatar: avatar
|
|
33
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
35
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
style: {
|
|
37
|
+
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
38
|
+
borderRadius: "9px",
|
|
39
|
+
padding: "10px 12px",
|
|
40
|
+
color: "var(--im-msg-bubble-font-color)"
|
|
41
|
+
},
|
|
42
|
+
className: "inline-block"
|
|
43
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
className: "p-4 flex justify-between items-center flex-shrink-0"
|
|
45
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: "flex items-center gap-1 text-white text-[10px] font-normal"
|
|
47
|
+
}, /*#__PURE__*/React.createElement("svg", {
|
|
48
|
+
width: "11",
|
|
49
|
+
height: "11",
|
|
50
|
+
viewBox: "0 0 11 11",
|
|
51
|
+
fill: "none",
|
|
52
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
53
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
54
|
+
fillRule: "evenodd",
|
|
55
|
+
clipRule: "evenodd",
|
|
56
|
+
d: "M8 0.0214844H2.58333V2.5396H0.0214844V8.01198H2.58333V10.5301H8V8.01198H10.5618V2.5396H8V0.0214844Z",
|
|
57
|
+
fill: "#0083FF"
|
|
58
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
59
|
+
className: "text-[#000]"
|
|
60
|
+
}, "main.py")), /*#__PURE__*/React.createElement("button", {
|
|
61
|
+
onClick: function onClick() {
|
|
62
|
+
onApply && onApply(msg.customExts.code);
|
|
63
|
+
},
|
|
64
|
+
className: "flex items-center h-6 px-2 py-1 bg-white rounded text-black/90 text-[10px] font-normal"
|
|
65
|
+
}, "Apply")), /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: "flex-1 px-4 pt-2 pb-4 gap-2 flex flex-col justify-between h-full overflow-hidden"
|
|
67
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: "code-scroll-container w-full max-h-[300px] overflow-y-auto"
|
|
69
|
+
}, /*#__PURE__*/React.createElement("pre", {
|
|
70
|
+
className: "bg-transparent w-full h-full"
|
|
71
|
+
}, /*#__PURE__*/React.createElement("code", {
|
|
72
|
+
className: "language-python hljs",
|
|
73
|
+
style: {
|
|
74
|
+
display: "block",
|
|
75
|
+
overflow: "auto",
|
|
76
|
+
background: "transparent",
|
|
77
|
+
fontSize: "14px",
|
|
78
|
+
lineHeight: "1.5",
|
|
79
|
+
fontFamily: "Monaco, Consolas, monospace",
|
|
80
|
+
whiteSpace: "pre-wrap",
|
|
81
|
+
wordWrap: "break-word",
|
|
82
|
+
width: "100%",
|
|
83
|
+
maxWidth: "100%",
|
|
84
|
+
padding: "0.5rem"
|
|
85
|
+
},
|
|
86
|
+
dangerouslySetInnerHTML: {
|
|
87
|
+
__html: hljs.highlight(rawCode, {
|
|
88
|
+
language: "python",
|
|
89
|
+
ignoreIllegals: true
|
|
90
|
+
}).value
|
|
91
|
+
}
|
|
92
|
+
})))))));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export { CodeMsg as default };
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
2
|
+
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface IQuestionButtonMsg {
|
|
5
|
+
msg: ChatSDK.MessageBody | NoticeMessageBody;
|
|
6
|
+
isMySelf: boolean;
|
|
7
|
+
avatar?: React.ReactNode;
|
|
8
|
+
onSelectAnswer?: (answer: string) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const QustionButtonMsg: React.FC<IQuestionButtonMsg>;
|
|
11
|
+
export default QustionButtonMsg;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
2
|
+
import { BaseMessage } from 'agora-chat-uikit';
|
|
3
|
+
import { Button } from 'antd';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
var QustionButtonMsg = function QustionButtonMsg(props) {
|
|
7
|
+
var _context;
|
|
8
|
+
var msg = props.msg,
|
|
9
|
+
isMySelf = props.isMySelf,
|
|
10
|
+
avatar = props.avatar,
|
|
11
|
+
onSelectAnswer = props.onSelectAnswer;
|
|
12
|
+
return /*#__PURE__*/React.createElement(BaseMessage, {
|
|
13
|
+
bubbleType: "none",
|
|
14
|
+
reaction: false,
|
|
15
|
+
select: false,
|
|
16
|
+
thread: false,
|
|
17
|
+
direction: isMySelf ? "rtl" : "ltr",
|
|
18
|
+
renderUserProfile: function renderUserProfile() {
|
|
19
|
+
return null;
|
|
20
|
+
},
|
|
21
|
+
nickName: undefined,
|
|
22
|
+
showMessageInfo: false,
|
|
23
|
+
message: msg,
|
|
24
|
+
customAction: {
|
|
25
|
+
visible: false,
|
|
26
|
+
icon: null,
|
|
27
|
+
actions: []
|
|
28
|
+
},
|
|
29
|
+
avatar: avatar
|
|
30
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: "text-[var(--im-main-fontColor)] flex flex-col gap-1 ".concat(isMySelf ? "items-end" : "items-start")
|
|
32
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
style: {
|
|
34
|
+
background: isMySelf ? "var(--im-msg-bubble-color-right)" : "var(--im-msg-bubble-color-left)",
|
|
35
|
+
borderRadius: "9px",
|
|
36
|
+
padding: "10px 12px",
|
|
37
|
+
color: "var(--im-msg-bubble-font-color)"
|
|
38
|
+
},
|
|
39
|
+
className: "inline-block"
|
|
40
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
41
|
+
className: "cui-message-text"
|
|
42
|
+
}, msg.customExts.content)), /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
className: "flex flex-col gap-3"
|
|
44
|
+
}, _mapInstanceProperty(_context = msg.customExts.guidance_list).call(_context, function (text) {
|
|
45
|
+
return /*#__PURE__*/React.createElement(Button, {
|
|
46
|
+
key: text,
|
|
47
|
+
className: "w-[400px] !h-[45px] !bg-[#2c7cf5]",
|
|
48
|
+
onClick: function onClick() {
|
|
49
|
+
onSelectAnswer && onSelectAnswer(text);
|
|
50
|
+
}
|
|
51
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
className: "text-[#fff]"
|
|
53
|
+
}, text));
|
|
54
|
+
}))));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { QustionButtonMsg as default };
|
|
File without changes
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import { Conversation } from "agora-chat-uikit";
|
|
3
3
|
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
4
4
|
import { ChatType } from "agora-chat-uikit/types/module/types/messageType";
|
|
5
|
+
import { AIReportMessageExts } from "@components/type";
|
|
5
6
|
import "./style/index.scss";
|
|
6
7
|
export interface IHighlyCustomChat {
|
|
7
8
|
conversationId: string;
|
|
@@ -13,6 +14,8 @@ export interface IHighlyCustomChat {
|
|
|
13
14
|
renderQuestionList?: (cvs: Conversation, sendMessage: (text: string) => void) => React.ReactNode;
|
|
14
15
|
sendMessageSuccessCallback?: (msg: ChatSDK.MessageBody) => void;
|
|
15
16
|
onLoginSuccess?: () => void;
|
|
17
|
+
onApply?: (code: string) => void;
|
|
18
|
+
onReportClick?: (report: AIReportMessageExts) => void;
|
|
16
19
|
}
|
|
17
20
|
declare const HighlyCustomChat: React.FC<IHighlyCustomChat>;
|
|
18
21
|
export default HighlyCustomChat;
|
|
@@ -22,7 +22,10 @@ import { commonMessageInputConfig, commonMessageProps } from '../type.js';
|
|
|
22
22
|
import { reportAgentInUse } from '../tools.js';
|
|
23
23
|
import img from '../Icon/avatar_default.svg.js';
|
|
24
24
|
import { aesKey, aesDecrypt } from '../IM/encryption.js';
|
|
25
|
+
import QustionButtonMsg from './QuestionButton/index.js';
|
|
26
|
+
import CodeMsg from './CodeMsg/index.js';
|
|
25
27
|
import './style/index.scss';
|
|
28
|
+
import AIReportMsg from './AIReportMsg/index.js';
|
|
26
29
|
|
|
27
30
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
31
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context4, _context5; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context4 = ownKeys(Object(t), true)).call(_context4, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context5 = ownKeys(Object(t))).call(_context5, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -137,6 +140,8 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
137
140
|
}, formatMessageTime(msg.time)));
|
|
138
141
|
};
|
|
139
142
|
var _renderMessage = function renderMessage(msg) {
|
|
143
|
+
var _userInfo$uid3;
|
|
144
|
+
var isMySelf = (msg === null || msg === void 0 ? void 0 : msg.bySelf) === true || (msg === null || msg === void 0 ? void 0 : msg.from.toLowerCase()) === ((_userInfo$uid3 = userInfo.uid) === null || _userInfo$uid3 === void 0 ? void 0 : _userInfo$uid3.toLowerCase());
|
|
140
145
|
if (msg.type === "txt") {
|
|
141
146
|
return renderTxtMsg(msg);
|
|
142
147
|
} else if (msg.type === "img") {
|
|
@@ -190,6 +195,36 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
190
195
|
},
|
|
191
196
|
videoMessage: msg
|
|
192
197
|
});
|
|
198
|
+
} else if (msg.type === "custom" && (msg === null || msg === void 0 ? void 0 : msg.customEvent) === "custom_ai_report") {
|
|
199
|
+
return /*#__PURE__*/React.createElement(AIReportMsg, {
|
|
200
|
+
onReportClick: props.onReportClick,
|
|
201
|
+
msg: msg,
|
|
202
|
+
isMySelf: isMySelf,
|
|
203
|
+
avatar: !isMySelf ? /*#__PURE__*/React.createElement("img", {
|
|
204
|
+
src: headerInfo.headerImageURL || img,
|
|
205
|
+
className: "w-[48px] h-[48px] rounded-full overflow-hidden object-fit"
|
|
206
|
+
}) : undefined
|
|
207
|
+
});
|
|
208
|
+
} else if (msg.type === "custom" && (msg === null || msg === void 0 ? void 0 : msg.customEvent) === "custom_coding") {
|
|
209
|
+
return /*#__PURE__*/React.createElement(CodeMsg, {
|
|
210
|
+
onApply: props.onApply,
|
|
211
|
+
msg: msg,
|
|
212
|
+
isMySelf: isMySelf,
|
|
213
|
+
avatar: !isMySelf ? /*#__PURE__*/React.createElement("img", {
|
|
214
|
+
src: headerInfo.headerImageURL || img,
|
|
215
|
+
className: "w-[48px] h-[48px] rounded-full overflow-hidden object-fit"
|
|
216
|
+
}) : undefined
|
|
217
|
+
});
|
|
218
|
+
} else if (msg.type === "custom" && (msg === null || msg === void 0 ? void 0 : msg.customEvent) === "custom_qa_guidance") {
|
|
219
|
+
return /*#__PURE__*/React.createElement(QustionButtonMsg, {
|
|
220
|
+
onSelectAnswer: handleSendMessage,
|
|
221
|
+
msg: msg,
|
|
222
|
+
isMySelf: isMySelf,
|
|
223
|
+
avatar: !isMySelf ? /*#__PURE__*/React.createElement("img", {
|
|
224
|
+
src: headerInfo.headerImageURL || img,
|
|
225
|
+
className: "w-[48px] h-[48px] rounded-full overflow-hidden object-fit"
|
|
226
|
+
}) : undefined
|
|
227
|
+
});
|
|
193
228
|
} else {
|
|
194
229
|
return undefined;
|
|
195
230
|
}
|
|
@@ -401,7 +436,7 @@ var HighlyCustomChat = function HighlyCustomChat(props) {
|
|
|
401
436
|
cuiScrollList = document.querySelector(".cui-scrollList div");
|
|
402
437
|
cuiScrollListWrap = document.querySelector(".cui-scrollList");
|
|
403
438
|
if (cuiScrollList) {
|
|
404
|
-
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\"
|
|
439
|
+
htmlString = "<div id=\"agent-generating-loader\" class=\"cui-messageList-msgItem\"><div><div class=\"thread-container\"><div id=\"1393207307050949578\" class=\"cui-message-base cui-message-base-left cui-message-base-hasAvatar cui-message-base-secondly cui-message-base-square cui-message-base-dark\"><img src=\"/icon/im/avatar_default.svg\" class=\"w-[48px] h-[48px] rounded-full overflow-hidden object-fit\"><div class=\"cui-message-base-box\"><div class=\"cui-message-base-info\"></div><div class=\"cui-message-base-body\"><div class=\"cui-message-base-content\" style=\"background: var(--im-msg-bubble-color-left); border-radius: 9px; padding: 10px 12px; color: var(--im-msg-bubble-font-color);\"><div style=\"display:flex;align-items:center\"><div class=\"generating-loader-wrap\"><div class=\"generating-loader\"></div></div><span class=\"cui-message-text\">Generating</span></div></div><div class=\"cui-message-base-time-and-status-box\"><span class=\"cui-message-status cui-message-status-icon\"></span><span class=\"cui-message-base-time\"></span></div></div></div></div></div></div><div class=\"cui-modal-root\"><div tabindex=\"-1\" class=\"cui-modal-wrap modify-message-modal\" style=\"display: none;\"></div></div></div>";
|
|
405
440
|
template = document.createElement('template');
|
|
406
441
|
template.innerHTML = _trimInstanceProperty(htmlString).call(htmlString);
|
|
407
442
|
node = template.content.firstChild;
|
package/es/type.d.ts
CHANGED
|
@@ -1,7 +1,79 @@
|
|
|
1
1
|
import { MessageInputProps, MsgListProps } from "agora-chat-uikit";
|
|
2
|
+
import { ChatSDK } from "agora-chat-uikit/types/module/SDK";
|
|
3
|
+
import { NoticeMessageBody } from "agora-chat-uikit/types/module/noticeMessage/NoticeMessage";
|
|
2
4
|
export type ICommonComponentProps = {
|
|
3
5
|
className?: string;
|
|
4
6
|
style?: React.CSSProperties;
|
|
5
7
|
};
|
|
6
8
|
export declare const commonMessageInputConfig: MessageInputProps;
|
|
7
9
|
export declare const commonMessageProps: MsgListProps['messageProps'];
|
|
10
|
+
/**
|
|
11
|
+
* 自定义IM消息类型
|
|
12
|
+
* 基于Agora的ChatSDK.MessageBody扩展
|
|
13
|
+
*/
|
|
14
|
+
export interface AIReportMessageExts {
|
|
15
|
+
/** 报告标题 */
|
|
16
|
+
title: string;
|
|
17
|
+
/** 报告描述内容 */
|
|
18
|
+
content: string;
|
|
19
|
+
/** token地址 */
|
|
20
|
+
tokenaddress: string;
|
|
21
|
+
/** token铸造平台: pumpfun, moonpump 或 others */
|
|
22
|
+
platform: 'pumpfun' | 'moonpump' | 'others';
|
|
23
|
+
/** 是否已在交易所上架: yes - 已在交易所; no - 内盘 */
|
|
24
|
+
isOnDex: boolean;
|
|
25
|
+
/** token名称 */
|
|
26
|
+
token_name: string;
|
|
27
|
+
/** token符号 */
|
|
28
|
+
token_symbol: string;
|
|
29
|
+
}
|
|
30
|
+
export interface PythonCodeMessageExts {
|
|
31
|
+
/** 代码内容 */
|
|
32
|
+
code: string;
|
|
33
|
+
/** 代码类型 默认‘python’ */
|
|
34
|
+
code_type: string;
|
|
35
|
+
/** 是否显示apply按钮 */
|
|
36
|
+
can_apply: boolean;
|
|
37
|
+
/** 是否显示copy按钮 */
|
|
38
|
+
can_copy: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface QAGuidanceMessageExts {
|
|
41
|
+
/** 引导内容描述 */
|
|
42
|
+
content: string;
|
|
43
|
+
/** 引导词数组,包含0到多个引导选项 */
|
|
44
|
+
guidance_list: string[];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 自定义消息类型定义
|
|
48
|
+
* 每种类型都与特定的扩展字段结构关联
|
|
49
|
+
*/
|
|
50
|
+
/** AI报告消息 */
|
|
51
|
+
export interface AIReportMessage {
|
|
52
|
+
customEvent: 'custom_ai_report';
|
|
53
|
+
customExts: AIReportMessageExts;
|
|
54
|
+
}
|
|
55
|
+
/** 编程代码消息 */
|
|
56
|
+
export interface PythonCodeMessage {
|
|
57
|
+
customEvent: 'custom_coding';
|
|
58
|
+
customExts: PythonCodeMessageExts;
|
|
59
|
+
}
|
|
60
|
+
/** 问答引导消息 */
|
|
61
|
+
export interface QAGuidanceMessage {
|
|
62
|
+
customEvent: 'custom_qa_guidance';
|
|
63
|
+
customExts: QAGuidanceMessageExts;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 自定义消息类型守卫函数,用于判断和类型转换
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* 判断是否为AI报告消息
|
|
70
|
+
*/
|
|
71
|
+
export declare function isAIReportMessage(msg: ChatSDK.MessageBody | NoticeMessageBody): msg is (ChatSDK.MessageBody | NoticeMessageBody) & AIReportMessage;
|
|
72
|
+
/**
|
|
73
|
+
* 判断是否为编程代码消息
|
|
74
|
+
*/
|
|
75
|
+
export declare function isPythonCodeMessage(msg: ChatSDK.MessageBody | NoticeMessageBody): msg is (ChatSDK.MessageBody | NoticeMessageBody) & PythonCodeMessage;
|
|
76
|
+
/**
|
|
77
|
+
* 判断是否为问答引导消息
|
|
78
|
+
*/
|
|
79
|
+
export declare function isQAGuidanceMessage(msg: ChatSDK.MessageBody | NoticeMessageBody): msg is (ChatSDK.MessageBody | NoticeMessageBody) & QAGuidanceMessage;
|