forked from lobehub/lobe-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💄 style: support switch model with tag (lobehub#1435)
- Loading branch information
Showing
10 changed files
with
221 additions
and
174 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
src/app/chat/(desktop)/features/ChatHeader/HeaderAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ActionIcon } from '@lobehub/ui'; | ||
import { PanelRightClose, PanelRightOpen } from 'lucide-react'; | ||
import { memo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { DESKTOP_HEADER_ICON_SIZE } from '@/const/layoutTokens'; | ||
import { useGlobalStore } from '@/store/global'; | ||
|
||
import SettingButton from '../../../features/ChatHeader/SettingButton'; | ||
import ShareButton from '../../../features/ChatHeader/ShareButton'; | ||
|
||
const HeaderAction = memo(() => { | ||
const { t } = useTranslation('chat'); | ||
|
||
const [showAgentSettings, toggleConfig] = useGlobalStore((s) => [ | ||
s.preference.showChatSideBar, | ||
s.toggleChatSideBar, | ||
]); | ||
|
||
return ( | ||
<> | ||
<ShareButton /> | ||
<ActionIcon | ||
icon={showAgentSettings ? PanelRightClose : PanelRightOpen} | ||
onClick={() => toggleConfig()} | ||
size={DESKTOP_HEADER_ICON_SIZE} | ||
title={t('roleAndArchive')} | ||
/> | ||
<SettingButton /> | ||
</> | ||
); | ||
}); | ||
|
||
export default HeaderAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Avatar, ChatHeaderTitle } from '@lobehub/ui'; | ||
import { Skeleton } from 'antd'; | ||
import { useRouter } from 'next/navigation'; | ||
import { memo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Flexbox } from 'react-layout-kit'; | ||
|
||
import { useSessionStore } from '@/store/session'; | ||
import { agentSelectors, sessionSelectors } from '@/store/session/selectors'; | ||
import { pathString } from '@/utils/url'; | ||
|
||
import Tags from './Tags'; | ||
|
||
const Main = memo(() => { | ||
const { t } = useTranslation('chat'); | ||
|
||
const router = useRouter(); | ||
|
||
const [init, isInbox, title, description, avatar, backgroundColor] = useSessionStore((s) => [ | ||
sessionSelectors.isSomeSessionActive(s), | ||
sessionSelectors.isInboxSession(s), | ||
agentSelectors.currentAgentTitle(s), | ||
agentSelectors.currentAgentDescription(s), | ||
agentSelectors.currentAgentAvatar(s), | ||
agentSelectors.currentAgentBackgroundColor(s), | ||
]); | ||
|
||
const displayTitle = isInbox ? t('inbox.title') : title; | ||
const displayDesc = isInbox ? t('inbox.desc') : description; | ||
|
||
return !init ? ( | ||
<Flexbox horizontal> | ||
<Skeleton | ||
active | ||
avatar={{ shape: 'circle', size: 'default' }} | ||
paragraph={false} | ||
title={{ style: { margin: 0, marginTop: 8 }, width: 200 }} | ||
/> | ||
</Flexbox> | ||
) : ( | ||
<Flexbox align={'flex-start'} gap={12} horizontal> | ||
<Avatar | ||
avatar={avatar} | ||
background={backgroundColor} | ||
onClick={() => | ||
isInbox | ||
? router.push('/settings/agent') | ||
: router.push(pathString('/chat/settings', { search: location.search })) | ||
} | ||
size={40} | ||
title={title} | ||
/> | ||
<ChatHeaderTitle desc={displayDesc} tag={<Tags />} title={displayTitle} /> | ||
</Flexbox> | ||
); | ||
}); | ||
|
||
export default Main; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { memo } from 'react'; | ||
|
||
import ModelTag from '@/components/ModelTag'; | ||
import ModelSwitchPanel from '@/features/ModelSwitchPanel'; | ||
import { useGlobalStore } from '@/store/global'; | ||
import { modelProviderSelectors } from '@/store/global/selectors'; | ||
import { useSessionStore } from '@/store/session'; | ||
import { agentSelectors } from '@/store/session/selectors'; | ||
|
||
import PluginTag from '../../../features/PluginTag'; | ||
|
||
const TitleTags = memo(() => { | ||
const [model, plugins] = useSessionStore((s) => [ | ||
agentSelectors.currentAgentModel(s), | ||
agentSelectors.currentAgentPlugins(s), | ||
]); | ||
|
||
const showPlugin = useGlobalStore(modelProviderSelectors.modelEnabledFunctionCall(model)); | ||
|
||
return ( | ||
<> | ||
<ModelSwitchPanel> | ||
<ModelTag model={model} /> | ||
</ModelSwitchPanel> | ||
{showPlugin && plugins?.length > 0 && <PluginTag plugins={plugins} />} | ||
</> | ||
); | ||
}); | ||
|
||
export default TitleTags; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ChatHeader } from '@lobehub/ui'; | ||
import { memo } from 'react'; | ||
|
||
import HeaderAction from './HeaderAction'; | ||
import Main from './Main'; | ||
|
||
const Header = memo(() => <ChatHeader left={<Main />} right={<HeaderAction />} />); | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.