Commit bc099041ce13c64c999c6f7df6470b74e94db84b
Committed by
GitHub
1 parent
0629cc7b
style: optimize the way success hints are encoded in transformRespons… (#2411)
* style: optimize the way success hints are encoded in transformResponseHook #2410 * style: move to introduce location Co-authored-by: 邱子建 <qiuzijian@qiuzijiandeMacBook-Air.local>
Showing
3 changed files
with
7 additions
and
3 deletions
src/locales/lang/en/sys.ts
src/locales/lang/zh-CN/sys.ts
src/utils/http/axios/index.ts
... | ... | @@ -10,7 +10,7 @@ import { checkStatus } from './checkStatus'; |
10 | 10 | import { useGlobSetting } from '/@/hooks/setting'; |
11 | 11 | import { useMessage } from '/@/hooks/web/useMessage'; |
12 | 12 | import { RequestEnum, ResultEnum, ContentTypeEnum } from '/@/enums/httpEnum'; |
13 | -import { isString } from '/@/utils/is'; | |
13 | +import { isString, isUnDef, isNull, isEmpty } from '/@/utils/is'; | |
14 | 14 | import { getToken } from '/@/utils/auth'; |
15 | 15 | import { setObjToUrlParams, deepMerge } from '/@/utils'; |
16 | 16 | import { useErrorLogStoreWithOut } from '/@/store/modules/errorLog'; |
... | ... | @@ -57,9 +57,11 @@ const transform: AxiosTransform = { |
57 | 57 | const hasSuccess = data && Reflect.has(data, 'code') && code === ResultEnum.SUCCESS; |
58 | 58 | if (hasSuccess) { |
59 | 59 | let successMsg = message; |
60 | - if (successMsg === null || successMsg === undefined || successMsg === '') { | |
61 | - successMsg = '操作成功'; | |
60 | + | |
61 | + if (isNull(successMsg) || isUnDef(successMsg) || isEmpty(successMsg)) { | |
62 | + successMsg = t(`sys.api.operationSuccess`); | |
62 | 63 | } |
64 | + | |
63 | 65 | if (options.successMessageMode === 'modal') { |
64 | 66 | createSuccessModal({ title: t('sys.api.successTip'), content: successMsg }); |
65 | 67 | } else if (options.successMessageMode === 'message') { | ... | ... |