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

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

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

@ -1,18 +1,22 @@
<!DOCTYPE html>
<html>
<html lang="zh-CN">
<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>
<body>
<h1>攻击坐标列表</h1>
<ul>
<div class="login">
<h2>攻击坐标列表</h2>
<ul class="white-text">
{% if attacks %}
{% for attack in attacks %}
<li>
<strong>坐标:</strong> {{ attack.coordinate }} - <em>{{ attack.created_at }}</em>
{% if not attack.attacked %}
<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>
{% else %}
<span>已完成打击</span>
@ -23,5 +27,6 @@
<li>No attack coordinates available.</li>
{% endif %}
</ul>
</div>
</body>
</html>

@ -1,46 +1,118 @@
<!DOCTYPE html>
<html>
<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>
<body>
<h1>指挥者界面</h1>
<div class="container">
<h1>指挥者</h1>
<h2>发送攻击坐标</h2>
<form action="{{ url_for('send_attack') }}" method="post">
<label for="coordinate">攻击坐标:</label>
<input type="text" id="coordinate" name="coordinate" required>
<button type="submit">发送消息</button>
</form>
<h2>发送攻击坐标</h2>
<form action="{{ url_for('send_attack') }}" method="post">
<label for="coordinate">攻击坐标:</label>
<input type="text" id="coordinate" name="coordinate" required>
<button type="submit">发送消息</button>
</form>
<h2>攻击坐标状态</h2>
<ul class="white-text">
{% if attacks %}
{% for attack in attacks %}
<li>
<strong>坐标:</strong> {{ attack.coordinate }}
- <em>{{ attack.created_at }}</em>
- <span>{% if attack.attacked %}已完成打击{% else %}等待打击{% endif %}</span>
</li>
{% endfor %}
{% else %}
<li>No attack coordinates available.</li>
{% endif %}
</ul>
<h2>攻击坐标状态</h2>
<ul>
{% if attacks %}
{% for attack in attacks %}
<li>
<strong>坐标:</strong> {{ attack.coordinate }}
- <em>{{ attack.created_at }}</em>
- <span>{% if attack.attacked %}已完成打击{% else %}等待打击{% endif %}</span>
</li>
{% endfor %}
{% else %}
<li>No attack coordinates available.</li>
{% endif %}
</ul>
<h2>查看照片</h2>
<ul>
{% if media_items %}
{% for filename in media_items %}
<li>
<a href="{{ url_for('uploaded_file', filename=filename) }}" target="_blank">
<img src="{{ url_for('uploaded_file', filename=filename) }}" width="100">
</a>
</li>
{% endfor %}
{% else %}
<li>No images found in the directory.</li>
{% endif %}
</ul>
<h2>查看照片</h2>
<ul>
{% if media_items %}
{% for filename in media_items %}
<li>
<a href="{{ url_for('uploaded_file', filename=filename) }}" target="_blank">
<img src="{{ url_for('uploaded_file', filename=filename) }}" width="100">
</a>
</li>
{% endfor %}
{% else %}
<li>No images found in the directory.</li>
{% endif %}
</ul>
</div>
</body>
</html>

@ -3,11 +3,14 @@
<head>
<meta charset="UTF-8">
<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>
<body>
<h1>Scout Page</h1>
<button onclick="window.location.href='http://192.168.146.178:5000/'">控制小车</button>
<button onclick="window.location.href='{{ url_for('send_message') }}'">发送消息</button>
<div class="login">
<h2>侦查者</h2>
<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>
</html>

@ -1,18 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<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>
<body>
<h1>Send Message</h1>
<div class="login">
<h2>发送消息</h2>
<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>
<label for="photo">Upload Photo:</label>
<h3>选择图片</h3>
<input type="file" id="photo" name="photo"><br><br>
<button type="submit">Send Message</button>
<button type="submit" class="register-button">发送</button>
</form>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Loading…
Cancel
Save