balibabu
commited on
Commit
·
6e3eead
1
Parent(s):
93339b0
feat: enlarge the size of the next button for uploading files and add locale config to global.ts (#195)
Browse files- web/src/global.ts +1 -0
- web/src/hooks/loginHooks.ts +44 -0
- web/src/locales/config.ts +11 -11
- web/src/locales/en.json +20 -19
- web/src/locales/zh.json +20 -19
- web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.less +11 -3
- web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx +2 -1
- web/src/pages/login/index.tsx +26 -26
web/src/global.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
import '@/locales/config';
|
web/src/hooks/loginHooks.ts
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { useCallback } from 'react';
|
2 |
+
import { useDispatch } from 'umi';
|
3 |
+
|
4 |
+
export interface ILoginRequestBody {
|
5 |
+
email: string;
|
6 |
+
password: string;
|
7 |
+
}
|
8 |
+
|
9 |
+
export interface IRegisterRequestBody extends ILoginRequestBody {
|
10 |
+
nickname: string;
|
11 |
+
}
|
12 |
+
|
13 |
+
export const useLogin = () => {
|
14 |
+
const dispatch = useDispatch();
|
15 |
+
|
16 |
+
const login = useCallback(
|
17 |
+
(requestBody: ILoginRequestBody) => {
|
18 |
+
// TODO: Type needs to be improved
|
19 |
+
return dispatch<any>({
|
20 |
+
type: 'loginModel/login',
|
21 |
+
payload: requestBody,
|
22 |
+
});
|
23 |
+
},
|
24 |
+
[dispatch],
|
25 |
+
);
|
26 |
+
|
27 |
+
return login;
|
28 |
+
};
|
29 |
+
|
30 |
+
export const useRegister = () => {
|
31 |
+
const dispatch = useDispatch();
|
32 |
+
|
33 |
+
const register = useCallback(
|
34 |
+
(requestBody: IRegisterRequestBody) => {
|
35 |
+
return dispatch<any>({
|
36 |
+
type: 'loginModel/register',
|
37 |
+
payload: requestBody,
|
38 |
+
});
|
39 |
+
},
|
40 |
+
[dispatch],
|
41 |
+
);
|
42 |
+
|
43 |
+
return register;
|
44 |
+
};
|
web/src/locales/config.ts
CHANGED
@@ -5,20 +5,20 @@ import translation_en from './en.json';
|
|
5 |
import translation_zh from './zh.json';
|
6 |
|
7 |
const resources = {
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
};
|
15 |
|
16 |
i18n.use(initReactI18next).init({
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
});
|
23 |
|
24 |
export default i18n;
|
|
|
5 |
import translation_zh from './zh.json';
|
6 |
|
7 |
const resources = {
|
8 |
+
en: {
|
9 |
+
translation: translation_en,
|
10 |
+
},
|
11 |
+
zh: {
|
12 |
+
translation: translation_zh,
|
13 |
+
},
|
14 |
};
|
15 |
|
16 |
i18n.use(initReactI18next).init({
|
17 |
+
resources,
|
18 |
+
lng: 'en',
|
19 |
+
interpolation: {
|
20 |
+
escapeValue: false,
|
21 |
+
},
|
22 |
});
|
23 |
|
24 |
export default i18n;
|
web/src/locales/en.json
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
{
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
}
|
|
|
|
1 |
{
|
2 |
+
"login": { "login": "Sign in" },
|
3 |
+
"header": {
|
4 |
+
"register": "Register",
|
5 |
+
"signin": "Sign in",
|
6 |
+
"home": "Home",
|
7 |
+
"setting": "用户设置",
|
8 |
+
"logout": "登出"
|
9 |
+
},
|
10 |
+
"footer": {
|
11 |
+
"detail": "All rights reserved @ React"
|
12 |
+
},
|
13 |
+
"layout": {
|
14 |
+
"file": "file",
|
15 |
+
"knowledge": "knowledge",
|
16 |
+
"chat": "chat"
|
17 |
+
},
|
18 |
+
"setting": {
|
19 |
+
"btn": "en"
|
20 |
+
}
|
21 |
+
}
|
web/src/locales/zh.json
CHANGED
@@ -1,20 +1,21 @@
|
|
1 |
{
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
}
|
|
|
|
1 |
{
|
2 |
+
"login": { "login": "登录" },
|
3 |
+
"header": {
|
4 |
+
"register": "注册",
|
5 |
+
"signin": "登陆",
|
6 |
+
"home": "首页",
|
7 |
+
"setting": "user setting",
|
8 |
+
"logout": "logout"
|
9 |
+
},
|
10 |
+
"footer": {
|
11 |
+
"detail": "版权所有 @ React"
|
12 |
+
},
|
13 |
+
"layout": {
|
14 |
+
"file": "文件",
|
15 |
+
"knowledge": "知识库",
|
16 |
+
"chat": "聊天"
|
17 |
+
},
|
18 |
+
"setting": {
|
19 |
+
"btn": "中文"
|
20 |
+
}
|
21 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.less
CHANGED
@@ -1,16 +1,24 @@
|
|
1 |
.uploadWrapper {
|
2 |
display: flex;
|
3 |
flex-direction: column;
|
4 |
-
padding: 32px;
|
5 |
height: 100%;
|
6 |
.backToList {
|
|
|
7 |
padding-bottom: 60px;
|
8 |
}
|
9 |
.footer {
|
10 |
-
text-align:
|
11 |
padding-top: 16px;
|
12 |
.nextButton {
|
13 |
-
background-color: @purple;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
}
|
16 |
.uploadContent {
|
|
|
1 |
.uploadWrapper {
|
2 |
display: flex;
|
3 |
flex-direction: column;
|
4 |
+
padding: 64px 32px 32px;
|
5 |
height: 100%;
|
6 |
.backToList {
|
7 |
+
display: none;
|
8 |
padding-bottom: 60px;
|
9 |
}
|
10 |
.footer {
|
11 |
+
text-align: center;
|
12 |
padding-top: 16px;
|
13 |
.nextButton {
|
14 |
+
// background-color: @purple;
|
15 |
+
font-weight: 700;
|
16 |
+
font-size: 24px;
|
17 |
+
display: inline-flex;
|
18 |
+
align-items: center;
|
19 |
+
padding: 26px 40px;
|
20 |
+
justify-content: center;
|
21 |
+
width: 10%;
|
22 |
}
|
23 |
}
|
24 |
.uploadContent {
|
web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx
CHANGED
@@ -287,9 +287,10 @@ const KnowledgeUploadFile = () => {
|
|
287 |
<section className={styles.footer}>
|
288 |
<Button
|
289 |
type="primary"
|
290 |
-
|
291 |
onClick={handleNextClick}
|
292 |
disabled={!enabled}
|
|
|
293 |
>
|
294 |
Next
|
295 |
</Button>
|
|
|
287 |
<section className={styles.footer}>
|
288 |
<Button
|
289 |
type="primary"
|
290 |
+
className={styles.nextButton}
|
291 |
onClick={handleNextClick}
|
292 |
disabled={!enabled}
|
293 |
+
size="large"
|
294 |
>
|
295 |
Next
|
296 |
</Button>
|
web/src/pages/login/index.tsx
CHANGED
@@ -1,59 +1,56 @@
|
|
|
|
1 |
import { rsaPsw } from '@/utils';
|
2 |
import { Button, Checkbox, Form, Input } from 'antd';
|
3 |
import { useEffect, useState } from 'react';
|
4 |
-
import {
|
|
|
5 |
import RightPanel from './right-panel';
|
6 |
|
|
|
7 |
import styles from './index.less';
|
8 |
|
9 |
const Login = () => {
|
10 |
const [title, setTitle] = useState('login');
|
11 |
-
|
12 |
-
const
|
13 |
-
const
|
14 |
-
|
15 |
-
);
|
16 |
|
17 |
// TODO: When the server address request is not accessible, the value of dva-loading always remains true.
|
18 |
|
19 |
-
const signLoading =
|
20 |
-
|
|
|
|
|
21 |
|
22 |
const changeTitle = () => {
|
23 |
setTitle((title) => (title === 'login' ? 'register' : 'login'));
|
24 |
};
|
25 |
const [form] = Form.useForm();
|
26 |
-
const [checkNick, setCheckNick] = useState(false);
|
27 |
|
28 |
useEffect(() => {
|
29 |
form.validateFields(['nickname']);
|
30 |
-
}, [
|
31 |
|
32 |
const onCheck = async () => {
|
33 |
try {
|
34 |
const params = await form.validateFields();
|
35 |
|
36 |
-
|
|
|
37 |
if (title === 'login') {
|
38 |
-
const retcode = await
|
39 |
-
|
40 |
-
|
41 |
-
email: params.email,
|
42 |
-
password: rsaPassWord,
|
43 |
-
},
|
44 |
});
|
45 |
if (retcode === 0) {
|
46 |
navigate('/knowledge');
|
47 |
}
|
48 |
} else {
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
nickname: params.nickname,
|
54 |
-
email: params.email,
|
55 |
-
password: rsaPassWord,
|
56 |
-
},
|
57 |
});
|
58 |
if (retcode === 0) {
|
59 |
setTitle('login');
|
@@ -72,12 +69,15 @@ const Login = () => {
|
|
72 |
window.location.href =
|
73 |
'https://github.com/login/oauth/authorize?scope=user:email&client_id=302129228f0d96055bee';
|
74 |
};
|
|
|
75 |
return (
|
76 |
<div className={styles.loginPage}>
|
77 |
<div className={styles.loginLeft}>
|
78 |
<div className={styles.leftContainer}>
|
79 |
<div className={styles.loginTitle}>
|
80 |
-
<div>
|
|
|
|
|
81 |
<span>
|
82 |
{title === 'login'
|
83 |
? 'We’re so excited to see you again!'
|
|
|
1 |
+
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
2 |
import { rsaPsw } from '@/utils';
|
3 |
import { Button, Checkbox, Form, Input } from 'antd';
|
4 |
import { useEffect, useState } from 'react';
|
5 |
+
import { useTranslation } from 'react-i18next';
|
6 |
+
import { Icon, useNavigate } from 'umi';
|
7 |
import RightPanel from './right-panel';
|
8 |
|
9 |
+
import { useLogin, useRegister } from '@/hooks/loginHooks';
|
10 |
import styles from './index.less';
|
11 |
|
12 |
const Login = () => {
|
13 |
const [title, setTitle] = useState('login');
|
14 |
+
const navigate = useNavigate();
|
15 |
+
const login = useLogin();
|
16 |
+
const register = useRegister();
|
17 |
+
const { t } = useTranslation();
|
|
|
18 |
|
19 |
// TODO: When the server address request is not accessible, the value of dva-loading always remains true.
|
20 |
|
21 |
+
const signLoading = useOneNamespaceEffectsLoading('loginModel', [
|
22 |
+
'login',
|
23 |
+
'register',
|
24 |
+
]);
|
25 |
|
26 |
const changeTitle = () => {
|
27 |
setTitle((title) => (title === 'login' ? 'register' : 'login'));
|
28 |
};
|
29 |
const [form] = Form.useForm();
|
|
|
30 |
|
31 |
useEffect(() => {
|
32 |
form.validateFields(['nickname']);
|
33 |
+
}, [form]);
|
34 |
|
35 |
const onCheck = async () => {
|
36 |
try {
|
37 |
const params = await form.validateFields();
|
38 |
|
39 |
+
const rsaPassWord = rsaPsw(params.password) as string;
|
40 |
+
|
41 |
if (title === 'login') {
|
42 |
+
const retcode = await login({
|
43 |
+
email: params.email,
|
44 |
+
password: rsaPassWord,
|
|
|
|
|
|
|
45 |
});
|
46 |
if (retcode === 0) {
|
47 |
navigate('/knowledge');
|
48 |
}
|
49 |
} else {
|
50 |
+
const retcode = await register({
|
51 |
+
nickname: params.nickname,
|
52 |
+
email: params.email,
|
53 |
+
password: rsaPassWord,
|
|
|
|
|
|
|
|
|
54 |
});
|
55 |
if (retcode === 0) {
|
56 |
setTitle('login');
|
|
|
69 |
window.location.href =
|
70 |
'https://github.com/login/oauth/authorize?scope=user:email&client_id=302129228f0d96055bee';
|
71 |
};
|
72 |
+
|
73 |
return (
|
74 |
<div className={styles.loginPage}>
|
75 |
<div className={styles.loginLeft}>
|
76 |
<div className={styles.leftContainer}>
|
77 |
<div className={styles.loginTitle}>
|
78 |
+
<div>
|
79 |
+
{title === 'login' ? t('login.login') : 'Create an account'}
|
80 |
+
</div>
|
81 |
<span>
|
82 |
{title === 'login'
|
83 |
? 'We’re so excited to see you again!'
|