diff --git a/css/pages/facilities.css b/css/pages/facilities.css index 23a5342..2c412b9 100644 --- a/css/pages/facilities.css +++ b/css/pages/facilities.css @@ -453,6 +453,27 @@ box-shadow: 0 4px 12px rgba(0,0,0,0.05); } +/* Video Embed */ +.video-embed-wrapper { + position: relative; + width: 100%; + padding-bottom: 56.25%; /* 16:9 aspect ratio */ + margin: 12px 0 20px; + border-radius: 12px; + overflow: hidden; + background: #000; + box-shadow: 0 4px 12px rgba(0,0,0,0.08); +} + +.video-embed-wrapper iframe { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + border: none; +} + .no-results-message { text-align: center; padding: 60px; @@ -999,6 +1020,11 @@ color: #1565c0; } +.badge-video { + background: #fce4ec; + color: #c62828; +} + .sortable-item .item-content { flex: 1; border: 1px solid rgba(0,0,0,0.06) !important; diff --git a/data/facilities.json b/data/facilities.json index 563c114..37663f1 100644 --- a/data/facilities.json +++ b/data/facilities.json @@ -23,8 +23,8 @@ "content": "使用前请仔细阅读告示牌说明。指示灯熄灭前请勿离开。" }, { - "type": "text", - "content": "参考视频:BV1qPhWzdEwU" + "type": "video", + "content": "BV1qPhWzdEwU" } ] }, @@ -59,8 +59,8 @@ ], "notes": [ { - "type": "text", - "content": "参考视频:BV1g142167tJ" + "type": "video", + "content": "BV1g142167tJ" } ] }, diff --git a/facilities.html b/facilities.html index 8a03b45..994334d 100644 --- a/facilities.html +++ b/facilities.html @@ -266,6 +266,9 @@ +
${escapeHtml(block.content) || '空文字'}
`; - } else { + } else if (block.type === 'image') { html += block.content ? `空图片
'; + } else if (block.type === 'video') { + html += renderVideoPreviewHtml(block.content); } }); } else { @@ -623,8 +667,10 @@ document.addEventListener('DOMContentLoaded', () => { editorNotes.forEach(block => { if (block.type === 'text') { html += `${escapeHtml(block.content) || '空文字'}
`; - } else { + } else if (block.type === 'image') { html += block.content ? `空图片
'; + } else if (block.type === 'video') { + html += renderVideoPreviewHtml(block.content); } }); } else { @@ -657,8 +703,8 @@ document.addEventListener('DOMContentLoaded', () => { z: parseInt(document.getElementById('editor-z').value) || 0 }, contributors: [...editorContributors], - instructions: editorInstructions.filter(i => i.content.trim() !== ''), - notes: editorNotes.filter(n => n.content.trim() !== '') + instructions: editorInstructions.filter(i => i.content.trim() !== '').map(i => i.type === 'video' ? { type: 'video', content: parseBVNumber(i.content) || i.content } : {...i}), + notes: editorNotes.filter(n => n.content.trim() !== '').map(n => n.type === 'video' ? { type: 'video', content: parseBVNumber(n.content) || n.content } : {...n}) }; const jsonStr = JSON.stringify(facilityObj, null, 4); @@ -689,6 +735,14 @@ document.addEventListener('DOMContentLoaded', () => { }); }); + function renderVideoPreviewHtml(content) { + const bv = parseBVNumber(content); + if (bv) { + return ``; + } + return '请输入有效的 BV 号或 bilibili 视频地址
'; + } + // --- Utility --- function escapeHtml(text) { if (!text) return '';