mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: enlarge the size of the next button for uploading files and add locale config to global.ts (#195)
feat: enlarge the size of the next button for uploading files feat: add locale config to global.ts
This commit is contained in:
1
web/src/global.ts
Normal file
1
web/src/global.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
import '@/locales/config';
|
||||||
44
web/src/hooks/loginHooks.ts
Normal file
44
web/src/hooks/loginHooks.ts
Normal file
@ -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;
|
||||||
|
};
|
||||||
@ -15,7 +15,7 @@ const resources = {
|
|||||||
|
|
||||||
i18n.use(initReactI18next).init({
|
i18n.use(initReactI18next).init({
|
||||||
resources,
|
resources,
|
||||||
lng: 'zh',
|
lng: 'en',
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false,
|
escapeValue: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
|
"login": { "login": "Sign in" },
|
||||||
"header": {
|
"header": {
|
||||||
"register": "Register",
|
"register": "Register",
|
||||||
"signin": "Sign In",
|
"signin": "Sign in",
|
||||||
"home": "Home",
|
"home": "Home",
|
||||||
"setting": "用户设置",
|
"setting": "用户设置",
|
||||||
"logout": "登出"
|
"logout": "登出"
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"login": { "login": "登录" },
|
||||||
"header": {
|
"header": {
|
||||||
"register": "注册",
|
"register": "注册",
|
||||||
"signin": "登陆",
|
"signin": "登陆",
|
||||||
|
|||||||
@ -1,16 +1,24 @@
|
|||||||
.uploadWrapper {
|
.uploadWrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 32px;
|
padding: 64px 32px 32px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
.backToList {
|
.backToList {
|
||||||
|
display: none;
|
||||||
padding-bottom: 60px;
|
padding-bottom: 60px;
|
||||||
}
|
}
|
||||||
.footer {
|
.footer {
|
||||||
text-align: right;
|
text-align: center;
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
.nextButton {
|
.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 {
|
.uploadContent {
|
||||||
|
|||||||
@ -287,9 +287,10 @@ const KnowledgeUploadFile = () => {
|
|||||||
<section className={styles.footer}>
|
<section className={styles.footer}>
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
// className={styles.nextButton}
|
className={styles.nextButton}
|
||||||
onClick={handleNextClick}
|
onClick={handleNextClick}
|
||||||
disabled={!enabled}
|
disabled={!enabled}
|
||||||
|
size="large"
|
||||||
>
|
>
|
||||||
Next
|
Next
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -1,59 +1,56 @@
|
|||||||
|
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||||
import { rsaPsw } from '@/utils';
|
import { rsaPsw } from '@/utils';
|
||||||
import { Button, Checkbox, Form, Input } from 'antd';
|
import { Button, Checkbox, Form, Input } from 'antd';
|
||||||
import { useEffect, useState } from 'react';
|
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 RightPanel from './right-panel';
|
||||||
|
|
||||||
|
import { useLogin, useRegister } from '@/hooks/loginHooks';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const [title, setTitle] = useState('login');
|
const [title, setTitle] = useState('login');
|
||||||
let navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const dispatch = useDispatch();
|
const login = useLogin();
|
||||||
const effectsLoading: any = useSelector<any>( // TODO: Type needs to be improved
|
const register = useRegister();
|
||||||
(state) => state.loading.effects,
|
const { t } = useTranslation();
|
||||||
);
|
|
||||||
|
|
||||||
// TODO: When the server address request is not accessible, the value of dva-loading always remains true.
|
// TODO: When the server address request is not accessible, the value of dva-loading always remains true.
|
||||||
|
|
||||||
const signLoading =
|
const signLoading = useOneNamespaceEffectsLoading('loginModel', [
|
||||||
effectsLoading['loginModel/login'] || effectsLoading['loginModel/register'];
|
'login',
|
||||||
|
'register',
|
||||||
|
]);
|
||||||
|
|
||||||
const changeTitle = () => {
|
const changeTitle = () => {
|
||||||
setTitle((title) => (title === 'login' ? 'register' : 'login'));
|
setTitle((title) => (title === 'login' ? 'register' : 'login'));
|
||||||
};
|
};
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [checkNick, setCheckNick] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
form.validateFields(['nickname']);
|
form.validateFields(['nickname']);
|
||||||
}, [checkNick, form]);
|
}, [form]);
|
||||||
|
|
||||||
const onCheck = async () => {
|
const onCheck = async () => {
|
||||||
try {
|
try {
|
||||||
const params = await form.validateFields();
|
const params = await form.validateFields();
|
||||||
|
|
||||||
var rsaPassWord = rsaPsw(params.password);
|
const rsaPassWord = rsaPsw(params.password) as string;
|
||||||
|
|
||||||
if (title === 'login') {
|
if (title === 'login') {
|
||||||
const retcode = await dispatch<any>({
|
const retcode = await login({
|
||||||
type: 'loginModel/login',
|
|
||||||
payload: {
|
|
||||||
email: params.email,
|
email: params.email,
|
||||||
password: rsaPassWord,
|
password: rsaPassWord,
|
||||||
},
|
|
||||||
});
|
});
|
||||||
if (retcode === 0) {
|
if (retcode === 0) {
|
||||||
navigate('/knowledge');
|
navigate('/knowledge');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: Type needs to be improved
|
const retcode = await register({
|
||||||
const retcode = await dispatch<any>({
|
|
||||||
type: 'loginModel/register',
|
|
||||||
payload: {
|
|
||||||
nickname: params.nickname,
|
nickname: params.nickname,
|
||||||
email: params.email,
|
email: params.email,
|
||||||
password: rsaPassWord,
|
password: rsaPassWord,
|
||||||
},
|
|
||||||
});
|
});
|
||||||
if (retcode === 0) {
|
if (retcode === 0) {
|
||||||
setTitle('login');
|
setTitle('login');
|
||||||
@ -72,12 +69,15 @@ const Login = () => {
|
|||||||
window.location.href =
|
window.location.href =
|
||||||
'https://github.com/login/oauth/authorize?scope=user:email&client_id=302129228f0d96055bee';
|
'https://github.com/login/oauth/authorize?scope=user:email&client_id=302129228f0d96055bee';
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.loginPage}>
|
<div className={styles.loginPage}>
|
||||||
<div className={styles.loginLeft}>
|
<div className={styles.loginLeft}>
|
||||||
<div className={styles.leftContainer}>
|
<div className={styles.leftContainer}>
|
||||||
<div className={styles.loginTitle}>
|
<div className={styles.loginTitle}>
|
||||||
<div>{title === 'login' ? 'Sign in' : 'Create an account'}</div>
|
<div>
|
||||||
|
{title === 'login' ? t('login.login') : 'Create an account'}
|
||||||
|
</div>
|
||||||
<span>
|
<span>
|
||||||
{title === 'login'
|
{title === 'login'
|
||||||
? 'We’re so excited to see you again!'
|
? 'We’re so excited to see you again!'
|
||||||
|
|||||||
Reference in New Issue
Block a user