Browse Source
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>
pull/2424/head
coder_Q
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
@ -1,5 +1,6 @@
export default {
api : {
operationSuccess : 'Operation Success' ,
operationFailed : 'Operation failed' ,
errorTip : 'Error Tip' ,
successTip : 'Success Tip' ,
@ -1,5 +1,6 @@
export default {
api : {
operationSuccess : '操作成功' ,
operationFailed : '操作失败' ,
errorTip : '错误提示' ,
successTip : '成功提示' ,
@ -10,7 +10,7 @@ import { checkStatus } from './checkStatus';
import { useGlobSetting } from '/@/hooks/setting' ;
import { useMessage } from '/@/hooks/web/useMessage' ;
import { RequestEnum , ResultEnum , ContentTypeEnum } from '/@/enums/httpEnum' ;
import { isString } from '/@/utils/is' ;
import { isString , isUnDef , isNull , isEmpty } from '/@/utils/is' ;
import { getToken } from '/@/utils/auth' ;
import { setObjToUrlParams , deepMerge } from '/@/utils' ;
import { useErrorLogStoreWithOut } from '/@/store/modules/errorLog' ;
@ -57,9 +57,11 @@ const transform: AxiosTransform = {
const hasSuccess = data && Reflect . has ( data , 'code' ) && code === ResultEnum . SUCCESS ;
if ( hasSuccess ) {
let successMsg = message ;
if ( successMsg === null || successMsg === undefined || successMsg === '' ) {
successMsg = '操作成功' ;
if ( isNull ( successMsg ) || isUnDef ( successMsg ) || isEmpty ( successMsg ) ) {
successMsg = t ( ` sys.api.operationSuccess ` ) ;
}
if ( options . successMessageMode === 'modal' ) {
createSuccessModal ( { title : t ( 'sys.api.successTip' ) , content : successMsg } ) ;
} else if ( options . successMessageMode === 'message' ) {