diff --git a/config/proxy.ts b/config/proxy.ts index 3fa70dde..d6c81ea7 100644 --- a/config/proxy.ts +++ b/config/proxy.ts @@ -1,5 +1,6 @@ /** * 在生产环境 代理是无法生效的,所以这里没有生产环境的配置 + * ------------------------------- * The agent cannot take effect in the production environment * so there is no configuration of the production environment * For details, please see diff --git a/src/components/Authorized/CheckPermissions.tsx b/src/components/Authorized/CheckPermissions.tsx index 8b741385..021b7cb3 100644 --- a/src/components/Authorized/CheckPermissions.tsx +++ b/src/components/Authorized/CheckPermissions.tsx @@ -11,6 +11,15 @@ export type IAuthorityType = | ((currentAuthority: string | string[]) => IAuthorityType); /** + * @en-US + * General permission check method + * Common check permissions method + * @param {Permission judgment} authority + * @param {Your permission | Your permission description} currentAuthority + * @param {Passing components} target + * @param {no pass components | no pass components} Exception + * ------------------------------------------------------- + * @zh-CN * 通用权限检查方法 Common check permissions method * * @param { 权限判定 | Permission judgment } authority @@ -24,12 +33,12 @@ const checkPermissions = ( target: T, Exception: K, ): T | K | React.ReactNode => { - // 没有判定权限.默认查看所有 + // No judgment permission. View all by default // Retirement authority, return target; if (!authority) { return target; } - // 数组处理 + // Array processing if (Array.isArray(authority)) { if (Array.isArray(currentAuthority)) { if (currentAuthority.some((item) => authority.includes(item))) { @@ -40,7 +49,7 @@ const checkPermissions = ( } return Exception; } - // string 处理 + // Deal with string if (typeof authority === 'string') { if (Array.isArray(currentAuthority)) { if (currentAuthority.some((item) => authority === item)) { @@ -51,14 +60,14 @@ const checkPermissions = ( } return Exception; } - // Promise 处理 + // Deal with promise if (authority instanceof Promise) { return ok={target} error={Exception} promise={authority} />; } - // Function 处理 + // Deal with function if (typeof authority === 'function') { const bool = authority(currentAuthority); - // 函数执行后返回值是 Promise + // The return value after the function is executed is Promise if (bool instanceof Promise) { return ok={target} error={Exception} promise={bool} />; } diff --git a/src/components/Authorized/Secured.tsx b/src/components/Authorized/Secured.tsx index 372b20eb..1a6d1c69 100644 --- a/src/components/Authorized/Secured.tsx +++ b/src/components/Authorized/Secured.tsx @@ -1,7 +1,10 @@ import React from 'react'; import CheckPermissions from './CheckPermissions'; -/** 默认不能访问任何页面 default is "NULL" */ +/** + * @en-US No pages can be accessed by default,default is "NULL" + * @zh-CN 默认不能访问任何页面 default is "NULL" + * */ const Exception403 = () => 403; export const isComponentClass = (component: React.ComponentClass | React.ReactNode): boolean => { @@ -27,6 +30,20 @@ const checkIsInstantiation = (target: React.ComponentClass | React.ReactNode) => }; /** + * @en-US + * Used to determine whether you have permission to access this view permission + * authority supports incoming string, () => boolean | Promise + * e.g.'user' Only user user can access + * e.g.'user,admin' user and admin can access + * e.g. ()=>boolean return true to access, return false to not access + * e.g. Promise then can be accessed, catch can not be accessed + * e.g. authority support incoming string, () => boolean | Promise + * e.g.'user' only user user can access + * e.g.'user, admin' user and admin can access + * e.g. () => boolean true to be able to visit, return false can not be accessed + * e.g. Promise then can not access the visit to catch + *------------------------------------------------------------- + * @zh-CN * 用于判断是否拥有权限访问此 view 权限 authority 支持传入 string, () => boolean | Promise e.g. 'user' 只有 user 用户能访问 * e.g. 'user,admin' user 和 admin 都能访问 e.g. ()=>boolean 返回true能访问,返回false不能访问 e.g. Promise then 能访问 * catch不能访问 e.g. authority support incoming string, () => boolean | Promise e.g. 'user' only user @@ -34,10 +51,16 @@ const checkIsInstantiation = (target: React.ComponentClass | React.ReactNode) => * to visit, return false can not be accessed e.g. Promise then can not access the visit to catch * * @param {string | function | Promise} authority - * @param {ReactNode} error 非必需参数 + * @param {ReactNode} error non-required parameter */ const authorize = (authority: string, error?: React.ReactNode) => { /** + * @en-US + * conversion into a class + * Prevent the staticContext from being found to cause an error when the string is passed in + * String parameters can cause staticContext not found error + *------------------------------------------------------------- + * @zh-CN * Conversion into a class 防止传入字符串时找不到staticContext造成报错 String parameters can cause staticContext * not found error */ diff --git a/src/components/GlobalHeader/NoticeIconView.tsx b/src/components/GlobalHeader/NoticeIconView.tsx index 87635e87..d908e9f8 100644 --- a/src/components/GlobalHeader/NoticeIconView.tsx +++ b/src/components/GlobalHeader/NoticeIconView.tsx @@ -43,7 +43,7 @@ class GlobalHeaderRight extends Component { handleNoticeClear = (title: string, key: string) => { const { dispatch } = this.props; - message.success(`${'清空了'} ${title}`); + message.success(`${'Emptied'} ${title}`); if (dispatch) { dispatch({ @@ -123,8 +123,8 @@ class GlobalHeaderRight extends Component { this.changeReadState(item as NoticeItem); }} loading={fetchingNotices} - clearText="清空" - viewMoreText="查看更多" + clearText="Empty" + viewMoreText="See more" onClear={this.handleNoticeClear} onPopupVisibleChange={onNoticeVisibleChange} onViewMore={() => message.info('Click on view more')} @@ -134,22 +134,22 @@ class GlobalHeaderRight extends Component { tabKey="notification" count={unreadMsg.notification} list={noticeData.notification} - title="通知" - emptyText="你已查看所有通知" + title="Notification" + emptyText="You have viewed all notifications" showViewMore /> = (props) => { diff --git a/src/pages/Admin.tsx b/src/pages/Admin.tsx index 7270ec78..abd291f6 100644 --- a/src/pages/Admin.tsx +++ b/src/pages/Admin.tsx @@ -10,14 +10,14 @@ export default (): React.ReactNode => { { - const hide = message.loading('正在添加'); + const hide = message.loading('Adding'); try { await addRule({ ...fields }); hide(); - message.success('添加成功'); + message.success('Added successfully'); return true; } catch (error) { hide(); - message.error('添加失败请重试!'); + message.error('Adding failed, please try again!'); return false; } }; /** - * 更新节点 + * @en-US Update node + * @zh-CN 更新节点 * * @param fields */ const handleUpdate = async (fields: FormValueType) => { - const hide = message.loading('正在配置'); + const hide = message.loading('Configuring'); try { await updateRule({ name: fields.name, @@ -47,41 +48,48 @@ const handleUpdate = async (fields: FormValueType) => { }); hide(); - message.success('配置成功'); + message.success('Configuration is successful'); return true; } catch (error) { hide(); - message.error('配置失败请重试!'); + message.error('Configuration failed, please try again!'); return false; } }; /** - * 删除节点 + * Delete node + * @zh-CN 删除节点 * * @param selectedRows */ const handleRemove = async (selectedRows: TableListItem[]) => { - const hide = message.loading('正在删除'); + const hide = message.loading('Deleting'); if (!selectedRows) return true; try { await removeRule({ key: selectedRows.map((row) => row.key), }); hide(); - message.success('删除成功,即将刷新'); + message.success('Deleted successfully and will refresh soon'); return true; } catch (error) { hide(); - message.error('删除失败,请重试'); + message.error('Delete failed, please try again'); return false; } }; const TableList: React.FC = () => { - /** 新建窗口的弹窗 */ + /** + * @en-US Pop-up window of new window + * @zh-CN 新建窗口的弹窗 + * */ const [createModalVisible, handleModalVisible] = useState(false); - /** 分布更新窗口的弹窗 */ + /** + * @en-US The pop-up window of the distribution update window + * @zh-CN 分布更新窗口的弹窗 + * */ const [updateModalVisible, handleUpdateModalVisible] = useState(false); const [showDetail, setShowDetail] = useState(false); @@ -90,7 +98,10 @@ const TableList: React.FC = () => { const [currentRow, setCurrentRow] = useState(); const [selectedRowsState, setSelectedRows] = useState([]); - /** 国际化配置 */ + /** + * @en-US International configuration + * @zh-CN 国际化配置 + * */ const intl = useIntl(); const columns: ProColumns[] = [ @@ -98,11 +109,11 @@ const TableList: React.FC = () => { title: ( ), dataIndex: 'name', - tip: '规则名称是唯一的 key', + tip: 'The rule name is the unique key', render: (dom, entity) => { return ( { }, }, { - title: , + title: , dataIndex: 'desc', valueType: 'textarea', }, { - title: , + title: ( + + ), dataIndex: 'callNo', sorter: true, hideInForm: true, @@ -133,31 +149,37 @@ const TableList: React.FC = () => { })}`, }, { - title: , + title: , dataIndex: 'status', hideInForm: true, valueEnum: { 0: { text: ( - + ), status: 'Default', }, 1: { text: ( - + ), status: 'Processing', }, 2: { text: ( - + ), status: 'Success', }, 3: { text: ( - + ), status: 'Error', }, @@ -165,7 +187,10 @@ const TableList: React.FC = () => { }, { title: ( - + ), sorter: true, dataIndex: 'updatedAt', @@ -181,7 +206,7 @@ const TableList: React.FC = () => { {...rest} placeholder={intl.formatMessage({ id: 'pages.searchTable.exception', - defaultMessage: '请输入异常原因!', + defaultMessage: 'Please enter the reason for the exception!', })} /> ); @@ -190,7 +215,7 @@ const TableList: React.FC = () => { }, }, { - title: , + title: , dataIndex: 'option', valueType: 'option', render: (_, record) => [ @@ -201,10 +226,13 @@ const TableList: React.FC = () => { setCurrentRow(record); }} > - + , - + , ], }, @@ -215,7 +243,7 @@ const TableList: React.FC = () => { headerTitle={intl.formatMessage({ id: 'pages.searchTable.title', - defaultMessage: '查询表格', + defaultMessage: 'Enquiry form', })} actionRef={actionRef} rowKey="key" @@ -230,7 +258,7 @@ const TableList: React.FC = () => { handleModalVisible(true); }} > - + , ]} request={(params, sorter, filter) => queryRule({ ...params, sorter, filter })} @@ -245,14 +273,14 @@ const TableList: React.FC = () => { - {' '} + {' '} {selectedRowsState.length}{' '}    {' '} {selectedRowsState.reduce((pre, item) => pre + item.callNo, 0)}{' '} @@ -267,17 +295,23 @@ const TableList: React.FC = () => { actionRef.current?.reloadAndRest?.(); }} > - + )} { message: ( ), }, diff --git a/src/pages/User/login/index.tsx b/src/pages/User/login/index.tsx index 0d50bcc9..03e3a099 100644 --- a/src/pages/User/login/index.tsx +++ b/src/pages/User/login/index.tsx @@ -77,14 +77,14 @@ const Login: React.FC = (props) => { key="account" tab={intl.formatMessage({ id: 'pages.login.accountLogin.tab', - defaultMessage: '账户密码登录', + defaultMessage: 'Account password login', })} /> @@ -93,7 +93,7 @@ const Login: React.FC = (props) => { )} @@ -107,7 +107,7 @@ const Login: React.FC = (props) => { }} placeholder={intl.formatMessage({ id: 'pages.login.username.placeholder', - defaultMessage: '用户名: admin or user', + defaultMessage: 'Username: admin or user', })} rules={[ { @@ -115,7 +115,7 @@ const Login: React.FC = (props) => { message: ( ), }, @@ -129,7 +129,7 @@ const Login: React.FC = (props) => { }} placeholder={intl.formatMessage({ id: 'pages.login.password.placeholder', - defaultMessage: '密码: ant.design', + defaultMessage: 'Password: ant.design', })} rules={[ { @@ -137,7 +137,7 @@ const Login: React.FC = (props) => { message: ( ), }, @@ -147,7 +147,7 @@ const Login: React.FC = (props) => { )} {status === 'error' && loginType === 'mobile' && !submitting && ( - + )} {type === 'mobile' && ( <> @@ -159,7 +159,7 @@ const Login: React.FC = (props) => { name="mobile" placeholder={intl.formatMessage({ id: 'pages.login.phoneNumber.placeholder', - defaultMessage: '手机号', + defaultMessage: 'Phone number', })} rules={[ { @@ -167,7 +167,7 @@ const Login: React.FC = (props) => { message: ( ), }, @@ -176,7 +176,7 @@ const Login: React.FC = (props) => { message: ( ), }, @@ -192,18 +192,18 @@ const Login: React.FC = (props) => { }} placeholder={intl.formatMessage({ id: 'pages.login.captcha.placeholder', - defaultMessage: '请输入验证码', + defaultMessage: 'Please enter verification code', })} captchaTextRender={(timing, count) => { if (timing) { return `${count} ${intl.formatMessage({ id: 'pages.getCaptchaSecondText', - defaultMessage: '获取验证码', + defaultMessage: 'Get verification code', })}`; } return intl.formatMessage({ id: 'pages.login.phoneLogin.getVerificationCode', - defaultMessage: '获取验证码', + defaultMessage: 'Get verification code', }); }} name="captcha" @@ -213,7 +213,7 @@ const Login: React.FC = (props) => { message: ( ), }, @@ -223,7 +223,9 @@ const Login: React.FC = (props) => { if (result === false) { return; } - message.success('获取验证码成功!验证码为:1234'); + message.success( + 'Get the verification code successfully! The verification code is: 1234', + ); }} /> @@ -234,19 +236,19 @@ const Login: React.FC = (props) => { }} > - + - + - + diff --git a/src/pages/Welcome.tsx b/src/pages/Welcome.tsx index 20cd9646..12bf6d2a 100644 --- a/src/pages/Welcome.tsx +++ b/src/pages/Welcome.tsx @@ -20,7 +20,7 @@ export default (): React.ReactNode => { { }} /> - {' '} + {' '} - + yarn add @ant-design/pro-table @@ -47,13 +47,13 @@ export default (): React.ReactNode => { marginBottom: 12, }} > - {' '} + {' '} - + yarn add @ant-design/pro-layout diff --git a/src/pages/document.ejs b/src/pages/document.ejs index e42657a6..bce02ada 100644 --- a/src/pages/document.ejs +++ b/src/pages/document.ejs @@ -5,7 +5,7 @@ void; // preview.pro.ant.design only do not use in your production ; -// preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 +// preview.pro.ant.design Dedicated environment variable, please do not use it in your project. declare let ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: 'site' | undefined; declare const REACT_APP_ENV: 'test' | 'dev' | 'pre' | false; diff --git a/src/utils/authority.ts b/src/utils/authority.ts index d99659d1..ddf15ec0 100644 --- a/src/utils/authority.ts +++ b/src/utils/authority.ts @@ -17,7 +17,7 @@ export function getAuthority(str?: string): string | string[] { return [authority]; } // preview.pro.ant.design only do not use in your production. - // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 + // preview.pro.ant.design Dedicated environment variable, please do not use it in your project. if (!authority && ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') { return ['admin']; } diff --git a/src/utils/request.ts b/src/utils/request.ts index 3b7a5698..64b00774 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -2,7 +2,7 @@ import { extend } from 'umi-request'; import { notification } from 'antd'; -const codeMessage: { [status: number]: string } = { +const codeMessage: Record = { 200: '服务器成功返回请求的数据。', 201: '新建或修改数据成功。', 202: '一个请求已经进入后台排队(异步任务)。', @@ -20,7 +20,10 @@ const codeMessage: { [status: number]: string } = { 504: '网关超时。', }; -/** 异常处理程序 */ +/** + * @zh-CN 异常处理程序 + * @en-US Exception handler + */ const errorHandler = (error: { response: Response }): Response => { const { response } = error; if (response && response.status) { @@ -28,22 +31,25 @@ const errorHandler = (error: { response: Response }): Response => { const { status, url } = response; notification.error({ - message: `请求错误 ${status}: ${url}`, + message: `Request error ${status}: ${url}`, description: errorText, }); } else if (!response) { notification.error({ - description: '您的网络发生异常,无法连接服务器', - message: '网络异常', + description: 'Your network is abnormal and cannot connect to the server', + message: 'Network anomaly', }); } return response; }; -/** 配置request请求时的默认参数 */ +/** + * @en-US Configure the default parameters for request + * @zh-CN 配置request请求时的默认参数 + */ const request = extend({ - errorHandler, // 默认错误处理 - credentials: 'include', // 默认请求是否带上cookie + errorHandler, // default error handling + credentials: 'include', // Does the default request bring cookies }); export default request; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 71ed4ca5..75f61807 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -12,7 +12,7 @@ export const isAntDesignPro = (): boolean => { return window.location.hostname === 'preview.pro.ant.design'; }; -// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性 +// For the official demo site, it is used to turn off features that are not needed in the real development environment export const isAntDesignProOrDev = (): boolean => { const { NODE_ENV } = process.env; if (NODE_ENV === 'development') {