-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from lobehub/chore/update-assets
feat:重构 Agent 和 Dance Panel
- Loading branch information
Showing
52 changed files
with
581 additions
and
655 deletions.
There are no files selected for viewing
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
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,49 @@ | ||
'use client'; | ||
|
||
import { Avatar } from '@lobehub/ui'; | ||
|
||
import { sessionSelectors, useSessionStore } from '@/store/session'; | ||
|
||
import { useStyles } from './style'; | ||
|
||
const AvatarSize = 64; | ||
|
||
const QuickSwitch = () => { | ||
const { styles } = useStyles({ avatarSize: AvatarSize }); | ||
const [sessionList, getAgentById] = useSessionStore((s) => [ | ||
s.sessionList, | ||
sessionSelectors.getAgentById(s), | ||
]); | ||
const [switchSession, activeId] = useSessionStore((s) => [s.switchSession, s.activeId]); | ||
|
||
return ( | ||
<div className={styles.sidebar}> | ||
{/*<div className={styles.header}>聊天列表</div>*/} | ||
<div className={styles.list}> | ||
{sessionList.map((item) => { | ||
const agent = getAgentById(item.agentId); | ||
if (!agent) return null; | ||
const isActive = activeId === agent.agentId; | ||
return ( | ||
<div key={agent.agentId} style={{ position: 'relative' }}> | ||
<Avatar | ||
className={isActive ? styles.active : ''} | ||
onClick={() => switchSession(agent.agentId)} | ||
size={AvatarSize} | ||
src={agent.meta.avatar} | ||
/> | ||
{isActive ? ( | ||
<> | ||
{/*<div className={styles.satellite} />*/} | ||
<div className={styles.orbit} /> | ||
</> | ||
) : null} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default QuickSwitch; |
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
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,36 @@ | ||
import { CheckCircleFilled } from '@ant-design/icons'; | ||
import { Typography } from 'antd'; | ||
import classNames from 'classnames'; | ||
import React, { memo } from 'react'; | ||
|
||
import { useStyles } from './style'; | ||
|
||
const { Text } = Typography; | ||
|
||
interface AvatarProps { | ||
active?: boolean; | ||
avatar: string; | ||
checked?: boolean; | ||
className?: string; | ||
onClick?: () => void; | ||
style?: React.CSSProperties; | ||
title: string; | ||
} | ||
|
||
const ListItem = (props: AvatarProps) => { | ||
const { avatar, title, style, className, onClick, active = false, checked = false } = props; | ||
const { styles } = useStyles({ active, avatar }); | ||
return ( | ||
<div style={style} className={classNames(className, styles.item)} onClick={onClick}> | ||
<div className={styles.avatar} /> | ||
<div className={styles.info}> | ||
<Text ellipsis={{ tooltip: title }} className={styles.title}> | ||
{title} | ||
</Text> | ||
{checked ? <CheckCircleFilled className={styles.check} /> : null} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(ListItem); |
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,47 @@ | ||
import { createStyles } from 'antd-style'; | ||
import { rgba } from 'polished'; | ||
|
||
interface ListItemProps { | ||
active: boolean; | ||
avatar: string; | ||
} | ||
|
||
export const useStyles = createStyles(({ css, token }, { active, avatar }: ListItemProps) => ({ | ||
item: css` | ||
cursor: pointer; | ||
position: relative; | ||
width: 100%; | ||
height: 100%; | ||
background: url(${avatar}) no-repeat center center; | ||
background-size: cover; | ||
border: 2px solid ${active ? token.colorPrimary : token.colorFillTertiary}; | ||
`, | ||
avatar: css``, | ||
|
||
info: css` | ||
position: absolute; | ||
bottom: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
height: 24px; | ||
padding: 4px; | ||
background-color: ${rgba(token.colorBgContainer, 0.8)}; | ||
backdrop-filter: saturate(180%) blur(2px); | ||
`, | ||
title: css` | ||
font-size: ${token.sizeSM}px; | ||
line-height: 16px; | ||
`, | ||
check: css` | ||
font-size: ${token.sizeSM}px; | ||
color: ${token.colorSuccessText}; | ||
`, | ||
})); |
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,83 @@ | ||
import { Icon } from '@lobehub/ui'; | ||
import { Empty, Space } from 'antd'; | ||
import classNames from 'classnames'; | ||
import { Loader2 } from 'lucide-react'; | ||
import React, { memo } from 'react'; | ||
import { Center } from 'react-layout-kit'; | ||
|
||
import ListItem from './ListItem'; | ||
import { useStyles } from './style'; | ||
|
||
interface Item { | ||
avatar: string; | ||
id: string; | ||
name: string; | ||
} | ||
|
||
interface GridListProps { | ||
className?: string; | ||
empty?: { | ||
actions?: React.ReactNode[]; | ||
}; | ||
isActivated?: (id: string) => boolean; | ||
isChecked?: (id: string) => boolean; | ||
items: Item[]; | ||
loading?: boolean; | ||
onClick?: (id: string) => void; | ||
style?: React.CSSProperties; | ||
} | ||
|
||
const GridList = (props: GridListProps) => { | ||
const { | ||
items, | ||
className, | ||
style, | ||
onClick, | ||
isActivated, | ||
isChecked, | ||
loading = false, | ||
empty, | ||
} = props; | ||
const { styles } = useStyles(); | ||
|
||
const Loading = () => ( | ||
<Center gap={16} horizontal className={styles.loading}> | ||
<Icon icon={Loader2} spin /> | ||
加载中... | ||
</Center> | ||
); | ||
|
||
const List = () => ( | ||
<div className={styles.list}> | ||
{items.map((item) => { | ||
const { avatar, name, id } = item; | ||
return ( | ||
<ListItem | ||
key={id} | ||
title={name} | ||
avatar={avatar} | ||
onClick={() => { | ||
if (onClick) onClick(id); | ||
}} | ||
active={isActivated ? isActivated(id) : false} | ||
checked={isChecked ? isChecked(id) : false} | ||
/> | ||
); | ||
})} | ||
</div> | ||
); | ||
|
||
const EmptyList = () => ( | ||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无数据"> | ||
{empty?.actions ? <Space>{empty.actions}</Space> : null} | ||
</Empty> | ||
); | ||
|
||
return ( | ||
<div className={classNames(className, styles.grid)} style={style}> | ||
{loading ? <Loading /> : items.length === 0 ? <EmptyList /> : <List />} | ||
</div> | ||
); | ||
}; | ||
|
||
export default memo(GridList); |
Oops, something went wrong.