admin 右侧导航栏修改为 js 生成,根据用户身份权限变化
This commit is contained in:
@@ -21,43 +21,110 @@ define("admin", ["jquery", "avalon"], function ($, avalon) {
|
||||
hash = "index/index";
|
||||
}
|
||||
|
||||
var superAdminNav = [
|
||||
{ name: "首页",
|
||||
children: [{name: "主页", hash: "#index/index"},
|
||||
{name: "监控", hash: "#monitor/monitor"},
|
||||
{name: "统计", hash: "#statistics/statistics"}]
|
||||
},
|
||||
{
|
||||
name: "通用",
|
||||
children: [{name: "公告管理", hash: "#announcement/announcement"},
|
||||
{name: "用户管理", hash: "#user/user_list"}]
|
||||
},
|
||||
{
|
||||
name: "题目管理",
|
||||
children: [{name: "题目列表", hash: "#problem/problem_list"},
|
||||
{name: "创建题目", hash: "#problem/add_problem"}]
|
||||
},
|
||||
{
|
||||
name: "比赛管理",
|
||||
children: [{name: "比赛列表", hash: "#contest/contest_list"},
|
||||
{name: "创建比赛", hash: "#contest/add_contest"}]
|
||||
},
|
||||
{
|
||||
name: "小组管理",
|
||||
children: [{name: "小组列表", hash: "#group/group"},
|
||||
{name: "加入小组请求", hash: "#group/join_group_request_list"}]
|
||||
}
|
||||
];
|
||||
|
||||
var adminNav = [
|
||||
{ name: "首页",
|
||||
children: [{name: "主页", hash: "#index/index"}]
|
||||
},
|
||||
{
|
||||
name: "通用",
|
||||
children: [{name: "公告管理", hash: "#announcement/announcement"}]
|
||||
},
|
||||
{
|
||||
name: "比赛管理",
|
||||
children: [{name: "比赛列表", hash: "#contest/contest_list"},
|
||||
{name: "创建比赛", hash: "#contest/add_contest"}]
|
||||
},
|
||||
{
|
||||
name: "小组管理",
|
||||
children: [{name: "小组列表", hash: "#group/group"},
|
||||
{name: "加入小组请求", hash: "#group/join_group_request_list"}]
|
||||
}
|
||||
];
|
||||
|
||||
var vm = avalon.define({
|
||||
$id: "admin",
|
||||
template_url: "template/" + hash + ".html",
|
||||
groupId: -1,
|
||||
problemId: -1,
|
||||
adminNavList: [],
|
||||
hide_loading: function () {
|
||||
$("#loading-gif").hide();
|
||||
},
|
||||
getLiId: function(hash){
|
||||
return hash.replace("#", "li-").replace("/", "-");
|
||||
}
|
||||
});
|
||||
|
||||
vm.$watch("showGroupDetailPage", function(groupId){
|
||||
|
||||
$.ajax({
|
||||
url: "/api/user/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function(data){
|
||||
if(!data.code){
|
||||
if (data.data.admin_type == 2){
|
||||
vm.adminNavList = superAdminNav;
|
||||
}
|
||||
else{
|
||||
vm.adminNavList = adminNav;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vm.$watch("showGroupDetailPage", function (groupId) {
|
||||
vm.groupId = groupId;
|
||||
vm.template_url = "template/group/group_detail.html";
|
||||
});
|
||||
|
||||
vm.$watch("showEditProblemPage", function(problemId){
|
||||
vm.$watch("showEditProblemPage", function (problemId) {
|
||||
vm.problemId = problemId;
|
||||
vm.template_url = "template/problem/edit_problem.html";
|
||||
});
|
||||
|
||||
vm.$watch("showProblemListPage", function(){
|
||||
vm.template_url = "template/problem/problem_list.html";
|
||||
vm.$watch("showProblemListPage", function () {
|
||||
vm.template_url = "template/problem/problem_list.html";
|
||||
});
|
||||
|
||||
vm.$watch("showGroupListPage", function(){
|
||||
vm.template_url = "template/group/group.html";
|
||||
vm.$watch("showGroupListPage", function () {
|
||||
vm.template_url = "template/group/group.html";
|
||||
});
|
||||
|
||||
vm.$watch("showProblemSubmissionPage", function(problemId){
|
||||
vm.$watch("showProblemSubmissionPage", function (problemId) {
|
||||
vm.problemId = problemId;
|
||||
vm.template_url = "template/problem/submission_list.html";
|
||||
});
|
||||
|
||||
avalon.scan();
|
||||
|
||||
li_active("#li-" + hash.replace("/", "-"));
|
||||
|
||||
window.onhashchange = function () {
|
||||
var hash = window.location.hash.substring(1);
|
||||
if (hash) {
|
||||
@@ -66,6 +133,7 @@ define("admin", ["jquery", "avalon"], function ($, avalon) {
|
||||
show_template("template/" + hash + ".html");
|
||||
}
|
||||
};
|
||||
setTimeout(function(){li_active("#li-" + hash.replace("/", "-"));}, 500)
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user