AIDaohang/templates/attachments.html
2025-07-05 22:41:21 +08:00

98 lines
5.1 KiB
HTML

{% extends "base.html" %}
{% block title %}附件管理{% endblock %}
{% block content %}
<div class="card">
<div class="card-header bg-primary text-white">
<h4><i class="fas fa-paperclip me-2"></i>附件管理</h4>
</div>
<div class="card-body">
<div class="mb-4">
<h5 class="border-bottom pb-2 mb-3">上传新附件</h5>
<form method="POST" action="{{ url_for('upload_attachment') }}" enctype="multipart/form-data">
<div class="row">
<div class="col-md-4 mb-3">
<label for="type" class="form-label">附件类型</label>
<select name="type" id="type" class="form-select" required>
<option value="logo">Logo</option>
<option value="background">背景图片</option>
<option value="video">背景视频</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label for="file" class="form-label">选择文件</label>
<input type="file" class="form-control" id="file" name="file" accept="image/*,video/mp4" required>
</div>
<div class="col-md-2 mb-3 d-flex align-items-end">
<button type="submit" class="btn btn-primary">
<i class="fas fa-upload me-2"></i>上传
</button>
</div>
</div>
</form>
</div>
<div class="mb-4">
<h5 class="border-bottom pb-2 mb-3">附件列表</h5>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>预览</th>
<th>文件名</th>
<th>类型</th>
<th>上传时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{% for attachment in attachments %}
<tr>
<td>
{% if attachment.type == 'logo' %}
<img src="{{ url_for('uploaded_logo', filename=attachment.filename) }}" style="max-width: 50px; max-height: 50px;" class="img-thumbnail">
{% elif attachment.type == 'background' %}
<img src="{{ url_for('uploaded_background', filename=attachment.filename) }}" style="max-width: 50px; max-height: 50px;" class="img-thumbnail">
{% else %}
<video width="80" height="45" muted style="max-width: 50px; max-height: 50px;" class="img-thumbnail">
<source src="{{ url_for('uploaded_video', filename=attachment.filename) }}" type="video/mp4">
</video>
{% endif %}
</td>
<td>{{ attachment.filename }}</td>
<td>
{% if attachment.type == 'logo' %}
Logo
{% elif attachment.type == 'background' %}
背景图片
{% else %}
背景视频
{% endif %}
</td>
<td>{{ attachment.upload_time }}</td>
<td>
<form method="POST" action="{{ url_for('delete_attachment_route', filename=attachment.filename) }}" style="display: inline;">
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('确定要删除这个附件吗?')">
<i class="fas fa-trash"></i> 删除
</button>
</form>
</td>
</tr>
{% else %}
<tr>
<td colspan="5" class="text-center">暂无附件</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="mt-4">
<a href="{{ url_for('index') }}" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> 返回首页
</a>
</div>
</div>
</div>
{% endblock %}