mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-20 18:54:09 +00:00
perf: mark icon show
This commit is contained in:
@@ -75,6 +75,12 @@ export type ComponentRef = {
|
||||
scrollToBottom: (behavior?: 'smooth' | 'auto') => void;
|
||||
};
|
||||
|
||||
enum FeedbackTypeEnum {
|
||||
user = 'user',
|
||||
admin = 'admin',
|
||||
hidden = 'hidden'
|
||||
}
|
||||
|
||||
const VariableLabel = ({
|
||||
required = false,
|
||||
children
|
||||
@@ -128,7 +134,9 @@ const ChatAvatar = ({ src, type }: { src?: string; type: 'Human' | 'AI' }) => {
|
||||
|
||||
const ChatBox = (
|
||||
{
|
||||
isLogs = false,
|
||||
feedbackType = FeedbackTypeEnum.hidden,
|
||||
showMarkIcon = false,
|
||||
showVoiceIcon = true,
|
||||
showEmptyIntro = false,
|
||||
chatId,
|
||||
appAvatar,
|
||||
@@ -139,7 +147,9 @@ const ChatBox = (
|
||||
onStartChat,
|
||||
onDelMessage
|
||||
}: {
|
||||
isLogs?: boolean;
|
||||
feedbackType?: `${FeedbackTypeEnum}`;
|
||||
showMarkIcon?: boolean;
|
||||
showVoiceIcon?: boolean;
|
||||
showEmptyIntro?: boolean;
|
||||
chatId?: string;
|
||||
appAvatar?: string;
|
||||
@@ -428,7 +438,7 @@ const ChatBox = (
|
||||
const controlContainerStyle = {
|
||||
className: 'control',
|
||||
color: 'myGray.400',
|
||||
display: isLogs ? 'flex' : ['flex', 'none'],
|
||||
display: feedbackType === FeedbackTypeEnum.admin ? 'flex' : ['flex', 'none'],
|
||||
pl: 1,
|
||||
mt: 2
|
||||
};
|
||||
@@ -544,7 +554,9 @@ const ChatBox = (
|
||||
label: item.value,
|
||||
value: item.value
|
||||
}))}
|
||||
value={getValues(item.key)}
|
||||
{...register(item.key, {
|
||||
required: item.required
|
||||
})}
|
||||
onchange={(e) => {
|
||||
setValue(item.key, e);
|
||||
setRefresh(!refresh);
|
||||
@@ -664,7 +676,7 @@ const ChatBox = (
|
||||
/>
|
||||
</MyTooltip>
|
||||
)}
|
||||
{!isLogs && hasVoiceApi && (
|
||||
{showVoiceIcon && hasVoiceApi && (
|
||||
<MyTooltip label={'语音播报'}>
|
||||
<MyIcon
|
||||
{...controlIconStyle}
|
||||
@@ -675,7 +687,7 @@ const ChatBox = (
|
||||
</MyTooltip>
|
||||
)}
|
||||
{/* admin mark icon */}
|
||||
{isLogs && (
|
||||
{showMarkIcon && (
|
||||
<MyTooltip label={t('chat.Mark')}>
|
||||
<MyIcon
|
||||
{...controlIconStyle}
|
||||
@@ -702,9 +714,7 @@ const ChatBox = (
|
||||
/>
|
||||
</MyTooltip>
|
||||
)}
|
||||
{/* user feed back icon */}
|
||||
{item.dataId &&
|
||||
(isLogs ? (
|
||||
{feedbackType === FeedbackTypeEnum.admin && (
|
||||
<MyTooltip label={t('chat.Read User Feedback')}>
|
||||
<MyIcon
|
||||
display={item.userFeedback ? 'block' : 'none'}
|
||||
@@ -722,7 +732,8 @@ const ChatBox = (
|
||||
}
|
||||
/>
|
||||
</MyTooltip>
|
||||
) : (
|
||||
)}
|
||||
{feedbackType === FeedbackTypeEnum.user && (
|
||||
<MyTooltip
|
||||
label={
|
||||
item.userFeedback
|
||||
@@ -758,7 +769,7 @@ const ChatBox = (
|
||||
name={'badLight'}
|
||||
/>
|
||||
</MyTooltip>
|
||||
))}
|
||||
)}
|
||||
</Flex>
|
||||
{/* chatting status */}
|
||||
{statusBoxData && index === chatHistory.length - 1 && (
|
||||
@@ -796,7 +807,7 @@ const ChatBox = (
|
||||
responseData={item.responseData}
|
||||
/>
|
||||
{/* admin mark content */}
|
||||
{isLogs && item.adminFeedback && (
|
||||
{showMarkIcon && item.adminFeedback && (
|
||||
<Box>
|
||||
<Flex alignItems={'center'} py={2}>
|
||||
<MyIcon name={'markLight'} w={'14px'} color={'myGray.900'} />
|
||||
|
@@ -113,6 +113,7 @@ const ChatTest = (
|
||||
ref={ChatBoxRef}
|
||||
appAvatar={app.avatar}
|
||||
userAvatar={userInfo?.avatar}
|
||||
showMarkIcon
|
||||
{...getSpecialModule(modules)}
|
||||
onStartChat={startChat}
|
||||
onDelMessage={() => {}}
|
||||
|
@@ -639,6 +639,7 @@ const ChatTest = ({ appId }: { appId: string }) => {
|
||||
ref={ChatBoxRef}
|
||||
appAvatar={appDetail.avatar}
|
||||
userAvatar={userInfo?.avatar}
|
||||
showMarkIcon
|
||||
{...getSpecialModule(modules)}
|
||||
onStartChat={startChat}
|
||||
onDelMessage={() => {}}
|
||||
|
@@ -287,13 +287,14 @@ function DetailLogsModal({
|
||||
<Box pt={2} flex={'1 0 0'}>
|
||||
<ChatBox
|
||||
ref={ChatBoxRef}
|
||||
isLogs
|
||||
chatId={chatId}
|
||||
appAvatar={chat?.app.avatar}
|
||||
userAvatar={HUMAN_ICON}
|
||||
feedbackType={'admin'}
|
||||
showMarkIcon
|
||||
showVoiceIcon={false}
|
||||
variableModules={chat?.app.variableModules}
|
||||
welcomeText={chat?.app.welcomeText}
|
||||
onUpdateVariable={(e) => {}}
|
||||
/>
|
||||
</Box>
|
||||
</Flex>
|
||||
|
@@ -362,6 +362,7 @@ const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
|
||||
appAvatar={chatData.app.avatar}
|
||||
userAvatar={userInfo?.avatar}
|
||||
variableModules={chatData.app.variableModules}
|
||||
feedbackType={'user'}
|
||||
welcomeText={chatData.app.welcomeText}
|
||||
onUpdateVariable={(e) => {}}
|
||||
onStartChat={startChat}
|
||||
|
@@ -226,6 +226,7 @@ const OutLink = ({ shareId, chatId }: { shareId: string; chatId: string }) => {
|
||||
userAvatar={shareChatData.userAvatar}
|
||||
variableModules={shareChatData.app.variableModules}
|
||||
welcomeText={shareChatData.app.welcomeText}
|
||||
feedbackType={'user'}
|
||||
onUpdateVariable={(e) => {
|
||||
setShareChatData((state) => ({
|
||||
...state,
|
||||
|
@@ -55,7 +55,6 @@ export async function saveChat({
|
||||
]);
|
||||
} else {
|
||||
promise.push(
|
||||
...[
|
||||
Chat.create({
|
||||
chatId,
|
||||
userId,
|
||||
@@ -65,7 +64,6 @@ export async function saveChat({
|
||||
source,
|
||||
shareId
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user