mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
[feature](webapp) add a minimize button for copilot (#78)
This commit is contained in:
@@ -207,7 +207,7 @@ const ChatFooter: ForwardRefRenderFunction<any, Props> = (
|
|||||||
: `${item.modelName || ''}${item.recommend}` === value,
|
: `${item.modelName || ''}${item.recommend}` === value,
|
||||||
);
|
);
|
||||||
if (option && isSelect) {
|
if (option && isSelect) {
|
||||||
onSendMsg(option.recommend, option.modelId);
|
onSendMsg(option.recommend, Object.keys(stepOptions).length > 1 ? option.modelId : undefined);
|
||||||
} else {
|
} else {
|
||||||
onSendMsg(value.trim());
|
onSendMsg(value.trim());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import IconFont from '@/components/IconFont';
|
import IconFont from '@/components/IconFont';
|
||||||
import { CaretRightOutlined, CloseOutlined } from '@ant-design/icons';
|
import { CaretRightOutlined, CloseOutlined } from '@ant-design/icons';
|
||||||
|
import classNames from 'classnames';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import Chat from '../Chat';
|
import Chat from '../Chat';
|
||||||
import { DefaultEntityType, ModelType } from '../Chat/type';
|
import { DefaultEntityType, ModelType } from '../Chat/type';
|
||||||
@@ -15,6 +16,7 @@ const Copilot: React.FC<Props> = ({ globalCopilotFilter, copilotSendMsg }) => {
|
|||||||
const [defaultModelName, setDefaultModelName] = useState('');
|
const [defaultModelName, setDefaultModelName] = useState('');
|
||||||
const [defaultEntityFilter, setDefaultEntityFilter] = useState<DefaultEntityType>();
|
const [defaultEntityFilter, setDefaultEntityFilter] = useState<DefaultEntityType>();
|
||||||
const [triggerNewConversation, setTriggerNewConversation] = useState(false);
|
const [triggerNewConversation, setTriggerNewConversation] = useState(false);
|
||||||
|
const [copilotMinimized, setCopilotMinimized] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (globalCopilotFilter && globalCopilotFilter.entityId !== defaultEntityFilter?.entityId) {
|
if (globalCopilotFilter && globalCopilotFilter.entityId !== defaultEntityFilter?.entityId) {
|
||||||
@@ -58,10 +60,29 @@ const Copilot: React.FC<Props> = ({ globalCopilotFilter, copilotSendMsg }) => {
|
|||||||
setTriggerNewConversation(false);
|
setTriggerNewConversation(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onMinimizeCopilot = (e: any) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
updateChatVisible(false);
|
||||||
|
setCopilotMinimized(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
const copilotClass = classNames(styles.copilot, {
|
||||||
|
[styles.copilotMinimized]: copilotMinimized,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.copilot} onClick={onToggleChatVisible}>
|
<div
|
||||||
|
className={copilotClass}
|
||||||
|
onMouseEnter={() => {
|
||||||
|
setCopilotMinimized(false);
|
||||||
|
}}
|
||||||
|
onClick={onToggleChatVisible}
|
||||||
|
>
|
||||||
<IconFont type="icon-copilot-fill" />
|
<IconFont type="icon-copilot-fill" />
|
||||||
|
<div className={styles.minimizeWrapper} onClick={onMinimizeCopilot}>
|
||||||
|
<div className={styles.minimize}>-</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.copilotContent} style={{ display: chatVisible ? 'block' : 'none' }}>
|
<div className={styles.copilotContent} style={{ display: chatVisible ? 'block' : 'none' }}>
|
||||||
<div className={styles.chatPopover}>
|
<div className={styles.chatPopover}>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 54px;
|
width: 54px;
|
||||||
height: 54px;
|
height: 54px;
|
||||||
overflow: hidden;
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 26px;
|
font-size: 26px;
|
||||||
background-color: var(--chat-blue);
|
background-color: var(--chat-blue);
|
||||||
@@ -19,11 +18,48 @@
|
|||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
box-shadow: 8px 8px 20px 0 rgba(55, 99, 170, 0.1);
|
box-shadow: 8px 8px 20px 0 rgba(55, 99, 170, 0.1);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: all 0.3s ease-in-out;
|
transition: all 0.2s ease-in-out;
|
||||||
|
|
||||||
|
&.copilotMinimized {
|
||||||
|
right: -40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.minimizeWrapper {
|
||||||
|
display: none;
|
||||||
|
cursor: pointer;
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
position: absolute;
|
||||||
|
right: -6px;
|
||||||
|
top: -18px;
|
||||||
|
padding: 4px;
|
||||||
|
|
||||||
|
.minimize {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--text-color-fifth-4);
|
||||||
|
transition: all 0.1s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.minimize {
|
||||||
|
background-color: var(--text-color-fifth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
box-shadow: 8px 8px 20px rgba(55, 99, 170, 0.3);
|
box-shadow: 8px 8px 20px rgba(55, 99, 170, 0.3);
|
||||||
|
|
||||||
|
.minimizeWrapper {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user