Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
钟摆人-Puppet゜
ant-design-pro
提交
67659a00
A
ant-design-pro
项目概览
钟摆人-Puppet゜
/
ant-design-pro
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design-pro
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
67659a00
编写于
6月 03, 2021
作者:
丁
丁田秀
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(locale): 删除request错误捕捉
上级
6f930077
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
19 addition
and
59 deletion
+19
-59
src/app.tsx
src/app.tsx
+19
-15
src/locales/en-US.ts
src/locales/en-US.ts
+0
-2
src/locales/en-US/request.ts
src/locales/en-US/request.ts
+0
-21
src/locales/zh-CN.ts
src/locales/zh-CN.ts
+0
-2
src/locales/zh-CN/request.ts
src/locales/zh-CN/request.ts
+0
-19
未找到文件。
src/app.tsx
浏览文件 @
67659a00
...
@@ -2,7 +2,7 @@ import type { Settings as LayoutSettings } from '@ant-design/pro-layout';
...
@@ -2,7 +2,7 @@ import type { Settings as LayoutSettings } from '@ant-design/pro-layout';
import
{
PageLoading
}
from
'
@ant-design/pro-layout
'
;
import
{
PageLoading
}
from
'
@ant-design/pro-layout
'
;
import
{
notification
}
from
'
antd
'
;
import
{
notification
}
from
'
antd
'
;
import
type
{
RequestConfig
,
RunTimeLayoutConfig
}
from
'
umi
'
;
import
type
{
RequestConfig
,
RunTimeLayoutConfig
}
from
'
umi
'
;
import
{
getIntl
,
getLocale
,
history
,
Link
}
from
'
umi
'
;
import
{
history
,
Link
}
from
'
umi
'
;
import
RightContent
from
'
@/components/RightContent
'
;
import
RightContent
from
'
@/components/RightContent
'
;
import
Footer
from
'
@/components/Footer
'
;
import
Footer
from
'
@/components/Footer
'
;
import
type
{
ResponseError
}
from
'
umi-request
'
;
import
type
{
ResponseError
}
from
'
umi-request
'
;
...
@@ -51,7 +51,6 @@ export async function getInitialState(): Promise<{
...
@@ -51,7 +51,6 @@ export async function getInitialState(): Promise<{
/**
/**
* 异常处理程序
* 异常处理程序
const codeMessage = {
200: '服务器成功返回请求的数据。',
200: '服务器成功返回请求的数据。',
201: '新建或修改数据成功。',
201: '新建或修改数据成功。',
202: '一个请求已经进入后台排队(异步任务)。',
202: '一个请求已经进入后台排队(异步任务)。',
...
@@ -68,25 +67,30 @@ export async function getInitialState(): Promise<{
...
@@ -68,25 +67,30 @@ export async function getInitialState(): Promise<{
502: '网关错误。',
502: '网关错误。',
503: '服务不可用,服务器暂时过载或维护。',
503: '服务不可用,服务器暂时过载或维护。',
504: '网关超时。',
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
* @see https://beta-pro.ant.design/docs/request-cn
*/
*/
export
const
request
:
RequestConfig
=
{
export
const
request
:
RequestConfig
=
{
errorHandler
:
(
error
:
ResponseError
)
=>
{
errorHandler
:
(
error
:
ResponseError
)
=>
{
const
{
messages
}
=
getIntl
(
getLocale
());
const
{
response
}
=
error
;
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
)
{
if
(
!
response
)
{
notification
.
error
({
notification
.
error
({
description
:
'
您的网络发生异常,无法连接服务器
'
,
description
:
'
您的网络发生异常,无法连接服务器
'
,
...
...
src/locales/en-US.ts
浏览文件 @
67659a00
...
@@ -3,7 +3,6 @@ import globalHeader from './en-US/globalHeader';
...
@@ -3,7 +3,6 @@ import globalHeader from './en-US/globalHeader';
import
menu
from
'
./en-US/menu
'
;
import
menu
from
'
./en-US/menu
'
;
import
pages
from
'
./en-US/pages
'
;
import
pages
from
'
./en-US/pages
'
;
import
pwa
from
'
./en-US/pwa
'
;
import
pwa
from
'
./en-US/pwa
'
;
import
request
from
'
./en-US/request
'
;
import
settingDrawer
from
'
./en-US/settingDrawer
'
;
import
settingDrawer
from
'
./en-US/settingDrawer
'
;
import
settings
from
'
./en-US/settings
'
;
import
settings
from
'
./en-US/settings
'
;
...
@@ -23,5 +22,4 @@ export default {
...
@@ -23,5 +22,4 @@ export default {
...
pwa
,
...
pwa
,
...
component
,
...
component
,
...
pages
,
...
pages
,
...
request
,
};
};
src/locales/en-US/request.ts
已删除
100644 → 0
浏览文件 @
6f930077
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.
'
,
};
src/locales/zh-CN.ts
浏览文件 @
67659a00
...
@@ -2,7 +2,6 @@ import component from './zh-CN/component';
...
@@ -2,7 +2,6 @@ import component from './zh-CN/component';
import
globalHeader
from
'
./zh-CN/globalHeader
'
;
import
globalHeader
from
'
./zh-CN/globalHeader
'
;
import
menu
from
'
./zh-CN/menu
'
;
import
menu
from
'
./zh-CN/menu
'
;
import
pwa
from
'
./zh-CN/pwa
'
;
import
pwa
from
'
./zh-CN/pwa
'
;
import
request
from
'
./zh-CN/request
'
;
import
settingDrawer
from
'
./zh-CN/settingDrawer
'
;
import
settingDrawer
from
'
./zh-CN/settingDrawer
'
;
import
settings
from
'
./zh-CN/settings
'
;
import
settings
from
'
./zh-CN/settings
'
;
import
pages
from
'
./zh-CN/pages
'
;
import
pages
from
'
./zh-CN/pages
'
;
...
@@ -23,5 +22,4 @@ export default {
...
@@ -23,5 +22,4 @@ export default {
...
settings
,
...
settings
,
...
pwa
,
...
pwa
,
...
component
,
...
component
,
...
request
,
};
};
src/locales/zh-CN/request.ts
已删除
100644 → 0
浏览文件 @
6f930077
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
'
:
'
网关超时。
'
,
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录