84 lines
3.9 KiB
JavaScript
84 lines
3.9 KiB
JavaScript
app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', function ($routeProvider, $httpProvider, $locationProvider, config) {
|
|
var rootPath = config.rootPath;
|
|
var resolve = {
|
|
delay: ['auth',function(auth){
|
|
return auth.get_bind();
|
|
}]
|
|
};
|
|
var makeRoute = function(path, ctrl){
|
|
return {
|
|
templateUrl: rootPath + path,
|
|
controller: ctrl
|
|
//resolve: resolve
|
|
}
|
|
}
|
|
//$locationProvider.html5Mode(true);
|
|
$routeProvider
|
|
.when('/login', {
|
|
templateUrl: rootPath + 'login.html',
|
|
controller: 'LoginController'
|
|
})
|
|
.when('/reg', {
|
|
templateUrl: rootPath + 'reg.html',
|
|
controller: 'RegController'
|
|
})
|
|
.when('/activites', makeRoute('activities.html', 'ActivityController'))
|
|
.when('/issues/:id', makeRoute('issue_detail.html', 'IssueController'))
|
|
.when('/project_discussion/:id', makeRoute('project_discussion.html', 'DiscussionController'))
|
|
.when('/homework/:id', makeRoute('homework_detail.html', 'HomeworkController'))
|
|
.when('/course_notice/:id', makeRoute('course_notice.html', 'CourseNoticeController'))
|
|
.when('/course_discussion/:id', makeRoute('course_discussion.html', 'DiscussionController'))
|
|
.when('/journal_for_message/:id', makeRoute('jour_message_detail.html', 'JournalsController'))
|
|
.when('/blog_comment/:id', makeRoute('blog_detail.html', 'BlogController'))
|
|
.when('/class', makeRoute('class.html', 'ClassController'))
|
|
.when('/new_class', makeRoute('new_class.html', 'NewClassController'))
|
|
.when('/edit_class', makeRoute('edit_class.html', 'EditClassController'))
|
|
.when('/class_list', makeRoute('class_list.html', 'ClassListController'))
|
|
.when('/edit_class_member', makeRoute('edit_class_member.html', 'EditClassMemberController'))
|
|
.when('/myresource', makeRoute('myresource.html', 'MyResourceController'))
|
|
.when('/invite_code', {templateUrl: rootPath + 'invite_code.html', controller: 'InviteCodeController'})
|
|
.when('/send_class_list', makeRoute('send_class_list.html', 'SendClassListController'))
|
|
.when('/project_list', makeRoute('project_list.html', 'ProjectListController'))
|
|
.when('/project', makeRoute('project.html', 'ProjectController'))
|
|
.when('/edit_project_member', makeRoute('edit_project_member.html', 'EditProjectMemberController'))
|
|
.when('/new_project', makeRoute('new_project.html', 'NewProjectController'))
|
|
.when('/project_invite_code', {templateUrl: rootPath + 'project_invite_code.html', controller: 'ProjectInviteCodeController'})
|
|
.otherwise({
|
|
redirectTo: '/activites'
|
|
});
|
|
|
|
//监听异步请求,实现加载中显隐标记
|
|
$httpProvider.interceptors.push(['$q', '$rootScope', function ($q, $rootScope) {
|
|
if ($rootScope.activeCalls == undefined) {
|
|
$rootScope.activeCalls = 0;
|
|
}
|
|
|
|
return {
|
|
request: function (config) {
|
|
$rootScope.activeCalls += 1;
|
|
return config;
|
|
},
|
|
requestError: function (rejection) {
|
|
$rootScope.activeCalls -= 1;
|
|
return rejection;
|
|
},
|
|
response: function (response) {
|
|
// var data = response.data;
|
|
// if(data && data.status==405){
|
|
// var rootScope = $injector.get('$rootScope');
|
|
// var state = $injector.get('$rootScope').$state.current.name;
|
|
// rootScope.stateBeforLogin = state;
|
|
// rootScope.$state.go("login");
|
|
// return $q.reject(response);
|
|
// }
|
|
$rootScope.activeCalls -= 1;
|
|
return response;
|
|
},
|
|
responseError: function (rejection) {
|
|
$rootScope.activeCalls -= 1;
|
|
return rejection;
|
|
}
|
|
};
|
|
}]);
|
|
}]);
|