Compare commits
3 Commits
08790e3e9e
...
e172d78c30
| Author | SHA1 | Date |
|---|---|---|
|
|
e172d78c30 | |
|
|
caefaa4472 | |
|
|
6770e100ff |
|
|
@ -24,7 +24,7 @@
|
|||
{{ session.nickname }}
|
||||
</a>
|
||||
<dl class="layui-nav-child">
|
||||
<dd><a href="/home/profile">资料</a></dd> <!-- 修改这里的href指向/profile -->
|
||||
<dd><a href="/profile">资料</a></dd> <!-- 修改这里的href指向/profile -->
|
||||
<dd><a href="javascript:;" id="logoutLink">登出</a></dd>
|
||||
</dl>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -6,16 +6,15 @@
|
|||
<meta name="renderer" content="webkit"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<link href="static/css/layui.css" rel="stylesheet"/>
|
||||
<link href="/static/css/layui.css" rel="stylesheet"/>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-layout layui-layout-admin">
|
||||
<div class="layui-header">
|
||||
<div class="layui-logo layui-hide-xs layui-bg-black">网上上课点名系统</div>
|
||||
<!-- 头部区域(可配合layui 已有的水平导航) -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="layui-body">
|
||||
<!-- 内容主体区域 -->
|
||||
<div style="padding: 15px">
|
||||
|
|
@ -59,35 +58,21 @@
|
|||
</div>
|
||||
|
||||
|
||||
<script src="static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||
<script src="static/layui.js"></script>
|
||||
<script src="/static/jquery.min.js"></script> <!-- 确保已经引入jQuery -->
|
||||
<script src="/static/layui.js"></script>
|
||||
<script>
|
||||
|
||||
// 请求后端获取菜单数据
|
||||
$.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对象
|
||||
|
||||
$('#logoutLink').on('click', function () {
|
||||
// 向后端发送登出请求
|
||||
$.get('/logout', function (data) {
|
||||
// 重定向到登录页面,或根据后端响应做其他处理
|
||||
window.location.href = '/login';
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from config import SECRET_KEY
|
|||
from db.database_manager import DatabaseManager
|
||||
from models.User import User
|
||||
|
||||
app = Flask(__name__)
|
||||
app = Flask(__name__, static_folder='static')
|
||||
app.secret_key = SECRET_KEY # 从配置文件设置
|
||||
|
||||
# 一个全局MySQLPool对象,用于管理数据库连接
|
||||
|
|
@ -107,7 +107,7 @@ def get_menu():
|
|||
return jsonify([]), 401 # 未授权状态码
|
||||
|
||||
|
||||
@app.route('/home/profile', methods=['GET', 'POST'])
|
||||
@app.route('/profile', methods=['GET', 'POST'])
|
||||
def profile():
|
||||
if request.method == 'POST':
|
||||
# 从表单获取数据
|
||||
|
|
|
|||
Reference in New Issue