Browse Source

feat: 后台管理分类页面前端初步完成。

pull/6/head
zjz1993 6 years ago
parent
commit
8d103251e5
  1. 16
      modules/admin.js
  2. 55
      views/admin_classify.ejs
  3. 1
      views/admin_header.ejs
  4. 2
      views/header.ejs

16
modules/admin.js

@ -291,6 +291,22 @@ app.get('/admin/rejudge', async (req, res) => {
} }
}); });
app.get('/admin/classify', async (req, res) => {
try {
if (!res.locals.user || !res.locals.user.is_admin) throw new ErrorMessage('您没有权限进行此操作。');
res.render('admin_classify', {
form: {},
count: null
});
} catch (e) {
syzoj.log(e);
res.render('error', {
err: e
})
}
});
app.post('/admin/other', async (req, res) => { app.post('/admin/other', async (req, res) => {
try { try {
if (!res.locals.user || !res.locals.user.is_admin) throw new ErrorMessage('您没有权限进行此操作。'); if (!res.locals.user || !res.locals.user.is_admin) throw new ErrorMessage('您没有权限进行此操作。');

55
views/admin_classify.ejs

@ -0,0 +1,55 @@
<% this.adminPage = 'classify'; %>
<% include admin_header %>
<style>
[v-cloak] {
display: none;
}
.current-classify{
margin-bottom: 20px;
}
</style>
<div id="classify" v-cloak>
<div v-if="mockClassify.length === 0">
暂无分类
</div>
<div v-else>
<div class="current-classify">
<h4>目前分类</h4>
<div class="ui cards">
<div class="card" v-for="item in mockClassify">
<div class="content">
<div class="header">{{item.title}}</div>
<div class="description">
{{item.description}}
</div>
</div>
<div class="ui bottom attached button">
<i class="add icon"></i>
编辑分类信息
</div>
</div>
</div>
</div>
</div>
<div class="ui labeled button" tabindex="0">
<div class="ui button">
<i class="plus icon"></i> 新增分类
</div>
</div>
</div>
<script>
new window.Vue({
el: '#classify',
data: {
message: 'Hello Vue!',
mockClassify: [{
title: '测试分类',
description: '测试介绍'
}, {
title: '测试分类1',
description: '测试介绍1'
}]
},
})
</script>
<% include admin_footer %>

1
views/admin_header.ejs

@ -2,6 +2,7 @@
let items = { let items = {
info: '统计信息', info: '统计信息',
config: '系统配置', config: '系统配置',
classify: '分类管理',
privilege: '权限管理', privilege: '权限管理',
rejudge: '一键重测', rejudge: '一键重测',
links: '友链管理', links: '友链管理',

2
views/header.ejs

@ -33,6 +33,7 @@
<link href="<%- this.builtInCdnUrl %>/google-fonts/exo-2.css" rel="stylesheet"> <link href="<%- this.builtInCdnUrl %>/google-fonts/exo-2.css" rel="stylesheet">
<% } %> <% } %>
<script src="<%- lib('jquery/3.3.1/jquery.min.js') %>"></script> <script src="<%- lib('jquery/3.3.1/jquery.min.js') %>"></script>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<% if (syzoj.config.google_analytics && syzoj.config.google_analytics !== 'UA-XXXXXXXX-X') { %> <% if (syzoj.config.google_analytics && syzoj.config.google_analytics !== 'UA-XXXXXXXX-X') { %>
<script> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
@ -60,6 +61,7 @@
<% } %> <% } %>
<a class="item<% if (active === '') { %> active<% } %>" href="/"><i class="home icon"></i> 首页</a> <a class="item<% if (active === '') { %> active<% } %>" href="/"><i class="home icon"></i> 首页</a>
<a class="item<% if (active.startsWith('problem')) { %> active<% } %>" href="/problems"><i class="list icon"></i> 题库</a> <a class="item<% if (active.startsWith('problem')) { %> active<% } %>" href="/problems"><i class="list icon"></i> 题库</a>
<a class="item<% if (active.startsWith('contest')) { %> active<% } %>" href="/contests"><i class="pencil icon"></i> 练习</a>
<a class="item<% if (active.startsWith('contest')) { %> active<% } %>" href="/contests"><i class="calendar icon"></i> 比赛</a> <a class="item<% if (active.startsWith('contest')) { %> active<% } %>" href="/contests"><i class="calendar icon"></i> 比赛</a>
<a class="item<% if (active.startsWith('submission')) { %> active<% } %>" href="/submissions"><i class="tasks icon"></i> 评测</a> <a class="item<% if (active.startsWith('submission')) { %> active<% } %>" href="/submissions"><i class="tasks icon"></i> 评测</a>
<a class="item<% if (active.startsWith('ranklist')) { %> active<% } %>" href="/ranklist"><i class="signal icon"></i> 排名</a> <a class="item<% if (active.startsWith('ranklist')) { %> active<% } %>" href="/ranklist"><i class="signal icon"></i> 排名</a>

Loading…
Cancel
Save