mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 10:28:42 +00:00
app page
This commit is contained in:
@@ -30,7 +30,7 @@ const Navbar = ({ unread }: { unread: number }) => {
|
||||
label: '应用',
|
||||
icon: 'model',
|
||||
link: `/app/list`,
|
||||
activeLink: ['/app/list']
|
||||
activeLink: ['/app/list', '/app/detail']
|
||||
},
|
||||
{
|
||||
label: '知识库',
|
||||
|
72
client/src/components/SlideTabs/index.tsx
Normal file
72
client/src/components/SlideTabs/index.tsx
Normal file
@@ -0,0 +1,72 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { Box, Flex, useTheme } from '@chakra-ui/react';
|
||||
import type { GridProps } from '@chakra-ui/react';
|
||||
import MyIcon, { type IconName } from '../Icon';
|
||||
|
||||
// @ts-ignore
|
||||
export interface Props extends GridProps {
|
||||
list: { id: string; label: string; icon: string }[];
|
||||
activeId: string;
|
||||
size?: 'sm' | 'md' | 'lg';
|
||||
onChange: (id: string) => void;
|
||||
}
|
||||
|
||||
const SlideTabs = ({ list, size = 'md', activeId, onChange, ...props }: Props) => {
|
||||
const sizeMap = useMemo(() => {
|
||||
switch (size) {
|
||||
case 'sm':
|
||||
return {
|
||||
fontSize: 'sm',
|
||||
inlineP: 1
|
||||
};
|
||||
case 'md':
|
||||
return {
|
||||
fontSize: 'md',
|
||||
inlineP: 2
|
||||
};
|
||||
case 'lg':
|
||||
return {
|
||||
fontSize: 'lg',
|
||||
inlineP: 3
|
||||
};
|
||||
}
|
||||
}, [size]);
|
||||
|
||||
return (
|
||||
<Box fontSize={sizeMap.fontSize} {...props}>
|
||||
{list.map((item) => (
|
||||
<Flex
|
||||
key={item.id}
|
||||
py={sizeMap.inlineP}
|
||||
borderRadius={'md'}
|
||||
px={3}
|
||||
mb={2}
|
||||
alignItems={'center'}
|
||||
_hover={{
|
||||
bg: 'myWhite.600'
|
||||
}}
|
||||
{...(activeId === item.id
|
||||
? {
|
||||
// backgroundImage: 'linear-gradient(to right, #85b1ff 0%, #EBF7FD 100%)',
|
||||
bg: ' myBlue.300',
|
||||
fontWeight: 'bold',
|
||||
color: 'myBlue.700',
|
||||
cursor: 'default'
|
||||
}
|
||||
: {
|
||||
cursor: 'pointer'
|
||||
})}
|
||||
onClick={() => {
|
||||
if (activeId === item.id) return;
|
||||
onChange(item.id);
|
||||
}}
|
||||
>
|
||||
<MyIcon mr={2} name={item.icon as IconName} w={'14px'} />
|
||||
{item.label}
|
||||
</Flex>
|
||||
))}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(SlideTabs);
|
Reference in New Issue
Block a user