80 lines
2.2 KiB
HTML
80 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>图片资源展示</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #fff; }
|
|
|
|
.header {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
padding: 16px 20px;
|
|
font-size: 18px;
|
|
font-weight: 500;
|
|
border-bottom: 1px solid #eee;
|
|
}
|
|
|
|
.content { padding: 30px; }
|
|
|
|
.image-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 140px);
|
|
gap: 30px;
|
|
justify-content: center;
|
|
}
|
|
|
|
.image-item {
|
|
width: 140px; height: 140px;
|
|
background: #e8e8e8;
|
|
}
|
|
.image-item img {
|
|
width: 100%; height: 100%;
|
|
object-fit: cover;
|
|
display: block;
|
|
}
|
|
|
|
.empty {
|
|
text-align: center;
|
|
color: #999;
|
|
padding: 80px 0;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="header">首页</div>
|
|
<div class="content">
|
|
<div class="image-grid" id="imageGrid"></div>
|
|
<div class="empty" id="empty">暂无图片</div>
|
|
</div>
|
|
|
|
<script>
|
|
fetch('/api/state').then(function(res) {
|
|
return res.json();
|
|
}).then(function(state) {
|
|
var grid = document.getElementById('imageGrid');
|
|
var empty = document.getElementById('empty');
|
|
|
|
if (!state.playing || state.images.length === 0) {
|
|
empty.style.display = 'block';
|
|
return;
|
|
}
|
|
|
|
empty.style.display = 'none';
|
|
state.images.forEach(function(img) {
|
|
var div = document.createElement('div');
|
|
div.className = 'image-item';
|
|
var imgEl = document.createElement('img');
|
|
imgEl.src = '/uploads/' + img.filename;
|
|
imgEl.loading = 'lazy';
|
|
div.appendChild(imgEl);
|
|
grid.appendChild(div);
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|