File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,41 @@ util.ajax.interceptors.request.use(function (config) {
2929 config . headers . common [ "Abp.TenantId" ] = abp . multiTenancy . getTenantIdCookie ( ) ;
3030 return config ;
3131 } , function ( error ) {
32-
32+
3333 return Promise . reject ( error ) ;
3434} ) ;
35+ util . ajax . interceptors . response . use ( function ( response ) {
36+ // Do something with response data
37+ return response ;
38+ } , function ( error ) {
39+ // Do something with response error
40+ if ( ! ! error . response && ! ! error . response . data && ! ! error . response . data . __abp ) {
41+ abp . ajax . showError ( error . response . data . error ) ;
42+ } else {
43+ if ( ! error . response ) {
44+ abp . ajax . showError ( abp . ajax . defaultError ) ;
45+ return
46+ }
47+ switch ( error . response . status ) {
48+ case 401 :
49+ abp . ajax . handleUnAuthorizedRequest (
50+ abp . ajax . showError ( abp . ajax . defaultError401 ) ,
51+ abp . appPath
52+ ) ;
53+ break ;
54+ case 403 :
55+ abp . ajax . showError ( abp . ajax . defaultError403 ) ;
56+ break ;
57+ case 404 :
58+ abp . ajax . showError ( abp . ajax . defaultError404 ) ;
59+ break ;
60+ default :
61+ abp . ajax . showError ( abp . ajax . defaultError ) ;
62+ break ;
63+ }
64+ }
65+ return Promise . reject ( error ) ;
66+ } )
3567util . inOf = function ( arr , targetArr ) {
3668 let res = true ;
3769 arr . forEach ( item => {
Original file line number Diff line number Diff line change @@ -14,6 +14,14 @@ util.ajax.get('/AbpUserConfiguration/GetAll').then(result=>{
1414 Vue . use ( VueI18n ) ;
1515 Vue . use ( iView ) ;
1616 window . abp = $ . extend ( true , abp , result . data . result ) ;
17+ abp . ajax . defaultError . message = abp . localization . abpWeb ( 'DefaultError' ) ;
18+ abp . ajax . defaultError . details = abp . localization . abpWeb ( 'DefaultErrorDetail' ) ;
19+ abp . ajax . defaultError401 . message = abp . localization . abpWeb ( 'DefaultError401' ) ;
20+ abp . ajax . defaultError401 . details = abp . localization . abpWeb ( 'DefaultErrorDetail401' ) ;
21+ abp . ajax . defaultError403 . message = abp . localization . abpWeb ( 'DefaultError403' ) ;
22+ abp . ajax . defaultError403 . details = abp . localization . abpWeb ( 'DefaultErrorDetail403' ) ;
23+ abp . ajax . defaultError404 . message = abp . localization . abpWeb ( 'DefaultError404' ) ;
24+ abp . ajax . defaultError404 . details = abp . localization . abpWeb ( 'DefaultErrorDetail404' ) ;
1725 Vue . prototype . L = function ( text , ...args ) {
1826 let localizedText = window . abp . localization . localize ( text , AppConsts . localization . defaultLocalizationSourceName ) ;
1927 if ( ! localizedText ) {
You can’t perform that action at this time.
0 commit comments