feat: app detail

This commit is contained in:
archer
2023-07-13 15:07:13 +08:00
parent 6c72c20317
commit b4d46ff34d
47 changed files with 1088 additions and 1091 deletions

View File

@@ -9,9 +9,11 @@ import {
MenuList,
MenuItem
} from '@chakra-ui/react';
import MyIcon from '@/components/Icon';
import { useGlobalStore } from '@/store/global';
import { useRouter } from 'next/router';
import Avatar from '@/components/Avatar';
import MyTooltip from '@/components/MyTooltip';
import MyIcon from '@/components/Icon';
type HistoryItemType = {
id: string;
@@ -20,6 +22,7 @@ type HistoryItemType = {
};
const ChatHistorySlider = ({
appId,
appName,
appAvatar,
history,
@@ -29,6 +32,7 @@ const ChatHistorySlider = ({
onSetHistoryTop,
onCloseSlider
}: {
appId?: string;
appName: string;
appAvatar: string;
history: HistoryItemType[];
@@ -39,6 +43,7 @@ const ChatHistorySlider = ({
onCloseSlider: () => void;
}) => {
const theme = useTheme();
const router = useRouter();
const { isPc } = useGlobalStore();
const concatHistory = useMemo<HistoryItemType[]>(
@@ -57,12 +62,27 @@ const ChatHistorySlider = ({
whiteSpace={'nowrap'}
>
{isPc && (
<Flex pt={5} pb={2} px={[2, 5]} alignItems={'center'}>
<Avatar src={appAvatar} />
<Box ml={2} fontWeight={'bold'} className={'textEllipsis'}>
{appName}
</Box>
</Flex>
<MyTooltip label={appId ? '应用详情' : ''} offset={[0, 0]}>
<Flex
pt={5}
pb={2}
px={[2, 5]}
alignItems={'center'}
cursor={appId ? 'pointer' : 'default'}
onClick={() =>
appId &&
router.push({
pathname: '/app/detail',
query: { appId }
})
}
>
<Avatar src={appAvatar} />
<Box ml={2} fontWeight={'bold'} className={'textEllipsis'}>
{appName}
</Box>
</Flex>
</MyTooltip>
)}
{/* 新对话 */}
<Box w={'100%'} px={[2, 5]} h={'36px'} my={5}>

View File

@@ -21,11 +21,11 @@ import { getErrText } from '@/utils/tools';
const QuoteModal = ({
historyId,
chatId,
contentId,
onClose
}: {
historyId: string;
chatId: string;
contentId: string;
onClose: () => void;
}) => {
const theme = useTheme();
@@ -41,7 +41,7 @@ const QuoteModal = ({
data: quote = [],
refetch,
isLoading
} = useQuery(['getHistoryQuote'], () => getHistoryQuote({ historyId, chatId }));
} = useQuery(['getHistoryQuote'], () => getHistoryQuote({ historyId, contentId }));
/**
* update kbData, update mongo status and reload quotes
@@ -51,7 +51,7 @@ const QuoteModal = ({
setIsLoading(true);
try {
await updateHistoryQuote({
chatId,
contentId,
historyId,
quoteId,
sourceText
@@ -66,7 +66,7 @@ const QuoteModal = ({
}
setIsLoading(false);
},
[chatId, historyId, refetch, setIsLoading, toast]
[contentId, historyId, refetch, setIsLoading, toast]
);
/**

View File

@@ -21,7 +21,7 @@ const SliderApps = ({ appId }: { appId: string }) => {
px={3}
borderRadius={'md'}
_hover={{ bg: 'myGray.200' }}
onClick={() => router.replace('/app/list')}
onClick={() => router.back()}
>
<IconButton
mr={3}

View File

@@ -54,8 +54,8 @@ const Chat = () => {
const {
lastChatAppId,
setLastChatAppId,
lastChatId,
setLastChatId,
lastHistoryId,
setLastHistoryId,
history,
loadHistory,
updateHistory,
@@ -192,13 +192,13 @@ const Chat = () => {
} catch (e: any) {
// reset all chat tore
setLastChatAppId('');
setLastChatId('');
setLastHistoryId('');
router.replace('/chat');
}
setIsLoading(false);
return null;
},
[setIsLoading, setChatData, router, setLastChatAppId, setLastChatId]
[setIsLoading, setChatData, router, setLastChatAppId, setLastHistoryId]
);
// 初始化聊天框
useQuery(['init', appId, historyId], () => {
@@ -207,7 +207,7 @@ const Chat = () => {
router.replace({
query: {
appId: lastChatAppId,
historyId: lastChatId
historyId: lastHistoryId
}
});
return null;
@@ -215,7 +215,7 @@ const Chat = () => {
// store id
appId && setLastChatAppId(appId);
setLastChatId(historyId);
setLastHistoryId(historyId);
if (forbidRefresh.current) {
forbidRefresh.current = false;
@@ -254,6 +254,7 @@ const Chat = () => {
);
})(
<ChatHistorySlider
appId={appId}
appName={chatData.app.name}
appAvatar={chatData.app.avatar}
activeHistoryId={historyId}