diff --git a/client/src/components/Tag/index.tsx b/client/src/components/Tag/index.tsx new file mode 100644 index 000000000..32733eaec --- /dev/null +++ b/client/src/components/Tag/index.tsx @@ -0,0 +1,47 @@ +import React, { useMemo } from 'react'; +import { Box, type BoxProps } from '@chakra-ui/react'; + +interface Props extends BoxProps { + children: string; + colorSchema?: 'blue' | 'green' | 'gray'; +} + +const Tag = ({ children, colorSchema = 'blue', ...props }: Props) => { + const theme = useMemo(() => { + const map = { + blue: { + borderColor: 'myBlue.700', + bg: '#F2FBFF', + color: 'myBlue.700' + }, + green: { + borderColor: '#52C41A', + bg: '#EDFFED', + color: '#52C41A' + }, + gray: { + borderColor: '#979797', + bg: '#F7F7F7', + color: '#979797' + } + }; + return map[colorSchema]; + }, [colorSchema]); + return ( + + {children} + + ); +}; + +export default Tag; diff --git a/client/src/constants/theme.ts b/client/src/constants/theme.ts index 57738c030..4685e62d2 100644 --- a/client/src/constants/theme.ts +++ b/client/src/constants/theme.ts @@ -220,7 +220,6 @@ export const theme = extendTheme({ 900: '#1237b3', 1000: '#07228c' }, - myRead: { 600: '#ff4d4f' } diff --git a/client/src/pages/chat/components/PhoneSliderBar.tsx b/client/src/pages/chat/components/PhoneSliderBar.tsx index 04aa12c00..3c76b05a7 100644 --- a/client/src/pages/chat/components/PhoneSliderBar.tsx +++ b/client/src/pages/chat/components/PhoneSliderBar.tsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react'; +import React, { useMemo, useState } from 'react'; import { AddIcon, ChatIcon } from '@chakra-ui/icons'; import { Box, @@ -17,6 +17,12 @@ import WxConcat from '@/components/WxConcat'; import { delChatHistoryById } from '@/api/chat'; import { useChatStore } from '@/store/chat'; import Avatar from '@/components/Avatar'; +import Tabs from '@/components/Tabs'; + +enum TabEnum { + app = 'app', + history = 'history' +} const PhoneSliderBar = ({ chatId, @@ -28,7 +34,7 @@ const PhoneSliderBar = ({ onClose: () => void; }) => { const router = useRouter(); - const { colorMode, toggleColorMode } = useColorMode(); + const [currentTab, setCurrentTab] = useState(TabEnum.app); const { myModels, myCollectionModels, loadMyModels } = useUserStore(); const { isOpen: isOpenWx, onOpen: onOpenWx, onClose: onCloseWx } = useDisclosure(); @@ -73,101 +79,116 @@ const PhoneSliderBar = ({ backgroundColor={useColorModeValue('blackAlpha.800', 'blackAlpha.500')} color={'white'} > - - AI应用 + + setCurrentTab(e)} + /> {/* 新对话 */} - + {currentTab === TabEnum.app && ( + + )} {/* 我的模型 & 历史记录 折叠框*/} - - {models.map((item) => ( - { - if (item._id === modelId) return; - router.replace(`/chat?modelId=${item._id}`); - onClose(); - }} - > - - - {item.name} - - - ))} - - - <> - 历史记录 - {history.map((item) => ( - { - if (item._id === chatId) return; - router.replace(`/chat?modelId=${item.modelId}&chatId=${item._id}`); - onClose(); - }} - > - - - {item.title} - - - { - e.stopPropagation(); - console.log(111); - await delChatHistoryById(item._id); - loadHistory({ pageNum: 1, init: true }); - if (item._id === chatId) { - router.replace(`/chat?modelId=${modelId}`); + {currentTab === TabEnum.app && ( + <> + {models.map((item) => ( + - - - ))} - + : {})} + onClick={async () => { + if (item._id === modelId) return; + router.replace(`/chat?modelId=${item._id}`); + onClose(); + }} + > + + + {item.name} + + + ))} + + )} + {currentTab === TabEnum.history && ( + <> + {history.map((item) => ( + { + if (item._id === chatId) return; + router.replace(`/chat?modelId=${item.modelId}&chatId=${item._id}`); + onClose(); + }} + > + + + {item.title} + + + { + e.stopPropagation(); + console.log(111); + await delChatHistoryById(item._id); + loadHistory({ pageNum: 1, init: true }); + if (item._id === chatId) { + router.replace(`/chat?modelId=${modelId}`); + } + }} + /> + + + ))} + + )} diff --git a/client/src/pages/chat/index.tsx b/client/src/pages/chat/index.tsx index 55410e88c..acbf4f4e1 100644 --- a/client/src/pages/chat/index.tsx +++ b/client/src/pages/chat/index.tsx @@ -893,7 +893,7 @@ const Chat = ({ modelId, chatId }: { modelId: string; chatId: string }) => { {!isPc && ( - + diff --git a/client/src/pages/kb/components/Info.tsx b/client/src/pages/kb/components/Info.tsx index 4ae0d186f..37df77ce7 100644 --- a/client/src/pages/kb/components/Info.tsx +++ b/client/src/pages/kb/components/Info.tsx @@ -7,7 +7,7 @@ import React, { ForwardedRef } from 'react'; import { useRouter } from 'next/router'; -import { Box, Flex, Button, FormControl, IconButton, Tooltip, Input, Tag } from '@chakra-ui/react'; +import { Box, Flex, Button, FormControl, IconButton, Tooltip, Input } from '@chakra-ui/react'; import { QuestionOutlineIcon, DeleteIcon } from '@chakra-ui/icons'; import { delKbById, putKbById } from '@/api/plugins/kb'; import { useSelectFile } from '@/hooks/useSelectFile'; @@ -18,6 +18,7 @@ import { UseFormReturn } from 'react-hook-form'; import { compressImg } from '@/utils/file'; import type { KbItemType } from '@/types/plugin'; import Avatar from '@/components/Avatar'; +import Tag from '@/components/Tag'; export interface ComponentRef { initInput: (tags: string) => void; @@ -211,7 +212,7 @@ const Info = ( .split(' ') .filter((item) => item) .map((item, i) => ( - + {item} ))} diff --git a/client/src/pages/kb/components/KbList.tsx b/client/src/pages/kb/components/KbList.tsx index 645136707..399db0962 100644 --- a/client/src/pages/kb/components/KbList.tsx +++ b/client/src/pages/kb/components/KbList.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useState, useMemo } from 'react'; -import { Box, Flex, useTheme, Input, IconButton, Tooltip, Tag } from '@chakra-ui/react'; +import { Box, Flex, useTheme, Input, IconButton, Tooltip } from '@chakra-ui/react'; import { AddIcon } from '@chakra-ui/icons'; import { useRouter } from 'next/router'; import { postCreateKb } from '@/api/plugins/kb'; @@ -9,6 +9,7 @@ import { useQuery } from '@tanstack/react-query'; import { useUserStore } from '@/store/user'; import MyIcon from '@/components/Icon'; import Avatar from '@/components/Avatar'; +import Tag from '@/components/Tag'; const KbList = ({ kbId }: { kbId: string }) => { const theme = useTheme(); @@ -118,12 +119,12 @@ const KbList = ({ kbId }: { kbId: string }) => { {item.name} {/* tags */} - + {!item.tags ? ( <>{item.tags || '你还没设置标签~'} ) : ( item.tags.split(' ').map((item, i) => ( - + {item} ))