-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
94 lines (92 loc) · 3.64 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Created on 20171106.
* Angular入口模块
*/
define([
'angular',
'ngCookies',
// 'ngAnimate', //后期需要时放开注释
// 'ngStorage', //后期需要时放开注释
'ocLazyLoad',
'eCharts',
'uiRouter',
'business',
'utilitie',
'mock/backend-mocks', // mock模块仅供本地测试 提交生产时需要注释
'angular-ui-tree'
], function (angular,a,d,g,h) {
'use strict';
var app = angular.module('prpins', [
'ngCookies',
// 'ngAnimate', //后期需要时放开注释
// 'ngStorage',
'oc.lazyLoad',
'ui.router',
'ui.router.state',
'backend-mocks', // mock模块仅供本地测试 提交生产时需要注释
'business',
'utilities',
'ui.tree'
]);
app.config([
'$controllerProvider',
'$compileProvider',
'$filterProvider',
'$provide',
function ($controllerProvider, $compileProvider, $filterProvider, $provide) {
app.register = {
controller: $controllerProvider.register,//按需加载控制器
directive: $compileProvider.directive,
filter: $filterProvider.register,
factory: $provide.factory,
service: $provide.service
};
}]);
app.config(['$httpProvider', function($httpProvider){
$httpProvider.interceptors.push(['$q', '$location',function($q, $location, $localStorage){
return {
'request': function (config) {
config.headers = config.headers || {};
return config;
},
'responseError': function(response) {
if(response.status === 401 || response.status === 403) {
$location.path('/login');
}
return $q.reject(response);
}
};
}]);
}]);
// 禁用ie的 ajax request caching
app.config(['$httpProvider','treeConfig',function($httpProvider,treeConfig){
//菜单折叠配置
treeConfig.defaultCollapsed = false; //true折叠,false展开
if (!$httpProvider.defaults.headers.get) {
$httpProvider.defaults.headers.get = {};
}
$httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
$httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
}]);
app.run(['$state', '$stateParams', '$rootScope','promptServ',
function ($state, $stateParams, $rootScope, promptServ) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
$rootScope.$on('$stateChangeStart',
function (event, toState, toParams, fromState, fromParams, options) {
if("calculate" ===fromState.name){
$(window).unbind("scroll")
}
}
);
$rootScope.$on('$locationChangeSuccess',
function(event, toState, toParams, fromState, fromParams){
console.log("location change!");
});
}
]);
return app;
}
);