diff --git a/src/app.tsx b/src/app.tsx index 70cd4d4d4f2fe2765d332a1e5fd50169c547bbc1..e03b7300cab86f663370fc9cb6c56dfd7fc49b84 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -2,7 +2,7 @@ import type { Settings as LayoutSettings } from '@ant-design/pro-layout'; import { PageLoading } from '@ant-design/pro-layout'; import { notification } from 'antd'; import type { RequestConfig, RunTimeLayoutConfig } from 'umi'; -import { getIntl, getLocale, history, Link } from 'umi'; +import { history, Link } from 'umi'; import RightContent from '@/components/RightContent'; import Footer from '@/components/Footer'; import type { ResponseError } from 'umi-request'; @@ -51,7 +51,6 @@ export async function getInitialState(): Promise<{ /** * 异常处理程序 - const codeMessage = { 200: '服务器成功返回请求的数据。', 201: '新建或修改数据成功。', 202: '一个请求已经进入后台排队(异步任务)。', @@ -68,25 +67,30 @@ export async function getInitialState(): Promise<{ 502: '网关错误。', 503: '服务不可用,服务器暂时过载或维护。', 504: '网关超时。', - }; + //-----English + 200: The server successfully returned the requested data. ', + 201: New or modified data is successful. ', + 202: A request has entered the background queue (asynchronous task). ', + 204: Data deleted successfully. ', + 400: 'There was an error in the request sent, and the server did not create or modify data. ', + 401: The user does not have permission (token, username, password error). ', + 403: The user is authorized, but access is forbidden. ', + 404: The request sent was for a record that did not exist. ', + 405: The request method is not allowed. ', + 406: The requested format is not available. ', + 410': + 'The requested resource is permanently deleted and will no longer be available. ', + 422: When creating an object, a validation error occurred. ', + 500: An error occurred on the server, please check the server. ', + 502: Gateway error. ', + 503: The service is unavailable. ', + 504: The gateway timed out. ', * @see https://beta-pro.ant.design/docs/request-cn */ export const request: RequestConfig = { errorHandler: (error: ResponseError) => { - const { messages } = getIntl(getLocale()); const { response } = error; - if (response && response.status) { - const { status, statusText, url } = response; - const requestErrorMessage = messages['app.request.error']; - const errorMessage = `${requestErrorMessage} ${status}: ${url}`; - const errorDescription = messages[`app.request.${status}`] || statusText; - notification.error({ - message: errorMessage, - description: errorDescription, - }); - } - if (!response) { notification.error({ description: '您的网络发生异常,无法连接服务器', diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index a51da4a98f8cc392774f5ab352412440c06418b1..acb0f42f446f59a45c698d5209cf3a8ea948b11c 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -3,7 +3,6 @@ import globalHeader from './en-US/globalHeader'; import menu from './en-US/menu'; import pages from './en-US/pages'; import pwa from './en-US/pwa'; -import request from './en-US/request'; import settingDrawer from './en-US/settingDrawer'; import settings from './en-US/settings'; @@ -23,5 +22,4 @@ export default { ...pwa, ...component, ...pages, - ...request, }; diff --git a/src/locales/en-US/request.ts b/src/locales/en-US/request.ts deleted file mode 100644 index 022c1cd9026eedd6e472fab5534f1ab942e17143..0000000000000000000000000000000000000000 --- a/src/locales/en-US/request.ts +++ /dev/null @@ -1,21 +0,0 @@ -export default { - 'app.request.error': 'Request error', - 'app.request.200': 'The server successfully returned the requested data. ', - 'app.request.201': 'New or modified data is successful. ', - 'app.request.202': 'A request has entered the background queue (asynchronous task). ', - 'app.request.204': 'Data deleted successfully. ', - 'app.request.400': - 'There was an error in the request sent, and the server did not create or modify data. ', - 'app.request.401': 'The user does not have permission (token, username, password error). ', - 'app.request.403': 'The user is authorized, but access is forbidden. ', - 'app.request.404': 'The request sent was for a record that did not exist. ', - 'app.request.405': 'The request method is not allowed. ', - 'app.request.406': 'The requested format is not available. ', - 'app.request.410': - 'The requested resource is permanently deleted and will no longer be available. ', - 'app.request.422': 'When creating an object, a validation error occurred. ', - 'app.request.500': 'An error occurred on the server, please check the server. ', - 'app.request.502': 'Gateway error. ', - 'app.request.503': 'The service is unavailable. ', - 'app.request.504': 'The gateway timed out. ', -}; diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index e225898738db3dff2a192dc1b4e769585994184a..e4258ce8f548196af63367c8cb70dd55ffd0a57b 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -2,7 +2,6 @@ import component from './zh-CN/component'; import globalHeader from './zh-CN/globalHeader'; import menu from './zh-CN/menu'; import pwa from './zh-CN/pwa'; -import request from './zh-CN/request'; import settingDrawer from './zh-CN/settingDrawer'; import settings from './zh-CN/settings'; import pages from './zh-CN/pages'; @@ -23,5 +22,4 @@ export default { ...settings, ...pwa, ...component, - ...request, }; diff --git a/src/locales/zh-CN/request.ts b/src/locales/zh-CN/request.ts deleted file mode 100644 index 0ee39a7213ff9566d4c898e440a2efd2932dacec..0000000000000000000000000000000000000000 --- a/src/locales/zh-CN/request.ts +++ /dev/null @@ -1,19 +0,0 @@ -export default { - 'app.request.error': '请求错误', - 'app.request.200': '服务器成功返回请求的数据。', - 'app.request.201': '新建或修改数据成功。', - 'app.request.202': '一个请求已经进入后台排队(异步任务)。', - 'app.request.204': '删除数据成功。', - 'app.request.400': '发出的请求有错误,服务器没有进行新建或修改数据的操作。', - 'app.request.401': '用户没有权限(令牌、用户名、密码错误)。', - 'app.request.403': '用户得到授权,但是访问是被禁止的。', - 'app.request.404': '发出的请求针对的是不存在的记录,服务器没有进行操作。', - 'app.request.405': '请求方法不被允许。', - 'app.request.406': '请求的格式不可得。', - 'app.request.410': '请求的资源被永久删除,且不会再得到的。', - 'app.request.422': '当创建一个对象时,发生一个验证错误。', - 'app.request.500': '服务器发生错误,请检查服务器。', - 'app.request.502': '网关错误。', - 'app.request.503': '服务不可用,服务器暂时过载或维护。', - 'app.request.504': '网关超时。', -};