Browse Source

拦截器修改还原

yangc 8 years ago
parent
commit
1ecd068a9d
1 changed files with 11 additions and 10 deletions
  1. 11 10
      src/main/webapp/resources/js/common/controllers/commonCtrls.js

+ 11 - 10
src/main/webapp/resources/js/common/controllers/commonCtrls.js

@@ -15,29 +15,30 @@ define([ 'app/app' ], function(app) {
 			if(--i < 1) Loading.hide();
 		};
 
+		var im_api_url = 'api/chat/message';
 		return {
 			request: function(cfg){
-				if(cfg.url) {
-					if(cfg.url.indexOf('api/chat/message') < 0) {
-						startLoading();
-					}
+				if(cfg.url && cfg.url.indexOf(im_api_url) < 0) {
+					startLoading();
 				}
 				return cfg;
 			},
 			requestError: function(rejection) {
-				endLoading();
+				if(rejection.config.url && rejection.config.url.indexOf(im_api_url) < 0) {
+					endLoading();
+				}
 				return $q.reject(rejection);
 			},
 			response: function(res) {
-				if(res.config.url) {
-					if(res.config.url.indexOf('api/chat/message') < 0) {
-						endLoading();
-					}
+				if(res.config.url && res.config.url.indexOf(im_api_url) < 0) {
+					endLoading();
 				}
 				return res;
 			},
 			responseError: function(rejection) {
-				endLoading();
+				if(rejection.config.url && rejection.config.url.indexOf(im_api_url) < 0) {
+					endLoading();
+				}
 				if(rejection.status == 401) {
 					window.location.href = rejection.data.loginUrl || 'index';
 				}