215 lines
13 KiB
HTML
215 lines
13 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}附件管理{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="card">
|
|
<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>
|
|
<option value="icon">图标图片</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 w-100" style="height: 38px; width: 100px">
|
|
<i class="fas fa-upload me-2"></i>上传
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<h5 class="border-bottom pb-2 mb-0">附件列表</h5>
|
|
</div>
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<form class="d-flex align-items-center" method="GET">
|
|
<select name="type" class="form-select me-2" style="width: 120px; height: 38px;">
|
|
<option value="all" {% if type_filter == 'all' %}selected{% endif %}>所有类型</option>
|
|
<option value="logo" {% if type_filter == 'logo' %}selected{% endif %}>Logo</option>
|
|
<option value="background" {% if type_filter == 'background' %}selected{% endif %}>背景图片</option>
|
|
<option value="video" {% if type_filter == 'video' %}selected{% endif %}>背景视频</option>
|
|
<option value="icon" {% if type_filter == 'icon' %}selected{% endif %}>图标图片</option>
|
|
</select>
|
|
<input type="text" name="search" class="form-control me-2" placeholder="搜索文件名..." value="{{ search_query }}" style="height: 38px;">
|
|
<input type="hidden" name="sort" value="{{ sort_order }}">
|
|
<button type="submit" class="btn btn-primary me-2" style="height: 38px;">
|
|
<i class="fas fa-search"></i>
|
|
</button>
|
|
{% if type_filter != 'all' or search_query %}
|
|
<a href="{{ url_for('manage_attachments') }}" class="btn btn-secondary" style="height: 38px; width: 100px">重置</a>
|
|
{% endif %}
|
|
</form>
|
|
</div>
|
|
|
|
<!-- 桌面端显示表格 -->
|
|
<div class="d-none d-md-block">
|
|
<div class="table-responsive">
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>预览</th>
|
|
<th>文件名</th>
|
|
<th>类型</th>
|
|
<th>文件大小</th>
|
|
<th>
|
|
<a href="{{ url_for('manage_attachments', type=type_filter, search=search_query, sort='asc' if sort_order == 'desc' else 'desc') }}" class="text-decoration-none">
|
|
上传时间
|
|
{% if sort_order == 'desc' %}
|
|
<i class="fas fa-sort-up"></i>
|
|
{% else %}
|
|
<i class="fas fa-sort-down"></i>
|
|
{% endif %}
|
|
</a>
|
|
</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">
|
|
{% elif attachment.type == 'video' %}
|
|
<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>
|
|
{% else %}
|
|
<img src="{{ url_for('uploaded_icon', filename=attachment.filename) }}" style="max-width: 50px; max-height: 50px;" class="img-thumbnail">
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ attachment.filename }}</td>
|
|
<td>
|
|
{% if attachment.type == 'logo' %}
|
|
Logo
|
|
{% elif attachment.type == 'background' %}
|
|
背景图片
|
|
{% elif attachment.type == 'video' %}
|
|
背景视频
|
|
{% else %}
|
|
图标图片
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ attachment.size|filesizeformat }}</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="6" class="text-center">没有找到匹配的附件</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 移动端显示卡片 -->
|
|
<div class="d-md-none">
|
|
<div class="row">
|
|
{% for attachment in attachments %}
|
|
<div class="col-12 mb-3">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row align-items-center">
|
|
<div class="col-4">
|
|
{% if attachment.type == 'logo' %}
|
|
<img src="{{ url_for('uploaded_logo', filename=attachment.filename) }}" class="img-fluid rounded">
|
|
{% elif attachment.type == 'background' %}
|
|
<img src="{{ url_for('uploaded_background', filename=attachment.filename) }}" class="img-fluid rounded">
|
|
{% elif attachment.type == 'video' %}
|
|
<video width="100%" muted class="rounded">
|
|
<source src="{{ url_for('uploaded_video', filename=attachment.filename) }}" type="video/mp4">
|
|
</video>
|
|
{% else %}
|
|
<img src="{{ url_for('uploaded_icon', filename=attachment.filename) }}" class="img-fluid rounded">
|
|
{% endif %}
|
|
</div>
|
|
<div class="col-8">
|
|
<h6 class="mb-1">{{ attachment.filename }}</h6>
|
|
<p class="mb-1 text-muted small">
|
|
{% if attachment.type == 'logo' %}
|
|
Logo
|
|
{% elif attachment.type == 'background' %}
|
|
背景图片
|
|
{% elif attachment.type == 'video' %}
|
|
背景视频
|
|
{% else %}
|
|
图标图片
|
|
{% endif %}
|
|
</p>
|
|
<p class="mb-1 text-muted small">{{ attachment.size|filesizeformat }}</p>
|
|
<p class="mb-2 text-muted small">{{ attachment.upload_time }}</p>
|
|
<form method="POST" action="{{ url_for('delete_attachment_route', filename=attachment.filename) }}" class="mt-2">
|
|
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('确定要删除这个附件吗?')">
|
|
<i class="fas fa-trash"></i> 删除
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<div class="col-12">
|
|
<div class="alert alert-info text-center">没有找到匹配的附件</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 分页导航 -->
|
|
{% if total_pages > 1 %}
|
|
<nav aria-label="Page navigation">
|
|
<ul class="pagination justify-content-center">
|
|
<li class="page-item {% if current_page == 1 %}disabled{% endif %}">
|
|
<a class="page-link" href="{{ url_for('manage_attachments', page=current_page-1, type=type_filter, search=search_query, sort=sort_order) }}" aria-label="Previous">
|
|
<span aria-hidden="true">«</span>
|
|
</a>
|
|
</li>
|
|
|
|
{% for page_num in range(1, total_pages + 1) %}
|
|
<li class="page-item {% if page_num == current_page %}active{% endif %}">
|
|
<a class="page-link" href="{{ url_for('manage_attachments', page=page_num, type=type_filter, search=search_query, sort=sort_order) }}">{{ page_num }}</a>
|
|
</li>
|
|
{% endfor %}
|
|
|
|
<li class="page-item {% if current_page == total_pages %}disabled{% endif %}">
|
|
<a class="page-link" href="{{ url_for('manage_attachments', page=current_page+1, type=type_filter, search=search_query, sort=sort_order) }}" aria-label="Next">
|
|
<span aria-hidden="true">»</span>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
{% endif %}
|
|
</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 %} |