mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-18 12:14:29 +08:00
remove showDeleteConfirm function and center the Empty of knowledge list and extract the text of the login page to en.json (#203)
feat: remove showDeleteConfirm function feat: center the Empty of knowledge list feat: extract the text of the login page to en.json #204
This commit is contained in:
parent
f89c6c9d59
commit
2673be8bc1
@ -1,16 +1,16 @@
|
|||||||
import { ConfigProvider } from 'antd';
|
import { App, ConfigProvider } from 'antd';
|
||||||
import React, { ReactNode } from 'react';
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
export function rootContainer(container: ReactNode) {
|
export function rootContainer(container: ReactNode) {
|
||||||
return React.createElement(
|
return (
|
||||||
ConfigProvider,
|
<ConfigProvider
|
||||||
{
|
theme={{
|
||||||
theme: {
|
|
||||||
token: {
|
token: {
|
||||||
fontFamily: 'Inter',
|
fontFamily: 'Inter',
|
||||||
},
|
},
|
||||||
},
|
}}
|
||||||
},
|
>
|
||||||
container,
|
<App> {container}</App>
|
||||||
|
</ConfigProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
import { ExclamationCircleFilled } from '@ant-design/icons';
|
|
||||||
import { Modal } from 'antd';
|
|
||||||
|
|
||||||
const { confirm } = Modal;
|
|
||||||
|
|
||||||
interface IProps {
|
|
||||||
onOk?: (...args: any[]) => any;
|
|
||||||
onCancel?: (...args: any[]) => any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const showDeleteConfirm = ({
|
|
||||||
onOk,
|
|
||||||
onCancel,
|
|
||||||
}: IProps): Promise<number> => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
confirm({
|
|
||||||
title: 'Are you sure delete this item?',
|
|
||||||
icon: <ExclamationCircleFilled />,
|
|
||||||
content: 'Some descriptions',
|
|
||||||
okText: 'Yes',
|
|
||||||
okType: 'danger',
|
|
||||||
cancelText: 'No',
|
|
||||||
async onOk() {
|
|
||||||
try {
|
|
||||||
const ret = await onOk?.();
|
|
||||||
resolve(ret);
|
|
||||||
console.info(ret);
|
|
||||||
} catch (error) {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onCancel() {
|
|
||||||
onCancel?.();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default showDeleteConfirm;
|
|
@ -4,7 +4,6 @@ import { IconComponentProps } from '@ant-design/icons/lib/components/Icon';
|
|||||||
const importAll = (requireContext: __WebpackModuleApi.RequireContext) => {
|
const importAll = (requireContext: __WebpackModuleApi.RequireContext) => {
|
||||||
const list = requireContext.keys().map((key) => {
|
const list = requireContext.keys().map((key) => {
|
||||||
const name = key.replace(/\.\/(.*)\.\w+$/, '$1');
|
const name = key.replace(/\.\/(.*)\.\w+$/, '$1');
|
||||||
console.log(name, requireContext(key));
|
|
||||||
return { name, value: requireContext(key) };
|
return { name, value: requireContext(key) };
|
||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
import { ExclamationCircleFilled } from '@ant-design/icons';
|
||||||
|
import { App } from 'antd';
|
||||||
import isEqual from 'lodash/isEqual';
|
import isEqual from 'lodash/isEqual';
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
export const useSetModalState = () => {
|
export const useSetModalState = () => {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
@ -72,3 +75,43 @@ export function useDynamicSVGImport(
|
|||||||
|
|
||||||
return { error, loading, SvgIcon: ImportedIconRef.current };
|
return { error, loading, SvgIcon: ImportedIconRef.current };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
onOk?: (...args: any[]) => any;
|
||||||
|
onCancel?: (...args: any[]) => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useShowDeleteConfirm = () => {
|
||||||
|
const { modal } = App.useApp();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const showDeleteConfirm = useCallback(
|
||||||
|
({ onOk, onCancel }: IProps): Promise<number> => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
modal.confirm({
|
||||||
|
title: t('common.deleteModalTitle'),
|
||||||
|
icon: <ExclamationCircleFilled />,
|
||||||
|
// content: 'Some descriptions',
|
||||||
|
okText: 'Yes',
|
||||||
|
okType: 'danger',
|
||||||
|
cancelText: 'No',
|
||||||
|
async onOk() {
|
||||||
|
try {
|
||||||
|
const ret = await onOk?.();
|
||||||
|
resolve(ret);
|
||||||
|
console.info(ret);
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onCancel() {
|
||||||
|
onCancel?.();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[t, modal],
|
||||||
|
);
|
||||||
|
|
||||||
|
return showDeleteConfirm;
|
||||||
|
};
|
@ -1,4 +1,4 @@
|
|||||||
import showDeleteConfirm from '@/components/deleting-confirm';
|
import { useShowDeleteConfirm } from '@/hooks/commonHooks';
|
||||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||||
import { useCallback, useEffect, useMemo } from 'react';
|
import { useCallback, useEffect, useMemo } from 'react';
|
||||||
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
||||||
@ -17,6 +17,7 @@ export const useDeleteDocumentById = (): {
|
|||||||
} => {
|
} => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const knowledgeBaseId = useKnowledgeBaseId();
|
const knowledgeBaseId = useKnowledgeBaseId();
|
||||||
|
const showDeleteConfirm = useShowDeleteConfirm();
|
||||||
|
|
||||||
const removeDocument = (documentId: string) => () => {
|
const removeDocument = (documentId: string) => () => {
|
||||||
return dispatch({
|
return dispatch({
|
||||||
@ -79,6 +80,7 @@ export const useDeleteChunkByIds = (): {
|
|||||||
removeChunk: (chunkIds: string[], documentId: string) => Promise<number>;
|
removeChunk: (chunkIds: string[], documentId: string) => Promise<number>;
|
||||||
} => {
|
} => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const showDeleteConfirm = useShowDeleteConfirm();
|
||||||
|
|
||||||
const removeChunk = useCallback(
|
const removeChunk = useCallback(
|
||||||
(chunkIds: string[], documentId: string) => () => {
|
(chunkIds: string[], documentId: string) => () => {
|
||||||
@ -97,7 +99,7 @@ export const useDeleteChunkByIds = (): {
|
|||||||
(chunkIds: string[], documentId: string): Promise<number> => {
|
(chunkIds: string[], documentId: string): Promise<number> => {
|
||||||
return showDeleteConfirm({ onOk: removeChunk(chunkIds, documentId) });
|
return showDeleteConfirm({ onOk: removeChunk(chunkIds, documentId) });
|
||||||
},
|
},
|
||||||
[removeChunk],
|
[removeChunk, showDeleteConfirm],
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -8,6 +8,7 @@ import styles from './index.less';
|
|||||||
|
|
||||||
import { useNavigateWithFromState } from '@/hooks/routeHook';
|
import { useNavigateWithFromState } from '@/hooks/routeHook';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useLocation } from 'umi';
|
import { useLocation } from 'umi';
|
||||||
|
|
||||||
const { Header } = Layout;
|
const { Header } = Layout;
|
||||||
@ -18,14 +19,15 @@ const RagHeader = () => {
|
|||||||
} = theme.useToken();
|
} = theme.useToken();
|
||||||
const navigate = useNavigateWithFromState();
|
const navigate = useNavigateWithFromState();
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
|
const { t } = useTranslation('translation', { keyPrefix: 'header' });
|
||||||
|
|
||||||
const tagsData = useMemo(
|
const tagsData = useMemo(
|
||||||
() => [
|
() => [
|
||||||
{ path: '/knowledge', name: 'Knowledge Base', icon: KnowledgeBaseIcon },
|
{ path: '/knowledge', name: t('knowledgeBase'), icon: KnowledgeBaseIcon },
|
||||||
{ path: '/chat', name: 'Chat', icon: StarIon },
|
{ path: '/chat', name: t('chat'), icon: StarIon },
|
||||||
// { path: '/file', name: 'File Management', icon: FileIcon },
|
// { path: '/file', name: 'File Management', icon: FileIcon },
|
||||||
],
|
],
|
||||||
[],
|
[t],
|
||||||
);
|
);
|
||||||
|
|
||||||
const currentPath = useMemo(() => {
|
const currentPath = useMemo(() => {
|
||||||
|
@ -1,12 +1,41 @@
|
|||||||
{
|
{
|
||||||
"login": { "login": "Sign in" },
|
"common": {
|
||||||
|
"delete": "Delete",
|
||||||
|
"deleteModalTitle": "Are you sure delete this item?"
|
||||||
|
},
|
||||||
|
"login": {
|
||||||
|
"login": "Sign in",
|
||||||
|
"signUp": "Sign up",
|
||||||
|
"loginDescription": "We’re so excited to see you again!",
|
||||||
|
"registerDescription": "Glad to have you on board!",
|
||||||
|
"emailLabel": "Email",
|
||||||
|
"emailPlaceholder": "Please input email",
|
||||||
|
"passwordLabel": "Password",
|
||||||
|
"passwordPlaceholder": "Please input password",
|
||||||
|
"rememberMe": "Remember me",
|
||||||
|
"signInTip": "Don’t have an account?",
|
||||||
|
"signUpTip": "Already have an account?",
|
||||||
|
"nicknameLabel": "Nickname",
|
||||||
|
"nicknamePlaceholder": "Please input nickname",
|
||||||
|
"register": "Create an account",
|
||||||
|
"continue": "Continue"
|
||||||
|
},
|
||||||
"header": {
|
"header": {
|
||||||
|
"knowledgeBase": "Knowledge Base",
|
||||||
|
"chat": "Chat",
|
||||||
"register": "Register",
|
"register": "Register",
|
||||||
"signin": "Sign in",
|
"signin": "Sign in",
|
||||||
"home": "Home",
|
"home": "Home",
|
||||||
"setting": "用户设置",
|
"setting": "用户设置",
|
||||||
"logout": "登出"
|
"logout": "登出"
|
||||||
},
|
},
|
||||||
|
"knowledgeList": {
|
||||||
|
"welcome": "Welcome back",
|
||||||
|
"description": "Which database are we going to use today?",
|
||||||
|
"createKnowledgeBase": "Create knowledge base",
|
||||||
|
"name": "Name",
|
||||||
|
"namePlaceholder": "Please input name!"
|
||||||
|
},
|
||||||
"footer": {
|
"footer": {
|
||||||
"detail": "All rights reserved @ React"
|
"detail": "All rights reserved @ React"
|
||||||
},
|
},
|
||||||
|
@ -203,7 +203,6 @@ const model: DvaModel<KFModelState> = {
|
|||||||
const documentId = payload;
|
const documentId = payload;
|
||||||
try {
|
try {
|
||||||
const ret = yield call(getDocumentFile, documentId);
|
const ret = yield call(getDocumentFile, documentId);
|
||||||
console.info('fetch_document_file:', ret);
|
|
||||||
return ret;
|
return ret;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
@ -238,7 +237,6 @@ const model: DvaModel<KFModelState> = {
|
|||||||
payload: { current: 1, pageSize: 10 },
|
payload: { current: 1, pageSize: 10 },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.info(location);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import showDeleteConfirm from '@/components/deleting-confirm';
|
import { useShowDeleteConfirm } from '@/hooks/commonHooks';
|
||||||
import { useRemoveDocument } from '@/hooks/documentHooks';
|
import { useRemoveDocument } from '@/hooks/documentHooks';
|
||||||
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
||||||
import { api_host } from '@/utils/api';
|
import { api_host } from '@/utils/api';
|
||||||
@ -31,6 +31,7 @@ const ParsingActionCell = ({
|
|||||||
const isRunning = isParserRunning(record.run);
|
const isRunning = isParserRunning(record.run);
|
||||||
|
|
||||||
const removeDocument = useRemoveDocument(documentId);
|
const removeDocument = useRemoveDocument(documentId);
|
||||||
|
const showDeleteConfirm = useShowDeleteConfirm();
|
||||||
|
|
||||||
const onRmDocument = () => {
|
const onRmDocument = () => {
|
||||||
if (!isRunning) {
|
if (!isRunning) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import showDeleteConfirm from '@/components/deleting-confirm';
|
|
||||||
import { MessageType } from '@/constants/chat';
|
import { MessageType } from '@/constants/chat';
|
||||||
import { fileIconMap } from '@/constants/common';
|
import { fileIconMap } from '@/constants/common';
|
||||||
import { useSetModalState } from '@/hooks/commonHooks';
|
import { useSetModalState, useShowDeleteConfirm } from '@/hooks/commonHooks';
|
||||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
||||||
import { IConversation, IDialog } from '@/interfaces/database/chat';
|
import { IConversation, IDialog } from '@/interfaces/database/chat';
|
||||||
import { IChunk } from '@/interfaces/database/knowledge';
|
import { IChunk } from '@/interfaces/database/knowledge';
|
||||||
@ -150,6 +149,7 @@ export const useSelectPromptConfigParameters = (): VariableTableDataType[] => {
|
|||||||
|
|
||||||
export const useRemoveDialog = () => {
|
export const useRemoveDialog = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const showDeleteConfirm = useShowDeleteConfirm();
|
||||||
|
|
||||||
const removeDocument = (dialogIds: Array<string>) => () => {
|
const removeDocument = (dialogIds: Array<string>) => () => {
|
||||||
return dispatch({
|
return dispatch({
|
||||||
@ -668,6 +668,7 @@ export const useRemoveConversation = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { dialogId } = useGetChatSearchParams();
|
const { dialogId } = useGetChatSearchParams();
|
||||||
const { handleClickConversation } = useClickConversationCard();
|
const { handleClickConversation } = useClickConversationCard();
|
||||||
|
const showDeleteConfirm = useShowDeleteConfirm();
|
||||||
|
|
||||||
const removeConversation = (conversationIds: Array<string>) => async () => {
|
const removeConversation = (conversationIds: Array<string>) => async () => {
|
||||||
const ret = await dispatch<any>({
|
const ret = await dispatch<any>({
|
||||||
|
@ -44,4 +44,7 @@
|
|||||||
.knowledgeCardContainer {
|
.knowledgeCardContainer {
|
||||||
padding: 0 60px;
|
padding: 0 60px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
.knowledgeEmpty {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,22 +6,22 @@ import { Button, Empty, Flex, Space, Spin } from 'antd';
|
|||||||
import KnowledgeCard from './knowledge-card';
|
import KnowledgeCard from './knowledge-card';
|
||||||
import KnowledgeCreatingModal from './knowledge-creating-modal';
|
import KnowledgeCreatingModal from './knowledge-creating-modal';
|
||||||
|
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
const Knowledge = () => {
|
const Knowledge = () => {
|
||||||
const { list, loading } = useFetchKnowledgeList();
|
const { list, loading } = useFetchKnowledgeList();
|
||||||
const userInfo = useSelectUserInfo();
|
const userInfo = useSelectUserInfo();
|
||||||
|
const { t } = useTranslation('translation', { keyPrefix: 'knowledgeList' });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex className={styles.knowledge} vertical flex={1}>
|
<Flex className={styles.knowledge} vertical flex={1}>
|
||||||
<div className={styles.topWrapper}>
|
<div className={styles.topWrapper}>
|
||||||
<div>
|
<div>
|
||||||
<span className={styles.title}>
|
<span className={styles.title}>
|
||||||
Welcome back, {userInfo.nickname}
|
{t('welcome')}, {userInfo.nickname}
|
||||||
</span>
|
</span>
|
||||||
<p className={styles.description}>
|
<p className={styles.description}>{t('description')}</p>
|
||||||
Which database are we going to use today?
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<Space size={'large'}>
|
<Space size={'large'}>
|
||||||
{/* <Button icon={<FilterIcon />} className={styles.filterButton}>
|
{/* <Button icon={<FilterIcon />} className={styles.filterButton}>
|
||||||
@ -38,7 +38,7 @@ const Knowledge = () => {
|
|||||||
}}
|
}}
|
||||||
className={styles.topButton}
|
className={styles.topButton}
|
||||||
>
|
>
|
||||||
Create knowledge base
|
{t('createKnowledgeBase')}
|
||||||
</Button>
|
</Button>
|
||||||
<KnowledgeCreatingModal
|
<KnowledgeCreatingModal
|
||||||
visible={visible}
|
visible={visible}
|
||||||
@ -62,7 +62,7 @@ const Knowledge = () => {
|
|||||||
);
|
);
|
||||||
})
|
})
|
||||||
) : (
|
) : (
|
||||||
<Empty></Empty>
|
<Empty className={styles.knowledgeEmpty}></Empty>
|
||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Spin>
|
</Spin>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { ReactComponent as MoreIcon } from '@/assets/svg/more.svg';
|
import { ReactComponent as MoreIcon } from '@/assets/svg/more.svg';
|
||||||
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
||||||
|
import { useShowDeleteConfirm } from '@/hooks/commonHooks';
|
||||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||||
import { formatDate } from '@/utils/date';
|
import { formatDate } from '@/utils/date';
|
||||||
import {
|
import {
|
||||||
@ -11,7 +12,6 @@ import {
|
|||||||
import { Avatar, Card, Dropdown, MenuProps, Space } from 'antd';
|
import { Avatar, Card, Dropdown, MenuProps, Space } from 'antd';
|
||||||
import { useDispatch, useNavigate } from 'umi';
|
import { useDispatch, useNavigate } from 'umi';
|
||||||
|
|
||||||
import showDeleteConfirm from '@/components/deleting-confirm';
|
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@ -21,6 +21,7 @@ interface IProps {
|
|||||||
const KnowledgeCard = ({ item }: IProps) => {
|
const KnowledgeCard = ({ item }: IProps) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const showDeleteConfirm = useShowDeleteConfirm();
|
||||||
|
|
||||||
const removeKnowledge = () => {
|
const removeKnowledge = () => {
|
||||||
return dispatch({
|
return dispatch({
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
||||||
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
||||||
import { Form, Input, Modal } from 'antd';
|
import { Form, Input, Modal } from 'antd';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useDispatch, useNavigate, useSelector } from 'umi';
|
import { useDispatch, useNavigate, useSelector } from 'umi';
|
||||||
|
|
||||||
type FieldType = {
|
type FieldType = {
|
||||||
@ -17,6 +18,7 @@ const KnowledgeCreatingModal = ({
|
|||||||
(state: any) => state.loading.effects['kSModel/createKb'],
|
(state: any) => state.loading.effects['kSModel/createKb'],
|
||||||
);
|
);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { t } = useTranslation('translation', { keyPrefix: 'knowledgeList' });
|
||||||
|
|
||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
const ret = await form.validateFields();
|
const ret = await form.validateFields();
|
||||||
@ -50,7 +52,7 @@ const KnowledgeCreatingModal = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title="Create knowledge base"
|
title={t('createKnowledgeBase')}
|
||||||
open={visible}
|
open={visible}
|
||||||
onOk={handleOk}
|
onOk={handleOk}
|
||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
@ -67,11 +69,11 @@ const KnowledgeCreatingModal = ({
|
|||||||
form={form}
|
form={form}
|
||||||
>
|
>
|
||||||
<Form.Item<FieldType>
|
<Form.Item<FieldType>
|
||||||
label="Name"
|
label={t('name')}
|
||||||
name="name"
|
name="name"
|
||||||
rules={[{ required: true, message: 'Please input name!' }]}
|
rules={[{ required: true, message: t('namePlaceholder') }]}
|
||||||
>
|
>
|
||||||
<Input />
|
<Input placeholder={t('namePlaceholder')} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { useLogin, useRegister } from '@/hooks/loginHooks';
|
||||||
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
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';
|
||||||
@ -6,7 +7,6 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { Icon, useNavigate } from 'umi';
|
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 = () => {
|
||||||
@ -14,7 +14,7 @@ const Login = () => {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const login = useLogin();
|
const login = useLogin();
|
||||||
const register = useRegister();
|
const register = useRegister();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation('translation', { keyPrefix: 'login' });
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
||||||
@ -75,13 +75,11 @@ const Login = () => {
|
|||||||
<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>
|
<div>{title === 'login' ? t('login') : 'Create an account'}</div>
|
||||||
{title === 'login' ? t('login.login') : 'Create an account'}
|
|
||||||
</div>
|
|
||||||
<span>
|
<span>
|
||||||
{title === 'login'
|
{title === 'login'
|
||||||
? 'We’re so excited to see you again!'
|
? t('loginDescription')
|
||||||
: 'Glad to have you on board!'}
|
: t('registerDescription')}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -94,55 +92,52 @@ const Login = () => {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
{...formItemLayout}
|
{...formItemLayout}
|
||||||
name="email"
|
name="email"
|
||||||
label="Email"
|
label={t('emailLabel')}
|
||||||
rules={[{ required: true, message: 'Please input value' }]}
|
rules={[{ required: true, message: t('emailPlaceholder') }]}
|
||||||
>
|
>
|
||||||
<Input size="large" placeholder="Please input value" />
|
<Input size="large" placeholder={t('emailPlaceholder')} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{title === 'register' && (
|
{title === 'register' && (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
{...formItemLayout}
|
{...formItemLayout}
|
||||||
name="nickname"
|
name="nickname"
|
||||||
label="Nickname"
|
label={t('nicknameLabel')}
|
||||||
rules={[
|
rules={[{ required: true, message: t('nicknamePlaceholder') }]}
|
||||||
{ required: true, message: 'Please input your nickname' },
|
|
||||||
]}
|
|
||||||
>
|
>
|
||||||
<Input size="large" placeholder="Please input your nickname" />
|
<Input size="large" placeholder={t('nicknamePlaceholder')} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
{...formItemLayout}
|
{...formItemLayout}
|
||||||
name="password"
|
name="password"
|
||||||
label="Password"
|
label={t('passwordLabel')}
|
||||||
rules={[{ required: true, message: 'Please input value' }]}
|
rules={[{ required: true, message: t('passwordPlaceholder') }]}
|
||||||
>
|
>
|
||||||
<Input.Password
|
<Input.Password
|
||||||
size="large"
|
size="large"
|
||||||
placeholder="Please input value"
|
placeholder={t('passwordPlaceholder')}
|
||||||
onPressEnter={onCheck}
|
onPressEnter={onCheck}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
{title === 'login' && (
|
{title === 'login' && (
|
||||||
<Form.Item name="remember" valuePropName="checked">
|
<Form.Item name="remember" valuePropName="checked">
|
||||||
<Checkbox> Remember me</Checkbox>
|
<Checkbox> {t('rememberMe')}</Checkbox>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
{' '}
|
|
||||||
{title === 'login' && (
|
{title === 'login' && (
|
||||||
<div>
|
<div>
|
||||||
Don’t have an account?
|
{t('signInTip')}
|
||||||
<Button type="link" onClick={changeTitle}>
|
<Button type="link" onClick={changeTitle}>
|
||||||
Sign up
|
{t('signUp')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{title === 'register' && (
|
{title === 'register' && (
|
||||||
<div>
|
<div>
|
||||||
Already have an account?
|
{t('signUpTip')}
|
||||||
<Button type="link" onClick={changeTitle}>
|
<Button type="link" onClick={changeTitle}>
|
||||||
Sign in
|
{t('login')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -154,7 +149,7 @@ const Login = () => {
|
|||||||
onClick={onCheck}
|
onClick={onCheck}
|
||||||
loading={signLoading}
|
loading={signLoading}
|
||||||
>
|
>
|
||||||
{title === 'login' ? 'Sign in' : 'Continue'}
|
{title === 'login' ? t('login') : t('continue')}
|
||||||
</Button>
|
</Button>
|
||||||
{title === 'login' && (
|
{title === 'login' && (
|
||||||
<>
|
<>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user