diff --git a/web/src/global.ts b/web/src/global.ts new file mode 100644 index 0000000000000000000000000000000000000000..d025e4a3373ad39de74782143886e41efab0405d --- /dev/null +++ b/web/src/global.ts @@ -0,0 +1 @@ +import '@/locales/config'; diff --git a/web/src/hooks/loginHooks.ts b/web/src/hooks/loginHooks.ts new file mode 100644 index 0000000000000000000000000000000000000000..590ffadde3dfce01de8092501d4b49dc57060e35 --- /dev/null +++ b/web/src/hooks/loginHooks.ts @@ -0,0 +1,44 @@ +import { useCallback } from 'react'; +import { useDispatch } from 'umi'; + +export interface ILoginRequestBody { + email: string; + password: string; +} + +export interface IRegisterRequestBody extends ILoginRequestBody { + nickname: string; +} + +export const useLogin = () => { + const dispatch = useDispatch(); + + const login = useCallback( + (requestBody: ILoginRequestBody) => { + // TODO: Type needs to be improved + return dispatch<any>({ + type: 'loginModel/login', + payload: requestBody, + }); + }, + [dispatch], + ); + + return login; +}; + +export const useRegister = () => { + const dispatch = useDispatch(); + + const register = useCallback( + (requestBody: IRegisterRequestBody) => { + return dispatch<any>({ + type: 'loginModel/register', + payload: requestBody, + }); + }, + [dispatch], + ); + + return register; +}; diff --git a/web/src/locales/config.ts b/web/src/locales/config.ts index dd92cd3dcd14b41428a6c1ebed4cc7968584e324..b127f914776558a59a08b54600b5c16da5d222f0 100644 --- a/web/src/locales/config.ts +++ b/web/src/locales/config.ts @@ -5,20 +5,20 @@ import translation_en from './en.json'; import translation_zh from './zh.json'; const resources = { - en: { - translation: translation_en, - }, - zh: { - translation: translation_zh, - }, + en: { + translation: translation_en, + }, + zh: { + translation: translation_zh, + }, }; i18n.use(initReactI18next).init({ - resources, - lng: 'zh', - interpolation: { - escapeValue: false, - }, + resources, + lng: 'en', + interpolation: { + escapeValue: false, + }, }); export default i18n; diff --git a/web/src/locales/en.json b/web/src/locales/en.json index 91ad5c44693f327e199c8ad6545ec811d1289f66..9f0778ec1a617f9569f96d16b94b18a0a2dc1137 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -1,20 +1,21 @@ { - "header": { - "register": "Register", - "signin": "Sign In", - "home": "Home", - "setting": "用ć·č®ľç˝®", - "logout": "登出" - }, - "footer": { - "detail": "All rights reserved @ React" - }, - "layout": { - "file": "file", - "knowledge": "knowledge", - "chat": "chat" - }, - "setting": { - "btn": "en" - } -} \ No newline at end of file + "login": { "login": "Sign in" }, + "header": { + "register": "Register", + "signin": "Sign in", + "home": "Home", + "setting": "用ć·č®ľç˝®", + "logout": "登出" + }, + "footer": { + "detail": "All rights reserved @ React" + }, + "layout": { + "file": "file", + "knowledge": "knowledge", + "chat": "chat" + }, + "setting": { + "btn": "en" + } +} diff --git a/web/src/locales/zh.json b/web/src/locales/zh.json index 057310543df7c37fadd59eff14468b420a2f65e0..7eb7974a0effa717da5909868abf92c89cfb792a 100644 --- a/web/src/locales/zh.json +++ b/web/src/locales/zh.json @@ -1,20 +1,21 @@ { - "header": { - "register": "注册", - "signin": "登陆", - "home": "首页", - "setting": "user setting", - "logout": "logout" - }, - "footer": { - "detail": "ç‰ćťć‰€ćś‰ @ React" - }, - "layout": { - "file": "文件", - "knowledge": "知识库", - "chat": "čŠĺ¤©" - }, - "setting": { - "btn": "ä¸ć–‡" - } -} \ No newline at end of file + "login": { "login": "登录" }, + "header": { + "register": "注册", + "signin": "登陆", + "home": "首页", + "setting": "user setting", + "logout": "logout" + }, + "footer": { + "detail": "ç‰ćťć‰€ćś‰ @ React" + }, + "layout": { + "file": "文件", + "knowledge": "知识库", + "chat": "čŠĺ¤©" + }, + "setting": { + "btn": "ä¸ć–‡" + } +} diff --git a/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.less b/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.less index b3d17f1e1e11a1d83342eed4f371bf875d1d89a2..e11dd150e9962dff43e089e36c44f51f5285a65e 100644 --- a/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.less +++ b/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.less @@ -1,16 +1,24 @@ .uploadWrapper { display: flex; flex-direction: column; - padding: 32px; + padding: 64px 32px 32px; height: 100%; .backToList { + display: none; padding-bottom: 60px; } .footer { - text-align: right; + text-align: center; padding-top: 16px; .nextButton { - background-color: @purple; + // background-color: @purple; + font-weight: 700; + font-size: 24px; + display: inline-flex; + align-items: center; + padding: 26px 40px; + justify-content: center; + width: 10%; } } .uploadContent { diff --git a/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx b/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx index 8cb6433047108b0a15277f9754a4fd46f23e9898..aaff97ccd221dabc91d84554e212520828b9c5b5 100644 --- a/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx @@ -287,9 +287,10 @@ const KnowledgeUploadFile = () => { <section className={styles.footer}> <Button type="primary" - // className={styles.nextButton} + className={styles.nextButton} onClick={handleNextClick} disabled={!enabled} + size="large" > Next </Button> diff --git a/web/src/pages/login/index.tsx b/web/src/pages/login/index.tsx index 5a89c98d2f23b3358a9bcecc7d2c5943643e7ddc..d494c295e08094791b50d92c1409a73c697c0262 100644 --- a/web/src/pages/login/index.tsx +++ b/web/src/pages/login/index.tsx @@ -1,59 +1,56 @@ +import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks'; import { rsaPsw } from '@/utils'; import { Button, Checkbox, Form, Input } from 'antd'; import { useEffect, useState } from 'react'; -import { Icon, useDispatch, useNavigate, useSelector } from 'umi'; +import { useTranslation } from 'react-i18next'; +import { Icon, useNavigate } from 'umi'; import RightPanel from './right-panel'; +import { useLogin, useRegister } from '@/hooks/loginHooks'; import styles from './index.less'; const Login = () => { const [title, setTitle] = useState('login'); - let navigate = useNavigate(); - const dispatch = useDispatch(); - const effectsLoading: any = useSelector<any>( // TODO: Type needs to be improved - (state) => state.loading.effects, - ); + const navigate = useNavigate(); + const login = useLogin(); + const register = useRegister(); + const { t } = useTranslation(); // TODO: When the server address request is not accessible, the value of dva-loading always remains true. - const signLoading = - effectsLoading['loginModel/login'] || effectsLoading['loginModel/register']; + const signLoading = useOneNamespaceEffectsLoading('loginModel', [ + 'login', + 'register', + ]); const changeTitle = () => { setTitle((title) => (title === 'login' ? 'register' : 'login')); }; const [form] = Form.useForm(); - const [checkNick, setCheckNick] = useState(false); useEffect(() => { form.validateFields(['nickname']); - }, [checkNick, form]); + }, [form]); const onCheck = async () => { try { const params = await form.validateFields(); - var rsaPassWord = rsaPsw(params.password); + const rsaPassWord = rsaPsw(params.password) as string; + if (title === 'login') { - const retcode = await dispatch<any>({ - type: 'loginModel/login', - payload: { - email: params.email, - password: rsaPassWord, - }, + const retcode = await login({ + email: params.email, + password: rsaPassWord, }); if (retcode === 0) { navigate('/knowledge'); } } else { - // TODO: Type needs to be improved - const retcode = await dispatch<any>({ - type: 'loginModel/register', - payload: { - nickname: params.nickname, - email: params.email, - password: rsaPassWord, - }, + const retcode = await register({ + nickname: params.nickname, + email: params.email, + password: rsaPassWord, }); if (retcode === 0) { setTitle('login'); @@ -72,12 +69,15 @@ const Login = () => { window.location.href = 'https://github.com/login/oauth/authorize?scope=user:email&client_id=302129228f0d96055bee'; }; + return ( <div className={styles.loginPage}> <div className={styles.loginLeft}> <div className={styles.leftContainer}> <div className={styles.loginTitle}> - <div>{title === 'login' ? 'Sign in' : 'Create an account'}</div> + <div> + {title === 'login' ? t('login.login') : 'Create an account'} + </div> <span> {title === 'login' ? 'We’re so excited to see you again!'