Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
2b993b92
authored
Jul 25, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: i18n change
parent
b367082d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
58 additions
and
31 deletions
+58
-31
client/src/components/Language/index.tsx
+4
-8
client/src/components/MyModal/index.tsx
+29
-0
client/src/pages/_app.tsx
+12
-3
client/src/pages/api/system/getModels.ts
+0
-17
client/src/pages/chat/index.tsx
+3
-1
client/src/pages/chat/share.tsx
+2
-1
client/src/pages/kb/detail/index.tsx
+1
-1
client/src/pages/login/index.tsx
+7
-0
No files found.
client/src/components/Language/index.tsx
View file @
2b993b92
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
import
{
Menu
,
MenuButton
,
MenuItem
,
MenuList
,
MenuButtonProps
}
from
'@chakra-ui/react'
;
import
{
Menu
,
MenuButton
,
MenuItem
,
MenuList
,
MenuButtonProps
}
from
'@chakra-ui/react'
;
import
{
useRouter
}
from
'next/router'
;
import
{
getLangStore
,
LangEnum
,
setLangStore
}
from
'@/utils/i18n'
;
import
{
getLangStore
,
LangEnum
,
setLangStore
}
from
'@/utils/i18n'
;
import
MyIcon
from
'@/components/Icon'
;
import
MyIcon
from
'@/components/Icon'
;
import
{
useTranslation
}
from
'react-i18next'
;
const
langMap
=
{
const
langMap
=
{
[
LangEnum
.
en
]:
{
[
LangEnum
.
en
]:
{
...
@@ -16,7 +16,8 @@ const langMap = {
...
@@ -16,7 +16,8 @@ const langMap = {
};
};
const
Language
=
(
props
:
MenuButtonProps
)
=>
{
const
Language
=
(
props
:
MenuButtonProps
)
=>
{
const
router
=
useRouter
();
const
{
i18n
}
=
useTranslation
();
const
[
language
,
setLanguage
]
=
useState
<
`
${
LangEnum
}
`
>
(
getLangStore
());
const
[
language
,
setLanguage
]
=
useState
<
`
${
LangEnum
}
`
>
(
getLangStore
());
return
(
return
(
...
@@ -41,12 +42,7 @@ const Language = (props: MenuButtonProps) => {
...
@@ -41,12 +42,7 @@ const Language = (props: MenuButtonProps) => {
const
lang
=
key
as
`${LangEnum}`
;
const
lang
=
key
as
`${LangEnum}`
;
setLangStore
(
lang
);
setLangStore
(
lang
);
setLanguage
(
lang
);
setLanguage
(
lang
);
router
.
replace
({
i18n
?.
changeLanguage
?.(
lang
);
query
:
{
...
router
.
query
,
lang
}
});
}
}
}
}
>
>
{
lang
.
label
}
{
lang
.
label
}
...
...
client/src/components/MyModal/index.tsx
0 → 100644
View file @
2b993b92
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
(
<
Modal
isOpen=
{
isOpen
}
onClose=
{
onClose
}
autoFocus=
{
false
}
{
...
props
}
>
<
ModalOverlay
/>
<
ModalContent
>
{
!!
title
&&
<
ModalHeader
>
{
title
}
</
ModalHeader
>
}
{
showCloseBtn
&&
<
ModalCloseButton
/>
}
{
children
}
</
ModalContent
>
</
Modal
>
);
};
export
default
MyModal
;
client/src/pages/_app.tsx
View file @
2b993b92
...
@@ -9,8 +9,9 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
...
@@ -9,8 +9,9 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import
NProgress
from
'nprogress'
;
//nprogress module
import
NProgress
from
'nprogress'
;
//nprogress module
import
Router
from
'next/router'
;
import
Router
from
'next/router'
;
import
{
clientInitData
,
feConfigs
}
from
'@/store/static'
;
import
{
clientInitData
,
feConfigs
}
from
'@/store/static'
;
import
{
appWithTranslation
}
from
'next-i18next'
;
import
{
appWithTranslation
,
useTranslation
}
from
'next-i18next'
;
import
{
setLangStore
}
from
'@/utils/i18n'
;
import
{
getLangStore
,
setLangStore
}
from
'@/utils/i18n'
;
import
{
useRouter
}
from
'next/router'
;
import
'nprogress/nprogress.css'
;
import
'nprogress/nprogress.css'
;
import
'@/styles/reset.scss'
;
import
'@/styles/reset.scss'
;
...
@@ -32,6 +33,9 @@ const queryClient = new QueryClient({
...
@@ -32,6 +33,9 @@ const queryClient = new QueryClient({
});
});
function
App
({
Component
,
pageProps
}:
AppProps
)
{
function
App
({
Component
,
pageProps
}:
AppProps
)
{
const
router
=
useRouter
();
const
{
i18n
}
=
useTranslation
();
const
[
googleClientVerKey
,
setGoogleVerKey
]
=
useState
<
string
>
();
const
[
googleClientVerKey
,
setGoogleVerKey
]
=
useState
<
string
>
();
const
[
baiduTongji
,
setBaiduTongji
]
=
useState
<
string
>
();
const
[
baiduTongji
,
setBaiduTongji
]
=
useState
<
string
>
();
...
@@ -44,9 +48,14 @@ function App({ Component, pageProps }: AppProps) {
...
@@ -44,9 +48,14 @@ function App({ Component, pageProps }: AppProps) {
setBaiduTongji
(
baiduTongji
);
setBaiduTongji
(
baiduTongji
);
})();
})();
setLangStore
(
'
en
'
);
setLangStore
(
'
zh
'
);
},
[]);
},
[]);
useEffect
(()
=>
{
const
lang
=
getLangStore
()
||
'zh'
;
i18n
?.
changeLanguage
?.(
lang
);
},
[
router
.
asPath
]);
return
(
return
(
<>
<>
<
Head
>
<
Head
>
...
...
client/src/pages/api/system/getModels.ts
deleted
100644 → 0
View file @
b367082d
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
});
}
client/src/pages/chat/index.tsx
View file @
2b993b92
...
@@ -28,6 +28,7 @@ import SliderApps from './components/SliderApps';
...
@@ -28,6 +28,7 @@ import SliderApps from './components/SliderApps';
import
ChatHeader
from
'./components/ChatHeader'
;
import
ChatHeader
from
'./components/ChatHeader'
;
import
{
getErrText
}
from
'@/utils/tools'
;
import
{
getErrText
}
from
'@/utils/tools'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
useUserStore
}
from
'@/store/user'
;
import
{
serviceSideProps
}
from
'@/utils/i18n'
;
const
Chat
=
({
appId
,
chatId
}:
{
appId
:
string
;
chatId
:
string
})
=>
{
const
Chat
=
({
appId
,
chatId
}:
{
appId
:
string
;
chatId
:
string
})
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
...
@@ -338,7 +339,8 @@ export async function getServerSideProps(context: any) {
...
@@ -338,7 +339,8 @@ export async function getServerSideProps(context: any) {
return
{
return
{
props
:
{
props
:
{
appId
:
context
?.
query
?.
appId
||
''
,
appId
:
context
?.
query
?.
appId
||
''
,
chatId
:
context
?.
query
?.
chatId
||
''
chatId
:
context
?.
query
?.
chatId
||
''
,
...(
await
serviceSideProps
(
context
))
}
}
};
};
}
}
...
...
client/src/pages/chat/share.tsx
View file @
2b993b92
...
@@ -18,6 +18,7 @@ import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/
...
@@ -18,6 +18,7 @@ import ChatBox, { type ComponentRef, type StartChatFnProps } from '@/components/
import
PageContainer
from
'@/components/PageContainer'
;
import
PageContainer
from
'@/components/PageContainer'
;
import
ChatHeader
from
'./components/ChatHeader'
;
import
ChatHeader
from
'./components/ChatHeader'
;
import
ChatHistorySlider
from
'./components/ChatHistorySlider'
;
import
ChatHistorySlider
from
'./components/ChatHistorySlider'
;
import
{
serviceSideProps
}
from
'@/utils/i18n'
;
const
ShareChat
=
({
shareId
,
chatId
}:
{
shareId
:
string
;
chatId
:
string
})
=>
{
const
ShareChat
=
({
shareId
,
chatId
}:
{
shareId
:
string
;
chatId
:
string
})
=>
{
const
router
=
useRouter
();
const
router
=
useRouter
();
...
@@ -232,7 +233,7 @@ export async function getServerSideProps(context: any) {
...
@@ -232,7 +233,7 @@ export async function getServerSideProps(context: any) {
const
chatId
=
context
?.
query
?.
chatId
||
''
;
const
chatId
=
context
?.
query
?.
chatId
||
''
;
return
{
return
{
props
:
{
shareId
,
chatId
}
props
:
{
shareId
,
chatId
,
...(
await
serviceSideProps
(
context
))
}
};
};
}
}
...
...
client/src/pages/kb/detail/index.tsx
View file @
2b993b92
...
@@ -160,7 +160,7 @@ export async function getServerSideProps(context: any) {
...
@@ -160,7 +160,7 @@ export async function getServerSideProps(context: any) {
const
kbId
=
context
?.
query
?.
kbId
;
const
kbId
=
context
?.
query
?.
kbId
;
return
{
return
{
props
:
{
currentTab
,
kbId
,
...(
await
serviceSideProps
(
conte
n
t
))
}
props
:
{
currentTab
,
kbId
,
...(
await
serviceSideProps
(
conte
x
t
))
}
};
};
}
}
...
...
client/src/pages/login/index.tsx
View file @
2b993b92
...
@@ -9,6 +9,7 @@ import { useUserStore } from '@/store/user';
...
@@ -9,6 +9,7 @@ import { useUserStore } from '@/store/user';
import
{
useChatStore
}
from
'@/store/chat'
;
import
{
useChatStore
}
from
'@/store/chat'
;
import
LoginForm
from
'./components/LoginForm'
;
import
LoginForm
from
'./components/LoginForm'
;
import
dynamic
from
'next/dynamic'
;
import
dynamic
from
'next/dynamic'
;
import
{
serviceSideProps
}
from
'@/utils/i18n'
;
const
RegisterForm
=
dynamic
(()
=>
import
(
'./components/RegisterForm'
));
const
RegisterForm
=
dynamic
(()
=>
import
(
'./components/RegisterForm'
));
const
ForgetPasswordForm
=
dynamic
(()
=>
import
(
'./components/ForgetPasswordForm'
));
const
ForgetPasswordForm
=
dynamic
(()
=>
import
(
'./components/ForgetPasswordForm'
));
...
@@ -97,4 +98,10 @@ const Login = () => {
...
@@ -97,4 +98,10 @@ const Login = () => {
);
);
};
};
export
async
function
getServerSideProps
(
context
:
any
)
{
return
{
props
:
{
...(
await
serviceSideProps
(
context
))
}
};
}
export
default
Login
;
export
default
Login
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment