fix: solve the conflict

This commit is contained in:
shiweisong.ssw 2023-06-30 11:28:26 +08:00
commit 51c6f0064a
12 changed files with 101 additions and 75 deletions

View File

@ -1,8 +1,3 @@
{
"extends": "next/core-web-vitals",
"rules": {
"indent": ["warning", 2, {
"SwitchCase": 1
}]
}
"extends": "next/core-web-vitals"
}

View File

@ -1,44 +1,14 @@
"use client"
import { useRequest } from 'ahooks';
import { sendGetRequest, sendPostRequest } from '@/utils/request';
import useAgentChat from '@/hooks/useAgentChat';
import ChatBoxComp from '@/components/chatBox';
import { useDialogueContext } from '@/app/context/dialogue';
import dynamic from 'next/dynamic'
const AgentPage = (props) => {
const { refreshDialogList } = useDialogueContext();
const { data: historyList } = useRequest(async () => await sendGetRequest('/v1/chat/dialogue/messages/history', {
con_uid: props.params?.agentId
}), {
ready: !!props.params?.agentId
});
const { data: paramsList } = useRequest(async () => await sendPostRequest(`/v1/chat/mode/params/list?chat_mode=${props.searchParams?.scene}`), {
ready: !!props.searchParams?.scene
});
const { history, handleChatSubmit } = useAgentChat({
queryAgentURL: `http://30.183.154.8:5000/v1/chat/completions`,
queryBody: {
conv_uid: props.params?.agentId,
chat_mode: props.searchParams?.scene || 'chat_normal',
},
initHistory: historyList?.data
});
const DynamicWrapper = dynamic(() => import ('@/components/agentPage'), {
loading: () => <p>Loading...</p>,
ssr: false,
});
const DynamicAgentPage = (props: any) => {
return (
<div className='mx-auto flex h-full max-w-3xl flex-col gap-6 px-5 py-6 sm:gap-8 xl:max-w-5xl '>
<ChatBoxComp
initialMessage={historyList?.data ? (historyList?.data?.length <= 0 ? props.searchParams?.initMessage : undefined) : undefined}
clearIntialMessage={async () => {
await refreshDialogList();
}}
messages={history || []}
onSubmit={handleChatSubmit}
paramsList={paramsList?.data}
/>
</div>
<DynamicWrapper {...props} />
)
}
export default AgentPage;
export default DynamicAgentPage;

View File

@ -16,7 +16,7 @@ const Item = styled(Sheet)(({ theme }) => ({
const Agents = () => {
const { handleChatSubmit, history } = useAgentChat({
queryAgentURL: `http://30.183.154.8:5000/v1/chat/completions`,
queryAgentURL: `http://30.183.153.109:5000/v1/chat/completions`,
});
const data = [
@ -119,10 +119,10 @@ const Agents = () => {
<Grid key={item.label} xs={3}>
<Card className="flex-1 h-full">
<CardContent className="justify-around">
<Typography gutterBottom variant="h5" component="div">
<Typography gutterBottom component="div">
{item.label}
</Typography>
<Typography variant="body2">
<Typography>
{item.value}
</Typography>
</CardContent>
@ -134,7 +134,7 @@ const Agents = () => {
<Item className='flex-1'>
<Card className='h-full'>
<CardContent className='h-full'>
<Typography gutterBottom variant="h5" component="div">
<Typography gutterBottom component="div">
Revenue Won by Month
</Typography>
<div className='flex-1'>
@ -156,7 +156,7 @@ const Agents = () => {
<Grid xs={4} className='h-full'>
<Card className='flex-1 h-full'>
<CardContent className='h-full'>
<Typography gutterBottom variant="h5" component="div">
<Typography gutterBottom component="div">
Close % by Month
</Typography>
<div className='flex-1'>
@ -171,7 +171,7 @@ const Agents = () => {
<Grid xs={4} className='h-full'>
<Card className='flex-1 h-full'>
<CardContent className='h-full'>
<Typography gutterBottom variant="h5" component="div">
<Typography gutterBottom component="div">
Close % by Month
</Typography>
<div className='flex-1'>
@ -186,7 +186,7 @@ const Agents = () => {
<Grid xs={4} className='h-full'>
<Card className='flex-1 h-full'>
<CardContent className='h-full'>
<Typography gutterBottom variant="h5" component="div">
<Typography gutterBottom component="div">
Close % by Month
</Typography>
<div className='flex-1'>

View File

@ -10,7 +10,7 @@ export const [useDialogueContext, DialogueProvider] = createCtx<{
refreshDialogList: () => void;
}>();
export default ({ children }: {
const DialogueContext = ({ children }: {
children: React.ReactElement
}) => {
const {
@ -32,4 +32,6 @@ export default ({ children }: {
{children}
</DialogueProvider>
)
}
}
export default DialogueContext;

View File

@ -1,9 +1,9 @@
"use client"
import './globals.css'
import './nprogress.css';
import '@/nprogress.css';
import LeftSider from '@/components/leftSider';
import { CssVarsProvider, ThemeProvider } from '@mui/joy/styles';
import { joyTheme } from './defaultTheme';
import { joyTheme } from '@/defaultTheme';
import TopProgressBar from '@/components/topProgressBar';
import DialogueContext from './context/dialogue';

View File

@ -39,7 +39,7 @@ export default function Home() {
return (
<>
<div className={`${mode} absolute z-20 top-0 inset-x-0 flex justify-center overflow-hidden pointer-events-none`}>
<div className={`absolute z-20 top-0 inset-x-0 flex justify-center overflow-hidden pointer-events-none`}>
<div className='w-[108rem] flex-none flex justify-end'>
<picture>
<source srcSet='/bg1.avif' type='image/avif'></source>

View File

@ -0,0 +1,53 @@
"use client"
import { useRequest } from 'ahooks';
import { sendGetRequest, sendPostRequest } from '@/utils/request';
import useAgentChat from '@/hooks/useAgentChat';
import ChatBoxComp from '@/components/chatBox';
import { useDialogueContext } from '@/app/context/dialogue';
const AgentPage = (props: {
params: {
agentId?: string;
},
searchParams: {
scene?: string;
initMessage?: string;
}
}) => {
const { refreshDialogList } = useDialogueContext();
const { data: historyList } = useRequest(async () => await sendGetRequest('/v1/chat/dialogue/messages/history', {
con_uid: props.params?.agentId
}), {
ready: !!props.params?.agentId
});
const { data: paramsList } = useRequest(async () => await sendPostRequest(`/v1/chat/mode/params/list?chat_mode=${props.searchParams?.scene}`), {
ready: !!props.searchParams?.scene
});
const { history, handleChatSubmit } = useAgentChat({
queryAgentURL: `http://30.183.153.109:5000/v1/chat/completions`,
queryBody: {
conv_uid: props.params?.agentId,
chat_mode: props.searchParams?.scene || 'chat_normal',
},
initHistory: historyList?.data
});
return (
<div className='mx-auto flex h-full max-w-3xl flex-col gap-6 px-5 py-6 sm:gap-8 xl:max-w-5xl '>
<ChatBoxComp
initialMessage={historyList?.data ? (historyList?.data?.length <= 0 ? props.searchParams?.initMessage : undefined) : undefined}
clearIntialMessage={async () => {
await refreshDialogList();
}}
messages={history || []}
onSubmit={handleChatSubmit}
paramsList={paramsList?.data}
/>
</div>
)
}
export default AgentPage;

View File

@ -33,26 +33,28 @@ Router.events.on('routeChangeStart', load);
Router.events.on('routeChangeComplete', stop);
Router.events.on('routeChangeError', stop);
const originalFetch = window.fetch;
window.fetch = async function (...args) {
if (activeRequests === 0) {
load();
}
activeRequests++;
try {
const response = await originalFetch(...args);
return response;
} catch (error) {
return Promise.reject(error);
} finally {
activeRequests -= 1;
if (typeof window !== 'undefined' && typeof window?.fetch === 'function') {
const originalFetch = window.fetch;
window.fetch = async function (...args) {
if (activeRequests === 0) {
stop();
load();
}
}
};
activeRequests++;
try {
const response = await originalFetch(...args);
return response;
} catch (error) {
return Promise.reject(error);
} finally {
activeRequests -= 1;
if (activeRequests === 0) {
stop();
}
}
};
}
export default function TopProgressBar() {
return null;

View File

@ -1,7 +1,11 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
experimental: {
esmExternals: 'loose'
},
typescript: {
ignoreBuildErrors: true
}
}

View File

@ -2,7 +2,7 @@ import { message } from 'antd';
import axios from 'axios';
import { isPlainObject } from 'lodash';
axios.defaults.baseURL = 'http://30.183.154.8:5000';
axios.defaults.baseURL = 'http://30.183.153.109:5000';
axios.defaults.timeout = 10000;