2026-07-16 22:51:02 +08:00
|
|
|
<!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; }
|
2026-07-16 23:01:43 +08:00
|
|
|
|
2026-07-16 22:51:02 +08:00
|
|
|
.header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 16px 20px;
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
border-bottom: 1px solid #eee;
|
|
|
|
|
}
|
2026-07-16 23:01:43 +08:00
|
|
|
|
|
|
|
|
.content { padding: 30px; }
|
|
|
|
|
|
2026-07-16 22:51:02 +08:00
|
|
|
.image-grid {
|
2026-07-17 09:04:21 +08:00
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(2, 140px);
|
2026-07-16 22:51:02 +08:00
|
|
|
gap: 30px;
|
2026-07-17 09:00:02 +08:00
|
|
|
justify-content: center;
|
2026-07-16 22:51:02 +08:00
|
|
|
}
|
2026-07-16 23:01:43 +08:00
|
|
|
|
2026-07-16 22:51:02 +08:00
|
|
|
.image-item {
|
2026-07-16 23:01:43 +08:00
|
|
|
width: 140px; height: 140px;
|
2026-07-16 22:51:02 +08:00
|
|
|
background: #e8e8e8;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
}
|
|
|
|
|
.image-item img {
|
2026-07-16 23:01:43 +08:00
|
|
|
width: 100%; height: 100%;
|
2026-07-16 22:51:02 +08:00
|
|
|
object-fit: cover;
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
2026-07-16 23:01:43 +08:00
|
|
|
|
2026-07-16 22:51:02 +08:00
|
|
|
.empty {
|
|
|
|
|
text-align: center;
|
|
|
|
|
color: #999;
|
|
|
|
|
padding: 80px 0;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
2026-07-16 23:13:56 +08:00
|
|
|
<div class="header">首页</div>
|
2026-07-16 22:51:02 +08:00
|
|
|
<div class="content">
|
|
|
|
|
<div class="image-grid" id="imageGrid"></div>
|
|
|
|
|
<div class="empty" id="empty">暂无图片</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
2026-07-16 23:13:56 +08:00
|
|
|
var ws;
|
2026-07-16 23:01:43 +08:00
|
|
|
|
|
|
|
|
function connectWS() {
|
2026-07-16 23:13:56 +08:00
|
|
|
var protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
2026-07-16 23:01:43 +08:00
|
|
|
ws = new WebSocket(protocol + '//' + location.host);
|
|
|
|
|
|
|
|
|
|
ws.onmessage = function(e) {
|
|
|
|
|
try {
|
2026-07-16 23:13:56 +08:00
|
|
|
var data = JSON.parse(e.data);
|
2026-07-16 23:01:43 +08:00
|
|
|
if (data.type === 'state') renderState(data);
|
|
|
|
|
} catch(err) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ws.onclose = function() {
|
|
|
|
|
setTimeout(connectWS, 3000);
|
|
|
|
|
};
|
2026-07-16 22:51:02 +08:00
|
|
|
}
|
2026-07-16 23:01:43 +08:00
|
|
|
|
|
|
|
|
function renderState(state) {
|
2026-07-16 23:13:56 +08:00
|
|
|
var grid = document.getElementById('imageGrid');
|
|
|
|
|
var empty = document.getElementById('empty');
|
2026-07-16 23:01:43 +08:00
|
|
|
|
|
|
|
|
if (!state.playing || state.images.length === 0) {
|
|
|
|
|
grid.innerHTML = '';
|
|
|
|
|
empty.style.display = 'block';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
empty.style.display = 'none';
|
|
|
|
|
|
2026-07-16 22:51:02 +08:00
|
|
|
grid.innerHTML = '';
|
2026-07-16 23:01:43 +08:00
|
|
|
state.images.forEach(function(img) {
|
|
|
|
|
var div = document.createElement('div');
|
2026-07-16 22:51:02 +08:00
|
|
|
div.className = 'image-item';
|
2026-07-16 23:01:43 +08:00
|
|
|
var imgEl = document.createElement('img');
|
2026-07-16 22:51:02 +08:00
|
|
|
imgEl.src = '/uploads/' + img.filename;
|
|
|
|
|
imgEl.loading = 'lazy';
|
|
|
|
|
div.appendChild(imgEl);
|
|
|
|
|
grid.appendChild(div);
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-07-16 23:01:43 +08:00
|
|
|
|
|
|
|
|
connectWS();
|
2026-07-16 22:51:02 +08:00
|
|
|
</script>
|
|
|
|
|
</body>
|
2026-07-16 23:01:43 +08:00
|
|
|
</html>
|