diff --git a/client/src/components/Language/index.tsx b/client/src/components/Language/index.tsx
index 1d5023450..89217d7b1 100644
--- a/client/src/components/Language/index.tsx
+++ b/client/src/components/Language/index.tsx
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { Menu, MenuButton, MenuItem, MenuList, MenuButtonProps } from '@chakra-ui/react';
-import { useRouter } from 'next/router';
import { getLangStore, LangEnum, setLangStore } from '@/utils/i18n';
import MyIcon from '@/components/Icon';
+import { useTranslation } from 'react-i18next';
const langMap = {
[LangEnum.en]: {
@@ -16,7 +16,8 @@ const langMap = {
};
const Language = (props: MenuButtonProps) => {
- const router = useRouter();
+ const { i18n } = useTranslation();
+
const [language, setLanguage] = useState<`${LangEnum}`>(getLangStore());
return (
@@ -41,12 +42,7 @@ const Language = (props: MenuButtonProps) => {
const lang = key as `${LangEnum}`;
setLangStore(lang);
setLanguage(lang);
- router.replace({
- query: {
- ...router.query,
- lang
- }
- });
+ i18n?.changeLanguage?.(lang);
}}
>
{lang.label}
diff --git a/client/src/components/MyModal/index.tsx b/client/src/components/MyModal/index.tsx
new file mode 100644
index 000000000..655c8c142
--- /dev/null
+++ b/client/src/components/MyModal/index.tsx
@@ -0,0 +1,29 @@
+import React from 'react';
+import {
+ Modal,
+ ModalOverlay,
+ ModalContent,
+ ModalHeader,
+ ModalCloseButton,
+ ModalProps
+} from '@chakra-ui/react';
+
+interface Props extends ModalProps {
+ showCloseBtn?: boolean;
+ title?: string;
+}
+
+const MyModal = ({ isOpen, onClose, title, children, showCloseBtn = true, ...props }: Props) => {
+ return (
+
+
+
+ {!!title && {title}}
+ {showCloseBtn && }
+ {children}
+
+
+ );
+};
+
+export default MyModal;
diff --git a/client/src/pages/_app.tsx b/client/src/pages/_app.tsx
index 1c025494f..4a2c6b433 100644
--- a/client/src/pages/_app.tsx
+++ b/client/src/pages/_app.tsx
@@ -9,8 +9,9 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import NProgress from 'nprogress'; //nprogress module
import Router from 'next/router';
import { clientInitData, feConfigs } from '@/store/static';
-import { appWithTranslation } from 'next-i18next';
-import { setLangStore } from '@/utils/i18n';
+import { appWithTranslation, useTranslation } from 'next-i18next';
+import { getLangStore, setLangStore } from '@/utils/i18n';
+import { useRouter } from 'next/router';
import 'nprogress/nprogress.css';
import '@/styles/reset.scss';
@@ -32,6 +33,9 @@ const queryClient = new QueryClient({
});
function App({ Component, pageProps }: AppProps) {
+ const router = useRouter();
+ const { i18n } = useTranslation();
+
const [googleClientVerKey, setGoogleVerKey] = useState();
const [baiduTongji, setBaiduTongji] = useState();
@@ -44,9 +48,14 @@ function App({ Component, pageProps }: AppProps) {
setBaiduTongji(baiduTongji);
})();
- setLangStore('en');
+ setLangStore('zh');
}, []);
+ useEffect(() => {
+ const lang = getLangStore() || 'zh';
+ i18n?.changeLanguage?.(lang);
+ }, [router.asPath]);
+
return (
<>
diff --git a/client/src/pages/api/system/getModels.ts b/client/src/pages/api/system/getModels.ts
deleted file mode 100644
index 83767c63f..000000000
--- a/client/src/pages/api/system/getModels.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import type { NextApiRequest, NextApiResponse } from 'next';
-import { jsonRes } from '@/service/response';
-import type { ChatModelItemType } from '@/constants/model';
-import { ChatModelMap, OpenAiChatEnum } from '@/constants/model';
-
-// get the models available to the system
-export default async function handler(req: NextApiRequest, res: NextApiResponse) {
- const chatModelList: ChatModelItemType[] = [];
-
- chatModelList.push(ChatModelMap[OpenAiChatEnum.GPT3516k]);
- chatModelList.push(ChatModelMap[OpenAiChatEnum.GPT35]);
- chatModelList.push(ChatModelMap[OpenAiChatEnum.GPT4]);
-
- jsonRes(res, {
- data: chatModelList
- });
-}
diff --git a/client/src/pages/chat/index.tsx b/client/src/pages/chat/index.tsx
index c1a2dbffb..349338356 100644
--- a/client/src/pages/chat/index.tsx
+++ b/client/src/pages/chat/index.tsx
@@ -28,6 +28,7 @@ import SliderApps from './components/SliderApps';
import ChatHeader from './components/ChatHeader';
import { getErrText } from '@/utils/tools';
import { useUserStore } from '@/store/user';
+import { serviceSideProps } from '@/utils/i18n';
const Chat = ({ appId, chatId }: { appId: string; chatId: string }) => {
const router = useRouter();
@@ -338,7 +339,8 @@ export async function getServerSideProps(context: any) {
return {
props: {
appId: context?.query?.appId || '',
- chatId: context?.query?.chatId || ''
+ chatId: context?.query?.chatId || '',
+ ...(await serviceSideProps(context))
}
};
}
diff --git a/client/src/pages/chat/share.tsx b/client/src/pages/chat/share.tsx
index b18d914da..52cdacdbc 100644
--- a/client/src/pages/chat/share.tsx
+++ b/client/src/pages/chat/share.tsx
@@ -18,6 +18,7 @@ import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/
import PageContainer from '@/components/PageContainer';
import ChatHeader from './components/ChatHeader';
import ChatHistorySlider from './components/ChatHistorySlider';
+import { serviceSideProps } from '@/utils/i18n';
const ShareChat = ({ shareId, chatId }: { shareId: string; chatId: string }) => {
const router = useRouter();
@@ -232,7 +233,7 @@ export async function getServerSideProps(context: any) {
const chatId = context?.query?.chatId || '';
return {
- props: { shareId, chatId }
+ props: { shareId, chatId, ...(await serviceSideProps(context)) }
};
}
diff --git a/client/src/pages/kb/detail/index.tsx b/client/src/pages/kb/detail/index.tsx
index 318d9df7b..22c3997b3 100644
--- a/client/src/pages/kb/detail/index.tsx
+++ b/client/src/pages/kb/detail/index.tsx
@@ -160,7 +160,7 @@ export async function getServerSideProps(context: any) {
const kbId = context?.query?.kbId;
return {
- props: { currentTab, kbId, ...(await serviceSideProps(content)) }
+ props: { currentTab, kbId, ...(await serviceSideProps(context)) }
};
}
diff --git a/client/src/pages/login/index.tsx b/client/src/pages/login/index.tsx
index 36feb66e4..9011a4306 100644
--- a/client/src/pages/login/index.tsx
+++ b/client/src/pages/login/index.tsx
@@ -9,6 +9,7 @@ import { useUserStore } from '@/store/user';
import { useChatStore } from '@/store/chat';
import LoginForm from './components/LoginForm';
import dynamic from 'next/dynamic';
+import { serviceSideProps } from '@/utils/i18n';
const RegisterForm = dynamic(() => import('./components/RegisterForm'));
const ForgetPasswordForm = dynamic(() => import('./components/ForgetPasswordForm'));
@@ -97,4 +98,10 @@ const Login = () => {
);
};
+export async function getServerSideProps(context: any) {
+ return {
+ props: { ...(await serviceSideProps(context)) }
+ };
+}
+
export default Login;