更新样式,增加用户无权限表现

main
Kenneth 3 weeks ago
parent cbc1961f0f
commit 7477b1f93b

File diff suppressed because it is too large Load Diff

@ -88,9 +88,8 @@ def load_user(user_id):
return None return None
@app.route('/') @app.route('/')
def index(): def home():
current_app.logger.info("Index route accessed") return render_template('login.html')
return "Welcome to the Home Page!"
@app.route('/view_logs') @app.route('/view_logs')
@login_required @login_required
@ -218,7 +217,7 @@ def scout():
logger.info("Accessing scout page") logger.info("Accessing scout page")
if current_user.role != '侦查者': if current_user.role != '侦查者':
logger.warning("Unauthorized access to scout page") logger.warning("Unauthorized access to scout page")
return redirect(url_for('login')) return '用户无此页面访问权限 <a href="/">返回登录<a/>'
return render_template('scout.html') return render_template('scout.html')
# 指挥者页面 # 指挥者页面
@ -228,7 +227,7 @@ def commander():
logger.info("Accessing commander page") logger.info("Accessing commander page")
if current_user.role != '指挥者': if current_user.role != '指挥者':
logger.warning("Unauthorized access to commander page") logger.warning("Unauthorized access to commander page")
return redirect(url_for('login')) return '用户无此页面访问权限 <a href="/">返回登录<a/>'
# 获取特定目录下的所有文件和攻击坐标状态 # 获取特定目录下的所有文件和攻击坐标状态
directory = 'E:/_Ufo/0000jiegou/TheBattleCar/uploads' directory = 'E:/_Ufo/0000jiegou/TheBattleCar/uploads'
@ -280,7 +279,7 @@ def attacker():
logger.info("Accessing attacker page") logger.info("Accessing attacker page")
if current_user.role != '攻击者': if current_user.role != '攻击者':
logger.warning("Unauthorized access to attacker page") logger.warning("Unauthorized access to attacker page")
return redirect(url_for('login')) return '用户无此页面访问权限 <a href="/">返回登录<a/>'
# 获取攻击坐标列表 # 获取攻击坐标列表
cursor = mysql.connection.cursor() cursor = mysql.connection.cursor()

@ -36,6 +36,10 @@ body {
color: #fff; color: #fff;
margin-bottom: 30px; margin-bottom: 30px;
} }
.login h3{
color: #fff;
margin-bottom: 10px;
}
.login .login_box { .login .login_box {
/*相对定位*/ /*相对定位*/
position: relative; position: relative;
@ -197,3 +201,11 @@ body {
border: 3 solid #999; border: 3 solid #999;
border-radius: 5px; border-radius: 5px;
} }
.white-text {
color: #fff; /* 设置文本颜色为白色 */
}
.attack-button {
background: #add8e6; /* 背景颜色 */
}

@ -1,18 +1,22 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html lang="zh-CN">
<head> <head>
<title>攻击者界面</title> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>攻击者</title>
<link rel="stylesheet" href="/static/login.css">
</head> </head>
<body> <body>
<h1>攻击坐标列表</h1> <div class="login">
<ul> <h2>攻击坐标列表</h2>
<ul class="white-text">
{% if attacks %} {% if attacks %}
{% for attack in attacks %} {% for attack in attacks %}
<li> <li>
<strong>坐标:</strong> {{ attack.coordinate }} - <em>{{ attack.created_at }}</em> <strong>坐标:</strong> {{ attack.coordinate }} - <em>{{ attack.created_at }}</em>
{% if not attack.attacked %} {% if not attack.attacked %}
<form action="{{ url_for('execute_attack', attack_id=attack.id) }}" method="post" style="display:inline;"> <form action="{{ url_for('execute_attack', attack_id=attack.id) }}" method="post" style="display:inline;">
<button type="submit">打击</button> <button type="submit" class="attack-button">打击</button>
</form> </form>
{% else %} {% else %}
<span>已完成打击</span> <span>已完成打击</span>
@ -23,5 +27,6 @@
<li>No attack coordinates available.</li> <li>No attack coordinates available.</li>
{% endif %} {% endif %}
</ul> </ul>
</div>
</body> </body>
</html> </html>

@ -1,11 +1,82 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>指挥者界面</title> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>指挥者</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
background: linear-gradient(#141e30,#243b55);
}
h1, h2 {
text-align: center;
margin-top: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
form {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
}
label, input, button {
margin: 10px 0;
}
input[type="text"] {
padding: 10px;
width: 100%;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px 20px;
background-color: #add8e6;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #0056b3;
}
ul {
list-style-type: none;
padding: 0;
}
li {
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
background-color: #f9f9f9;
}
li strong {
margin-right: 10px;
}
li span {
font-style: italic;
color: #777;
}
li img {
vertical-align: middle;
margin-right: 10px;
}
</style>
</head> </head>
<body> <body>
<h1>指挥者界面</h1> <div class="container">
<h1>指挥者</h1>
<h2>发送攻击坐标</h2> <h2>发送攻击坐标</h2>
<form action="{{ url_for('send_attack') }}" method="post"> <form action="{{ url_for('send_attack') }}" method="post">
<label for="coordinate">攻击坐标:</label> <label for="coordinate">攻击坐标:</label>
@ -14,7 +85,7 @@
</form> </form>
<h2>攻击坐标状态</h2> <h2>攻击坐标状态</h2>
<ul> <ul class="white-text">
{% if attacks %} {% if attacks %}
{% for attack in attacks %} {% for attack in attacks %}
<li> <li>
@ -42,5 +113,6 @@
<li>No images found in the directory.</li> <li>No images found in the directory.</li>
{% endif %} {% endif %}
</ul> </ul>
</div>
</body> </body>
</html> </html>

@ -3,11 +3,14 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Scout Page</title> <title>侦查者</title>
<link rel="stylesheet" href="/static/login.css">
</head> </head>
<body> <body>
<h1>Scout Page</h1> <div class="login">
<button onclick="window.location.href='http://192.168.146.178:5000/'">控制小车</button> <h2>侦查者</h2>
<button onclick="window.location.href='{{ url_for('send_message') }}'">发送消息</button> <button onclick="window.location.href='http://192.168.146.178:5000/'" class="register-button">控制小车</button>
<button onclick="window.location.href='{{ url_for('send_message') }}'" class="register-button">发送消息</button>
</div>
</body> </body>
</html> </html>

@ -1,18 +1,21 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="zh-CN">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Send Message</title> <title>发送消息</title>
<link rel="stylesheet" href="/static/login.css">
</head> </head>
<body> <body>
<h1>Send Message</h1> <div class="login">
<h2>发送消息</h2>
<form method="post" enctype="multipart/form-data"> <form method="post" enctype="multipart/form-data">
<label for="message">Message:</label> <h3>消息内容</h3>
<textarea id="message" name="message" rows="4" cols="50" required></textarea><br><br> <textarea id="message" name="message" rows="4" cols="50" required></textarea><br><br>
<label for="photo">Upload Photo:</label> <h3>选择图片</h3>
<input type="file" id="photo" name="photo"><br><br> <input type="file" id="photo" name="photo"><br><br>
<button type="submit">Send Message</button> <button type="submit" class="register-button">发送</button>
</form> </form>
</div>
</body> </body>
</html> </html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Loading…
Cancel
Save