mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-03 05:19:51 +00:00
fix: i18n change
This commit is contained in:
@@ -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<string>();
|
||||
const [baiduTongji, setBaiduTongji] = useState<string>();
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<Head>
|
||||
|
@@ -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
|
||||
});
|
||||
}
|
@@ -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))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -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)) }
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -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)) }
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user