93 lines
4.8 KiB
JavaScript
93 lines
4.8 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', makeRoute('issue_detail.html', 'IssueController'))
|
|
.when('/project_discussion', makeRoute('project_discussion.html', 'DiscussionController'))
|
|
.when('/homework', makeRoute('homework_detail.html', 'HomeworkController'))
|
|
.when('/course_notice', makeRoute('course_notice.html', 'CourseNoticeController'))
|
|
.when('/course_discussion', makeRoute('course_discussion.html', 'DiscussionController'))
|
|
.when('/journal_for_message', makeRoute('jour_message_detail.html', 'JournalsController'))
|
|
.when('/blog_comment', 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('/join_class', makeRoute('join_class.html', 'JoinClassController'))
|
|
.when('/review_class_member', makeRoute('review_class_member.html', 'ReviewClassMemberController'))
|
|
.when('/class_publishnotice', makeRoute('class_publishnotice.html', 'ClassPublishNoticeController'))
|
|
.when('/class_publishissue', makeRoute('class_publishissue.html', 'ClassPublishIssueController'))
|
|
.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'})
|
|
.when('/join_project', makeRoute('join_project.html', 'JoinProjectController'))
|
|
.when('/review_project_member', makeRoute('review_project_member.html', 'ReviewProjectMemberController'))
|
|
.when('/project_publishnote', makeRoute('project_publishnote.html', 'ProjectPublishNoteController'))
|
|
.when('/login_tip', makeRoute('login_tip.html', 'LoginTipController'))
|
|
.when('/edit_userinfo', makeRoute('edit_userinfo.html', 'EditUserInfoController'))
|
|
.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;
|
|
}
|
|
};
|
|
}]);
|
|
}]);
|