Compare commits
No commits in common. "01aa0afd3effbe01608b45292d28bd9d4b5d132b" and "f3ef70b09618404d06606fc2bbfe102c86df7bcb" have entirely different histories.
01aa0afd3e
...
f3ef70b096
|
|
@ -2,7 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<title>首页</title>
|
<title>layout 管理界面大布局示例 - Layui</title>
|
||||||
<meta name="renderer" content="webkit"/>
|
<meta name="renderer" content="webkit"/>
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
</a>
|
</a>
|
||||||
<dl class="layui-nav-child">
|
<dl class="layui-nav-child">
|
||||||
<dd><a href="javascript:;">资料</a></dd>
|
<dd><a href="javascript:;">资料</a></dd>
|
||||||
|
<dd><a href="javascript:;">设置</a></dd>
|
||||||
<dd><a href="javascript:;" id="logoutLink">登出</a></dd>
|
<dd><a href="javascript:;" id="logoutLink">登出</a></dd>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
|
|
@ -41,35 +42,47 @@
|
||||||
<div class="layui-side-scroll">
|
<div class="layui-side-scroll">
|
||||||
<!-- 左侧导航区域(可配合layui已有的垂直导航) -->
|
<!-- 左侧导航区域(可配合layui已有的垂直导航) -->
|
||||||
<ul class="layui-nav layui-nav-tree" lay-filter="test">
|
<ul class="layui-nav layui-nav-tree" lay-filter="test">
|
||||||
|
<li class="layui-nav-item"><a href="javascript:;">首页</a></li>
|
||||||
|
<li class="layui-nav-item layui-nav-itemed">
|
||||||
|
<a class="" href="javascript:;">模块管理</a>
|
||||||
|
<dl class="layui-nav-child">
|
||||||
|
<dd><a href="javascript:;">课程类别</a></dd>
|
||||||
|
<dd><a href="javascript:;">课程信息</a></dd>
|
||||||
|
<dd><a href="javascript:;">课程签到</a></dd>
|
||||||
|
<dd><a href="javascript:;">签到提醒</a></dd>
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="layui-body">
|
||||||
|
<!-- 内容主体区域 -->
|
||||||
|
<div style="padding: 15px">
|
||||||
|
<blockquote class="layui-elem-quote layui-text">
|
||||||
|
Layui 框体布局内容主体区域
|
||||||
|
</blockquote>
|
||||||
|
<div class="layui-card layui-panel">
|
||||||
|
<div class="layui-card-header">
|
||||||
|
下面是充数内容,为的是出现滚动条
|
||||||
|
</div>
|
||||||
|
<div class="layui-card-body">
|
||||||
|
充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>充数内容<br/>你还真滑到了底部呀
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br/><br/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
<script src="static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||||
<script src="static/layui.js"></script>
|
<script src="static/layui.js"></script>
|
||||||
<script>
|
<script>
|
||||||
// 请求后端获取菜单数据
|
layui.use(['jquery'], function(){
|
||||||
$.get('/api/menu', function (menuItems) {
|
|
||||||
// 清空原有菜单项
|
|
||||||
var menuList = $('.layui-nav.layui-nav-tree');
|
|
||||||
menuList.empty();
|
|
||||||
|
|
||||||
// 动态添加菜单项
|
|
||||||
menuItems.forEach(function (item) {
|
|
||||||
menuList.append('<li class="layui-nav-item"><a href="' + item.link + '">' + item.name + '</a></li>');
|
|
||||||
});
|
|
||||||
|
|
||||||
// 更新菜单布局
|
|
||||||
layui.element.render('nav', 'test');
|
|
||||||
});
|
|
||||||
|
|
||||||
layui.use(['jquery'], function () {
|
|
||||||
var $ = layui.jquery; // 获取Layui的jQuery对象
|
var $ = layui.jquery; // 获取Layui的jQuery对象
|
||||||
|
|
||||||
$('#logoutLink').on('click', function () {
|
$('#logoutLink').on('click', function() {
|
||||||
// 向后端发送登出请求
|
// 向后端发送登出请求
|
||||||
$.get('/logout', function (data) {
|
$.get('/logout', function(data) {
|
||||||
// 重定向到登录页面,或根据后端响应做其他处理
|
// 重定向到登录页面,或根据后端响应做其他处理
|
||||||
window.location.href = '/login';
|
window.location.href = '/login';
|
||||||
});
|
});
|
||||||
|
|
|
||||||
13
app/views.py
13
app/views.py
|
|
@ -81,18 +81,5 @@ def logout():
|
||||||
return redirect('/login')
|
return redirect('/login')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api/menu')
|
|
||||||
def get_menu():
|
|
||||||
# 根据用户角色或其他逻辑获取菜单项
|
|
||||||
menu_items = [
|
|
||||||
{"name": "课程信息", "link": "#"},
|
|
||||||
{"name": "课程签到", "link": "#"},
|
|
||||||
{"name": "公告信息", "link": "#"},
|
|
||||||
{"name": "签到提醒", "link": "#"},
|
|
||||||
# ... 其他菜单项
|
|
||||||
]
|
|
||||||
return jsonify(menu_items)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|
|
||||||
22
mysql.sql
22
mysql.sql
|
|
@ -18,25 +18,3 @@ INSERT INTO user (nickname, phone_number, password, identity, is_active) VALUES
|
||||||
('Hank', '10000000008', 'password8', 'teacher', TRUE),
|
('Hank', '10000000008', 'password8', 'teacher', TRUE),
|
||||||
('Ivy', '10000000009', 'password9', 'student', FALSE),
|
('Ivy', '10000000009', 'password9', 'student', FALSE),
|
||||||
('Jack', '10000000010', 'password10', 'teacher', TRUE);
|
('Jack', '10000000010', 'password10', 'teacher', TRUE);
|
||||||
|
|
||||||
|
|
||||||
CREATE TABLE menu_items (
|
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
menu_name VARCHAR(100),
|
|
||||||
role ENUM('student', 'teacher'),
|
|
||||||
`order` INT
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO menu_items (menu_name, role, `order`) VALUES
|
|
||||||
('课程信息', 'student', 1),
|
|
||||||
('课程签到', 'student', 2),
|
|
||||||
('公告信息', 'student', 3),
|
|
||||||
('签到提醒', 'student', 4);
|
|
||||||
|
|
||||||
INSERT INTO menu_items (menu_name, role, `order`) VALUES
|
|
||||||
('课程类别', 'teacher', 1),
|
|
||||||
('课程信息', 'teacher', 2),
|
|
||||||
('课程签到', 'teacher', 3),
|
|
||||||
('签到提醒', 'teacher', 4);
|
|
||||||
|
|
||||||
|
|
|
||||||
Reference in New Issue