'use strict'; var app = angular.module('app'); app.constant('main_host', main_host); app.factory('frameAjaxInterceptor', function($q, $rootScope) { return { 'request': function(config) { return config; }, 'requestError': function(rejection) { return $q.reject(rejection); }, 'response': function(response) { return response; }, 'responseError': function(rejection) { if (rejection.status == 504) { var d = dialog({ title: '错误提示', content: "您超时间未操作,请重新登录本系统", ok: function() { document.location.href = ''; }, okValue: '确定' }); d.showModal(); return $q.reject(rejection); } else if (rejection.status == 500) { var d = dialog({ title: '错误提示', content: (rejection.data && rejection.data.errorMsg ? rejection.data.errorMsg : "操作失败,请与管理员联系。"), ok: function() { //donothing }, okValue: '确定' }); d.showModal(); return $q.reject(rejection); } else { return $q.reject(rejection); } } }; }).config(['$httpProvider', function($httpProvider) { $httpProvider.interceptors.push('frameAjaxInterceptor'); $httpProvider.defaults.cache = false; if (!$httpProvider.defaults.headers.get) { $httpProvider.defaults.headers.get = {}; } // disable IE ajax request caching $httpProvider.defaults.headers.get['If-Modified-Since'] = '0'; }]) .run(['$rootScope', '$state', '$stateParams', function($rootScope, $state, $stateParams) { $rootScope.$state = $state; $rootScope.$stateParams = $stateParams; }])