mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-08 03:44:14 +00:00
fix: change router
This commit is contained in:
parent
096d665042
commit
c4ef35d1ef
@ -28,7 +28,7 @@ export default function Home() {
|
|||||||
chat_mode: 'chat_normal'
|
chat_mode: 'chat_normal'
|
||||||
});
|
});
|
||||||
if (res?.success && res?.data?.conv_uid) {
|
if (res?.success && res?.data?.conv_uid) {
|
||||||
router.push(`/agents/${res?.data?.conv_uid}?initMessage=${query}`);
|
router.push(`/chat?id=${res?.data?.conv_uid}&initMessage=${query}`);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
} finally {
|
} finally {
|
||||||
@ -66,7 +66,7 @@ export default function Home() {
|
|||||||
chat_mode: scene['chat_scene']
|
chat_mode: scene['chat_scene']
|
||||||
});
|
});
|
||||||
if (res?.success && res?.data?.conv_uid) {
|
if (res?.success && res?.data?.conv_uid) {
|
||||||
router.push(`/agents/${res?.data?.conv_uid}?scene=${scene['chat_scene']}`);
|
router.push(`/chat?id=${res?.data?.conv_uid}&scene=${scene['chat_scene']}`);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -6,10 +6,8 @@ import ChatBoxComp from '@/components/chatBoxTemp';
|
|||||||
import { useDialogueContext } from '@/app/context/dialogue';
|
import { useDialogueContext } from '@/app/context/dialogue';
|
||||||
|
|
||||||
const AgentPage = (props: {
|
const AgentPage = (props: {
|
||||||
params: {
|
|
||||||
agentId?: string;
|
|
||||||
},
|
|
||||||
searchParams: {
|
searchParams: {
|
||||||
|
id?: string;
|
||||||
scene?: string;
|
scene?: string;
|
||||||
initMessage?: string;
|
initMessage?: string;
|
||||||
}
|
}
|
||||||
@ -17,19 +15,21 @@ const AgentPage = (props: {
|
|||||||
const { refreshDialogList } = useDialogueContext();
|
const { refreshDialogList } = useDialogueContext();
|
||||||
|
|
||||||
const { data: historyList } = useRequest(async () => await sendGetRequest('/v1/chat/dialogue/messages/history', {
|
const { data: historyList } = useRequest(async () => await sendGetRequest('/v1/chat/dialogue/messages/history', {
|
||||||
con_uid: props.params?.agentId
|
con_uid: props.searchParams?.id
|
||||||
}), {
|
}), {
|
||||||
ready: !!props.params?.agentId
|
ready: !!props.searchParams?.id,
|
||||||
|
refreshDeps: [props.searchParams?.id]
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: paramsList } = useRequest(async () => await sendPostRequest(`/v1/chat/mode/params/list?chat_mode=${props.searchParams?.scene}`), {
|
const { data: paramsList } = useRequest(async () => await sendPostRequest(`/v1/chat/mode/params/list?chat_mode=${props.searchParams?.scene}`), {
|
||||||
ready: !!props.searchParams?.scene
|
ready: !!props.searchParams?.scene,
|
||||||
|
refreshDeps: [props.searchParams?.scene]
|
||||||
});
|
});
|
||||||
|
|
||||||
const { history, handleChatSubmit } = useAgentChat({
|
const { history, handleChatSubmit } = useAgentChat({
|
||||||
queryAgentURL: `/v1/chat/completions`,
|
queryAgentURL: `/v1/chat/completions`,
|
||||||
queryBody: {
|
queryBody: {
|
||||||
conv_uid: props.params?.agentId,
|
conv_uid: props.searchParams?.id,
|
||||||
chat_mode: props.searchParams?.scene || 'chat_normal',
|
chat_mode: props.searchParams?.scene || 'chat_normal',
|
||||||
},
|
},
|
||||||
initHistory: historyList?.data
|
initHistory: historyList?.data
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import React, { useEffect, useMemo } from 'react';
|
import React, { useEffect, useMemo } from 'react';
|
||||||
import { usePathname, useRouter } from 'next/navigation';
|
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { Modal } from 'antd';
|
import { Modal } from 'antd';
|
||||||
import { Box, List, ListItem, ListItemButton, ListItemDecorator, ListItemContent, Typography, Button, useColorScheme, IconButton } from '@/lib/mui';
|
import { Box, List, ListItem, ListItemButton, ListItemDecorator, ListItemContent, Typography, Button, useColorScheme, IconButton } from '@/lib/mui';
|
||||||
@ -15,6 +15,7 @@ import { sendPostRequest } from '@/utils/request';
|
|||||||
|
|
||||||
const LeftSider = () => {
|
const LeftSider = () => {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
const searchParams = useSearchParams();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { dialogueList, queryDialogueList, refreshDialogList } = useDialogueContext();
|
const { dialogueList, queryDialogueList, refreshDialogList } = useDialogueContext();
|
||||||
const { mode, setMode } = useColorScheme();
|
const { mode, setMode } = useColorScheme();
|
||||||
@ -114,7 +115,7 @@ const LeftSider = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{dialogueList?.data?.map((each) => {
|
{dialogueList?.data?.map((each) => {
|
||||||
const isSelect = pathname === `/agents/${each.conv_uid}`;
|
const isSelect = pathname === `/chat` && searchParams.get('id') === each.conv_uid;
|
||||||
return (
|
return (
|
||||||
<ListItem key={each.conv_uid}>
|
<ListItem key={each.conv_uid}>
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
@ -127,7 +128,7 @@ const LeftSider = () => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ListItemContent>
|
<ListItemContent>
|
||||||
<Link href={`/agents/${each.conv_uid}?scene=${each?.chat_mode}`} className="flex items-center justify-between">
|
<Link href={`/chat?id=${each.conv_uid}&scene=${each?.chat_mode}`} className="flex items-center justify-between">
|
||||||
<Typography fontSize={14} noWrap={true}>
|
<Typography fontSize={14} noWrap={true}>
|
||||||
<SmsOutlinedIcon className='mr-2' />
|
<SmsOutlinedIcon className='mr-2' />
|
||||||
{each?.user_name || each?.user_input || 'undefined'}
|
{each?.user_name || each?.user_input || 'undefined'}
|
||||||
@ -147,7 +148,7 @@ const LeftSider = () => {
|
|||||||
async onOk() {
|
async onOk() {
|
||||||
await sendPostRequest(`v1/chat/dialogue/delete?con_uid=${each.conv_uid}`);
|
await sendPostRequest(`v1/chat/dialogue/delete?con_uid=${each.conv_uid}`);
|
||||||
await refreshDialogList();
|
await refreshDialogList();
|
||||||
if (pathname === `/agents/${each.conv_uid}`) {
|
if (pathname === `/chat` && searchParams.get('id') === each.conv_uid) {
|
||||||
router.push('/');
|
router.push('/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user