121 lines
5.1 KiB
HTML
Executable File
121 lines
5.1 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Image Tagging</title>
|
|
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="/static/css/toastr.min.css">
|
|
<link rel="stylesheet" href="/static/css/sweetalert2.min.css">
|
|
<script src="/static/js/sweetalert2@11"></script>
|
|
</head>
|
|
<body>
|
|
<div class="container mt-5">
|
|
<h1 class="mb-4">Images to Tag</h1>
|
|
|
|
<!-- 图片列表 -->
|
|
<div class="row">
|
|
{% for image in images %}
|
|
<div class="col-md-4 mb-4">
|
|
<div class="card">
|
|
<img src="{{ url_for('serve_catch_file', filename=image) }}" alt="{{ image }}" class="card-img-top">
|
|
<div class="card-body text-center">
|
|
<form action="{{ url_for('index') }}" method="post">
|
|
<input type="hidden" name="original_filename" value="{{ image }}">
|
|
{{ form.hidden_tag() }}
|
|
<div class="form-group">
|
|
{{ form.filename.label(class="form-control-label") }}
|
|
{{ form.filename(id='filename', class="form-control", value=image) }}
|
|
</div>
|
|
<div class="form-group">
|
|
{{ form.theme.label(class="form-control-label") }}
|
|
{{ form.theme(class="form-control") }}
|
|
</div>
|
|
<div class="form-group">
|
|
{{ form.et.label(class="form-control-label") }}
|
|
{{ form.et(class="form-control") }}
|
|
</div>
|
|
<div class="form-group">
|
|
{{ form.submit(class="btn btn-primary btn-block") }}
|
|
</div>
|
|
</form>
|
|
<button class="btn btn-danger btn-block delete-image" data-filename="{{ image }}">Delete Image</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<!-- 分页导航 -->
|
|
<nav aria-label="Page navigation example">
|
|
<ul class="pagination justify-content-center">
|
|
{% if page > 1 %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page - 1 }}">Previous</a>
|
|
</li>
|
|
{% endif %}
|
|
{% if page < total_pages %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page + 1 }}">Next</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
|
|
<!-- 引入JavaScript库 -->
|
|
<script src="/static/js/jquery.min.js"></script>
|
|
<script src="/static/js/bootstrap.bundle.min.js"></script>
|
|
<script src="/static/js/toastr.min.js"></script>
|
|
<script>
|
|
$(document).ready(function () {
|
|
// 使用toastr显示闪现消息
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
{% for category, message in messages %}
|
|
toastr.{{ category }}("{{ message|safe }}");
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
// 自动填充新文件名
|
|
function autoFillFilename(original_filename) {
|
|
$.ajax({
|
|
url: '/generate-short-hash',
|
|
type: 'POST',
|
|
data: { filename: original_filename },
|
|
success: function (response) {
|
|
$('#filename').val(response.short_hash + '.' + original_filename.split('.').pop());
|
|
}
|
|
});
|
|
}
|
|
|
|
// 图片点击事件
|
|
$('.card-img-top').click(function () {
|
|
var original_filename = $(this).attr('alt');
|
|
autoFillFilename(original_filename);
|
|
});
|
|
|
|
// 删除图片事件
|
|
$('.delete-image').click(function (e) {
|
|
e.preventDefault();
|
|
var filename = $(this).data('filename');
|
|
|
|
Swal.fire({
|
|
title: '删除?',
|
|
text: "图片将无法恢复!",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#d33',
|
|
cancelButtonColor: '#3085d6',
|
|
confirmButtonText: '是的'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
window.location.href = "{{ url_for('delete_image', filename='') }}" + encodeURIComponent(filename);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |