Commit ebecd7ef authored by 前端-许佳敏's avatar 前端-许佳敏

feat: 后端提示语国际化

parent 6dcc00c7
import { extend, ResponseError, OnionOptions, RequestOptionsInit, ResponseInterceptor, OnionMiddleware, Context, RequestMethod } from 'umi-request';
import responseCode from '@/constants/responseCode'
import { IRequestError, IRequestSuccess } from '..';
import { history } from 'umi'
import { getIntl } from 'umi'
import { message } from 'antd'
import { getCookieAuth, removeAuth } from './auth';
import { GlobalConfig } from '@/global/config';
......@@ -25,6 +25,8 @@ export interface IApiRequest extends RequestOptionsInit {
type httpStatus = {
[key: number]: string
}
const intl = getIntl()
const errorMessage: httpStatus = {
400: "发出的请求有错误,服务器没有进行新建或修改数据的操作。",
401: "用户没有权限(令牌、用户名、密码错误)。",
......@@ -142,7 +144,7 @@ class ApiRequest {
if (url != '/member/loginInfo') {
// 这是展示接口错误信息,任何 ctlType 都可以,不然一些 get 请求出错了
// 错误信息无法展示给用户
res.message && message.info(res.message)
res.message && message.info(intl.formatMessage({ id: res.code, defaultMessage: res.message}))
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment